// JavaScript Document for products page functionality

// this function will check to see if their user account already specified a country or not and then show states accordingly
function checkCountry1(){
	document.getElementById("nostates").style.display="none";
	document.getElementById("usstates").style.display="none";
	document.getElementById("otherstates").style.display="none";
	countryy = document.forms.step1.country.value;
	countryy = countryy.replace(/^\s+|\s+$/g, '') ;
	if(countryy==""){
		document.getElementById("nostates").style.display="block";
		document.getElementById("statelabel").innerHTML = "State";
	}else{
		if(countryy=="United States"){
			document.getElementById("usstates").style.display="block";
			document.getElementById("statelabel").innerHTML = "State";
		}else{
			document.getElementById("otherstates").style.display="block";
			document.getElementById("statelabel").innerHTML = "State/Province";
		}
	}
}

// this function will check to see if their user account already specified a country or not and then show states accordingly
function checkCountry3(){
	document.getElementById("nostates").style.display="none";
	document.getElementById("usstates").style.display="none";
	document.getElementById("otherstates").style.display="none";
	countryy = document.forms.step3.country.value;
	countryy = countryy.replace(/^\s+|\s+$/g, '') ;
	if(countryy==""){
		document.getElementById("nostates").style.display="block";
		document.getElementById("statelabel").innerHTML = "State";
	}else{
		if(countryy=="United States"){
			document.getElementById("usstates").style.display="block";
			document.getElementById("statelabel").innerHTML = "State";
		}else{
			document.getElementById("otherstates").style.display="block";
			document.getElementById("statelabel").innerHTML = "State/Province";
		}
	}
}

// this function will determine what type of field to show for the states
// a = value of selected country
function showStates(a){
	document.getElementById("nostates").style.display="none";
	document.getElementById("usstates").style.display="none";
	document.getElementById("otherstates").style.display="none";
	if(a.value==""){
		document.getElementById("nostates").style.display="block";
		document.getElementById("statelabel").innerHTML = "State";
	}else{
		if(a.value=="United States"){
			document.getElementById("usstates").style.display="block";
			document.getElementById("statelabel").innerHTML = "State";
		}else{
			document.getElementById("otherstates").style.display="block";
			document.getElementById("statelabel").innerHTML = "State/Province";
		}
	}
}

// this function will reload the billing page and use the shipping info to fill in some of the values
function copyShipping(a){
	if(a.value=="N"){
		location.href="shop.checkout.billing.php?useship";
	}else{
		location.href="shop.checkout.billing.php";
	}
}