Event.observe(window, 'load', function() {

	// Fancy fonts
	Cufon.replace('h1, h3, .cufon-js', {
/*		hover: true, 
		hoverables: { div: true, a: true }
*/	});

	// Image zoom
	if(typeof magnify == 'function') { 
		 magnify();
	}
	
	// Image box
	if(typeof Lightbox == 'function') { 
		initLightbox();
	}
	
	// Spin box
	if(typeof SpinBox == 'function') { 
		$$('.spinbox').each(function(element) {
			new SpinBox(element.id,1,99);
		});
	}
	
	// Image swap
	$$('.productThumb').each(function(element) {
		element.observe('click', function(event) {
			var productImg = $$('.productImg')[0];
			var curSrc = productImg.src;
			var curHref = productImg.up('a').href;

			productImg.src = this.src;
			productImg.up('a').href = this.up('a').href;

			this.src = curSrc;
			this.up('a').href = curHref;
		});
	});

	// Href fix
	var isMSIE7 = Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) == 7; 
	if (isMSIE7) {
		$$('img.thumb').each(function(element) {
			var href = element.up('a').href;
			if (!href) return;
			element.style.cursor = 'pointer';
			element.observe('click', function(event) {
				window.location = href;
			});
		});
	}
});

// Functions
function getRadio(form,field){
	var obj = document.forms[form].elements[field];
	if (obj.length){
		for (var i=0; i<obj.length; i++) {
			if(obj[i].checked){
				return obj[i].value;
				break;
			}
		}
	} else if (obj.checked){
		return obj.value;
	}
}

var ua = navigator.userAgent;
var isMSIE6 = (/msie 6/i.test(ua) && !/opera/i.test(ua));
if (window.attachEvent && isMSIE6) {
	window.attachEvent("onload", addHoverEffect = function() {
		var sfEls = document.getElementById("topnav").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	});
}
