// PO

var checkPayInterval = "";
var isCookied;
var displaying=0;

function checkPO(){
//var checkPayInterval = setInterval("checkit()",500);
checkit();
isCookied = checkForCookie();
}


function checkit(){
var payTrigger = document.order.paytype.value;
var outPutDiv = document.getElementById("popop");


if (payTrigger == 4){

	if (isCookied == true){
	
		if (displaying == 0){
		outPutDiv.style.display = "none";
		displaying = 0;
		//clearInterval(checkPayInterval);
		}


	}else{
	
		if (displaying == 0){
		outPutDiv.style.display = "block";
		displaying = 1;
		}

	}

} else {

	outPutDiv.style.display = "none";
	displaying = 0;

}


}


function checkForCookie(){
var allcookies = document.cookie;
var pos = allcookies.indexOf("paymentpo=");

if (pos != -1){
	var start = pos + 10;
	var end = allcookies.indexOf(";",start);
	if(end == -1) end = allcookies.length;
	var value = allcookies.substring(start,end);
}

if (value != 1){
return false;
}else{
return true;
}


}


function okayed(){

var expireddate = new Date();

expireddate.setTime(expireddate.getTime()+ (30*24*3600*1000));

document.cookie = "paymentpo=1;expires="+expireddate.toGMTString();

isCookied = true;

displaying = 0;

}


// ZIP CODE

function checkZip(){
	

if (typeof document.order.zip_code != "undefined") {
	var theZip = document.order.zip_code.value;
	var taxObj = document.order.tax[0];

	if (taxObj != null) {
		var theTax = taxObj.options[taxObj.selectedIndex].value;
		
		
		if(theZip >= 32003 && theZip <= 34990){
				if(theTax == 1){
				positionFloater("show");
				taxObj.selectedIndex = 2;
				}else{
				positionFloater("hide");	
				}
		}else{
		positionFloater("hide");
		taxObj.selectedIndex = 0;
		}
	}
}
} // END FUNCTION


function positionFloater(state){
var floater = document.getElementById("floater");

this.state = state;

if(state == "show"){
floater.style.display = "block";
}else if(state == "hide"){
floater.style.display = "none";
}


}

