
function getInsideWindowWidth() {
	isIE6CSS = (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? true : false;
	if (window.innerWidth) {
		return window.innerWidth;
	}
	else if (isIE6CSS) {
		// measure the html element's clientWidtht
		return document.documentElement.clientWidth;
	}
	else if (document.body && document.body.clientWidth) {
		return document.body.clientWidth;
	}
	return 1; // 0 could lead to dividing 0 by 2.
}


function getInsideWindowHeight() {
	isIE6CSS = (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? true : false;
	if (window.innerHeight) {
		return window.innerHeight;
	}
	else if (isIE6CSS) {
		// measure the html element's clientHeight
		return document.documentElement.clientHeight;
	}
	else if (document.body && document.body.clientHeight) {
		return document.body.clientHeight;
	}
	return 1; // 0 could lead to dividing 0 by 2.
}




function resetStyleSheet() {
	var winWidth = 0;
	var winHeight = 0;
	winWidth = getInsideWindowWidth();
	winHeight = getInsideWindowHeight();





	if (winWidth > 1245 ) { 
		if (document.styleSheets[0].rules) { // IE & safari
			//document.styleSheets[0].rules[0].style.backgroundColor =  '#F7F6E2';
			document.styleSheets[0].rules[1].style.width =  '1230px';
			document.styleSheets[0].rules[2].style.width =  '1230px';
			document.styleSheets[0].rules[3].style.width =  '1230px';
			document.styleSheets[0].rules[5].style.width =  '156px';
			document.styleSheets[0].rules[6].style.width =  '156px';
			document.styleSheets[0].rules[6].style.left =  '1074px';
			document.styleSheets[0].rules[7].style.width =  '1230px';
			document.styleSheets[0].rules[8].style.left =  '842px';
			document.styleSheets[0].rules[11].style.left =  '130px';
			document.styleSheets[0].rules[12].style.left =  '130px';
			document.styleSheets[0].rules[13].style.left =  '842px';
		}
		else { // MOZILLA
			//document.styleSheets[0].cssRules[0].style.backgroundColor =  '#F7F6E2';
			document.styleSheets[0].cssRules[1].style.width =  '1230px';
			document.styleSheets[0].cssRules[2].style.width =  '1230px';
			document.styleSheets[0].cssRules[3].style.width =  '1230px';
			document.styleSheets[0].cssRules[5].style.width =  '156px';
			document.styleSheets[0].cssRules[6].style.width =  '156px';
			document.styleSheets[0].cssRules[6].style.left =  '1074px';
			document.styleSheets[0].cssRules[7].style.width =  '1230px';
			document.styleSheets[0].cssRules[8].style.left =  '842px';
			document.styleSheets[0].cssRules[11].style.left =  '130px';
			document.styleSheets[0].cssRules[12].style.left =  '130px';
			document.styleSheets[0].cssRules[13].style.left =  '842px';
		}
		if (widthChecked == "yes") {
			document.getElementById("fixedrightimage").innerHTML = '<img src="images/1280right.gif" alt="" />';
			document.getElementById("fixedleftimagediv").innerHTML = '<a href="index.html"><img src="images/1280left.gif" alt="" /></a>';
			document.getElementById("lefthandwidelinks").style.display = "block";
			document.getElementById("lefthandnarrowlinks").style.display = "none";
			document.getElementById("brandlogolinks").style.display = 'block';

			if (winHeight < 550) {
				document.getElementById("navigationleft").style.visibility =  "hidden";
				document.getElementById("navigationright").style.display =  "none";
				document.getElementById("fixedleft").style.height =  "350px";
				document.getElementById("fixedright").style.height =  "350px";

			}
			else {
				document.getElementById("navigationleft").style.visibility =  "visible";
				document.getElementById("navigationright").style.display =  "block";
				document.getElementById("fixedleft").style.height =  "949px";
				document.getElementById("fixedright").style.height =  "949px";
			}
		}
	}
	else {

		if (widthChecked == "yes") {
			document.getElementById("navigationleft").style.visibility =  "hidden";
			document.getElementById("navigationright").style.display =  "none";
			document.getElementById("leftunderneath").style.width =  "26px";
			document.getElementById("fixedrightimage").innerHTML = '<a href="contact-cornwall-yarn.html"><img src="images/1024right.gif" alt="" /></a>';
			document.getElementById("fixedleftimagediv").innerHTML = '<a href="index.html"><img src="images/1024left.gif" alt="" /></a>';
			document.getElementById("lefthandwidelinks").style.display = "none";
			document.getElementById("lefthandnarrowlinks").style.display = "block";



			if (document.styleSheets[0].rules) { // IE & safari
				document.styleSheets[0].rules[1].style.width =  '970px';
				document.styleSheets[0].rules[2].style.width =  '970px';
				document.styleSheets[0].rules[3].style.width =  '970px';
				document.styleSheets[0].rules[5].style.width =  '26px';
				document.styleSheets[0].rules[6].style.width =  '26px';
				document.styleSheets[0].rules[6].style.left =  '944px';
				document.styleSheets[0].rules[7].style.width =  '970px';
				document.styleSheets[0].rules[8].style.left =  '713px';
				document.styleSheets[0].rules[11].style.left =  '0px';
				document.styleSheets[0].rules[12].style.left =  '0px';
				document.styleSheets[0].rules[13].style.left =  '713px';



			}
			else { // MOZILLA
				document.styleSheets[0].cssRules[1].style.width =  '970px';
				document.styleSheets[0].cssRules[2].style.width =  '970px';
				document.styleSheets[0].cssRules[3].style.width =  '970px';
				document.styleSheets[0].cssRules[5].style.width =  '26px';
				document.styleSheets[0].cssRules[6].style.width =  '26px';
				document.styleSheets[0].cssRules[6].style.left =  '944px';
				document.styleSheets[0].cssRules[7].style.width =  '970px';
				document.styleSheets[0].cssRules[8].style.left =  '713px';
				document.styleSheets[0].cssRules[11].style.left =  '0px';
				document.styleSheets[0].cssRules[12].style.left =  '0px';
				document.styleSheets[0].cssRules[13].style.left =  '713px';
			}

		}

	}
}


window.onresize=resetStyleSheet;


var widthChecked = "no";


function moveBars() {
	var maxOffset = document.getElementById('lhc').offsetHeight
	var ourYOffset = 0;
	if (document.styleSheets[0].rules) { // IE and safari
		if (!document.documentElement.scrollTop) { // safari
			ourYOffset = document.body.scrollTop;
	
		}	
		else {
			ourYOffset = document.documentElement.scrollTop;
		}
	}
	else { // MOZILLA
		ourYOffset = pageYOffset;
	}

	if (ourYOffset < 600) {
		if (videoBigSmall == "big") {
			document.getElementById("fixedleft").style.top = "465px";
			document.getElementById("fixedright").style.top = "465px";
		}
		else {
			document.getElementById("fixedleft").style.top = "365px";
			document.getElementById("fixedright").style.top = "365px";
		}

	}
	else if ((ourYOffset + 340) < maxOffset) {
		document.getElementById("fixedleft").style.top = (ourYOffset - 90) + "px";
		document.getElementById("fixedright").style.top = (ourYOffset - 90) + "px";

	}
//	else if ((ourYOffset + 10) < maxOffset) {
//		document.getElementById("fixedleft").style.top = (ourYOffset - 190) + "px";
//		document.getElementById("fixedright").style.top = (ourYOffset - 190) + "px";
//	}

	setTimeout("moveBars()", 1000); // 300
}






function checkWidth() {
	widthChecked = "yes";
	resetStyleSheet();
}





function navigate(choice) {
	if (choice.options[choice.selectedIndex].value == "Colours") {
		var url = "buy-yarns-by-colour-1.html";
	}
	else if (choice.options[choice.selectedIndex].value == "Designs") {
		var url = "buy-yarns-by-designs-1.html";
	}
	else if (choice.options[choice.selectedIndex].value == "Brands") {
		var url = "buy-yarns-brands-1.html";
	}
	else if (choice.options[choice.selectedIndex].value == "Designers") {
		var url = "buy-yarns-designers-1.html";
	}
	else if (choice.options[choice.selectedIndex].value == "Weight") {
		var url = "buy-yarns-by-weight.html";
	}
	else if (choice.options[choice.selectedIndex].value == "NewInYarns") {
		var url = "new-in-yarns.html";
	}

	else if (choice.options[choice.selectedIndex].value == "NewInDesigns") {
		var url = "buy-yarns-by-designs-1.html";
	}
	else if (choice.options[choice.selectedIndex].value == "Books") {
		var url = "buy-knitting-books.html";
	}
	else if (choice.options[choice.selectedIndex].value == "Accessories") {
		var url = "buy-knitting-accessories.html";
	}
	if (url) {
		top.location.href = url;
	}
}





function checkAndSubmit2(tF) { //tF = ref to form
	var continueOn = "yes";
	var emailOK = checkEmail();
	if ( emailOK != "good" ) {
		continueOn = "no"; 
	}
	else if (tF.name.value == "") { alert("Please type your name."); continueOn = "no"; }
	else if (tF.message.value == "" || tF.message.value == "Enter Your Message Here" ) { alert("Please type your message."); continueOn = "no"; }

	if ( continueOn  == "yes") {

		str = new String(tF.name.value);
		tF.name.value = replaceSpChars(str);

		str = new String(tF.myemail.value);
		tF.myemail.value = replaceSpChars(str);

		str = new String(tF.subject.value);
		tF.subject.value = replaceSpChars(str);

		str = new String(tF.message.value);
		tF.message.value = replaceSpChars(str);

		tF.action = "http://www.thecornwallyarnshop.co.uk/cgi-bin/cycontact.pl";
		tF.submit();	
	}		
}














