$(document).ready(function() {

	/* BODY FONT */
	$(function(){
	var fontDetector = new Detector();
	
		if(fontDetector.test('Calibri')){
		$('body, h3').css('font-size', '14px');
		$('h2').css('font-family', 'Calibri').css('font-size', '13px');
		$('h4, #footerleft, #footerright').css('font-size', '12px');
		}
	
	});
		
		
	/*NAV GUI*/
	$(".nav").hover(function() {
		$(this).stop().animate({ 
		right: "0px"
		}, 100 );
	},
	function() {
		$(this).animate({ 
		right: "-10px"
		}, 300 );
	});
	

	/*MENU GUI*/
	$(".button").hover(function() {
		if ($(this).attr("src").indexOf("_on") == -1) {
		var newSrc = $(this).attr("src").replace(".png","_on.png");
		$(this).attr("src",newSrc);
		}
	},
	function() {
		if($(this).attr("src").indexOf("_on.png") != -1) {
		var oldSrc = $(this).attr("src").replace("_on.png",".png");
		$(this).attr("src",oldSrc);
		}
	});
	
	
	/*SWITCH GUI*/
	$(".switch").hover(function() {
	$(this).addClass("switchon");					
	},
	function() {
	$(this).removeClass("switchon");
	});
	
	
	$(".button, .switch").click(function() {
	$(this).blur();	
	});
		
	
	 /*THUMB GUI*/
	$(".prodthumb").hover(function() {
	var thisPhoto = $(this).attr("src");
	$("#prodphotozoom").attr("src",thisPhoto);
	});
	
	
	/*VIEWPORT GUI*/
	$(".zoom").click(function() {
	var srcImg = $(this).attr("src");
	var srcTitle = $(this).attr("title");
	var srcUrl = $(this).attr("name");
	srcUrl = ("shop_online.php?colId=" + srcUrl + "&fabric=" + srcTitle);
	$("#zoomimage").attr("src",srcImg);
	$("#zoomtitle").html(srcTitle);
	$("#zoomlink").attr("href",srcUrl);
	$("#viewport").css("visibility", "visible");
	});
	
	$("#zoomclose").click(function() {
	$("#viewport").css("visibility", "hidden");
	});

        
});


/* SHOPPING */
function submitOrder(choiceQuantity) {
var fabricSet = 0;
var choiceSet = 0;

	if (document.setform.fabric) {
	
		if (document.setform.fabric.options[document.setform.fabric.selectedIndex].value) {
		document.orderform.fabric.value = document.setform.fabric.options[document.setform.fabric.selectedIndex].value;
		fabricSet = 1;
		}
	
	}
	else {
	fabricSet = 1;
	}

	if (document.setform.choice && (document.setform.choice != "")) {
	
		if (document.setform.choice.length > 1) {
			
			for (var i = 0; i < document.setform.choice.length; i++) {
			
				if (document.setform.choice[i].checked == true) {
				document.orderform.choice.value = document.setform.choice[i].value;
				choiceSet = 1;
				break;
				}
			
			}
		
		}
		else {
			
			if (document.setform.choice.checked == true) {
			document.orderform.choice.value = document.setform.choice.value;
			choiceSet = 1;
			}
			
		}
	
	}
	else {
	choiceSet = 1;
	}
	
	if (!fabricSet) {
	alert('Please select a print choice.');
	return false;
	}
	else if (!choiceSet) {
	alert('Please select a product choice.');
	return false;
	}

	if (document.setform.discount) {
	document.orderform.discountcode.value = document.setform.discount.value;
	}

document.orderform.submit();
return true;
}
