
/***********************************************
* Required field(s) validation v1.10- By NavSurf
* Visit Nav Surf at http://navsurf.com
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

function formCheck(formobj){
	// Enter name of mandatory fields
	var fieldRequired = Array("credit_card_number", "credit_card_verification_number", "bill_first_name", "bill_last_name", "bill_address_one", "bill_city", "bill_state_or_province", "bill_zip_or_postal_code", "bill_country_code", "bill_email", "ship_first_name", "ship_last_name", "ship_address_one", "ship_city", "ship_state_or_province", "ship_zip_or_postal_code", "ship_country_code", "ship_email");
	// Enter field description to appear in the dialog box
	var fieldDescription = Array("Credit Card Number", "CVV", "Billing First Name", "Billing Last Name", "Billing Address", "Billing City", "Billing State or Province", "Billing Zip or Postal Code", "Billing Country", "Billing Email", "Shipping First Name", "Shipping Last Name", "Shipping Address", "Shipping City", "Shipping State or Province", "Shipping Zip or Postal Code", "Shipping Country", "Shipping Email");
	// dialog message
	var alertMsg = "Please complete the following fields:\n";

	var l_Msg = alertMsg.length;

	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == "(choose one)" || obj.options[obj.selectedIndex].text == "" || obj.options[obj.selectedIndex].text == "--CANADA--" || obj.options[obj.selectedIndex].text == "--UNITED STATES--"){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}

function swapImg(name, ON_OFF, path, stat_txt){
	var suff = ""
	var type = ".gif";
		suff = ON_OFF ? "_h" : "";
	document.images[name].src = path + name + suff + type;
	window.status = stat_txt;
}

function InitSaveVariables(form) {
	var ship_first_name = "";
	var ship_last_name = "";
	var ship_email = "";
	var ship_company = "";
	var ship_address_one = "";
	var ship_address_two = "";
	var ship_city = "";
	var ship_state_or_province = "";
	var ship_state_or_province_index = 0;
	var ship_zip_or_postal_code = "";
	var ship_country_code = "";
	var ship_country_code_index = 0;
	var ship_phone = "";
	var ship_fax = "";
	ship_first_name = form.ship_first_name.value;
	ship_last_name = form.ship_last_name.value;
	ship_email = form.ship_email.value;
	ship_company = form.ship_company.value;
	ship_address_one = form.ship_address_one.value;
	ship_address_two = form.ship_address_two.value;
	ship_city = form.ship_city.value;
	ship_state_or_province_index = form.ship_state_or_province.selectedIndex;
	ship_state_or_province = form.ship_state_or_province[ship_state_or_province_index].value;
	ship_zip_or_postal_code = form.ship_zip_or_postal_code.value;
	ship_country_code_index = form.ship_country_code.selectedIndex;
	ship_country_code = form.ship_country_code[ship_country_code_index].value;
	ship_phone = form.ship_phone.value;
	ship_fax = form.ship_fax.value;
}

function ShipToBillPerson(form) {
	var ship_first_name = "";
	var ship_last_name = "";
	var ship_email = "";
	var ship_company = "";
	var ship_address_one = "";
	var ship_address_two = "";
	var ship_city = "";
	var ship_state_or_province = "";
	var ship_state_or_province_index = 0;
	var ship_zip_or_postal_code = "";
	var ship_country_code = "";
	var ship_country_code_index = 0;
	var ship_phone = "";
	var ship_fax = "";

	if (form.copy.checked) {
	InitSaveVariables(form);
	form.ship_first_name.value = form.bill_first_name.value;
	form.ship_last_name.value = form.bill_last_name.value;
	form.ship_email.value = form.bill_email.value;
	form.ship_company.value = form.bill_company.value;
	form.ship_address_one.value = form.bill_address_one.value;
	form.ship_address_two.value = form.bill_address_two.value;
	form.ship_city.value = form.bill_city.value;
	form.ship_state_or_province.selectedIndex = form.bill_state_or_province.selectedIndex;
	form.ship_zip_or_postal_code.value = form.bill_zip_or_postal_code.value;
	form.ship_country_code.selectedIndex = form.bill_country_code.selectedIndex;
	form.ship_phone.value = form.bill_phone.value;
	form.ship_fax.value = form.bill_fax.value;
}
else {
	form.ship_first_name.value = ship_first_name;
	form.ship_last_name.value = ship_last_name;
	form.ship_email.value = ship_email;
	form.ship_company.value = ship_company;
	form.ship_address_one.value = ship_address_one;
	form.ship_address_two.value = ship_address_two;
	form.ship_city.value = ship_city;
	form.ship_state_or_province.selectedIndex = ship_state_or_province;
	form.ship_zip_or_postal_code.value = ship_zip_or_postal_code;
	form.ship_country_code.selectedIndex = ship_country_code;
	form.ship_phone.value = ship_phone;
	form.ship_fax.value = ship_fax;
   }
}

function NewWindow(mypage,myname,w,h){
	var winl =(screen.width)?(screen.width-w)/2:100;
	var wint =(screen.height)?(screen.height-h)/2:100;
	var settings ='height='+h+',';
	settings +='width='+w+',';
	settings +='height='+h+',';
	settings +='top='+wint+',';
	settings +='left='+winl+',';
	settings +='scrollbars=no'+',';
	settings +='resizable=no';
	win=window.open(mypage,myname,settings);
	win.focus();
}
function NewWindowPDF(mypage,myname,w,h){
	var winl =(screen.width)?(screen.width-w)/2:100;
	var wint =(screen.height)?(screen.height-h)/2:100;
	var settings ='height='+h+',';
	settings +='width='+w+',';
	settings +='height='+h+',';
	settings +='top='+wint+',';
	settings +='left='+winl+',';
	settings +='scrollbars=yes'+',';
	settings +='resizable=yes';
	win=window.open(mypage,myname,settings);
	win.focus();
}
function NewWindowAdd(mypage,myname){
	w = 450;
	h = 630;
	var winl =(screen.width)?(screen.width-w)/2:100;
	var wint =(screen.height)?(screen.height-h)/2:100;
	var settings ='height='+h+',';
	settings +='width='+w+',';
	settings +='height='+h+',';
	settings +='top='+wint+',';
	settings +='left='+winl+',';
	settings +='scrollbars=no'+',';
	settings +='resizable=no';
	win=window.open(mypage,myname,settings);
	win.focus();
}
function NewWindowAddButton(mypage,myname){
	w = 300;
	h = 220;
	var winl =(screen.width)?(screen.width-w)/2:100;
	var wint =(screen.height)?(screen.height-h)/2:100;
	var settings ='height='+h+',';
	settings +='width='+w+',';
	settings +='height='+h+',';
	settings +='top='+wint+',';
	settings +='left='+winl+',';
	settings +='scrollbars=no'+',';
	settings +='resizable=no';
	win=window.open(mypage,myname,settings);
	win.focus();
}

function NewWindowAddVintage(mypage,myname){
	w = 500;
	h = 700;
	var winl =(screen.width)?(screen.width-w)/2:100;
	var wint =(screen.height)?(screen.height-h)/2:100;
	var settings ='height='+h+',';
	settings +='width='+w+',';
	settings +='height='+h+',';
	settings +='top='+wint+',';
	settings +='left='+winl+',';
	settings +='scrollbars=no'+',';
	settings +='resizable=no';
	win=window.open(mypage,myname,settings);
	win.focus();
}

function changeCurrency(toWhat){
alert (toWhat);

//javascript:document.location=window.location.href+'?curr=1
}