
function calculate_price(taxrate,price,desc) {

	var final_price;

	   final_price = price * (1 + (taxrate/100));
	   final_price = final_price.toFixed(2);

	   document.form1.totalprice.value = price ;
	   document.form1.price_with_tax.value = final_price ;
	   document.form1.product_desc.value = desc ;
}

//*************************************************************
function removeSpaces(string) {

	// remove all spaces from a string
	var tstring = "";
	string = '' + string;
	splitstring = string.split(" ");
	for(i = 0; i < splitstring.length; i++)
	tstring += splitstring[i];

	return tstring;
}
//*************************************************************
function removeSpacesAmp(string) {

	// remove all spaces from a string
	var tstring = "";
	string = '' + string;
	splitstring = string.split(" ");
	for(i = 0; i < splitstring.length; i++)
	tstring += splitstring[i];

	var r = "";
	  for (i=0; i < tstring.length; i++) {
		if (tstring.charAt(i) != '&' &&
			tstring.charAt(i) != '%') {
		  r += tstring.charAt(i);
		  }
		}
	return r;
}

//*************************************************************
function voucher_check() {
//can't pay for 3pack jobs with a voucher

	var flag1, flag2;

	flag1 = false;
	flag2 = false;

	if (document.form1.cost[2].checked == true){
		flag1 = true;
	}


	if (document.form1.payment[2].checked == true){
		flag2 = true;
	}

	if ((flag1 && flag2))	{	
		alert("You can not pay for a 3 Pack of job postings with a pre-paid voucher.  Please select another payment option.");
		return (false); 
	} else {
		return (true);
	}

}

//*************************************************************
function Validator() {
//validate submited form informaton when a new order is created.

// -----------<check job description>------------

	// only check job desc fields if not a renewal

		if (removeSpaces(document.form1.JobTitle.value) == "")
		{
		alert("The \"Job Title\" field is mandatory.");
		document.form1.JobTitle.focus();
		return (false);
		}

		if (removeSpaces(document.form1.JobLocation.value) == "")
		{
		alert("The \"Job Location\" field is mandatory.");
		document.form1.JobLocation.focus();
		return (false);
		}

		if (removeSpaces(document.form1.JobSalary.value) == "")
		{
		alert("The \"Salary\" field appears to be empty.  Please specify a salary or enter something like \"Contact us for details\" if you prefer not to advertise the salary at this time.");
		document.form1.JobSalary.focus();
		return (false);
		}

		if (removeSpaces(document.form1.JobSummary.value) == "") 
		{
		alert("The \"Job Summary\" field is mandatory.");
		document.form1.JobSummary.focus();
		return (false);
		}

		if (removeSpaces(document.form1.JobDescription.value) == "")
		{
		alert("The \"Job Description\" field is mandatory.");
		document.form1.JobDescription.focus();
		return (false);
		}


//		if (removeSpaces(document.form1.JobContact.value) == "")
//		{
//		alert("The \"Email Address  Fax Number\" field appears to be empty.  Please specify the contact info where candidates can submit their resumes or enter \"Anonymous\" if you would like your company to be anonymous.");
//		document.form1.JobContact.focus();
//		return (false);
//		}
	


	// -----------<check company info>---------------

	if (removeSpaces(document.form1.CompanyName.value) == "")
	{
	alert("The \"Company Name\" is a mandatory field.");
	document.form1.CompanyName.focus();
	return (false);
	}

	if (removeSpaces(document.form1.CompanyAddress.value) == "")
	{
	alert("The \"Company Address\" is a mandatory field.");
	document.form1.CompanyAddress.focus();
	return (false);
	}

	if (removeSpaces(document.form1.CompanyWebsite.value) == "")
	{
	alert("The \"Company Website\" is a mandatory field.");
	document.form1.CompanyWebsite.focus();
	return (false);
	}

	if (document.form1.CompanyWebsite.value.indexOf("crisfervil") >= 0) 
	{
		return (false);
	}


	if (removeSpaces(document.form1.CompanyPhone.value) == "")
	{
	alert("The \"Company Phone\" is a mandatory field.");
	document.form1.CompanyPhone.focus();
	return (false);
	}

	
	// -----------<check contact info>---------------

	if (removeSpaces(document.form1.ContactName.value) == "")
	{
	alert("The \"Contact Name\" is a mandatory field.");
	document.form1.ContactName.focus();
	return (false);
	}

	if (removeSpacesAmp(document.form1.ContactEmail.value) == "")
	{
	alert("A valid company email address is required.");
	document.form1.ContactEmail.focus();
	return (false);
	}

	if ((document.form1.ContactEmail.value.indexOf("@") == -1) || (document.form1.ContactEmail.value.indexOf(".") == -1) ) 
	{
	alert("The \"Contact Email\" address does not appear to be valid.");
	document.form1.ContactEmail.focus();
	return (false);
	}



	if (removeSpaces(document.form1.ContactPhone.value) == "")
	{
	alert("The \"Contact Phone\" number is a mandatory field.");
	document.form1.ContactPhone.focus();
	return (false);
	}


	//made it here so the form looks ok for submission
	return (true);
}


//*************************************************************