function setStyle(x)
{
document.getElementById(x).style.background="yellow";
}
function removeStyle(x)
{
document.getElementById(x).style.background="white";
}
function validateForm(myform) {
str  = myform.vstr.value;
arr=str.split(",");
for(act in arr) {
	val=arr[act].split("-");
	name=val[1];
	switch (val[0])	{
	case "1": //blank
	if (myform[eval("name")].value=="") {
		alert("This field can't be blank!");
		myform[eval("name")].focus(); 
		return false;}
	break;
	case "2":
		if (myform[eval("name")].value=="") {
		 alert("Please select an article!");
		myform[eval("name")].focus(); 
		return false;}
	break; 
	case "3":
		if (myform[eval("name")].value=="") {
		 var r=confirm("You didn't select image file.\nContinue?")
			 if (r==true)
		  {
  			return true;
		  }
		  else  {
		myform[eval("name")].focus(); 
		return false;}
	}
	break; 
	case "4":
	if (!validate_email(myform[eval("name")])) {
	   alert("Invalid Email Address!");
	   myform[eval("name")].focus(); 
	   return false;
	}
	break;
	case "5":
	if (myform[eval("name")].value=="") {
		alert("This field can't be blank!");
		myform[eval("name")].focus(); 
		return false;}
	if (!validate_zip(myform[eval("name")])) {
	 	alert("Invalid Postal Code!");
		myform[eval("name")].focus(); 
		return false;
	}
	break;
	case "6":
		if (myform[eval("name")].value=="") {
		alert("Please Select a Province!");
		myform[eval("name")].focus(); 
		return false;}
	break;
	case "7":
		filename = myform[eval("name")].value;
		num=(filename.lastIndexOf("."))+1;
		ext=filename.substr(num,3);
		ext=ext.toLowerCase();
		if (ext!="pdf" && ext!="doc") {
		alert("Please upload PDF file or Word Document only!");
		myform[eval("name")].focus(); 
		return false;}
	break;
	case "8":
		if (myform[eval("name")].value=="") {
			alert("This field can't be blank!");
			myform[eval("name")].focus(); 
		return false;}
		if (myform[eval("name")].value!=myform["pass1"].value) {
	 	alert("Password doesn't match!");
		myform[eval("name")].focus(); 
		return false;
	}
	case "9":
		if (myform[eval("name")].value=="0") {
			alert("Please select!");
			myform[eval("name")].focus(); 
		return false;
		}
	break;
	case "a":
		if (myform[eval("name")].value=="-1") {
			alert("Please select!");
			myform[eval("name")].focus(); 
		return false;
		}
	break;
	case "b":
		if (myform[eval("name")].value!=myform["password1"].value) {
	 	alert("Password doesn't match!");
		myform[eval("name")].focus(); 
		return false;
		}
		break;
	case "c":
		var sss=myform[eval("name")].value;
		if (myform[eval("name")].value=="") {
		alert("This field can't be blank!");
		myform[eval("name")].focus(); 
		return false;}
		else if(sss.indexOf(" ")!=-1) {
		alert("No spaces please!");
		myform[eval("name")].focus(); 
		return false;
		} 
		break;
	
	} //switch
}//for
return true;
}
function listModels(num,entry){
	var x=document.getElementById("filter_models");
	var model_arr = eval("model_arr"+num);
	while(x.firstChild) {
	x.removeChild(x.firstChild);
	} 
	h = "";
	j = 1;
	x.options[0] = new Option("All Models", 0);
	if(entry==0)
		x.options[0].selected = true;
	for(i in model_arr) {
		if(model_arr[i]!="") { 
			x.options[j] = new Option(model_arr[i], i);
			if(entry==i)
					x.options[j].selected = true;
			j++
		
		}
	}
}
function listMakes(num,entry){
	var x=document.getElementById("filter_makes");
	var make_arr = eval("make_arr"+num);
	while(x.firstChild) {
	x.removeChild(x.firstChild);
	} 
	h = "";
	j = 1;
	x.options[0] = new Option("All Make", 0);
	if(entry==0)
		x.options[0].selected = true;
	for(i in make_arr) {
		if(make_arr[i]!="") { 
			x.options[j] = new Option(make_arr[i], i);
			if(entry==i)
						x.options[j].selected = true;
			j++
		
		}
	}
}


//
function validate_email(field)
{

apos=field.value.indexOf("@")
dotpos=field.value.lastIndexOf(".")
if (apos<1||dotpos-apos<2) 
  {return false}
else {return true}
}
//
function validate_zip(field){ // CANADIAN CODES ONLY
entry = removeSpaces(field.value);
strlen=entry.length; if(strlen!=6) {return false;}
entry=entry.toUpperCase();    // in case of lowercase characters
// Check for legal characters in string - note index starts at zero
if('ABCEGHJKLMNPRSTVXY'.indexOf(entry.charAt(0))<0) {return false;}
if('0123456789'.indexOf(entry.charAt(1))<0) {return false;}
if('ABCDEFGHJKLMNPQRSTUVWXYZ'.indexOf(entry.charAt(2))<0) {return false;}
if('0123456789'.indexOf(entry.charAt(3))<0) {return false;}
if('ABCDEFGHJKLMNPQRSTUVWXYZ'.indexOf(entry.charAt(4))<0) {return false;}
if('0123456789'.indexOf(entry.charAt(5))<0) {return false;}
return true;
}
function deleteConfirm() {
	var r=confirm("Confirm Delete?")
	return r;
}