function confdel() {
return confirm("This will permenantly delete this record!");
}

function nodel() {
alert("You cannot delete this record!");
return false;
}

function toggle(id,trigger) {

// Layer visible
if (trigger=="1"){
        if (document.layers) document.layers[''+id+''].visibility = "show"
        else if (document.all) document.all[''+id+''].style.visibility = "visible"
        else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
        }
// Layer hidden
else if (trigger=="0"){
        if (document.layers) document.layers[''+id+''].visibility = "hide"
        else if (document.all) document.all[''+id+''].style.visibility = "hidden"
        else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
        }
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=50,screenY=50,top=50,left=50')
}

function popupPrintWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=525,height=550,screenX=0,screenY=0,top=0,left=0')
}

function mkButton(part,price,desc)
{
var newpart = part.replace(/-/g, ".");
return ("<form action='http://166.82.96.9/cgi-bin/cc102ipu.pl' method='post'> \
<input type='hidden' value='1' name='"+newpart+"_quant'> \
<input type='hidden' value='"+price+"' name='"+newpart+"_price'> \
<input type='hidden' value='"+desc+"' name='"+newpart+"_name'> \
<input type='hidden' value='/cgi-bin/cc102ipu.pl?action=order' name='page_name'> \
<input type='hidden' value='add' name='action'> \
<input type='image' src='images/buynow.gif' border='0'>" )
}


function checkFields() {

missinginfo = "";

if(document.form.a02First_Name.value==""){
missinginfo +="\n First Name";
}

if(document.form.a02Last_Name.value==""){
missinginfo +="\n Last Name";
}

if(document.form.a03Address1.value==""){
missinginfo +="\n Address";
}

if(document.form.a05city.value==""){
missinginfo +="\n City";
}

if(document.form.a06state.value==""){
missinginfo +="\n State";
}

if(document.form.a07zip.value==""){
missinginfo +="\n Zip/postal Code";
}

if(document.form.a08telephone.value==""){
missinginfo +="\n Telephone Number";
}

if (missinginfo != ""){
missinginfo ="\n"+
"These fields were left blank:\n"+
missinginfo+"\n"+
"\nPlease re-enter and submit again!";

alert(missinginfo);

return false;
}
else return true;
}


//javascript for contact page.

// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   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 stripCharsInBag(s, bag)
{   var i;
var returnString = "";
// Search through string's characters one by one.
// If character is not in bag, append to returnString.
for (i = 0; i < s.length; i++)
{
	// Check that current character isn't whitespace.
	var c = s.charAt(i);
	if (bag.indexOf(c) == -1) returnString += c;
}
return returnString;
}

function checkInternationalPhone(strPhone){
	s=stripCharsInBag(strPhone,validWorldPhoneChars);
	return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

function checkContactFields() {

	missinginfo = "";

	if (document.form.Name.value == ""){
		missinginfo +="\n Name";
	}

	/*
	if (document.form.how_to_contact.value == "phone"){

		if (document.form.Phone.value == ""){
			missinginfo +="\n Phone Number";

		}else{

			var Phone=document.form.Phone

			if (checkInternationalPhone(Phone.value)==false){
				alert("Please Enter a Valid Phone Number")
				return false
			}
		}

	}

	*/

	//commented out below because we removed how_to_contact dropdown but want to preserve code for future use
	//if (document.form.how_to_contact.value == "email"){

		if (document.form.Email.value == ""){
			missinginfo +="\n E-mail";
		}else{

			var str=document.form.Email.value;
			var at="@"
			var dot="."
			var lat=str.indexOf(at)
			var lstr=str.length
			var ldot=str.indexOf(dot)

			if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr || str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr || str.indexOf(at,(lat+1))!=-1 || str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot || str.indexOf(dot,(lat+2))==-1 || str.indexOf(" ")!=-1){
				missinginfo +="\n Invalid E-mail Address";
			}

		}

	//}



	if (missinginfo != ""){
		missinginfo ="\n"+
		"These Following Fields Are Required and Your E-mail Must Be Valid:\n"+
		missinginfo+"\n"+
		"\nPlease re-enter and submit again!";

		alert(missinginfo);

		return false;
	}
	else return true;
}

function checkRegisterFields() {

	missinginfo = "";

	if (document.form.Name.value == ""){
		missinginfo +="\n Name";
	}
	
	if (document.form.Phone.value == ""){
		missinginfo +="\n Phone Number";
	}

	if (document.form.Car_Year.value == ""){
		missinginfo +="\n Car Year";
	}
	
	if (document.form.Car_Make.value == ""){
		missinginfo +="\n Car Make";
	}
	
	if (document.form.Car_Model.value == ""){
		missinginfo +="\n Car Model";
	}

	if (missinginfo != ""){
		missinginfo ="\n"+
		"These Following Fields Are Required and Your E-mail Must Be Valid:\n"+
		missinginfo+"\n"+
		"\nPlease re-enter and submit again!";

		alert(missinginfo);

		return false;
	}
	else return true;
}

function checkShowCarFields() {

	missinginfo = "";

	if (document.form.Company_Name.value == ""){
		missinginfo +="\n Company Name";
	}
	
	if (document.form.Address_Line_1.value == ""){
		missinginfo +="\n Address Line 1";
	}

	if (document.form.City.value == ""){
		missinginfo +="\n City";
	}
	
	if (document.form.State.value == ""){
		missinginfo +="\n State";
	}
	
	if (document.form.Zip_Postal_Code.value == ""){
		missinginfo +="\n Zip/Postal Code";
	}
	
	if (document.form.Business_Phone.value == ""){
		missinginfo +="\n Business Phone";
	}
	
	if (document.form.Email.value == ""){
		missinginfo +="\n E-mail";
	}else{

		var str=document.form.Email.value;
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr || str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr || str.indexOf(at,(lat+1))!=-1 || str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot || str.indexOf(dot,(lat+2))==-1 || str.indexOf(" ")!=-1){
			missinginfo +="\n Invalid E-mail Address";
		}

	}
	
	if (document.form.Vehicle_Year.value == ""){
		missinginfo +="\n Vehicle Year";
	}
	
	if (document.form.Vehicle_Make.value == ""){
		missinginfo +="\n Vehicle Make";
	}

	if (missinginfo != ""){
		missinginfo ="\n"+
		"These Following Fields Are Required and Your E-mail Must Be Valid:\n"+
		missinginfo+"\n"+
		"\nPlease re-enter and submit again!";

		alert(missinginfo);

		return false;
	}
	else return true;
}