// JavaScript Document

function checkit()
{
	var obj = null;
	var obj1 = null;
	var obj2 = null;
	var obj3 = null;
	var obj4 = null;

	var fn_ok = false;
	var ln_ok = false;
	var email_ok = false;
	var state_ok = false;
	var zip_ok = false;
	var city_ok = false;
	var street_ok = false;
	var phone_ok = false;
	
	obj = eval(document.aform.first_name); // for text box
	fn_ok = obj.value != "";

	obj = eval(document.aform.last_name);
	ln_ok = obj.value != "";

	obj = eval(document.aform.street_address);
	street_ok = obj.value != "";

	obj = eval(document.aform.city);
	city_ok = obj.value != "";

	obj = eval(document.aform.state); // for state dropdown box
	state_ok = ((obj.selectedIndex != "-1") && (obj.selectedIndex != "0"));

	obj = eval(document.aform.zip);
	zip_ok = obj.value != "";

	var phone1 = document.aform.phone1.value;
	phone1 = phone1.replace(/\D/g, '');
	document.aform.phone1.value = phone1;
	
	var phone2 = document.aform.phone2.value;
	phone2 = phone2.replace(/\D/g, '');
	document.aform.phone2.value = phone2;
	
	var phone3 = document.aform.phone3.value;
	phone3 = phone3.replace(/\D/g, '');
	document.aform.phone3.value = phone3;
	
	phone_ok = (phone1.length == 3 && phone2.length == 3 && phone3.length == 4);

	obj = eval(document.aform.email);
	email_valid = obj.value.search(/(.)*@(.)*(\.)(.)*/);
	if (email_valid != -1){	email_ok = 1; }
	else { email_ok = 0; }


	if (fn_ok && ln_ok && email_ok && state_ok && zip_ok && phone_ok && street_ok && city_ok)
	{
		return true;
	}
	else
	{
		errmsg = "The following information is missing or invalid:\n\n";
		if (!fn_ok)      {errmsg += "          First Name\n";}
		if (!ln_ok)      {errmsg += "          Last Name\n";}
		if (!street_ok)  {errmsg += "          Address\n";}
		if (!city_ok)    {errmsg += "          City\n";}
		if (!state_ok)   {errmsg += "          State\n";}
		if (!zip_ok)     {errmsg += "          Zip code\n";}
		if (!email_ok)   {errmsg += "          E-mail address\n";}
		if (!phone_ok)   {errmsg += "          Phone\n";}
		errmsg += "\nPlease verify that all the information is correctly entered and try again.";
		window.alert(errmsg);
		return false;
	}
}

function checkit2()
{

	
	var name_ok = false;
	var type_ok = false;
	var number_ok = false;
	var month_ok = false;
	var year_ok = false;
	var cvv_ok = false;
	
	obj = eval(document.aform.cc_name); // for text box
	name_ok = obj.value != "";

	obj = eval(document.aform.cc_type);
	type_ok = obj.selectedIndex != 0;

	obj = eval(document.aform.cc_number);
	number_ok = obj.value != "";

	obj = eval(document.aform.cc_exp_year);
	year_ok = obj.selectedIndex != 0;

	obj = eval(document.aform.cc_exp_month);
	month_ok = obj.selectedIndex != 0;

	obj = eval(document.aform.cc_cvv2);
	cvv_ok = obj.value != "";
	



	if (name_ok && number_ok && month_ok && year_ok && cvv_ok)
	{
		if (document.aform.R1.checked){		return true;}
		else {
			window.alert("You must agree to the Terms of this offer!");
			return false;
		}
	}
	else
	{
		errmsg = "The following information is missing or invalid:\n\n";
		if (!name_ok)      {errmsg += "          Name On Card\n";}
		if (!number_ok)    {errmsg += "          Card Number\n";}
		if (!month_ok)     {errmsg += "          Expiration Month\n";}
		if (!year_ok)      {errmsg += "          Expiration Year\n";}
		if (!cvv_ok)       {errmsg += "          Cvv\n";}
  		errmsg += "\nPlease verify that all the information is correctly entered and try again.";
		window.alert(errmsg);
		return false;
	}
}