//checking when send button pressed
function formCheck(form) {
if (form.Medication.value=="")
	{alert("Please select your Medication from the drop down box.");
	form.Medication.focus();
	return false;}
if (form.Dosage.value=="")
	{alert("Please select your Dosage from the drop down box.");
	form.Dosage.focus();
	return false;}
if (form.Quantity.value=="0")
	{alert("Please select your Quantity from the drop down box.");
	form.Quantity.focus();
	return false;}
if (form.DelState.value=="")
	{alert("Please select your State from the drop down list.");
	form.DelState.focus();
	return false;}
if (form.DelZip.value=="")
	{alert("Please enter your Zip Code.\nThis enables us to find the cheapest\n Phentermine supplier for you.");
	form.DelZip.focus();
	return false;}
if (form.DelCountry.value=="")
	{alert("Please select your Country from the drop down list.");
	form.DelCountry.focus();
	return false;}
if (form.DelCountry.value=="USA" && form.DelState.value=="NONUSA")
	{alert("Please select your State from the drop down list.");
	form.DelState.focus();
	return false;}

// Now check drug combinations

if (form.Medication.value=="Phentermine" && form.Dosage.value=="30mg")
	{
		if(form.Quantity.value=="180")
		{alert("30mg Phentermine is only available in 30, 60 or 90 packs.");
		form.Quantity.focus();
		return false;}
	}

if (form.Medication.value=="Phentermine" && form.Dosage.value=="37mg")
	{
		if(form.Quantity.value=="180")
		{alert("37.5mg Phentermine is only available in 30, 60 or 90 packs.");
		form.Quantity.focus();
		return false;}
	}

if (form.Medication.value=="Ionamin" && form.Dosage.value!="30mg")
	{alert("Sorry - Ionamin is only available in 30mg dosage.");
	form.Dosage.focus();
	return false;}

if (form.Medication.value=="Ionamin" && form.Dosage.value=="30mg")
	{
		if(form.Quantity.value=="180")
		{alert("Sorry - Ionamin is only available in 30, 60 or 90 packs.");
		form.Quantity.focus();
		return false;}
	}

if (form.Medication.value=="Adipex" && form.Dosage.value!="37mg")
	{alert("Sorry - Adipex is only available in 37.5mg dosage.");
	form.Dosage.focus();
	return false;}

if (form.Medication.value=="Adipex" && form.Dosage.value=="37mg")
	{
		if(form.Quantity.value=="180")
		{alert("Sorry - Adipex is only available in 30, 60 or 90 packs.");
		form.Quantity.focus();
		return false;}
	}

// If country is USA check Zip is valid

if (form.DelCountry.value=="USA" && form.DelZip.value!=""){
// Parse the ZipCode into TestZipCode so we can check it out
TestDelZip = form.DelZip.value;

// check zip contents to see if its 5 digits long
var stringlength= TestDelZip.length;


// Set values check zip contents are only numbers and count the hyphens
var valid = "0123456789-";
var hyphencount = 0;
var temp = "";

// Check that we have either 5 or 10 characters in the zip code
	if (stringlength!=5 && stringlength!=10) {
	alert("Invalid Zip Code entered!\nPlease enter your 5 digit or 5 digit+4 zip code.");
	form.DelZip.focus();
	return false;
	}

//Check for improper characters and the number and position of the hyphen
	for (var i=0; i < TestDelZip.length; i++) {
	temp = "" + TestDelZip.substring(i, i+1);
		if (temp == "-") {hyphencount++;}
		if (valid.indexOf(temp) == "-1") {
		alert("Invalid characters in your zip code.  Please try again.");
		form.DelZip.focus();
		return false;
		}

		if ((hyphencount > 1) || ((TestDelZip.length==10) && ""+TestDelZip.charAt(5)!="-")) {
		alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
		form.DelZip.focus();
		return false;
		}
	}
return true;
}

// If country is not USA state must be Non US

if (form.DelCountry.value!="USA" && form.DelState.value!="NONUSA")
	{alert("Please select your Non US for the state from the drop down list.");
	form.DelState.focus();
	return false;}


}

//Check if email address is valid
function validEmail(form) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(form.EmailAddress.value)){
return (true)
}
else {alert("Invalid E-mail Address! Please re-enter.\nYour email address should look something like\nmyname@mydomain.com")
form.EmailAddress.focus();
return false;
	}
}


//Compare the email addresses
function emailCheck(form) {
	if (form.EmailAddress.value.toLowerCase() != form.EmailAddress1.value.toLowerCase()) {
		alert("The e-mail addresses that you entered do not match. Please amend. Thank you.");
		form.EmailAddress1.focus(); 
		return false;
	}
	return true;
}

