// JavaScript Document


var highlightColor = "#DC143C";
var baseColor = "#000000";

<!--- Hide the stuff that we dont want to show on the checkout page --->
function initCheckout1() {
	hideErrorMessage();

}
<!--- Hide the stuff that we dont want to show on the checkout page --->
function initCheckout2new() {
	if(document.orders){
		<!--- We start off with a select default, we know we are not in NY so hide the county for now --->
		hideErrorMessage();
		shippingAddress();
		county();
	}
}

<!--- Hide the stuff that we dont want to show on the checkout page --->
function initUpdateBillingAddress() {
	hideErrorMessage();
}

function initcheckout2returning() {
	//alert("wtf");
	hideErrorMessage();
	
	var x = document.getElementsByTagName('div');	
	for (var i=0;i<x.length;i++){
		if (x[i].className == 'shipmethoderror'){
			x[i].style.display = 'none';
			//return false;
		//alert("onload " +x[i].className );
		}
	}	

	if(document.orders){
		<!--- We start off with a select default, we know we are not in NY so hide the county for now --->
		shippingAddress();
	}
}

function initCheckout3() {
	hideErrorMessage();
	shippingAddress();
	
}

function initCheckout4() {
	hideErrorMessage();
}

<!--- Hide the stuff that we dont want to show on the checkout page --->
function initupdateShippingAddress_1() {
	hideErrorMessage();
}

<!--- Hide the stuff that we dont want to show on the checkout page --->
function initAccount1() {
	if(document.orders){
		<!--- We start off with a select default, we know we are not in NY so hide the county for now --->
		hideErrorMessage();
	}
}



function initZiperror() {
	var x = document.getElementsByTagName('div');
	for (var i=0;i<x.length;i++){
		if (x[i].className == 'ziperror'){
			x[i].style.display = 'none';
		//alert("onload " +x[i].className );
		}
	}
	for (var i=0;i<x.length;i++){
		if (x[i].className == 'shipmethoderror'){
			x[i].style.display = 'none';
		//alert("onload " +x[i].className );
		}
	}	
	
	if(document.orders){
		if(document.orders.noziperror){
		}else{
			for (var i=0;i<x.length;i++){
				if (x[i].className == 'noziperror'){
					x[i].style.display = 'none';
				//alert("onload " +x[i].className );
				}
			}
		}
	}
	for (var i=0;i<x.length;i++){
		if (x[i].className == 'blankzip'){
			x[i].style.display = 'none';
		//alert("onload " +x[i].className );
		}
	}	
}



<!--- Show or hide the shipping address based if the user wants to use a different shipping address or not --->
function hideErrorMessage() {
	//if the user does not user the same shipping address.
	var x = document.getElementsByTagName('div');
	//alert("we are in " + document.orders.useBillingAddress.checked);
	
	for (var i=0;i<x.length;i++){
		if (x[i].className == 'errormessage'){
			x[i].style.display = 'none';
		}
	}
}

function showErrorMessage() {
	var x = document.getElementsByTagName('div');
	for (var i=0;i<x.length;i++){
		if (x[i].className == 'errormessage'){
			x[i].style.display = 'block';	
		}
	}
}

function shippingdisplay (){
	var x = document.getElementsByTagName('div');
	for (var i=0;i<x.length;i++){
		if (x[i].className == 'shipping'){
			x[i].style.display = 'block';	
		}
	}
	for (var i=0;i<x.length;i++){
		if (x[i].className == 'shippingButton'){
			x[i].style.display = 'none';	
		}
	}
}

<!--- Show or hide the shipping address based if the user wants to use a different shipping address or not --->
function shippingAddress() {
	//if the user does not user the same shipping address.
	var x = document.getElementsByTagName('div');
	//alert("we are in " + document.orders.useBillingAddress.checked);
	if(document.orders.useBillingAddress && document.orders.useBillingAddress.checked == "1" || document.orders.useTheBillingAddress){	
		for (var i=0;i<x.length;i++){
			if (x[i].className == 'andShipping'){
				x[i].style.display = 'block';
			}
			if (x[i].className == 'shippingdisplay'){
				x[i].style.display = 'none';
			}
		}
	}else{
		for (var i=0;i<x.length;i++){
			if (x[i].className == 'andShipping'){
				x[i].style.display = 'none';
			}
			if (x[i].className == 'shippingdisplay'){
				x[i].style.display = 'block';	
			}
		}
	}
}


<!--- Show / Hide the County if we are inside of NY --->
function county() {
	if(document.getElementsByTagName){
		var x = document.getElementsByTagName('span');
		if(document.orders.State.value  == 'NY'){
			for (var i=0;i<x.length;i++){
				if (x[i].className == 'county'){
					x[i].style.display = 'inline';
				}
			}
		}else{
			for (var i=0;i<x.length;i++){
				if (x[i].className == 'county'){
					x[i].style.display = 'none';	
				}
			}
		}
	}
}


function checkAccount() {
	allGood = true;
	if(!checkAccountInfo()){
		//return false;
	allGood = false;
	}
	if (allGood){
		document.orders.submit(); 	
	}else{
		showErrorMessage();
		return false;
	}	
}

function checkCountry(){
	var x = document.getElementsByTagName('div');
	//alert(document.orders.Country.value);
	//Country
	if(document.orders.Country.value == 'OTHER'){
		for (var i=0;i<x.length;i++){
			if (x[i].className == 'USACA'){
				x[i].style.display = 'none';
			//alert("onload " +x[i].className );
			}
		}
		for (var i=0;i<x.length;i++){
			if (x[i].className == 'OTHER'){
				x[i].style.display = 'block';
			//alert("onload " +x[i].className );
			}
		}
	}else{
		for (var i=0;i<x.length;i++){
			if (x[i].className == 'USACA'){
				x[i].style.display = 'block';
			//alert("onload " +x[i].className );
			}
		}
		for (var i=0;i<x.length;i++){
			if (x[i].className == 'OTHER'){
				x[i].style.display = 'none';
			//alert("onload " +x[i].className );
			}
		}
	}
}

function checkShipCountry(){
	var x = document.getElementsByTagName('div');
	//alert(document.orders.Country.value);
	//Country
	if(document.orders.ShipCountry.value == 'SHIPOTHER'){
		for (var i=0;i<x.length;i++){
			if (x[i].className == 'SHIPUSACA'){
				x[i].style.display = 'none';
			//alert("onload " +x[i].className );
			}
		}
		for (var i=0;i<x.length;i++){
			if (x[i].className == 'SHIPOTHER'){
				x[i].style.display = 'block';
			//alert("onload " +x[i].className );
			}
		}
	}else{
		for (var i=0;i<x.length;i++){
			if (x[i].className == 'SHIPUSACA'){
				x[i].style.display = 'block';
			//alert("onload " +x[i].className );
			}
		}
		for (var i=0;i<x.length;i++){
			if (x[i].className == 'SHIPOTHER'){
				x[i].style.display = 'none';
			//alert("onload " +x[i].className );
			}
		}
	}
}
	
function CheckBillingAndShippingForm() {
	//alert("woot");
	var allGood = true;
	hideErrorMessage();
	county();
	if(!checkBillingAddress()){	
		//return false;
	allGood = false;
	}
	
	if(document.orders.useBillingAddress.checked != "1"){	
		if(!checkShippingAddress()){	
			//return false;
			allGood = false;
		}
	}
	
	if (allGood){
		document.orders.submit(); 	
	}else{
		showErrorMessage();
		return false;
	}
}	
	
	
function CheckBillingForm() {
	//alert("woot");
	var allGood = true;
	hideErrorMessage();
	county();
	if(!checkBillingAddress()){	
		//return false;
	allGood = false;
	}
	
	if (allGood){
		document.orders.submit(); 	
	}else{
		showErrorMessage();
		return false;
	}
}		
	
function CheckForm() {
	//alert("woot");
	var allGood = true;
	
	if(!checkAccountInfo()){
		//return false;
	allGood = false;
	}
						 
	if(!checkBillingAddress()){	
		//return false;
	allGood = false;
	}
	
	if(document.orders.useBillingAddress.checked != "1"){	
		if(!checkShippingAddress()){	
			//return false;
			allGood = false;
		}
	}
	
	//CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
	if (document.orders.CardName.value == "") {
	//alert("Please enter a name for your Credit Card.");
	document.orders.CardName.focus();
	mySelect=document.getElementById("CardName");
	mySelect.style.color = highlightColor;
	allGood = false;
	}	
	
	if(!isValidCreditCard(document.orders.CardType.value, document.orders.CardNumber.value)){
	//alert("The credit card number entered is invalid. Please check the card and try the number again.");
	mySelect=document.getElementById("CardType");
	mySelect.style.color = highlightColor;
	mySelect=document.getElementById("CardNumber");
	mySelect.style.color = highlightColor;
	document.orders.CardNumber.focus();
	allGood = false;	
	}
	
	if(document.orders.CardCode.value.length > 2){
		if(document.orders.CardType.value == "Visa" || document.orders.CardType.value == "Mastercard"){
			if(document.orders.CardCode.value.length != 3){
				//alert("Please enter a verification code for your credit card.");
				mySelect=document.getElementById("CardCode");
				mySelect.style.color = highlightColor;
				document.orders.CardCode.focus();
				allGood = false;	
			}
		}
	}else{
		mySelect=document.getElementById("CardCode");
		mySelect.style.color = highlightColor;
	}
	//CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
	
	if (allGood){
		document.orders.submit(); 	
	}else{
		showErrorMessage();
		return false;
	}
}

function checkCardInformation(){
	allGood = true;
	mySelect=document.getElementById("CardName");
	mySelect.style.color = baseColor;
	mySelect=document.getElementById("CardType");
	mySelect.style.color = baseColor;
	mySelect=document.getElementById("CardNumber");
	mySelect.style.color = baseColor;
	mySelect=document.getElementById("CardCode");
	mySelect.style.color = baseColor;


//CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
	if (document.orders.CardName.value == "") {
	//alert("Please enter a name for your Credit Card.");
	document.orders.CardName.focus();
	mySelect=document.getElementById("CardName");
	mySelect.style.color = highlightColor;
	allGood = false;
	}	
	if (document.orders.CardType.value == ""){
		mySelect=document.getElementById("CardType");
		mySelect.style.color = highlightColor;
	}
	
	if(!isValidCreditCard(document.orders.CardType.value, document.orders.CardNumber.value)){
	//alert("The credit card number entered is invalid. Please check the card and try the number again.");
	mySelect=document.getElementById("CardNumber");
	mySelect.style.color = highlightColor;
	document.orders.CardNumber.focus();
	allGood = false;	
	}
	
	if(document.orders.CardCode.value.length > 2){
		if(document.orders.CardType.value == "Visa" || document.orders.CardType.value == "Mastercard"){
			if(document.orders.CardCode.value.length != 3){
				//alert("Please enter a verification code for your credit card.");
				mySelect=document.getElementById("CardCode");
				mySelect.style.color = highlightColor;
				document.orders.CardCode.focus();
				allGood = false;	
			}
		}
	}else{
		mySelect=document.getElementById("CardCode");
		mySelect.style.color = highlightColor;
	}
	//CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
	
	if (allGood){
		document.orders.submit(); 	
	}else{
		showErrorMessage();
		return false;
	}
}

function checkBankInformation(){
	allGood = true;
	mySelect=document.getElementById("BankName");
	mySelect.style.color = baseColor;
	mySelect=document.getElementById("BankType");
	mySelect.style.color = baseColor;
	mySelect=document.getElementById("BankNumber");
	mySelect.style.color = baseColor;
	mySelect=document.getElementById("BankRouting");
	mySelect.style.color = baseColor;


//CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
	if (document.orders2.BankName.value == "") {
		document.orders2.BankName.focus();
		mySelect=document.getElementById("BankName");
		mySelect.style.color = highlightColor;
		allGood = false;
	}	
	if (document.orders2.BankType.value == ""){
		mySelect=document.getElementById("BankType");
		mySelect.style.color = highlightColor;
	}
	
	if(document.orders2.BankNumber.value == ""){
		mySelect=document.getElementById("BankNumber");
		mySelect.style.color = highlightColor;
		document.orders2.BankNumber.focus();
		allGood = false;	
	}

	if(document.orders2.BankRouting.value == ""){
		mySelect=document.getElementById("BankRouting");
		mySelect.style.color = highlightColor;
		document.orders2.BankRouting.focus();
		allGood = false;	
	}
//CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
	
	if (allGood){
		document.orders2.submit(); 	
	}else{
		showErrorMessage();
		return false;
	}
}
	

function CheckShippingForm() {
	if(!checkShippingAddress()){	
		showErrorMessage();
		return false;
	}
	
	document.orders.submit(); 	
}
function checkCheckout2returning() {
	//alert("checkCheckout2returning" + document.orders.ShipTo[2].value);
	//mySelect=document.getElementById("shippingType");
	//mySelect.style.color = baseColor;
	if(document.orders.shipMethod.selectedIndex == 0){
		for (var i=0;i<x.length;i++){
			if (x[i].className == 'shipmethoderror'){
				x[i].style.display = 'inline';
				return false;
			//alert("onload " +x[i].className );
			}
		}
	}
	var theAddress  = "0";
	if(document.orders.useBillingAddress.checked != "1"){
	
		for(var i=0; i<document.orders.ShipTo.length; i++){
			//alert("inloop")
			if((document.orders.ShipTo[i].checked)) { 
				//alert("incheckedbox");
				theAddress = document.orders.ShipTo[i].value; 
			}
		}
		
		if(theAddress == "NewAddress" || theAddress == 0){
			//alert("new Address");
			if(!checkShippingAddress()){	
				showErrorMessage();
				return false;
			}
		}
	}
	
/*	if(document.orders.shipMethod.selectedIndex == 0){
		var x = document.getElementsByTagName('div');
		for (var i=0;i<x.length;i++){
			if (x[i].className == 'shipmethoderror'){
				x[i].style.display = 'inline';
				

				mySelect=document.getElementById("shippingType");
				mySelect.style.color = highlightColor;
				document.orders.Email.focus();

				return false;
			//alert("onload " +x[i].className );
			}
		}
	}
	*/
	
	document.orders.submit(); 	
}


	
function checkAccountInfo() {
	allGood = true;	
	
	
	mySelect=document.getElementById("Email");
	mySelect.style.color = baseColor;
	mySelect=document.getElementById("accountPassword");
	mySelect.style.color = baseColor;
	mySelect=document.getElementById("returningaccountPassword");
	mySelect.style.color = baseColor;

	if(!echeck(document.orders.Email.value)){
		//alert("Please enter a valid email address. (name@domain.domaintype)");
		mySelect=document.getElementById("Email");
		mySelect.style.color = highlightColor;
		document.orders.Email.focus();
		allGood = false;	
		//return false;
	}
	if(document.orders.action[0].checked){
		if(!checkPassword(document.orders.accountPassword.value)){
			document.orders.accountPassword.focus();
			mySelect=document.getElementById("accountPassword");
			mySelect.style.color = highlightColor;
			document.orders.accountPassword.focus();
			allGood = false;	
			//return false;
		}	
	}
	else{
		if(!checkPassword(document.orders.returningaccountPassword.value)){
			document.orders.returningaccountPassword.focus();
			mySelect=document.getElementById("returningaccountPassword");
			mySelect.style.color = highlightColor;
			document.orders.returningaccountPassword.focus();
			allGood = false;	
			//return false;
		}	
	}
	return allGood;
}
	
function checkPassword (strng) {
	var error = "";
	if (strng == "") {
		//alert("Please enter a password");
		return false;
	}
	var illegalChars = /[\W_]/; // allow only letters and numbers
	if ((strng.length < 5) || (strng.length > 20)) {
		//alert("The password needs to be between 5 and 20 characters long.");
		return false;
    }
	else if (illegalChars.test(strng)) {
		//alert("The password contains illegal characters. Only letters and numbers will be accepted.");
		return false;
	}
	return true;
}

function checkBillingAddress() {
	//BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
	mySelect=document.getElementById("FirstName");
	mySelect.style.color = baseColor;
	mySelect=document.getElementById("LastName");
	mySelect.style.color = baseColor;
	mySelect=document.getElementById("Address1");
	mySelect.style.color = baseColor;
	mySelect=document.getElementById("City");
	mySelect.style.color = baseColor;
	mySelect=document.getElementById("State");
	mySelect.style.color = baseColor;
	mySelect=document.getElementById("County");
	mySelect.style.color = baseColor;	
	mySelect=document.getElementById("Zip");
	mySelect.style.color = baseColor;
	mySelect=document.getElementById("City");
	mySelect.style.color = baseColor;
	mySelect=document.getElementById("Phone");
	mySelect.style.color = baseColor;

	var allGood = true;
	

	//First Name
	if (document.orders.FirstName.value == "") {
	//alert("Please enter your first name.");
	mySelect=document.getElementById("FirstName");
	mySelect.style.color = highlightColor;
	document.orders.FirstName.focus();
	allGood = false;
	}
	//Last Name
	if (document.orders.LastName.value == "") {
	//alert("Please enter your last name.");
	mySelect=document.getElementById("LastName");
	mySelect.style.color = highlightColor;
	document.orders.LastName.focus();
	allGood = false;
	}
	if(document.orders.Country.value == 'OTHER'){
			return allGood;
	}
	// Address1
	if (document.orders.Address1.value == "") {
	//alert("Please enter your address.");
	mySelect=document.getElementById("Address1");
	mySelect.style.color = highlightColor;
	document.orders.Address1.focus();
	allGood = false;
	}
	//City
	if (document.orders.City.value == "") {
	//alert("Please enter your city.");
	mySelect=document.getElementById("City");
	mySelect.style.color = highlightColor;
	document.orders.City.focus();
	allGood = false;
	}
	//State or Province
	if (document.orders.State.selectedIndex == 0 && document.orders.Province.value == "") {
	//alert("Please select your state or enter a province.");
	mySelect=document.getElementById("State");
	mySelect.style.color = highlightColor;
	document.orders.State.focus();
	allGood = false;
	}
	// County
	if (document.orders.State.selectedIndex == 33 && document.orders.County.selectedIndex == 0) {
	//alert("Please enter your county.");
	mySelect=document.getElementById("County");
	mySelect.style.color = highlightColor;
	document.orders.County.focus();
	allGood = false;
	}
	//Zip Code
	if(!validateZIP(document.orders.Zip.value)){
		mySelect=document.getElementById("Zip");
		mySelect.style.color = highlightColor;
		document.orders.Zip.focus();
		allGood = false;
	}
	if (document.orders.City.value == "") {
	//alert("Please enter your city.");
	mySelect=document.getElementById("City");
	mySelect.style.color = highlightColor;
	document.orders.City.focus();
	allGood = false;
	}
	
	if(!checkInternationalPhone(document.orders.Phone.value)){
		//alert("Please enter a valid phone number.");
		mySelect=document.getElementById("Phone");
		mySelect.style.color = highlightColor;
		document.orders.Phone.focus();
		allGood = false;
	}
	if(allGood){
		return true;
	}else{
		return false;
	}
	//BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
}

function checkShippingAddress() {
	//BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB

	mySelect=document.getElementById("ShipFirstName");
	mySelect.style.color = baseColor;
	mySelect=document.getElementById("ShipLastName");
	mySelect.style.color = baseColor;
	mySelect=document.getElementById("ShipAddress1");
	mySelect.style.color = baseColor;
	mySelect=document.getElementById("ShipCity");
	mySelect.style.color = baseColor;
	mySelect=document.getElementById("ShipState");
	mySelect.style.color = baseColor;
	mySelect=document.getElementById("ShipZip");
	mySelect.style.color = baseColor;
	mySelect=document.getElementById("ShipCity");
	mySelect.style.color = baseColor;
	mySelect=document.getElementById("ShipPhone");
	mySelect.style.color = baseColor;
	mySelect=document.getElementById("ShipEmail");
	mySelect.style.color = baseColor;

	//First Name
	allGood = true;

	
	if (document.orders.ShipFirstName.value == "") {
		//alert("Please enter your shipping first name.");
		mySelect=document.getElementById("ShipFirstName");
		mySelect.style.color = highlightColor;
		document.orders.ShipFirstName.focus();
		allGood = false;
	}
	//Last Name
	if (document.orders.ShipLastName.value == "") {
		//alert("Please enter your shipping last name.");
		mySelect=document.getElementById("ShipLastName");
		mySelect.style.color = highlightColor;
		document.orders.ShipLastName.focus();
		allGood = false;
	}
	if(document.orders.ShipCountry.value == 'ShipOTHER'){
		return allGood;
	}	

	// Address1
	if (document.orders.ShipAddress1.value == "") {
		//alert("Please enter your shipping address.");
		mySelect=document.getElementById("ShipAddress1");
		mySelect.style.color = highlightColor;
		document.orders.ShipAddress1.focus();
		allGood = false;
	}
	//City
	if (document.orders.ShipCity.value == "") {
		//alert("Please enter your shipping city.");
		mySelect=document.getElementById("ShipCity");
		mySelect.style.color = highlightColor;
		document.orders.ShipCity.focus();
		allGood = false;
	}
	//State or Province
	if (document.orders.ShipState.selectedIndex == 0) {
		//alert("Please select your shipping state.");
		mySelect=document.getElementById("ShipState");
		mySelect.style.color = highlightColor;
		//document.orders.State.focus();
		allGood = false;
	}
	//Zip Code
	if(!validateZIP(document.orders.ShipZip.value)){
		mySelect=document.getElementById("ShipZip");
		mySelect.style.color = highlightColor;
		document.orders.ShipZip.focus();
		allGood = false;
	}
	if (document.orders.ShipCity.value == "") {
		//alert("Please enter your shipping city.");
		mySelect=document.getElementById("ShipCity");
		mySelect.style.color = highlightColor;
		document.orders.ShipCity.focus();
		allGood = false;
	}
	
	if(!checkInternationalPhone(document.orders.ShipPhone.value)){
		//alert("Please enter a valid shipping phone number.");
		mySelect=document.getElementById("ShipPhone");
		mySelect.style.color = highlightColor;
		document.orders.ShipPhone.focus();
		allGood = false;
	}
	if(document.orders.ShipEmail.value != ""){
		if(!echeck(document.orders.ShipEmail.value)){
			//alert("Please enter a valid email address. (name@domain.domaintype)");
			mySelect=document.getElementById("ShipEmail");
			mySelect.style.color = highlightColor;
			document.orders.ShipEmail.focus();
			allGood = false;	
			//return false;
		}	
	}
	return allGood;
		
}
function checkCheckout() {
	//alert("Checking");
	var x = document.getElementsByTagName('div');
	
	for (var i=0;i<x.length;i++){
		if (x[i].className == 'blankzip'){
			x[i].style.display = 'none';
		}
	}
	
	if(document.shippingCalulator)
	{
		document.checkout.submit();
	}
	else
	{
		for (var i=0;i<x.length;i++)
		{
			if (x[i].className == 'blankzip')
			{
				x[i].style.display = 'inline';
			}
		}
		return false;
	}
	

}

function checkShippingZip() {

	var x = document.getElementsByTagName('div');
	
	for (var i=0;i<x.length;i++){
		if (x[i].className == 'ziperror'){
			x[i].style.display = 'none';
		//alert("onload " +x[i].className );
		}
	}
	for (var i=0;i<x.length;i++){
		if (x[i].className == 'shipmethoderror'){
			x[i].style.display = 'none';
		//alert("onload " +x[i].className );
		}
	}
	
	if(validateZIP(document.orders.ShipZip.value) != 1){
		//if the user does not user the same shipping address.
			for (var i=0;i<x.length;i++){
				if (x[i].className == 'ziperror'){
					x[i].style.display = 'inline';
				//alert("onload " +x[i].className );
				}
			}
			document.orders.ShipZip.focus();
			return false;
	}
	
	
	if(document.orders.shipMethod.selectedIndex == 0){
		for (var i=0;i<x.length;i++){
			if (x[i].className == 'shipmethoderror'){
				x[i].style.display = 'inline';
				return false;
			//alert("onload " +x[i].className );
			}
		}
	}
	
	
	document.orders.submit();
	return true;
}




//VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV	
//Validation Functions.	
function validateZIP(field) {
	var valid = "0123456789-";
	var hyphencount = 0;
	
	if (field.length!=5 && field.length!=10) {
	//return("Please enter your 5 digit or 5 digit+4 zip code.");
	return false;
	}
	for (var i=0; i < field.length; i++) {
	temp = "" + field.substring(i, i+1);
	if (temp == "-") hyphencount++;
	if (valid.indexOf(temp) == "-1") {
	//return("Invalid characters in your zip code.  Please try again.");
	return false;
	}
	if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) {
	//return("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
	return false;
	   }
	}
	return 1;
}

	
function isValidCreditCard(type, ccnum) {

	if (ccnum == "1234123412341234" ) {
		//return true;
	}
	if (ccnum == "4111111111111111" ) {
		return true;
	}
	
	
   if (type == 1) {
      // Visa: length 16, prefix 4, dashes optional.
      var re = /^4\d{3}-?\d{4}-?\d{4}-?\d{4}$/;
   } else if (type == 3) {
      // Mastercard: length 16, prefix 51-55, dashes optional.
      var re = /^5[1-5]\d{2}-?\d{4}-?\d{4}-?\d{4}$/;
   } else if (type == "Disc") {
      // Discover: length 16, prefix 6011, dashes optional.
      var re = /^6011-?\d{4}-?\d{4}-?\d{4}$/;
   } else if (type == 2) {
      // American Express: length 15, prefix 34 or 37.
      var re = /^3[4,7]\d{13}$/;
   } else if (type == "Diners") {
      // Diners: length 14, prefix 30, 36, or 38.
      var re = /^3[0,6,8]\d{12}$/;
   }else{
	    return false;
   }
   if (!re.test(ccnum)){
	   //alert("Invalid CreditCard Number");
	  // document.orders.CardNumber.focus();
	   return false;
   }
   // Checksum ("Mod 10")
   // Add even digits in even length strings or odd digits in odd length strings.
   var checksum = 0;
   for (var i=(2-(ccnum.length % 2)); i<=ccnum.length; i+=2) {
      checksum += parseInt(ccnum.charAt(i-1));
   }
   // Analyze odd digits in even length strings or even digits in odd length strings.
   for (var i=(ccnum.length % 2) + 1; i<ccnum.length; i+=2) {
      var digit = parseInt(ccnum.charAt(i-1)) * 2;
      if (digit < 10) { checksum += digit; } else { checksum += (digit-9); }
   }
   if ((checksum % 10) == 0) {
   	//document.orders.submit();
   }
   else {
	//alert("Invalid CreditCard Number");
	//document.orders.CardNumber.focus();
	return false;
	}
	return true;
}

// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)

{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
} 

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}



function emailCheck(str) {
alert("Please enter your first name.");
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }
		//document.theForm.submit();
 		 //return true					
	}

//VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV	

