var home="http://www.scrubcenter.com";

var image = new Array(7);
	image[0] =     home+"/pics/aboutus_A.jpg";
	image[1] =     home+"/pics/terms_A.jpg";
	image[2] =     home+"/pics/related_sites_A.jpg";
	image[3] =     home+"/pics/related_sites_A.jpg";
	image[4] =     home+"/sitemap_A.jpg";
	image[5] =     home+"/pics/products_A.jpg";
	image[6] =     home+"/pics/order_A.jpg";
	image[7] =     home+"/pics/contactus_A.jpg";

for (i=0; i < image.length; i++) {
preload = new Image();
preload.src = image[i];
}

var part_arr = [];

function checkEmailForm (Form) {
		if (Form.txt_name.value.length < 1) {
			alert("Please fill out your name.");
			Form.txt_name.focus(); 
			return false;
		}
		if (Form.txt_company.value.length < 1) {
			alert("Please fill out your company name.");
			Form.txt_company.focus(); 
			return false;
		}

		if (Form.txt_email.value.indexOf("@") + "" == "-1" || Form.txt_email.value.indexOf(".") + "" == "-1" || Form.txt_email.value == "" )
				{ 
					alert("Please enter email address in correct format.");
					Form.txt_email.focus();
					return false;
				}

		if (Form.txt_phone.value.length < 1) {
			alert("Please fill out your company name.");
			Form.txt_phone.focus(); 
			return false;
		}
}

function checkOptInForm (Form) {
		if (Form.fname.value.length < 1) {
			alert("Please fill out your first name.");
			Form.fname.focus(); 
			return false;
		}

		if (Form.lname.value.length < 1) {
			alert("Please fill out your last name.");
			Form.lname.focus(); 
			return false;
		}

		if (Form.address.value.length < 1) {
			alert("Please fill out your street address.");
			Form.address.focus(); 
			return false;
		}

		if (Form.city.value.length < 1) {
			alert("Please fill out your city.");
			Form.city.focus(); 
			return false;
		}

		if (Form.state.value.length < 1) {
			alert("Please fill out your state.");
			Form.state.focus(); 
			return false;
		}

		if (Form.zip.value.length < 1) {
			alert("Please fill out your zipcode.");
			Form.zip.focus(); 
			return false;
		}
		
		if (Form.phone.value.length < 1) {
			alert("Please fill out your phone number.");
			Form.phone.focus(); 
			return false;
		}

		if (Form.email.value.indexOf("@") + "" == "-1" || Form.email.value.indexOf(".") + "" == "-1" || Form.email.value == "" )
				{ 
					alert("Please enter email address in correct format.");
					Form.email.focus();
					return false;
				}

		if (Form.phone.value.length < 1) {
			alert("Please fill out your phone number.");
			Form.phone.focus(); 
			return false;
		}
}

function onlyint(e,field)
{
	if (window.event) keynum = e.keyCode;
	else if (e.which) keynum = e.which;
	
	if(keynum == "0x0b") return true;//allow tabs
	if (keynum == "0x08") return true;
	if (keynum == "0x09") return true;
  	if (keynum == "0x20") return true; //allow space
	if (keynum == "0x2d" && field == 'phone') return true; //allow hyphen
	if (keynum == "0x28" && field == 'phone') return true; //left parenthesis
	if (keynum == "0x29" && field == 'phone') return true; //right parenthesis
	if (keynum == "0x2E" && field == 'currency') return true;
	if (keynum == "0x2F" && field == 'date') return true;
	if ((keynum >= "0x30") && (keynum <="0x39")) return true; //allow 0 - 9
	return false;
}







	function swapColor(name,file,controlFile) {
		if (controlFile != "")
		{
			if ( name != "White")
			{
				document.getElementById("controller").style.display="none";
				document.getElementById("controller2").style.display="";//style.filter = "alpha(opacity="+gI+",style=2,finishopacity=0)";
			}
			else
			{	
				document.getElementById("controller").style.display="";
				document.getElementById("controller2").style.display="none";//style.filter = "alpha(opacity="+gI+",style=2,finishopacity=0)";
			}
			
			document.getElementById("bgControl").style.backgroundImage="url("+home+"/colorsPainted/"+file+")";
			//alert(document.getElementById("bgControl").style.backgroundImage);
		}

		document.forms['cartForm'].colorInfo.value=name;

		for (i=0;i<document.forms['cartForm'].chosenColor.length;i++)	
			if ( document.forms['cartForm'].chosenColor.options[i].text ==name )
				document.forms['cartForm'].chosenColor.options[i].selected=true;
		setDefault();
		}


function swapColor2(name,file,controlFile) {
		if (controlFile != "")
		{
			if ( name != "White")
			{
				document.getElementById("controller").style.display="none";
				document.getElementById("controller2").style.display="";//style.filter = "alpha(opacity="+gI+",style=2,finishopacity=0)";
			}
			else
			{	
				document.getElementById("controller").style.display="";
				document.getElementById("controller2").style.display="none";//style.filter = "alpha(opacity="+gI+",style=2,finishopacity=0)";
			}

			document.getElementById("bgControl").style.backgroundImage="url("+home+"/colorsPainted/"+file+")";
		}
		document.forms['cartForm'].colorInfo.value=name;

		for (i=0;i<document.forms['cartForm'].chosenColor.length;i++)	
			if ( document.forms['cartForm'].chosenColor.options[i].text ==name )
				document.forms['cartForm'].chosenColor.options[i].selected=true;

		setDefault();
		}

function swapColor3(arg) {
	newItems=arg.split("','");
	swapColor(newItems[0],newItems[1],newItems[2]);
}

function swapColor4(arg) {
	newItems=arg.split("','");
	swapColor2(newItems[0],newItems[1],newItems[2]);
}

		function setDefault() {
    	//document.forms['cartForm'] = document.forms['document.forms['cartForm']'];
			//alert(document.forms['cartForm']);
			document.forms['cartForm'].test.value=globalItem+"-"+document.forms['cartForm'].colorInfo.value+"-"+document.forms['cartForm'].size.options[document.forms['cartForm'].size.selectedIndex].value;
		}
		
		function setDefaultMulti() {
    	//document.forms['cartForm'] = document.forms['document.forms['cartForm']'];
			//alert(document.forms['cartForm']);
			for(i=0;i<part_arr.length;i++)
				document.forms['cartForm']['test_'+part_arr[i]].value=document.forms['cartForm']['PartNo_'+part_arr[i]].value+" | Size: "+document.forms['cartForm']['size_'+part_arr[i]].options[document.forms['cartForm']['size_'+part_arr[i]].selectedIndex].value;
		}

		function changePartNum (val) {
			document.forms['cartForm'].test.value=globalItem+"-"+document.forms['cartForm'].colorInfo.value+"-"+val;

			if ( val == "3X" || val == "4X" || val == "5X")
			{
				var num=parseFloat(document.forms['cartForm'].price.value)+parseFloat(document.forms['cartForm'].lprice.value)
				num=num.toFixed(2); 
				document.getElementById("priceDisplay").innerHTML=num;
			}
			else
				document.getElementById("priceDisplay").innerHTML=document.forms['cartForm'].price.value;
		}

		function changePartNumMulti(id) {
			document.getElementById('test_'+id).value=document.getElementById('PartNo_'+id).value+" | Size: "+document.forms['cartForm']['size_'+id].options[document.forms['cartForm']['size_'+id].selectedIndex].value;
		}
		
		function setPartNum (f) {
			f.PartNo.value=f.test.value;
			if ( f.p1)
			{
				if ( f.p1.value == "no" )	// get rid of the text input from user
					f.p3.value='';
			}
		}

		function setPartNumMulti (f) {
			for(i=0;i<part_arr.length;i++) {
				document.getElementById("PartNo_"+part_arr[i]).value=document.getElementById("PartNo_"+part_arr[i]).value;
			}
		}
		
		function bigPic(file) {
		//opens pop-up windows for upload images
		URL=home+"/thumbNail.php?file="+file;
		var property='titlebar=no,scrollbars=yes,,width=600,height=500,screenX=400,screenY=400,top=400,left=400';
		window.open(URL,"upload",property);
		}

		function sendEmail(code) {
		//opens pop-up windows for upload images
		URL=home+"/sendEmailToFriend.php?code="+code;
		var property='titlebar=no,scrollbars=yes,,width=400,height=280,screenX=400,screenY=400,top=400,left=400';
		window.open(URL,"email",property);
		}

		function displayOptions(val) {
			if (val == "yes") {
				document.getElementById("options1").style.visibility="";
				document.getElementById("options2").style.visibility="";
			}
			else
			{
				document.getElementById("options1").style.visibility="hidden";
				document.getElementById("options2").style.visibility="hidden";
			}
		}
