var image = new Array(4);

var openedDiv="null";

var proto = (window.location.protocol == "https:")? "https://www.wholesalenutrition.net" : "";

image[0] = proto + "/pics/home-a.jpg";

image[1] = proto + "/pics/store-a.jpg";

image[2] = proto + "/pics/contact-a.jpg";

image[3] = proto + "/pics/about-us-a.jpg";



for (i=0; i < image.length; i++) {

var preload = new Image();

preload.src = image[i];

}



function closePopup() {

	if (openedDiv != "null")

	{

		var popup=document.getElementById(openedDiv);

		if ( popup.style.display == "" )

			popup.style.display="none";

	}

}





function largerView(id) {

	openedDiv=id;

	document.getElementById(id).style.display="";

}





function calculateAttribute(f) {

	var reg1= /[^0-9]/;		// catches everything except numbers

	f.qty.value;



	if ( reg1.test(f.qty.value) || f.qty.value == 0 )

	{

		alert ("Please enter valid value for the Quantity.");

		f.qty.value=1;

		f.qty.focus();

		return false;

	}



	maxCounter=f.attributeCounter.value;

	var val="";



	for (i=0;i<maxCounter;i++)

	{

		val=val+document.getElementById("att"+i).value;

		if ( i != maxCounter-1)

			val=val+"-";

	}



	if (val == "") val=0;



	f.trueAttValue.value=val;

}



function checkCartForm(f) {

	var reg1= /[^0-9]/;		// catches everything except numbers

	for (i=0;i<f.elements.length;i++)

	{

		if (f.elements[i].name.search("cID:") != -1)	 // if it finds the match

		{

			if ( reg1.test(f.elements[i].value) )

			{

				alert ("Please enter valid value for the Quantity.");

				f.elements[i].value=1;

				f.elements[i].focus();

				return false;

			}

		}

	}

}



function checkUserRegistration(f) {

  

	if (f.email.value.indexOf("@") + "" == "-1" || f.email.value.indexOf(".") + "" == "-1" || f.email.value == "" )

	 { 

		alert("Please enter email address in correct format.");

		f.email.focus();

		return false;

	 }

         

	if (f.pwd.value.length < 4 ) 

	 {

		alert("Password has to be at least 4 length long.");

		f.pwd.focus(); 

		return false;

	 }





//	return false;



         if (f.rpwd.value.length < 4) {

                alert("Please retype password for verification.");

				f.rpwd.focus(); 

                return false;

         }

         

         if (f.pwd.value != f.rpwd.value) {

                alert("Password verification failed.");

                f.pwd.value="";

                f.rpwd.value="";

				f.pwd.focus(); 

                return false;

         }

        

         if (f.fname.value.length < 1) {

                alert("Please enter first name.");

				f.fname.focus(); 

                return false;

         }



         if (f.lname.value.length < 1) {

                alert("Please enter last name.");

				f.lname.focus(); 

                return false;

         }		 



         if (f.address.value.length < 1) {

                alert("Please enter street address.");

				f.address.focus(); 

                return false;

         }

         if (f.city.value.length < 1) {

                alert("Please enter city.");

				f.city.focus(); 

                return false;

         }

    

         if (f.phone.value.length < 1) {

                alert("Please enter Phone Number.");

				f.phone.focus(); 

                return false;

         }		



 		 if (f.zip.value.length < 1 )

		 {

                alert("Please enter zipcode in correct format.");

				f.zip.focus(); 

                return false;             

         }

            

     //    if (f.phone.value.length < 1) {

       //         alert("Please enter contact phone number.");

		//		f.phone.focus(); 

          //      return false;

      //   }



         if (f.sAddress.value.length < 1) {

               alert("Please provide shipping address.");

				f.sAddress.focus(); 

                return false;

		  }



		  if (f.sCity.value.length < 1) {

			alert("Please provide shipping city.");

			f.sCity.focus(); 

			return false;

		  }



		 if (f.sZip.value.length < 1 )

		  {

			alert("Please provide shipping zipcode in correct format.");

			f.sZip.focus(); 

			return false;             

		  }

   }



function copyAddressInfo (name) {



	if ( document.getElementById("same").checked)

	{

		var f=document.getElementById(name);



		if ( f.country.value != 1 ) {

			var stateForm=document.getElementById("sState");

			var provinceForm=document.getElementById("sProvince");

			var displayZip=document.getElementById("sdisplay");

			stateForm.style.display="none";	

			provinceForm.style.display="";

			displayZip.innerHTML="Postalcode";



			f.sProvince.value=f.province.value;

		}





		f.sAddress.value=f.address.value;

		f.sAddress2.value=f.address2.value;

		f.sCity.value=f.city.value;

		f.sState.selectedIndex=f.state.selectedIndex;

		f.sZip.value=f.zip.value;

		f.sCountry.value=f.country.value;

	}

	else

	{

		var f=document.getElementById(name);

		f.sAddress.value="";

		f.sAddress2.value="";

		f.sCity.value="";

		f.sState.selectedIndex=0;

		f.sZip.value="";

		f.sCountry.value=1;		// set to default display country USA



		var stateForm=document.getElementById("sState");

		var provinceForm=document.getElementById("sProvince");

		var displayZip=document.getElementById("sdisplay");

		f.sProvince.value="";

		stateForm.style.display="";	

		provinceForm.style.display="none";

		displayZip.innerHTML="Zipcode";

	}

}



function internationalForm (id,state,province,display) {

	if ( id != 1 )

	{	

		var stateForm=document.getElementById(state);

		var provinceForm=document.getElementById(province);

		var displayZip=document.getElementById(display);

		stateForm.style.display="none";	

		provinceForm.style.display="";

		displayZip.innerHTML="Postalcode";

	}

	else

	{	

		var stateForm=document.getElementById(state);

		var provinceForm=document.getElementById(province);

		var displayZip=document.getElementById(display);

		provinceForm.style.display="none";

		stateForm.style.display="";	

		displayZip.innerHTML="Zipcode";

	}

}





function checkBillingForm(f) {

          





         if (f.fname.value.length < 1) {

                alert("Please enter first name.");

				f.fname.focus(); 

                return false;

         }



         if (f.lname.value.length < 1) {

                alert("Please enter last name.");

				f.lname.focus(); 

                return false;

         }		 



         if (f.address1.value.length < 1) {

                alert("Please enter street address.");

				f.address1.focus(); 

                return false;

         }



         if (f.phone.value.length < 1) {

                alert("Please enter Phone Number.");

				f.phone.focus(); 

                return false;

         }

        

         if (f.city.value.length < 1) {

                alert("Please enter city.");

				f.city.focus(); 

                return false;

         }

        



 		 if (f.zip.value.length < 1 )

		 {

                alert("Please enter zipcode in correct format.");

				f.zip.focus(); 

                return false;             

         }

            

//         if (f.phone.value.length < 1) {

  //              alert("Please enter contact phone number.");

	//			f.phone.focus(); 

      //          return false;

     //    }

}



function loadState(state) {

	var stateForm=document.getElementById("state");

	if (state == "OutsideUS")

		setOutsideUS('state','outside1');

	for (i=0;i<stateForm.options.length;i++)

	{	//find state and select it

		if (stateForm.options[i].value==state)

			stateForm.options[i].selected=true;

	}

}



function checkShippingForm(f) {

         

         if (f.profilename.value.length < 1) {

                alert("Please enter shipping profile name.");

				f.profilename.focus(); 

                return false;

         }



         if (f.address1.value.length < 1) {

                alert("Please enter street address.");

				f.address1.focus(); 

                return false;

         }



         if (f.city.value.length < 1) {

                alert("Please enter city.");

				f.city.focus(); 

                return false;

         }

        



 		 if (f.zip.value.length < 1 )

		 {

                alert("Please enter zipcode in correct format.");

				f.zip.focus(); 

                return false;             

         }

            

}



function loadOtherShipping(page,id,checkout) {

	if (checkout)

		self.location=page+"?loadVal="+id+"&checkout=true";

	else

		self.location=page+"?loadVal="+id;

}



function checkPwd(f) {

	if (f.oldpwd.value.length < 4 ) 

	 {

		alert("Password has to be at least 4 length long.");

		f.oldpwd.focus(); 

		return false;

	 }



     if (f.newpwd.value.length < 4) {

                alert("Please retype password for verification.");

				f.newpwd.focus(); 

                return false;

     }





     if (f.rnewpwd.value.length < 4) {

                alert("Please retype password for verification.");

				f.rnewpwd.focus(); 

                return false;

     }

         

	 if (f.newpwd.value != f.rnewpwd.value) {

			alert("Password verification failed.");

			f.newpwd.value="";

			f.rnewpwd.value="";

			f.newpwd.focus(); 

			return false;

	 }



}



function checkEmailForm(f) {

	if (f.newemail.value.indexOf("@") + "" == "-1" || f.newemail.value.indexOf(".") + "" == "-1" || f.newemail.value == "" )

	 { 

		alert("Please enter email address in correct format.");

		f.newemail.focus();

		return false;

	 }

}



function checkPwdForm(f) {

     if (f.newpwd.value.length < 4) {

                alert("Password must be longer than 4 characters long.");

				f.newpwd.focus(); 

                return false;

     }



     if (f.rnewpwd.value.length < 4) {

                alert("Password must be longer than 4 characters long.");

				f.rnewpwd.focus(); 

                return false;

     }



	 if (f.newpwd.value != f.rnewpwd.value) {

			alert("Password verification failed.");

			f.newpwd.value="";

			f.rnewpwd.value="";

			f.newpwd.focus(); 

			return false;

	 }

}



function contactForm(f) {

	if (f.email.value.indexOf("@") + "" == "-1" || f.email.value.indexOf(".") + "" == "-1" || f.email.value == "" )

	 { 

		alert("Please enter email address in correct format.");

		f.email.focus();

		return false;

	 }

    

	 if (f.phone.value.length < 1) {

        alert("Please enter contact phone number.");

		f.phone.focus(); 

        return false;

      }

}






aaa_h =new Image(); 
aaa_h.src =  proto + "/pics/home-a.jpg";
aaa_nh = new Image(); 
aaa_nh.src =  proto + "/pics/home.jpg";

bbb_h =new Image(); 
bbb_h.src =  proto + "/pics/store-a.jpg";
bbb_nh = new Image(); 
bbb_nh.src =  proto + "/pics/store.jpg";

ccc_h =new Image(); 
ccc_h.src =  proto + "/pics/contact-a.jpg";
ccc_nh = new Image(); 
ccc_nh.src =  proto + "/pics/contact.jpg";
 


function aaaover() {
document.getElementById('aaa').src=aaa_h.src;
}
function aaaout() {
document.getElementById('aaa').src=aaa_nh.src;
}





function bbbover() {
document.getElementById('bbb').src=bbb_h.src;
}
function bbbout() {
document.getElementById('bbb').src=bbb_nh.src;
}





function cccover() {
document.getElementById('ccc').src=ccc_h.src;
}
function cccout() {
document.getElementById('ccc').src=ccc_nh.src;
}