/*
	created by		: Ann Brown - Binary Ink Web Applications :: http://binaryink.com
	created on		: April 10, 2003
	purpose			: Evco Solutions Inc. website JavaScript file
*/
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}
function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}
var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		navHome_over = newImage("../images/navigation/navHome-over.gif");
		navCompanyInfo_over = newImage("../images/navigation/navCompanyInfo-over.gif");
		navProducts_over = newImage("../images/navigation/navProducts-over.gif");
		navOrderForm_over = newImage("../images/navigation/navOrderForm-over.gif");
		navPromotional_over = newImage("../images/navigation/navPromotional-over.gif");
		navContact_over = newImage("../images/navigation/navContact-over.gif");
		navOrderBusinessCards_over = newImage("../images/navigation/navOrderBusinessCards-over.gif");
		navOnlineWarehouse_over = newImage("../images/navigation/navOnlineWarehouse-over.gif");
		navStandardColours = newImage("../images/navigation/inkColours_over.gif");
		navStandardBackgrounds = newImage("../images/navigation/standardBackgrounds_over.gif");
		preloadFlag = true;
	}
}
// pop-up help window
function open_help(page)
{
	w = screen.width;
	h = screen.height;
	win_w = 285;
	win_h = 250 ;
	l = (w - win_w)/2;
	t = (h - win_h)/2;
	open(page,"help_window","width="+win_w+",height="+win_h+",screenX="+l+",left="+l+",screenY="+t+",top="+t+",resizable=yes");
}
// validate cheque reorder form
function validateReorder(f)
{
	if(f.previousOrderNumber.value == '' && f.comments.value == '')
	{
		alert("If you cannot remember your previous order number, please note this within the comment box.");
		f.comments.focus();
		return false;
	}
	else if(f.quantity.value == '' || isNaN(parseInt(f.quantity.value)))
	{
		alert("Please enter the quantity that you require.");
		f.quantity.value = 100;
		f.quantity.focus();
		return false;
	}
	else if(f.startNumber.value == '' || isNaN(parseInt(f.startNumber.value)))
	{
		alert("Please enter the start number that you require. If you are unsure, enter 0 and indicate this within your comments.");
		f.startNumber.value = 101;
		f.startNumber.focus();
		return false;
	}
	else if(f.ContactName.value == '')
	{
		alert("Please enter a contact name.");
		f.ContactName.focus();
		return false;
	}
	else if(f.BusinessName.value == '')
	{
		alert("Please enter a business name.");
		f.BusinessName.focus();
		return false;
	}
	if(f.rndWord.value == "")
	{
		alert("Please correctly enter the words from the image!")
		f.rndWord.focus();
		return false;
	}
}
// validate cheque new order 1 form
function validateNewOrder1(f)
{
	if(!f.elements[0].checked && !f.elements[1].checked)
	{
		alert("Please select your printer type!");
		f.elements[0].focus();
		return false;
	}
	// default to false (none checked)
	var isChecked = false;
	for(i=2; i < 15; i++) if(f.elements[i].checked) isChecked = true;
	if(!isChecked)
	{
		alert("Please select a compatible software!");
		f.elements[2].focus();
		return false;
	}	
	if(f.elements[14].checked && f.softwarePackageOther.value == '')
	{
		alert("Please indicate the name of your OTHER software!");
		f.softwarePackageOther.focus();
		return false;
	}
}
// validate cheque new order 2 form
function validateNewOrder2(f)
{
	if(f.startNumber.value == '' || isNaN(parseInt(f.startNumber.value)))
	{
		alert("Please enter a start number for your cheques!");
		f.startNumber.value = '000001';
		f.startNumber.focus();
		return false;
	}
	else if(f.elements[8].checked && f.backgroundColourOther.value == '')
	{
		alert("Please select your OTHER background colour.");
		f.backgroundColourOther.focus();
		return false;
	}
}
// validate cheque new order 3 form
function validateNewOrder3(f)
{
	if(f.BusinessName1.value == '')
	{
		alert("Please enter the Business Name for your cheques!");
		f.BusinessName1.focus();
		return false;
	}
	else if(f.AddressLine1.value == '')
	{
		alert("Please enter the Address for your cheques!");
		f.AddressLine1.focus();
		return false;
	}
	else if(f.City.value == '')
	{
		alert("Please enter the City for your cheques!");
		f.City.focus();
		return false;
	}
	else if(f.PostalCode.value == '')
	{
		alert("Please enter the Postal/Zip Code for your cheques!");
		f.PostalCode.focus();
		return false;
	}
	else if(f.AreaCode.value.length < 3 || isNaN(parseInt(f.AreaCode.value)) || f.Phone1.value.length < 3 || isNaN(parseInt(f.Phone1.value)) || f.Phone2.value.length < 4 || isNaN(parseInt(f.Phone2.value)))
	{
		alert("Please enter the Phone Number for your cheques!");
		f.AreaCode.focus();
		return false;
	}
	else if(f.FaxAreaCode.value.length < 3 || isNaN(parseInt(f.FaxAreaCode.value)) || f.FaxPhone1.value.length < 3 || isNaN(parseInt(f.FaxPhone1.value)) || f.FaxPhone2.value.length < 4 || isNaN(parseInt(f.FaxPhone2.value)))
	{
		alert("Please enter the Fax Number for your cheques!");
		f.FaxAreaCode.focus();
		return false;
	}
	else if(f.ContactName.value == '')
	{
		alert("Please enter a Contact Name!");
		f.ContactName.focus();
		return false;
	}
	else if(f.BankName.value == '')
	{
		alert("Please enter your Bank Name!");
		f.BankName.focus();
		return false;
	}
	else if(f.BankAddress.value == '')
	{
		alert("Please enter your Bank Address!");
		f.BankAddress.focus();
		return false;
	}
	else if(f.BankCity.value == '')
	{
		alert("Please enter your Bank City!");
		f.BankCity.focus();
		return false;
	}
	else if(f.BankProvince.value == '')
	{
		alert("Please enter your Bank Province!");
		f.BankProvince.focus();
		return false;
	}
	else if(f.BankPostalCode.value == '')
	{
		alert("Please enter your Bank Postal/Zip Code!");
		f.BankPostalCode.focus();
		return false;
	}
	if(f.rndWord.value == "")
	{
		alert("Please correctly enter the words from the image!")
		f.rndWord.focus();
		return false;
	}
}
// redirect warning
var red_warning = "Business cards orders are collected by Orderprinting.com.";
//proforma redirect warning
var proforma_warning = "Clicking here takes you to the Proforma Website.";
// validate order form
function validateOrderForm(f)
{	
	if(f.PersonOrderingTxt.value == "")
	{
		alert("Please tell us your name!")
		f.PersonOrderingTxt.focus();
		return false;
	}
	else if(f.BusinessNameTxt.value == "")
	{
		alert("Please tell us the name of your business!")
		f.BusinessNameTxt.focus();
		return false;
	}
	else if(f.PhoneTxt.value == "")
	{
		alert("Please tell us your phone number!")
		f.PhoneTxt.focus();
		return false;
	}
	else if(f.EmailTxt.value == ""  || f.EmailTxt.value.indexOf(".")==-1 || f.EmailTxt.value.indexOf("@")==-1)
	{
		alert("Please tell us your email address!")
		f.EmailTxt.focus();
		return false;
	}
	else if(f.StreetAddressTxt.value == "")
	{
		alert("Please tell us your street address!")
		f.StreetAddressTxt.focus();
		return false;
	}
	else if(f.CityTxt.value == "")
	{
		alert("Please tell us the name of your city!")
		f.CityTxt.focus();
		return false;
	}
	else if(f.ProvinceTxt.value == "")
	{
		alert("Please tell us the name of your province!")
		f.ProvinceTxt.focus();
		return false;
	}
	else if(f.PostalCodeTxt.value == "")
	{
		alert("Please tell us your postal code!")
		f.PostalCodeTxt.focus();
		return false;
	}
	// check for shipping address
	if(!f.elements[12].checked)
	{
		if(f.RecipientNameTxt.value == "" && f.RecipientBusinessNameTxt.value == "" && f.RecipientStreetAddressTxt.value == "" && f.RecipientCityTxt.value == "" && f.RecipientProvinceTxt.value == "" && f.RecipientPostalCodeTxt.value == "")
		{
			alert("Please tell us where you would like your order shipped to?")
			f.elements[12].focus();
			return false;
		}
		else if(f.RecipientNameTxt.value == "")
		{
			alert("Please tell us the name of your shipping recipient!")
			f.RecipientNameTxt.focus();
			return false;
		}
		else if(f.RecipientBusinessNameTxt.value == "")
		{
			alert("Please tell us the business name of your shipping recipient!")
			f.RecipientBusinessNameTxt.focus();
			return false;
		}
		else if(f.RecipientStreetAddressTxt.value == "")
		{
			alert("Please tell us the street address of your shipping recipient!")
			f.RecipientStreetAddressTxt.focus();
			return false;
		}
		else if(f.RecipientCityTxt.value == "")
		{
			alert("Please tell us the city of your shipping recipient!")
			f.RecipientCityTxt.focus();
			return false;
		}
		else if(f.RecipientProvinceTxt.value == "")
		{
			alert("Please tell us the province of your shipping recipient!")
			f.RecipientProvinceTxt.focus();
			return false;
		}
		else if(f.RecipientPostalCodeTxt.value == "")
		{
			alert("Please tell us the postal code of your shipping recipient!")
			f.RecipientPostalCodeTxt.focus();
			return false;
		}
	}
	if(f.rndWord.value == "")
	{
		alert("Please correctly enter the words from the image!")
		f.rndWord.focus();
		return false;
	}
}
