//------------------------------------------------------------------------------
// Update Log
// ==========
// 2008-03-28 - Remove validation for Event end date.
// 2008-04-05 - Increase word count for BO coloader and BO Agent from 100 to 400. Same for all BO.
// 2008-04-29 - Remove Comments field from Job form.
//------------------------------------------------------------------------------
	var maxwords = 100;
	testalert = 0;  //* Test alerts. Set to 0 to turn them off. 1 turns them on.
	
// 	sTestMode = "{Test}";   // Activates Test mode on internet secure
 	sTestMode = "";			// Uncomment to place into production

//* qsParm is set in includes/header1.asp. page called with ?p=test
// 	if (qsParm == "test") sTestMode = "{Test}";
// 	alert(sTestMode)

	if (thefile.substring(0,"order-db".length) == "order-db")	{
	  cTestMode	 = getCookie("cTestMode"); 
	  if (cTestMode == "test") {
	  	sTestMode = "{Test}";
	  	setCookie("cTestMode", "");
	  }	
	}
	else {
		if (qsParm == "test") {
			setCookie("cTestMode", "test"); 
			sTestMode = "{Test}";					
		}
	}
  	
function viewList (ref, item ){		
//******************************************************************************* 
//    View Listing  ref=E080213-123456   item=1 to 4  Item or Sale only.
//*******************************************************************************  
	var theCall = "viewlist.asp?ref=" + ref;
 	var ref_prefix = ref.substring(0,1);
 
	if (item == undefined) {
   		item = "";
	}  
 
	if (item != "") {
   		theCall = theCall + "&i=" + item;
	} 	

//* BUSINESS OPPORTUNITY
//* Page is /bo/ref.asp  eg. BA080213-123456.asp

	if (ref_prefix == "B") {
		theCall = "../bo/" + ref + ".asp"; 	  	
	}	
		
//  alert("ref=" + ref + "  item=" + item)
//  alert(theCall)
	newWindow=window.open(theCall,"newwin","width=600,height=600,menubar=yes,location=no,toolbar=no,scrollbars=yes,status=yes,resizable=yes");
  	newWindow.focus(); 					//* Bring to front
	return; 
}

function jumpTo(v) {
//----------------------------------------------------
//  Jump to anchor selection list
//----------------------------------------------------
 	var aname = document.form0.menu.options[v].value;
	document.form0.menu.selectedIndex = 0;  // Rest to first entry in list.
	if (aname == "") return;  // handles separator bars.
 
//	alert(htmldir)
    location.href = "#" + aname;	
}
 
function doJOBform ( form ) {	
//******************************************************************************* 
//  JOB FORM
//******************************************************************************* 
	var firstmessage="Please provide the following valid information:\n\n ";
	var errormessage="";

 	//* RADIOS
//* Fall special - one radio button (2 months) 	
//	if (document.form0.Months[0].checked ||
//		document.form0.Months[1].checked ) {  	
//	if (document.form0.Months[0].checked ) { 
//			if (document.form0.Months[0].checked) {
//			 	document.form0.theMonths.value = document.form0.Months[0].checked;
//			}
//	 		alert(document.form0.theMonths.value);
//		 }
//	else { errormessage = errormessage + "No. of Months to be listed\n" } 
	
	document.form0.theMonths.value = "2";  //* 2 months default
//	alert(document.form0.theMonths.value);	
//*------------------------------
//* JOB DETAILS
//*------------------------------
	if (spaceTrim(document.form0.Position.value) == "") errormessage=errormessage +  " Position\n";	
	if (spaceTrim(document.form0.City.value) == "") errormessage=errormessage +  " City\n";	

//* PROV SELECTION LIST	
	var item = document.form0.Prov.selectedIndex;
	var Provval = document.form0.Prov.options[item].value;
	if (Provval == "") {errormessage=errormessage+"Province\n"}  		
	
//* COUNTRY SELECTION LIST 	
	item = document.form0.Country.selectedIndex;
	countryval = document.form0.Country.options[item].value;
	if (countryval == "") {errormessage=errormessage+"Country\n"} 			

//* JOB TYPE SELECTION LIST 	
	item = document.form0.JobType.selectedIndex;
	jobtypeval = document.form0.JobType.options[item].value;
	if (jobtypeval == "") {errormessage=errormessage+"Job Type\n"} 	
	
//	if (spaceTrim(document.form0.Comp.value) == "") errormessage=errormessage +  "Compensation \n";	
//	if (spaceTrim(document.form0.Resp.value) == "") errormessage=errormessage +  "Responsibilities\n";	
//	if (spaceTrim(document.form0.Skills .value) == "") errormessage=errormessage +  "Knowledge and Skills\n";
//	if (spaceTrim(document.form0.Qual.value) == "") errormessage=errormessage +  "Qualifications / Experience\n";	
//	if (spaceTrim(document.form0.Educ.value) == "") errormessage=errormessage +  "Education\n";

//* CATEGORY  SELECTION LIST
	item = document.form0.Category.selectedIndex;
	catval = document.form0.Category.options[item].value;
	if (catval == "") {
		if (spaceTrim(document.form0.Cat_Other.value) == "") {
			errormessage=errormessage +  "Category\n";		
		}
		else {
//			document.form0.Category.selectedIndex = 1;
//			document.form0.Category.options[1].value = spaceTrim(document.form0.Cat_Other.value);
		}
	}
 
	 //var sJobDesc = spaceTrim(document.form0.JobDesc.value);
	sJobDesc = spaceTrim(document.form0.JobDesc.value);
	if (countWords(sJobDesc) > 600) errormessage=errormessage + "Position Description exceeds max. word count\n";
	if (sJobDesc.length < 11) errormessage=errormessage + "Position Description\n";		

//*------------------------------
//* CONTACT DETAILS
//*------------------------------
	
	if (spaceTrim(document.form0.Employer.value) == "") errormessage=errormessage +  " Employer\n";	
 
//* At least one of these must be entered.	

	sEmail			= spaceTrim(document.form0.Email.value);
	sWebsite 		= spaceTrim(document.form0.Website.value); 
	sPhone			= spaceTrim(document.form0.Phone.value);
	sFax			= spaceTrim(document.form0.Fax.value);
	sMailAddr 		= spaceTrim(document.form0.MailAddr.value);
	
	if (sEmail == "" && sWebsite == "" && sPhone == "" && sFax == "" && sMailAddr == ""  ) {
		errormessage=errormessage +  " Contact Method: Choose at least one\n";
	}	

//* if email not blank, it must be valid.
	if (sEmail != "") {
		if (document.form0.Email.value.length ==0 || document.form0.Email.value.indexOf('@', 0) == -1 || document.form0.Email.value.indexOf('.', 0) == -1) {errormessage=errormessage+"Email address\n"} 
	}

// 	errormessage ="";  // Uncomment to deactivate validation for Testing
   
   if (errormessage !="") { alert (firstmessage + errormessage)  }
   else { 
		//* If Category - Other specified, insert the value in selection list before submitting form. 
	 	if (spaceTrim(document.form0.Cat_Other.value) != "") {
 			document.form0.Category.selectedIndex = 1;
			document.form0.Category.options[1].value = spaceTrim(document.form0.Cat_Other.value);	
		} 
  	
		document.form0.action = "order-db.asp";
  		document.form0.method = "POST";
 		document.form0.submit()
		return(0);
   }  

} //* END FUNCTION doJOBform()
	
function doITEMform ( form ) {	
//******************************************************************************* 
//  ITEM FOR SALE FORM
//******************************************************************************* 

	var firstmessage="Please provide the following valid information:\n\n ";
	var errormessage="";	 
	var maxmessage=" exceeds maximum word count\n";
	var maxwords = 100;

 	//* RADIOS
	if (document.form0.Months[0].checked ||
		document.form0.Months[1].checked ||
		document.form0.Months[2].checked ) { 
			if (document.form0.Months[0].checked) { 
				document.form0.theMonths.value = document.form0.Months[0].checked;
			}
	//		alert(document.form0.theMonths.value);
		 }
	else { errormessage = errormessage + "No. of Months to be listed\n" } 

//*------------------------------
//* CONTACT DETAILS
//*------------------------------
	if (spaceTrim(document.form0.SellerName.value) == "") errormessage=errormessage +  "Seller Name\n";	
	
	sSellerEmail = spaceTrim(document.form0.SellerEmail.value);
 	sSellerPhone = spaceTrim(document.form0.SellerPhone.value);
	
	if (sSellerPhone == "" & sSellerEmail == "") {
		errormessage=errormessage +  "Contact Method\n";	
	}	
	
	if (spaceTrim(document.form0.SellerEmail.value) != "") {
		if (document.form0.SellerEmail.value.length ==0 || document.form0.SellerEmail.value.indexOf('@', 0) == -1 || document.form0.SellerEmail.value.indexOf('.', 0) == -1) {errormessage=errormessage+"Contact Method - Seller Email\n"} 		
	}
 		
	if (spaceTrim(document.form0.City.value) == "") errormessage=errormessage +  "City\n";	

//* PROV SELECTION LIST	
	var item = document.form0.Prov.selectedIndex;
	var Provval = document.form0.Prov.options[item].value;
	if (Provval == "") {errormessage=errormessage+"Province\n"}  		
	
//* COUNTRY SELECTION LIST 	
	item = document.form0.Country.selectedIndex;
	countryval = document.form0.Country.options[item].value;
	if (countryval == "") {errormessage=errormessage+"Country\n"} 
				
//*------------------------------
//* ITEM 1  
//*------------------------------
	
	if (spaceTrim(document.form0.ItemName1.value) == "") errormessage=errormessage +  "Item 1 Name\n";	
	if (spaceTrim(document.form0.Price1.value) == "") errormessage=errormessage +  "Item 1 Price\n";	

	
 	//* RADIOS
	if (document.form0.Currency1[0].checked ||
		document.form0.Currency1[1].checked ) { }
	else { errormessage = errormessage + "Item 1 Currency\n" } 
 
	Desc1 = spaceTrim(document.form0.Desc1.value);
	Desc2 = spaceTrim(document.form0.Desc2.value);
	Desc3 = spaceTrim(document.form0.Desc3.value);
	Desc4 = spaceTrim(document.form0.Desc4.value);	
	
	if (Desc1 == "") errormessage=errormessage +  "Item 1 Description\n";
	
	if (countWords(Desc1) > maxwords) errormessage=errormessage + "Item 1 Description" + maxmessage;
	if (countWords(Desc2) > maxwords) errormessage=errormessage + "Item 2 Description" + maxmessage;
	if (countWords(Desc3) > maxwords) errormessage=errormessage + "Item 3 Description" + maxmessage;
	if (countWords(Desc4) > maxwords) errormessage=errormessage + "Item 4 Description" + maxmessage;	

// 	errormessage ="";  // Uncomment to deactivate validation for Testing
	nCount = 0;  //* Count no. of description fields filled in
	if (Desc1 != "") { nCount = nCount + 1; }
	if (Desc2 != "") { nCount = nCount + 1; }
	if (Desc3 != "") { nCount = nCount + 1; }
	if (Desc4 != "") { nCount = nCount + 1; }

   
   if (errormessage !="") { alert (firstmessage + errormessage)  }
   else { 
  		document.form0.theNCount.value = nCount;
		document.form0.action = "order-db.asp";
  		document.form0.method = "POST";
 		document.form0.submit()
		return(0);
   }  

} //* END FUNCTION doITEMform()	

function doDIRform ( form ) {	
//******************************************************************************* 
//  DIR FORM
//******************************************************************************* 

	var firstmessage="Please provide the following valid information:\n\n ";
	var errormessage="";
	var sListingType = "B";  //* Basic or Premium
	var sTheMonths = "";

 	//* RADIOS
	if (document.form0.Months[0].checked ||
		document.form0.Months[1].checked ||
		document.form0.Months[2].checked ||
		document.form0.Months[3].checked ||
		document.form0.Months[4].checked ||
		document.form0.Months[5].checked ) { 
			if (document.form0.Months[0].checked) {	sTheMonths = document.form0.Months[0].value; }
			if (document.form0.Months[1].checked) {	sTheMonths = document.form0.Months[1].value; }
			if (document.form0.Months[2].checked) {	sTheMonths = document.form0.Months[2].value; }
			if (document.form0.Months[3].checked) {
					sTheMonths = document.form0.Months[3].value; 
					sListingType = "P";  //* Premium
			}
			if (document.form0.Months[4].checked) {
					sTheMonths = document.form0.Months[4].value; 
					sListingType = "P";  //* Premium
			}
			if (document.form0.Months[5].checked) {
					sTheMonths = document.form0.Months[5].value; 
					sListingType = "P";  //* Premium
			}						
	 	
		 }
	else { errormessage = errormessage + "No. of Months to be listed\n" } 
		
	document.form0.theMonths.value = sTheMonths; //* place no of months on form 
	document.form0.theListingType.value = sListingType; //* B or P
// 	alert(document.form0.theMonths.value);
//	alert(document.form0.theListingType.value);
	
//*------------------------------
//*  BASIC LISTING
//*------------------------------
	if (spaceTrim(document.form0.Company.value) == "") errormessage=errormessage +  " Company\n";	

//* Service Provider Type  SELECTION LIST
	item = document.form0.ServProvType.selectedIndex;
	theval = document.form0.ServProvType.options[item].value;
	if (theval == "") {
		if (spaceTrim(document.form0.ServProvType_Other.value) == "") {
			errormessage=errormessage +  "Service Provider Type\n";		
		}
 		else {
 //			document.form0.ServProvType.selectedIndex = 1;
// 			document.form0.ServProvType.options[1].value =      	  spaceTrim(document.form0.ServProvType_Other.value);
 		}
	} 
 
 	if (spaceTrim(document.form0.Address.value) == "") errormessage=errormessage + "Address\n";
 	if (spaceTrim(document.form0.City.value) == "") errormessage=errormessage + "City\n";

//* PROV SELECTION LIST	
	var item = document.form0.Prov.selectedIndex;
	var provval = document.form0.Prov.options[item].value;
	if (provval == "") {errormessage=errormessage+"Province\n"}  		
	
//* COUNTRY SELECTION LIST 	
	item = document.form0.Country.selectedIndex;
	countryval = document.form0.Country.options[item].value;
	if (countryval == "") {errormessage=errormessage+"Country\n"} 			

  	if (spaceTrim(document.form0.Postal.value) == "") errormessage=errormessage + "Postal_Code\n"; 	 
 	if (spaceTrim(document.form0.Telephone.value) == "") errormessage=errormessage +  "Telephone\n";
 	
//*------------------------------
//*  PREMIUM LISTING
//*------------------------------
 
 //* if email not blank, it must be valid.
	sEmail = spaceTrim(document.form0.Email.value);
	if (sEmail != "") {
		if (document.form0.Email.value.length ==0 || document.form0.Email.value.indexOf('@', 0) == -1 || document.form0.Email.value.indexOf('.', 0) == -1) {errormessage=errormessage+"Email address\n"} 
	}

	 //var sJobDesc = spaceTrim(document.form0.JobDesc.value);
	sDesc = spaceTrim(document.form0.Desc1.value);
	if (countWords(sDesc) > 400) errormessage=errormessage + "Description exceeds max. word count\n";

// 	errormessage ="";  // Uncomment to deactivate validation for Testing
   
   if (errormessage !="") { alert (firstmessage + errormessage)  }
   else { 
//* If Service Provider Type - Other specified, insert the value before submitting form. 
	 	if (spaceTrim(document.form0.ServProvType_Other.value) != "") {
				document.form0.ServProvType.selectedIndex = 1;
				document.form0.ServProvType.options[1].value =      	  spaceTrim(document.form0.ServProvType_Other.value);		
		}
 
 // 	document.form0.enctype = "multipart/form-data";   //* THis breaks things in Firefox!!!
		document.form0.action = "order-db.asp";
  		document.form0.method = "POST";
 		document.form0.submit()
		return(0);
   }  

} //* END FUNCTION doDIRForm()

function doEVENTSform ( form ) {	
//******************************************************************************* 
//  EVENTS FORM
//******************************************************************************* 

	var firstmessage="Please provide the following valid information:\n\n ";
	var errormessage="";	
	 maxwords = 400;
		if (document.form0.Months[0].checked ||
			document.form0.Months[1].checked ||
			document.form0.Months[2].checked) {  }
		else { errormessage = errormessage + "No. of Months to be listed\n" } 
		
		if (spaceTrim(document.form0.EventName.value) == "") errormessage=errormessage + "Event Name\n"; 
		if (spaceTrim(document.form0.StartDate.value) == "") errormessage=errormessage + "Start Date\n"; 
//		if (spaceTrim(document.form0.EndDate.value) == "") errormessage=errormessage + "End Date\n";
		if (spaceTrim(document.form0.Place.value) == "") errormessage=errormessage + "Event Place\n";  
		if (spaceTrim(document.form0.City.value) == "") errormessage=errormessage + "Event City\n";  
		
		//* PROV SELECTION LIST	
		itemx = document.form0.Prov.selectedIndex;
		Provval = document.form0.Prov.options[itemx].value;
		if (Provval == "") {errormessage=errormessage+"Province/State\n"} 
 
 		itemx = document.form0.Country.selectedIndex;
 		countryval = document.form0.Country.options[itemx].value;
 		if (countryval == "") {errormessage=errormessage+"Event Country\n"} 		
		  		
		Desc1 = spaceTrim(document.form0.Desc1.value);
		if (countWords(Desc1) > maxwords) errormessage=errormessage + "Description exceeds word count\n";
	 	if (Desc1.length < 11) errormessage=errormessage + "Description\n";	
	 	
// 	errormessage ="";  // Uncomment to deactivate validation for Testing
   
   if (errormessage !="") { alert (firstmessage + errormessage)  }
   else { 
 	
		document.form0.action = "order-db.asp";
  		document.form0.method = "POST";
 		document.form0.submit()
		return(0);
   }  	 	
	
} //*** END doEVENTSform	

function doIS ( form ) {	
//******************************************************************************* 
//  Submit to Internet Secure
//******************************************************************************* 	
	
  	var sMerchantNumber		= "12606";
	var sPrice				= "";
  	var sProd00				= "Price::Qty::Code::Description::Flags" ;
	var sProd01				= "";
//	var sTest				= ""; // Set to {Test} to trigger submit test transaction to IS
	var sGST				= "";
	var sQty 				= 1;
	var sDesc 				= "";
	var sCode 				= "";  //* eg. JOB01
	var sFunc 				= "job";  //* eg. JOB01
	var sCost				= "";
	var sMonths				= ""; //no of months entered on submission form	
	
	var sItemsText 			= "";	//* Used to format description line
	var sMonthsText 		= "";	//* Used to format description line		
		
// 	sTest = "{Test}";   // Activates Test mode on internet secure
// 	sTest = "";			// Uncomment to place into production
 	sTest = sTestMode;	//* Set at top of the script	 
// 	alert("sTest =" + sTest + "  sTestMode=" + sTestMode)
	sGST = "{GST}";			// sGST = "{GST}"

//*** forsale, job, dir, seller, buyer	
	sCodeForSale = "FS01";  
	sCodeJob 	= "JOB01";
	sCodeDir 	= "DIR01";
	sCodeSeller = "SEL01";
	sCodeBuyer 	= "BUY01";
	sCodeEvent 	= "EVT01";
	
	sFormType = document.form0.FormType.value;  //* job, dir, events, forsale
 
//*------------------------------
//* JOB FORM  to INTERNET SECURE
//*------------------------------	
	if (sFormType == "job") {
		sItemsText = " Jobs";
		sMonthsText = " months";
		//*  1 Month:  $299  2 Months:  $499 	
		//*  1 Month:  $199  2 Months:  $299 	INTRO PRICES
		sMonths		= document.form0.Months.value;
		
//		if (sMonths == 1)  {sCost = "199";	}
		if (sMonths == 2)  {sCost = "99";	}
		if (sMonths == 1) { sMonthsText = " month"; }   //* Only 1 item
		
		sPrice = sCost + ".00";  //* Maybe format dollar or convert to string ?????
 		sQty = 1;						 
 		sCode = sCodeJob;
		sDesc = "1 job posted for " + sMonths + sMonthsText;		

//	alert("Form Type = " + sFormType + "\nMonths = " + sMonths + "\nPrice = " + sPrice  + "\nDescription = " + sDesc + "\nRaw Transaction = " + sProd01 );
		
	} //* END JOB

//*---------------------------------------------------------------------
//* ITEM FOR SALE FORM  to INTERNET SECURE
//*---------------------------------------------------------------------	
if (sFormType == "forsale") {
	sItemsText = " Items";
	sMonthsText = " months";	
	sCost = 0;
 
	sMonths		= document.form0.Months.value;
	nCount		= document.form0.nCount.value;  //* No of Items on form
	
//	alert("sMonths=" +  sMonths); 
	
// 	alert("nCount=" + nCount);
//* 1 Month  2 Months 3 Months   
//* $30/item $45/item $80/item   
	
	sCost1 = 30;   //* cost matching months radio button on form
	sCost2 = 45;
	sCost3 = 80;
 	
	if (sMonths == 1)  { sCost = sCost1; }
	if (sMonths == 2)  { sCost = sCost2; }
	if (sMonths == 3)  { sCost = sCost3; }
 	
	if (nCount == 1) { sItemsText = " Item"; }   //* Only 1 item
	if (sMonths == 1) { sMonthsText = " month"; }   //* Only 1 item
		
	sPrice = nCount * sCost;
	sDiscountText = "";
//*---------------------------------	
//*** FOR TESTING DISCOUNTS	
//*---------------------------------
	sPriceSave = sPrice;
	if (nCount == 2) {		
		nDiscount = parseFloat(sPrice * .10);  //* 10%
//		nDiscount =  sPrice * .10;  //* 10%
		sPrice =  parseFloat(sPrice) - parseFloat(nDiscount);
	
	if (testalert == 1) {
		alert("Discount Calculations:"
		 + "\n\nNo. of Items = " + nCount
		 + "\nUnit Price = " + sCost 
		 + "\nRegular Total = " + sPriceSave 
		 + "\n10% Discount = " + nDiscount 
		 + "\nDiscounted Total = " + sPrice);
	}	
 
		sDiscountText = "(10% discount)";
	}
	if (nCount >= 3) {
		nDiscount = parseFloat(sPrice * .15);	//* 15%	
		sPrice =  parseFloat(sPrice) - parseFloat(nDiscount);

	if (testalert == 1) {		
		alert("Discount Calculations:"
		 + "\n\nNo. of Items = " + nCount
		 + "\nUnit Price = " + sCost 
		 + "\nRegular Total = " + sPriceSave 
		 + "\n15% Discount = " + nDiscount 
		 + "\nDiscounted Total = " + sPrice);
	}
		
		sDiscountText = " (15% discount)";
	}	
 			
//	alert("sPrice = " + sPrice);
//	alert("sMonths = " + sMonths);
//  alert("nCount = " + nCount);

 	sQty = 1;						 
 	sCode = sCodeForSale;
	sDesc = nCount + sItemsText + " listed for sale for " + sMonths + sMonthsText;
	sDesc = sDesc + sDiscountText;  //* Append discount percentage		
		
	} //* END FOR SALE ******* END FOR SALE ********* END FOR SALE ********* END FOR SALE

//*-------------------------
//* DIR to INTERNET SECURE
//*-------------------------

if (sFormType == "dir") {        
	
	sMonthsText = " months";
	sListingTypeText = "Basic ";
	
	sMonths		= document.form0.Months.value;
 
	sListingType = document.form0.theListingType.value;  //* B or P. Basic or Premium
	
//  alert("sFormType=" +  sFormType); 
//  alert("sMonths=" +  sMonths); 
	
//	alert("sListingType=" +  sListingType);

	//* DIR BASIC PRICING
	sDirBasicCost3 = 75; 
	sDirBasicCost6 = 120;
	sDirBasicCost12 = 199;		
	//* DIR PREMIUM PRICING
	sDirPremCost3 = 139; 
	sDirPremCost6 = 239;
	sDirPremCost12 = 329;
  
     //* cost matching months radio button on form
     //* BASIC PRICING
		sCost3 = sDirBasicCost3; 
		sCost6 = sDirBasicCost6;
		sCost12 = sDirBasicCost12;
		
	//* PREMIUM PRICING
	if (sListingType == "P") {
		sCost3 = sDirPremCost3; 
		sCost6 = sDirPremCost6;
		sCost12 = sDirPremCost12;		
	}	
	
	if (sMonths == 3)  { sCost = sCost3; }
	if (sMonths == 6)  { sCost = sCost6; }
	if (sMonths == 12) { sCost = sCost12; }

	if (sListingType == "P") {
		sListingTypeText = "Premium ";
	}	

	sPrice = sCost;
 	sQty = 1;						 
 	sCode = sCodeDir;
	sDesc = sListingTypeText + "Directory Listing for " + sMonths + sMonthsText;
 
} //* END DIR ****  END DIR ****  END DIR ****  END DIR ****  END DIR ****  END DIR **** 
	
//*-------------------------
//* EVENTS to INTERNET SECURE
//*-------------------------
if 	(sFormType == "events") {
	
	sMonthsText = " months";
	
	sMonths		= document.form0.Months.value;	
	
//* 3 Month  6 Months  12 Months   
//* $45/item $75/item $120/item 
  
	var sCost1 = 49;  //* cost matching months radio button on form
	var sCost3 = 79;
	var sCost6 = 99;
	
	if (sMonths == 1)  { sCost = sCost1; }
	if (sMonths == 3)  { sCost = sCost3; }
	if (sMonths == 6)  { sCost = sCost6; }	
 
 	if (sMonths == 1) { sMonthsText = " month"; }   //* Only 1 item
 	sPrice = sCost + ".00";	
 
//	sPrice = sCost;
 	sQty = 1;						 
 	sCode = sCodeEvent;
	sDesc = "Event Listing for " + sMonths + sMonthsText;
 	 	
} //*********** END EVENTS  END EVENTS  END EVENTS  END EVENTS
 
   	    if (sTest == "{Test}") {
//        	alert("NOTE: You are submitting a transaction with TEST flag ON.");
	    }   
 
	 sProd01 = "|" + sPrice + "::" + sQty + "::" + sCode + "::" + sDesc + "::" + sGST + sTest;
	    
//*------------------------------------------------
//* CREATE GOOD MOVES REFERENCE NUMBER TRANSACTION
//*------------------------------------------------
	sRef = document.form0.theRef.value;   
 	sRefQty = 1;		
 	sRefPrice = 0;				 
 	sRefCode = "INFO";
	sRefDesc = "Good Moves Reference Number: " +  document.form0.theRef.value;	    
	sRefProd = "|" + sRefPrice + "::" + sRefQty + "::" + sRefCode + "::" + sRefDesc + "::" + sGST + sTest;

//*-----------------------------
//* PLACE TRANSACTION IN FORM VAR
//*------------------------------	    
	document.form0.Products.value = sProd00 + sProd01 + sRefProd;
 
//* CONFIRM ALERT TESTING
//ans = confirm("Form Type = " + sFormType + "\nMonths = " + sMonths + "\nPrice = " + sPrice  + "\nDescription = " + sDesc + "\nI.S. Transaction = " + sProd01 + "\n\nClick OK to continue to payment server or Cancel to end here."); 

	ans = 0;
	if (testalert == 1) {
	ans = confirm("Form Type = " + sFormType  
		+ "\nGM Refno = " + sRef 
		+ "\nMonths = " + sMonths  		  
		+ "\nPrice = " + sPrice    
		+ "\nDescription = " + sDesc   
		+ "\nI.S. Transactions = \n" + sProd01 
		+ "\n" + sRefProd   
		+ "\n\nClick OK to continue to payment server or Cancel to end here."); 
	}		
     	
//     	alert("Products=|" + sProd00 + sProd01 + "|");
     	
 	document.form0.MerchantNumber.value = sMerchantNumber;
 	document.form0.xxxVar1.value = sFormType;  	//* eg. job,
 	document.form0.xxxVar2.value = sRef;  	 	//* GM Refno
 	document.form0.xxxVar5.value = "order-done.asp"; 			//* Internet Secure Exit script  	  	
  	document.form0.language.value = "English";
    document.form0.ReturnURL.value = "http://www.goodmoves.ca/en/order-confirm.asp";
    
  	document.form0.action = "https://secure.internetsecure.com/process.cgi";  
  	//* CONFIRM ALERT TESTING
/*----------  	
	if (testalert == 1) {  	
		if (ans==true){ 
			document.form0.method = "POST";
			document.form0.submit();
			return(0); 
		}  
  	 }
----------------------*/
  	
	document.form0.method = "POST";
 	document.form0.submit();
   	return(0);    

} //* END FUNCTION doIS()

function doPayInvoice (form, func)  {
//*******************************************************************************
//	 Func = "inv"
//Your payment has been received. Thank You
//*******************************************************************************
	var firstmessage="Please provide the following valid information:\n\n ";
	var errormessage="";
  	var sMerchantNumber		= "12606";
	var sPrice				= "";
  	var sProd00				= "Price::Qty::Code::Description::Flags" ;
	var sProd01				= "";
//	var sTest				= ""; // Set to {Test} to trigger submit test transaction to IS
	var sGST				= "";
	var sQty 				= 1;
	var sDesc 				= "Payment for Invoice: ";
	var sCode 				= "INV";
	var sFunc 				= "inv";
	
// 	sTest = "{Test}";   // Activates Test mode on internet secure
// 	sTest = "";			// Uncomment to place into production
 	sTest = sTestMode;	//* Set at top of the script	 	
 	
	sGST = "";			// sGST = "{GST}"

	if (spaceTrim(document.form0.Invoiceno.value) == "") errormessage=errormessage +  " Invoice No.\n";	
	
	sAmount = document.form0.Amount.value;
	if (sAmount == "" || isDollarString(sAmount) == false || formatDollar(sAmount) == false )
	  {errormessage=errormessage + " Amount\n";} 		 					

// 	errormessage ="";  // Uncomment to deactivate validation for Testing
   
   if (errormessage !="") { alert (firstmessage + errormessage)  }
   else { 
   	    if (sTest == "{Test}") {
//        	alert("NOTE: You are submitting a transaction with TEST flag ON.");
	    }   
	    
	    sDesc = sDesc + document.form0.Invoiceno.value;
	    sPrice = document.form0.Amount.value;
	    sProd01 = "|" + sPrice + "::" + sQty + "::" + sCode + "::" + sDesc + "::" + sGST + sTest;
	    document.form0.Products.value = sProd00 + sProd01;
     	
//     	alert("Products=|" + sProd00 + sProd01 + "|");
     	
 	  	document.form0.MerchantNumber.value = sMerchantNumber;
 	 	document.form0.xxxVar1.value = sFunc;  	 	
  	 	document.form0.xxxVar5.value = ""; 			//* Internet Secure Exit script (non required) 
// 	 	document.form0.xxxVar5.value = "order-done.asp"; 			//* Internet Secure Exit script  	  	
  	  	document.form0.language.value = "English";
      	document.form0.ReturnURL.value = "http://www.goodmoves.ca/en/contact-payinvoice-confirm.asp";
    	
  	 	document.form0.action = "https://secure.internetsecure.com/process.cgi";  
  		document.form0.method = "POST";
 		document.form0.submit();
  		return(0);  
   }  
} 

function doBOform ( form ) {	
//******************************************************************************* 
//  BUSINESS OPPORTUNITY FORMS - Use FORMMAIL.PHP
//******************************************************************************* 
	var firstmessage="Please provide the following valid information:\n\n ";
	var errormessage="";
	var sSubject="";  //*
	testFlag = 0;  //* xx in comments set this to 1
	sRef = "";					 //* GM Refno
	maxwords = 400;
 
//*-------------------------
//* BO BUYER/SELLER
//*-------------------------
    if (document.form0.FormType.value == "bo_buysell") {
    	 
    	sSubject = "GM - BO: BUY/SELL";
    	
		if (document.form0.Sell_or_Buy[0].checked ||
			document.form0.Sell_or_Buy[1].checked) {  }
		else { errormessage = errormessage + "Sell or Buy\n" }

		if (document.form0.Sell_or_Buy[0].checked) {
			sRef = "BS" + sTheRef;				//*** Ref deteremined in /include/gm-ref-inc.asp
			sSubject = "GM - BO: SELL"; 
		}
		if (document.form0.Sell_or_Buy[1].checked) {
			sRef = "BW" + sTheRef;	
			sSubject = "GM - BO: BUY (WANTED)";     	
		}
    	
		if (document.form0.Months[0].checked ||
			document.form0.Months[1].checked) {  }
		else { errormessage = errormessage + "No. of Months to be listed\n" } 
				
		if (document.form0.Protected_Identity[0].checked ||
			document.form0.Protected_Identity[1].checked ) {  }
		else { errormessage = errormessage + "Protected Identity Option\n" } 	
		
	if (spaceTrim(document.form0.BusType.value) == "") errormessage=errormessage +  "Type of Business\n";			

	if (spaceTrim(document.form0.BusCity.value) == "") errormessage=errormessage +  "Location: City\n";	

//* PROV SELECTION LIST	
	item = document.form0.BusProv.selectedIndex;
	Provval = document.form0.BusProv.options[item].value;
	if (Provval == "") {errormessage=errormessage+"Location: Province\n"}  		
	
//* COUNTRY SELECTION LIST 	
	item = document.form0.BusCountry.selectedIndex;
	countryval = document.form0.BusCountry.options[item].value;
	if (countryval == "") {errormessage=errormessage+"Location: Country\n"} 
	
	// getCheckedValue(document.forms['radioExampleForm'].elements['number']));

    //getCheckedValue(document.forms['form0'].elements['Months']));				

	} //* END BUYER/SELLER


//*-------------------------
//* BO CO-LOADER
//*-------------------------
    if (document.form0.FormType.value == "bo_coloader") {
    	sRef = "BC" + sTheRef;				//*** Ref deteremined in /include/gm-ref-inc.asp
    	sSubject = "GM - BO: CO-LOADER";
		
		if (document.form0.TransMethod[0].checked ||
			document.form0.TransMethod[1].checked) {  }
		else { errormessage = errormessage + "Transportation Method\n" }     	

//*** SERVICE RADIOS:  *** IMPORT
		if (document.form0.Service[0].checked) {
			 item = document.form0.ImportOriginCountry.selectedIndex;
			 countryval = document.form0.ImportOriginCountry.options[item].value;
			if (countryval == "") {errormessage=errormessage+"Import: Origin Country\n"} 
			
			if (spaceTrim(document.form0.ImportOriginCity.value) == "") errormessage=errormessage + "Import: Origin City\n"; 
			
			item = document.form0.ImportCanDestCity.selectedIndex;
			cityval = document.form0.ImportCanDestCity.options[item].value;
			if (cityval == "") {errormessage=errormessage+"Import: Canadian Destination City\n"} 
		}
		
//***SERVICE RADIOS: *** EXPORT		
		else if (document.form0.Service[1].checked) { 
			item = document.form0.ExportDestCountry.selectedIndex;
			countryval = document.form0.ExportDestCountry.options[item].value;
			if (countryval == "") {errormessage=errormessage+"Export: Destination Country\n"} 			
			
			if (spaceTrim(document.form0.ExportDestCity.value) == "") errormessage=errormessage + "Export: Destination City\n"; 			
			
			item = document.form0.ExportCanOriginCity.selectedIndex;
			cityval = document.form0.ExportCanOriginCity.options[item].value;
			if (cityval == "") {errormessage=errormessage+"Export: Canadian Origin City\n"}				
					
		 }
		else { errormessage = errormessage + "Service Type\n"; }  
 
		if (document.form0.Months[0].checked ||
			document.form0.Months[1].checked ||
			document.form0.Months[2].checked) {  }
		else { errormessage = errormessage + "No. of Months to be listed\n" } 

	} //* END CO-LOADER

//*-------------------------
//* BO AGENT
//*-------------------------
    if (document.form0.FormType.value == "bo_agent") {
    	sRef = "BA" + sTheRef;				//*** Ref deteremined in /include/gm-ref-inc.asp
    	sSubject = "GM - BO: AGENT";

	if (document.form0.Agent[0].checked) {    	
		
		if (spaceTrim(document.form0.Can_Your_City.value) == "") errormessage=errormessage + "Agent: Canadian: Your City\n"; 
		
		item = document.form0.Can_Your_Country.selectedIndex;
		countryval = document.form0.Can_Your_Country.options[item].value;
		if (countryval == "") {errormessage=errormessage+"Agent: Canadian: Your Country\n"} 
	}			
    	
	else if (document.form0.Agent[1].checked) {
		item = document.form0.Int_Your_Country_of_Interest.selectedIndex;
		countryval = document.form0.Int_Your_Country_of_Interest.options[item].value;
		if (countryval == "") {errormessage=errormessage+"Agent: International: Your Country of Interest\n"}		
		}
		else { errormessage = errormessage + "Agent\n" }     	
    	
		if (document.form0.Months[0].checked ||
			document.form0.Months[1].checked ||
			document.form0.Months[2].checked) {  }
		else { errormessage = errormessage + "No. of Months to be listed\n" } 

	} //* END AGENT

//*-------------------------
//* OTHER BUSINESS OPPORTUNITIES
//*-------------------------
    if (document.form0.FormType.value == "bo_other") {
    	sRef = "BO" + sTheRef;				//*** Ref deteremined in /include/gm-ref-inc.asp    	   	
    	sSubject = "GM - BO: OTHER";
  
		if (document.form0.Months[0].checked ||
			document.form0.Months[1].checked ||
			document.form0.Months[2].checked ) {  }
		else { errormessage = errormessage + "No. of Months to be listed\n" } 
		
		if (document.form0.Protected_Identity[0].checked ||
			document.form0.Protected_Identity[1].checked ) {  }
		else { errormessage = errormessage + "Protected Identity Option\n" } 
	
	if (spaceTrim(document.form0.OpportunityType.value) == "") errormessage=errormessage +  "Type of Opportunity\n";	
		
	if (spaceTrim(document.form0.BusCity.value) == "") errormessage=errormessage +  "Location: City\n";	

//* PROV SELECTION LIST	
	item = document.form0.BusProv.selectedIndex;
	Provval = document.form0.BusProv.options[item].value;
	if (Provval == "") {errormessage=errormessage+"Location: Province\n"}  		
	
//* COUNTRY SELECTION LIST 	
	item = document.form0.BusCountry.selectedIndex;
	countryval = document.form0.BusCountry.options[item].value;
	if (countryval == "") {errormessage=errormessage+"Location: Country\n"} 				
		  		
	} //* END OTHER	
//*-------------------------
//* COMMON
//*-------------------------
	Desc1 = spaceTrim(document.form0.Desc1.value);
//	alert(maxwords)
	if (countWords(Desc1) > maxwords) errormessage=errormessage + "Description exceeds word count\n";
		if (Desc1.length < 11) errormessage=errormessage + "Description\n";

//*-------------------------
//* PERSONAL INFO - from includes/persinfo.asp
//*-------------------------
	
 	if (spaceTrim(document.form0.Name.value) == "") errormessage=errormessage + "Name\n"; 
 	if (spaceTrim(document.form0.Company.value) == "") errormessage=errormessage + "Company\n"; 	
 	if (spaceTrim(document.form0.Address.value) == "") errormessage=errormessage + "Address\n";
 	if (spaceTrim(document.form0.City.value) == "") errormessage=errormessage + "City\n";
// 	if (spaceTrim(document.form0.Prov.value) == "") errormessage=errormessage + "Province\n";
 	
	var item = document.form0.Prov.selectedIndex;
	var Provval = document.form0.Prov.options[item].value;
	if (Provval == "") {errormessage=errormessage+"Province\n"}  	
 	
 	if (spaceTrim(document.form0.PostalCode.value) == "") errormessage=errormessage + "Postal/ZIP Code\n"; 	
 	
	item = document.form0.Country.selectedIndex;
	countryval = document.form0.Country.options[item].value;
	if (countryval == "") {errormessage=errormessage+"Country\n"}  	
 		
 	if (spaceTrim(document.form0.Telephone.value) == "") errormessage=errormessage +  "Telephone\n";
	if (document.form0.xEmail.value.length ==0 || document.form0.xEmail.value.indexOf('@', 0) == -1 || document.form0.xEmail.value.indexOf('.', 0) == -1) {errormessage=errormessage+"Email address\n"} 

// 	errormessage  = "";  //*** UNCOMMENT to REMOVE VALIDATION for TESTING
	
	if (spaceTrim(document.form0.Comments.value) == "xx") {errormessage=""; testFlag = 1;}
	
	
 	if (errormessage !="") { alert (firstmessage + errormessage) ;}
	else {
		
//*** SET COOKIES		 
	var exp = 365;	
    if (document.form0.Name.value !="") 		setCookie("Name", document.form0.Name.value, exp); 
    if (document.form0.Company.value !="") 		setCookie("Company", document.form0.Company.value, exp);  
    if (document.form0.Address.value !="") 		setCookie("Address", document.form0.Address.value, exp);
    if (document.form0.City.value !="") 		setCookie("City", document.form0.City.value, exp);    
  	setCookie("Prov", document.form0.Prov.selectedIndex, exp);
    if (document.form0.PostalCode.value !="") 	setCookie("PostalCode", document.form0.PostalCode.value, exp); 
    setCookie("Country", document.form0.Country.selectedIndex, exp);						
    if (document.form0.Telephone.value !="") 	setCookie("Telephone", document.form0.Telephone.value, exp);
    if (document.form0.xEmail.value !="") 		setCookie("Email", document.form0.xEmail.value, exp);		
			
 		sEmailto = "jon@goodmoves.ca"; 		// Default recipient
// 		sEmailto = "pc@twistedpixel.com";  	
 	  			
 		if (testFlag) {
 			 sEmailto = document.form0.xEmail.value; 
 			 sEmailto = "pc@twistedpixel.com"; 
 		}
 		
//*Calc Post and Expire dates and paste into form 	


//*------------------------------
//*Calc Post and Expire dates
//*------------------------------	
//		Get the value of the Checked Month
		sRadioMonths = getCheckedValue(document.forms['form0'].elements['Months']);
//	 	alert(sRadioMonths)
		sRadioMonths = parseFloat(sRadioMonths) //* Convert String to number	
 	
		//create the date
		sCurDate = new Date();
		sExpDate = new Date();
		sPostDate = sCurDate.format("isoDate"); 				//* YYYY-MM-DD
//	  	alert(sPostDate)
		
		sExpDate.setMonth(sExpDate.getMonth() + sRadioMonths);  //* Add no. of months
		sExpDate = sExpDate.format("isoDate");  				//* YYYY-MM-DD
// 	  	alert(sExpDate)	    
	
		document.form0.DatePosted.value = sPostDate;
		document.form0.DateExpire.value = sExpDate;
//*------------------------------ 		
//* Place GM Ref into form 	
//*------------------------------
		document.form0.Ref.value = sRef; //* Calculated in includes/gm-ref-inc.asp at top of forms		
		
//		document.form0.recipients.value = "pc@twistedpixel.com"; 	 //* Change to a goodmoves address
 	 	document.form0.bcc.value = "pc@twistedpixel.com"; 	  
   		document.form0.recipients.value = sEmailto;
	  	document.form0.subject.value = sSubject;
 	  	document.form0.email.value = document.form0.xEmail.value;
	  	document.form0.good_url.value = "http://www.goodmoves.ca/en/bo-order-confirm.asp";
	  	document.form0.action = "../mailer/formmail.php"; 
	  	document.form0.action = "http://www.goodmoves.ca/mailer/formmail.php";
  		document.form0.method = "POST";
	  	document.form0.submit();
 		return(0); 	
   }  	  			
	
}//* END

function doCookies () {
//******************************************************************************* 
//  If Name, company, etc is in cookie, display
//  on form so user does not have to enter it again.
//******************************************************************************* 		
	var theSalutation		= getCookie("Salutation"); 
	var theName 			= getCookie("Name"); 
	var theJobTitle 		= getCookie("JobTitle");
	var theCompany			= getCookie("Company");
	var theAddress			= getCookie("Address"); 
	var theCity				= getCookie("City"); 
	var theProv 			= getCookie("Prov"); 
	var thePostalCode		= getCookie("PostalCode"); 
	var theCountry			= getCookie("Country"); 
	var theTelephone		= getCookie("Telephone"); 
	var theFax 				= getCookie("Fax"); 
	var theEmail			= getCookie("Email"); 
 
 	if (theSalutation == null)	{theSalutation = "" };	
	if (theName == null) 	{theName = "" } // Just in case the cookie is not set.
	if (theJobTitle == null)	{theJobTitle = "" };		
	if (theCompany == null)	{theCompany = "" };	
	if (theAddress == null) {theAddress = "" };
	if (theCity == null)	{theCity = "" };
	if (theProv == null)		{theProv = 0 };  // Selection List
	if (thePostalCode == null)		{thePostalCode = "" };
	if (theCountry == null)		{theCountry = 0 };  // Selection List
	if (theTelephone == null) {theTelephone = "" };
	if (theFax == null)	{theFax = "" };	
	if (theEmail == null)	{theEmail = "" };
  
    document.form0.Name.value = theName;
    document.form0.JobTitle.value = theJobTitle;
    document.form0.Company.value = theCompany;
	document.form0.Address.value = theAddress;	
	document.form0.City.value = theCity;
	document.form0.Prov.selectedIndex = theProv;
	document.form0.PostalCode.value = thePostalCode;
	document.form0.Country.selectedIndex = theCountry;
    document.form0.Telephone.value = theTelephone;
    document.form0.Fax.value = theFax;
    document.form0.xEmail.value = theEmail;
}

function doCount( theDescNo ){
//******************************************************************************* 
//  Display word count when user presses word count button 
//******************************************************************************* 
	if (theDescNo == "1") theDesc = spaceTrim(document.form0.Desc1.value);
	else if (theDescNo == "2") theDesc = spaceTrim(document.form0.Desc2.value);
	else if (theDescNo == "3") theDesc = spaceTrim(document.form0.Desc3.value);
	else if (theDescNo == "4") theDesc = spaceTrim(document.form0.Desc4.value);
	else if (theDescNo == "5") theDesc = spaceTrim(document.form0.Desc5.value);
	else if (theDescNo == "J") theDesc = spaceTrim(document.form0.JobDesc.value);
 
	if (theDesc == "") theCount = 0;
	else theCount = countWords(theDesc);
	alert("Word count = " + theCount);
}

function countWords( theDesc ){
//******************************************************************************* 
//  Count words in the variable. Return the count
//  http://www.javascriptkit.com/script/cutindex13.shtml
//******************************************************************************* 
/*Word count script
By JavaScript Kit (http://javascriptkit.com)
Over 400+ free scripts here!
*/
//var formcontent=document.wordcount.wordcount2.value
//formcontent=formcontent.split(" ")
//document.wordcount.wordcount3.value=formcontent.length
	
	theDesc=theDesc.split(" ");
	count = theDesc.length;
	return (count);	
}

function doContact ( form ) {	
//******************************************************************************* 
//  Do the Contact form - processing script is mailer/FORMMAIL.PHP
//******************************************************************************* 
	var firstmessage="Please provide the following valid information:\n\n ";
	var errormessage="";
	var errorcode=0; 
	var len;
	var testFlag = 0;  // set to 1 if Comments = "xx" - bypass validation.
//***  
	var sEmailto = "";			// Default receipient 
		  			  		
//* Checkboxes
// alert(document.form0.Customer_Type_1.checked +  document.form0.Customer_Type_2.checked +  document.form0.Customer_Type_3.checked +  document.form0.Customer_Type_4.checked +  document.form0.Customer_Type_5.checked +  document.form0.Customer_Type_6.checked + document.form0.Customer_Type_7.checked +  document.form0.Customer_Type_8.checked +  document.form0.Customer_Type_9.checked + document.form0.Customer_Type_10.checked );
 
//  alert(document.form0.Customer_Type_2.checked );
 	Customer_Type_Other = spaceTrim(document.form0.Customer_Type_Other.value);
 	if (document.form0.Customer_Type_1.checked == 0 & 
 	 	document.form0.Customer_Type_2.checked == 0 & 
 	 	document.form0.Customer_Type_3.checked == 0 &
 	 	document.form0.Customer_Type_4.checked == 0 & 
 	 	document.form0.Customer_Type_5.checked == 0 & 
 	 	document.form0.Customer_Type_6.checked == 0 & 
 	 	document.form0.Customer_Type_7.checked == 0 & 
 	 	document.form0.Customer_Type_8.checked == 0 & 
 	 	document.form0.Customer_Type_9.checked == 0 & 
 	 	document.form0.Customer_Type_10.checked == 0 & 
 	   	Customer_Type_Other == "")    
 	{errormessage=errormessage+"I am a...\n"} 
	
 	if (spaceTrim(document.form0.Name.value) == "") errormessage=errormessage + "Name\n";
 	if (spaceTrim(document.form0.Company.value) == "") errormessage=errormessage + "Company\n";

// 	if (spaceTrim(document.form0.Address1.value) == "") errormessage=errormessage + "Address\n";
// 	if (spaceTrim(document.form0.City.value) == "") errormessage=errormessage + "City\n";
// 	if (spaceTrim(document.form0.Province.value) == "") errormessage=errormessage + "Province\n";
// 	if (spaceTrim(document.form0.Postal_Code.value) == "") errormessage=errormessage + "Postal_Code\n"; 		 	
 
 	if (spaceTrim(document.form0.Telephone.value) == "") errormessage=errormessage +  "Telephone\n";
	if (document.form0.Email.value.length ==0 || document.form0.Email.value.indexOf('@', 0) == -1 || document.form0.Email.value.indexOf('.', 0) == -1) {errormessage=errormessage+"Email address\n"} 
		
 		
//  	errormessage ="";  // Uncomment to deactivate validation for Testing
 
	if (spaceTrim(document.form0.Comments.value) == "xx") {errormessage=""; testFlag = 1;} 

	if (errormessage !="") { alert (firstmessage + errormessage) ;}
	else { 	
 		sEmailto = "jon@goodmoves.ca"; // Default recipient 	
 	  	document.form0.recipients.value = sEmailto;
		
		if (testFlag) {
			 document.form0.recipients.value = document.form0.Email.value; 
		}
			 	 	
 	 	document.form0.bcc.value = "pc@twistedpixel.com"; 	 //* for testing
 	  	document.form0.email.value = document.form0.Email.value;
	  	document.form0.subject.value = "GM - Contact Us";

	  	document.form0.good_url.value = "http://www.goodmoves.ca/en/contact-confirm.asp";
 		  	
	  	document.form0.action = "../mailer/formmail.php";
//	  	document.form0.enctype = "multipart/form-data";  
  		document.form0.method = "POST";
	  	document.form0.submit()
 		return(0); 	
   }  
}

function isNumberString (InString)  {
//*******************************************************************************
// IS String a number
//*******************************************************************************
	if(InString.length==0) 
		return (false);
	RefString="1234567890";
	for (Count=0; Count < InString.length; Count++)  {
		TempChar= InString.substring (Count, Count+1);
		if (RefString.indexOf (TempChar, 0)==-1)  
			return (false);
	}
	return (true);
}

 function spaceTrim(InString) {
//*******************************************************************************
// Trim leading and trailing spaces of form input fields
//*******************************************************************************
	var LoopCtrl=true;
	while (LoopCtrl) {
		if (InString.indexOf("  ") != -1) {
			Temp = InString.substring(0, InString.indexOf("  "))
			InString = Temp + InString.substring(InString.indexOf("  ")+1, 
				InString.length)
		} else
			LoopCtrl = false;
	}
	if (InString.substring(0, 1) == " ")
		InString = InString.substring(1, InString.length)
	if (InString.substring (InString.length-1) == " ")
		InString = InString.substring(0, InString.length-1)
	return (InString)
}

function formatDollar (Val, DollarSign)  {
//*******************************************************************************
// FORMAT DOLLAR
//*******************************************************************************	
	Val=""+Val;
	if (Val.indexOf (".", 0)!=-1) {
		Dollars = Val.substring(0, Val.indexOf (".", 0));
		Cents = Val.substring(Val.indexOf (".", 0)+1, Val.indexOf (".", 0)+3);
		if (Cents.length==0) 
			Cents="00";
		if (Cents.length==1)
			Cents=Cents+"0";
	} else {
		Dollars = Val;
		Cents = "00";
	}
	OutString="";
	len=Dollars.length;
	if (len>=3) {
		while (len>0) {
			TempString=Dollars.substring(len-3, len)
			if (TempString.length==3) {
				OutString=","+TempString+OutString
				len=len-3;
			} else {
				OutString=TempString+OutString
				len=0
			}
		}
		if (OutString.substring(0, 1)==",") 
			Dollars=OutString.substring (1, OutString.length)
		else
			Dollars=OutString
	} 
	if (DollarSign)
		return ("$"+Dollars+"."+Cents);
	else
		return (Dollars+"."+Cents);
}

function flipImg(imgNam,imgTyp,onoff){
//*******************************************************************************
//	Do the mouse over image flipping.
//******************************************************************************* 		
  	if(document.images){ 	
 		document.images[imgNam].src=eval(imgTyp+onoff+'.src');
  	}
}

function doClear ( form ) {	
//*******************************************************************************
// Clear Form  -  
//*******************************************************************************	
//alert(pagelang);
    var msg_e = "Are you sure that you want to clear all the data you have entered on this form?";
    var msg_f = "Voulez-vous vraiment effacer toutes les données?";
    var clearmsg = msg_e;
 // if (pagelang == "f") clearmsg = msg_f;
    
	var confirmOK = confirm(clearmsg);
  	if (confirmOK) document.form0.reset();    
}

function isInteger(s)
//*******************************************************************************
//	is it an integer?
//*******************************************************************************	
{   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 isDollarString (InString)  {
//*******************************************************************************
// Check if string contains dollar amount chars
//*******************************************************************************
	if(InString.length==0) 
		return (false);
	RefString="1234567890.";
	for (Count=0; Count < InString.length; Count++)  {
		TempChar= InString.substring (Count, Count+1);
		if (RefString.indexOf (TempChar, 0)==-1)  
			return (false);
	}
	return (true);
} 
 
function passWindow() {
//*******************************************************************************
//	Display a popup window with IS info  NOT USED
//*******************************************************************************
	window.open("ordercc-pop.php", "newwin", "width=300,height=210,scrollbars=yes,status=yes,resizable=yes");
} 

function loadJOBForm ( ) {
//*-----------------------------------------
//* LOAD JOB FORM WITH TEST DATA 
//*-----------------------------------------	
//	document.form0.Months[1].checked = 1;				//*    BUTTON
    document.form0.Position.value = "Truck Driver";
	document.form0.City.value = "Toronto";
	document.form0.Prov.selectedIndex = 9;   			//* SELECTION LIST
	document.form0.Country.selectedIndex = 1;
	document.form0.JobType.selectedIndex = 2;
	document.form0.Travel.value = "100%";
	document.form0.Country.selectedIndex = 1;
	document.form0.Comp.value = "$50k/yr.";	
	document.form0.Resp.value = "Drive a truck";	
	document.form0.Skills.value = "Driving";	
	document.form0.Qual.value = "Drivers Licence";	
	document.form0.Educ.value = "High School";		
	document.form0.Country.selectedIndex = 1;
	document.form0.Category.selectedIndex = 0;	
	document.form0.Cat_Other.value = "Tricycle Transit";	
	document.form0.JobDesc.value = "The candidate must be able to drive a truck<br><br>Lorem ipsum dolor sit amet, dolor excelsior magna aliqua erat very tastey. Lorem ipsum dolor sit amet, dolor excelsior magna aliqua erat very tastey.<br><br>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus sit amet sem. Vestibulum accumsan arcu mattis velit. Nulla posuere, elit id feugiat placerat, neque nisl ullamcorper velit, quis mattis lectus turpis ac odio. Proin ultricies molestie nisl.<br><br>Phasellus id dui. Aenean in risus. Etiam accumsan, mauris sed euismod pharetra, odio sem viverra leo, ac varius tellus turpis vitae tortor. Sed adipiscing lorem id massa. Ut interdum ligula dignissim nisi.<br><br>Lorem ipsum dolor sit amet, dolor excelsior magna aliqua erat very tastey. Lorem ipsum dolor sit amet, dolor excelsior magna aliqua erat very tastey.<br><br>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus sit amet sem. Vestibulum accumsan arcu mattis velit. Nulla posuere, elit id feugiat placerat, neque nisl ullamcorper velit, quis mattis lectus turpis ac odio. Proin ultricies molestie nisl.<br><br>Phasellus id dui. Aenean in risus. Etiam accumsan, mauris sed euismod pharetra, odio sem viverra leo, ac varius tellus turpis vitae tortor. Sed adipiscing lorem id massa. Ut interdum ligula dignissim nisi.";	
//	document.form0.Comments.value = "Post this quick.";
	document.form0.Employer.value = "Acme Customs and Brokerage";
	document.form0.Agency.checked = 1;
	document.form0.Contact.value = "John Smith";	
	document.form0.Email.value = "pc@twistedpixel.com";	
    document.form0.Website.value = "www.twistedpixel.com";
    document.form0.Phone.value = "555-444-4444";
    document.form0.Fax.value = "555-555-5555";
    document.form0.MailAddr.value = "11 Yeo Street, Penetang, Ontario";	
}


function loadITEMForm ( ) {
//*-----------------------------------------
//* LOAD ITEM FOR SALE FORM WITH TEST DATA 
//*-----------------------------------------	
	document.form0.Months[1].checked = 1;				//* RADIO BUTTON
    document.form0.SellerName.value = "Mister Twisted";
    document.form0.SellerPhone.value = "555-555-5555";
    document.form0.SellerEmail.value = "pc@twistedpixel.com";
	document.form0.City.value = "Toronto";
	document.form0.Prov.selectedIndex = 9;   			//* SELECTION LIST
	document.form0.Country.selectedIndex = 1;
	
	
	document.form0.ItemName1.value = "Big shiny forklift truck with fancy wheel covers. Used only a couple of times. Good Condition.";
	document.form0.Price1.value = "25,000";
	document.form0.Currency1[0].checked = 1;				//* RADIO BUTTON
	document.form0.Desc1.value = "Lorem ipsum dolor sit amet, dolor excelsior magna aliqua erat very tastey. Lorem ipsum dolor sit amet, dolor excelsior magna aliqua erat very tastey.<br><br>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus sit amet sem. Vestibulum accumsan arcu mattis velit. Nulla posuere, elit id feugiat placerat, neque nisl ullamcorper velit, quis mattis lectus turpis ac odio. Proin ultricies molestie nisl.<br><br>Phasellus id dui. Aenean in risus. Etiam accumsan, mauris sed euismod pharetra, odio sem viverra leo, ac varius tellus turpis vitae tortor. Sed adipiscing lorem id massa. Ut interdum ligula dignissim nisi.";
	
	document.form0.ItemName2.value = "Fancy Green Shippig Widget. Must Sell, Make an offer!";
	document.form0.Price2.value = "12,300";
	document.form0.Currency2[0].checked = 1;				//* RADIO BUTTON
	document.form0.Desc2.value = "Lorem ipsum dolor sit amet, dolor excelsior magna aliqua erat very tastey. Lorem ipsum dolor sit amet, dolor excelsior magna aliqua erat very tastey.<br><br>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus sit amet sem. Vestibulum accumsan arcu mattis velit. Nulla posuere, elit id feugiat placerat, neque nisl ullamcorper velit, quis mattis lectus turpis ac odio. Proin ultricies molestie nisl.<br><br>Phasellus id dui. Aenean in risus. Etiam accumsan, mauris sed euismod pharetra, odio sem viverra leo, ac varius tellus turpis vitae tortor. Sed adipiscing lorem id massa. Ut interdum ligula dignissim nisi.";
	
	document.form0.ItemName3.value = "Humungous Trailer that Hauls Just about Anything. Looks cool, too.";
	document.form0.Price3.value = "7,000";
	document.form0.Currency3[0].checked = 1;				//* RADIO BUTTON
	document.form0.Desc3.value = "Lorem ipsum dolor sit amet, dolor excelsior magna aliqua erat very tastey. Lorem ipsum dolor sit amet, dolor excelsior magna aliqua erat very tastey.<br><br>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus sit amet sem. Vestibulum accumsan arcu mattis velit. Nulla posuere, elit id feugiat placerat, neque nisl ullamcorper velit, quis mattis lectus turpis ac odio. Proin ultricies molestie nisl.<br><br>Phasellus id dui. Aenean in risus. Etiam accumsan, mauris sed euismod pharetra, odio sem viverra leo, ac varius tellus turpis vitae tortor. Sed adipiscing lorem id massa. Ut interdum ligula dignissim nisi.";
	
	document.form0.ItemName4.value = "Really Fast Airlplane with Folding Wings";
	document.form0.Price4.value = "500,000";
	document.form0.Currency4[0].checked = 1;				//* RADIO BUTTON
	document.form0.Desc4.value = "Lorem ipsum dolor sit amet, dolor excelsior magna aliqua erat very tastey. Lorem ipsum dolor sit amet, dolor excelsior magna aliqua erat very tastey.<br><br>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus sit amet sem. Vestibulum accumsan arcu mattis velit. Nulla posuere, elit id feugiat placerat, neque nisl ullamcorper velit, quis mattis lectus turpis ac odio. Proin ultricies molestie nisl.<br><br>Phasellus id dui. Aenean in risus. Etiam accumsan, mauris sed euismod pharetra, odio sem viverra leo, ac varius tellus turpis vitae tortor. Sed adipiscing lorem id massa. Ut interdum ligula dignissim nisi.";				
}

function loadDIRForm ( ) {
//*-----------------------------------------
//* LOAD DIR FORM WITH TEST DATA 
//*-----------------------------------------	
	document.form0.Months[4].checked = 1;				//* RADIO BUTTON
    document.form0.Company.value = "First-Rate Logistics Emporium";
    document.form0.ServProvType.selectedIndex = 9; 
	document.form0.Contact.value = "Mister Twisted";	
	document.form0.Address.value = "123 Eglinton Avenue East";	    
	document.form0.City.value = "Toronto";
	document.form0.Prov.selectedIndex = 9;   			//* SELECTION LIST
	document.form0.Country.selectedIndex = 1;
	document.form0.Postal.value = "L5G 2E5";	
	document.form0.Telephone.value = "555-555-5555";	
	document.form0.Fax.value = "666-666-6666";	
	document.form0.Website.value = "www.twistedpixel.com";
	document.form0.Email.value = "pc@twistedpixel.com";	
	document.form0.Desc1.value = "Lorem ipsum dolor sit amet, dolor excelsior magna aliqua erat very tastey. Lorem ipsum dolor sit amet, dolor excelsior magna aliqua erat very tastey.<br><br>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus sit amet sem. Vestibulum accumsan arcu mattis velit. Nulla posuere, elit id feugiat placerat, neque nisl ullamcorper velit, quis mattis lectus turpis ac odio. Proin ultricies molestie nisl.<br><br>Phasellus id dui. Aenean in risus. Etiam accumsan, mauris sed euismod pharetra, odio sem viverra leo, ac varius tellus turpis vitae tortor. Sed adipiscing lorem id massa. Ut interdum ligula dignissim nisi."; 
}


function loadEVENTSForm ( ) {
//*-----------------------------------------
//* LOAD EVENTS FORM WITH TEST DATA 
//*-----------------------------------------	
	document.form0.Months[1].checked = 1;				//* RADIO BUTTON
    document.form0.EventName.value = "World Wide Logistics Fair";
	document.form0.StartDate.value = "February 29, 2008";	
	document.form0.EndDate.value = "March 2, 2008";
	document.form0.HostedBy.value = "Logistics Management Services";	
	document.form0.Place.value = "Harbour Castle Hilton";    
	document.form0.City.value = "Toronto";
	document.form0.Prov.selectedIndex = 9;   			//* SELECTION LIST
	document.form0.Country.selectedIndex = 1;			//* SELECTION LIST
	document.form0.Link.value = "www.twistedpixel.com";		
	document.form0.Desc1.value = "Lorem ipsum dolor sit amet, dolor excelsior magna aliqua erat very tastey. Lorem ipsum dolor sit amet, dolor excelsior magna aliqua erat very tastey.<br><br>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus sit amet sem. Vestibulum accumsan arcu mattis velit. Nulla posuere, elit id feugiat placerat, neque nisl ullamcorper velit, quis mattis lectus turpis ac odio. Proin ultricies molestie nisl.<br><br>Phasellus id dui. Aenean in risus. Etiam accumsan, mauris sed euismod pharetra, odio sem viverra leo, ac varius tellus turpis vitae tortor. Sed adipiscing lorem id massa. Ut interdum ligula dignissim nisi."; 
} 

/*
	Date Format 1.1
	(c) 2007 Steven Levithan <stevenlevithan.com>
	MIT license
	With code by Scott Trenda (Z and o flags, and enhanced brevity)
	http://blog.stevenlevithan.com/archives/date-time-format
*/

/*** dateFormat
	Accepts a date, a mask, or a date and a mask.
	Returns a formatted version of the given date.
	The date defaults to the current date/time.
	The mask defaults ``"ddd mmm d yyyy HH:MM:ss"``.
*/
var dateFormat = function () {
	var	token        = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloZ]|"[^"]*"|'[^']*'/g,
		timezone     = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
		timezoneClip = /[^-+\dA-Z]/g,
		pad = function (value, length) {
			value = String(value);
			length = parseInt(length) || 2;
			while (value.length < length)
				value = "0" + value;
			return value;
		};

	// Regexes and supporting functions are cached through closure
	return function (date, mask) {
		// Treat the first argument as a mask if it doesn't contain any numbers
		if (
			arguments.length == 1 &&
			(typeof date == "string" || date instanceof String) &&
			!/\d/.test(date)
		) {
			mask = date;
			date = undefined;
		}

		date = date ? new Date(date) : new Date();
		if (isNaN(date))
			throw "invalid date";

		var dF = dateFormat;
		mask   = String(dF.masks[mask] || mask || dF.masks["default"]);

		var	d = date.getDate(),
			D = date.getDay(),
			m = date.getMonth(),
			y = date.getFullYear(),
			H = date.getHours(),
			M = date.getMinutes(),
			s = date.getSeconds(),
			L = date.getMilliseconds(),
			o = date.getTimezoneOffset(),
			flags = {
				d:    d,
				dd:   pad(d),
				ddd:  dF.i18n.dayNames[D],
				dddd: dF.i18n.dayNames[D + 7],
				m:    m + 1,
				mm:   pad(m + 1),
				mmm:  dF.i18n.monthNames[m],
				mmmm: dF.i18n.monthNames[m + 12],
				yy:   String(y).slice(2),
				yyyy: y,
				h:    H % 12 || 12,
				hh:   pad(H % 12 || 12),
				H:    H,
				HH:   pad(H),
				M:    M,
				MM:   pad(M),
				s:    s,
				ss:   pad(s),
				l:    pad(L, 3),
				L:    pad(L > 99 ? Math.round(L / 10) : L),
				t:    H < 12 ? "a"  : "p",
				tt:   H < 12 ? "am" : "pm",
				T:    H < 12 ? "A"  : "P",
				TT:   H < 12 ? "AM" : "PM",
				Z:    (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
				o:    (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4)
			};

		return mask.replace(token, function ($0) {
			return ($0 in flags) ? flags[$0] : $0.slice(1, $0.length - 1);
		});
	};
}();

// Some common format strings
dateFormat.masks = {
	"default":       "ddd mmm d yyyy HH:MM:ss",
	shortDate:       "m/d/yy",
	mediumDate:      "mmm d, yyyy",
	longDate:        "mmmm d, yyyy",
	fullDate:        "dddd, mmmm d, yyyy",
	shortTime:       "h:MM TT",
	mediumTime:      "h:MM:ss TT",
	longTime:        "h:MM:ss TT Z",
	isoDate:         "yyyy-mm-dd",
	isoTime:         "HH:MM:ss",
	isoDateTime:     "yyyy-mm-dd'T'HH:MM:ss",
	isoFullDateTime: "yyyy-mm-dd'T'HH:MM:ss.lo"
};

// Internationalization strings
dateFormat.i18n = {
	dayNames: [
		"Sun", "Mon", "Tue", "Wed", "Thr", "Fri", "Sat",
		"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
	],
	monthNames: [
		"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
		"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
	]
};

// For convenience...
Date.prototype.format = function (mask) {
	return dateFormat(this, mask);
}

// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function delcookie() {
//* Delete specific cookie. 	
   delete_cookie ( "banner" );
   showcookie();
   }    
 
function showcookie() {
//* Show specific cookie. 	
   var Cvote=getCookie('banner');
   alert('The cookie= ' + Cvote);
   }
   
function get_random(pcount) {
    var ranNum= Math.round(Math.random()* pcount);
    return ranNum;
}	    
 

 
