
// Function to Create Screen Pops
function OpenWindow(sURL){
	window.open(sURL, 'anew', config='height=550,width=495,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=yes');
}

function navigateURL(urlChars)
{
	sealWin = window.open(urlChars,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=550,height=400');
	self.name = "mainWin"; 
}

/* Validate the Shipping Step */
function ValidateShipping(){
	document.step2.submit1.disabled = true;
	errfound = false;
}

function Validate(form)
{
	if (form.Shipping_First_Name.value.length==0)
	{
		alert("Please enter the first name of the shipping contact");
		form.Shipping_First_Name.focus();
		return (false);
	}
   
	if (form.Shipping_Last_Name.value.length==0)
	{
		alert("Please enter the last name of the shipping contact");
		form.Shipping_Last_Name.focus();
		return (false);
	}
   
	if (form.Shipping_Address.value.length==0)
	{
		alert("Please enter the Shipping street address");
		form.Shipping_Address.focus();
		return (false);
	}
   
	if (form.Shipping_City.value.length==0)
	{
		alert("Please enter city");
		form.Shipping_City.focus();
		return (false);
	}
	
	if(form.Shipping_Zip.value.length >10)
    {
		alert("Invalid zipcode format. Sample 34807");
        form.Shipping_Zip.focus();
        return (false);
    }
   	
	if (form.Shipping_State.value.length < 2)
	{
		alert("Please select a 2 character state abbreviation");
        form.Shipping_State.focus();
        return (false);
	}
      
return(true);
}

/* Purchase Validation */
function ValidatePurchase(form)
{
	if (form.BillingFirstName.value.length==0)
	{
		alert("Please enter the first name of the Billing contact");
		form.BillingFirstName.focus();
		return (false);
	}
   
	if (form.BillingLastName.value.length==0)
	{
		alert("Please enter the last name of the Billing contact");
		form.BillingLastName.focus();
		return (false);
	}
   
	if (form.BillingAddress.value.length==0)
	{
		alert("Please enter the Billing street address");
		form.BillingAddress.focus();
		return (false);
	}
   
	if (form.BillingCity.value.length==0)
	{
		alert("Please enter the Billing city");
		form.BillingCity.focus();
		return (false);
	}
	
	if(form.BillingZip.value.length > 10 || form.BillingZip.value.length < 5)
    {
		alert("Invalid zipcode, please include 5 digit zip code.");
        form.BillingZip.focus();
        return (false);
    }
   	
	if (form.BillingPhone.value.length < 10)
	{
		alert("Please enter your phone number with area code");
        form.BillingPhone.focus();
        return (false);
	}
	
	if (form.CreditCardNumber.value.length < 15)
	{
		alert("Please enter your credit card number");
        form.CreditCardNumber.focus();
        return (false);
	}
	
	if (form.EmailAddress.value.length < 5)
	{
		alert("Please enter an email address");
        form.EmailAddress.focus();
        return (false);
	}
   
return(true);
}

/* Purchase Populators */
function undoFill()
{
	//customer has decided to undo the FillBillTo function
	(document.step3.BillingFirstName.value)= "";
	(document.step3.BillingLastName.value)= "";
	(document.step3.BillingAddress.value)= "";
	(document.step3.BillingSuiteApt.value)= "";
	(document.step3.BillingCity.value)= "";
	(document.step3.BillingState.value)= "";
	(document.step3.BillingZip.value)= "";
}

/* Ajax Search Functions */
var xmlHttp; 
var browser = ""; 
var uagString = new String(navigator.userAgent);
if (uagString.indexOf("Firefox") > -1 || uagString.indexOf("Chrome") > -1 || uagString.indexOf("Safari") > -1) { browser = "FF"; } else { browser = "IE"; }
function search(z){ Progress(); HTTPRequest(z);} 
function HTTPRequest(searchText){if(browser == "IE"){xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");}else if(browser == "FF"){xmlHttp = new XMLHttpRequest();}var requestUrl = location.protocol + "//" + location.host + "/server.asp?q=" + encodeURIComponent(searchText);var isAsyncRequest = true;if(xmlHttp){xmlHttp.onreadystatechange = Response;xmlHttp.open("GET", requestUrl, isAsyncRequest);xmlHttp.send(null);}} 
function Progress(s){var prog = document.getElementById("loading"); prog.style.visibility = "visible";} 
function Response(){if(xmlHttp.readyState == 4){if(xmlHttp.status == 200){Write(xmlHttp.responseText);}else{Write(xmlHttp.status);}}}
function Write(searchResults){var prog = document.getElementById("loading");prog.style.visibility = "hidden";var resultsPanel = document.getElementById("serps");resultsPanel.innerHTML = searchResults;if(searchResults != ""){resultsPanel.style.visibility = "visible";}else{resultsPanel.style.visibility = "hidden";}}
