onload = function loadModel(){
	
if (typeof no_onload == "undefined"){

	var a_maker = "";
	var maker = document.getElementById("maker").value;
	var model = document.getElementById("hidden_model").value;
	var model_maker_list = (document.getElementById("make_model").value).split("<>");
	var final_list = new Array();


var i = 0;
for (var a = 0;a < model_maker_list.length;a++){

	a_split = model_maker_list[a].split("//");
	a_maker = a_split[0];

	if (a_maker == maker){
	
		final_list[i] = a_split[1];
		//alert(a_split[1]);
		i++;
	}
	
}
	
//add value in the pull down
var selected = "";
var to_include = "<select name=\"model\" id=\"model\" style=\"border: 1px solid rgb(225, 225, 225);\"><option value=\"\">Select a Model</option>";
for (var j = 0; j < final_list.length; j++){

if (model == final_list[j]){
	selected= "SELECTED";
	
}


to_include = to_include + "<option value=\""+final_list[j]+"\" "+selected+">"+final_list[j]+"</option>";
selected = "";
// ne fonctionne pas sous IE

  
}

to_include = to_include + "</select>";

    document.getElementById('div_model').innerHTML = to_include;

	
}
	
}



function loadModel2(){
	

	var a_maker = "";
	var maker = document.getElementById("maker").value;
	var model = document.getElementById("hidden_model").value;
	var model_maker_list = (document.getElementById("make_model").value).split("<>");
	var final_list = new Array();


var i = 0;
for (var a = 0;a < model_maker_list.length;a++){
	
	a_split = model_maker_list[a].split("//");
	a_maker = a_split[0];
	
	if (a_maker == maker){
		
		final_list[i] = a_split[1];
		i++;
	}
	
}
	
//add value in the pull down
var selected = "";
var to_include = "<select name=\"model\" id=\"model\"><option value=\"\">Select a Model</option>";
for (var j = 0; j < final_list.length; j++){

if (model == final_list[j]){
	selected= "SELECTED";
	
}


to_include = to_include + "<option value=\""+final_list[j]+"\" "+selected+">"+final_list[j]+"</option>";
selected = "";


  
}
to_include = to_include + "</select>";
    document.getElementById('div_model').innerHTML = to_include;

}


function close_pop_up(id){
	
	document.getElementById(id).style.display = "none";
	
}


function verif_form(){
	
	
	if(document.getElementById("name").value == ""){
	alert("Please enter a Name !");
	document.getElementById("name").focus();
	return false;
		
	}
	
	
	if(document.getElementById("mail").value == ""){
	alert("Please enter a mail address !");
	document.getElementById("mail").focus();
	return false;
		
	}
	
    if(document.getElementById("country").value == ""){
	alert("Please enter a Country !");
	document.getElementById("country").focus();
	return false;
		
	}
	
	
	if(document.getElementById("message").value == ""){
	alert("Please enter a Message !");
	document.getElementById("message").focus();
	return false;
		
	}
	
	//if(document.getElementById("name").value == ""){
	//alert("Please enter a Name !");
	//document.getElementById("name").focus();
	//return false;
		
	//}
	
	return true;
	
}


function swap(link){
	
	document.getElementById("main").src=link;
}



function delete_currency(id){

var curr_id = "curr_id_"+id;
var curr_val = "curr_val_"+id;

document.getElementById(curr_id).value = "";
document.getElementById(curr_val).value = "";

document.getElementById("form1").submit();
}


function change_panel(num,obj){
	
	
	document.getElementById("tab1").style.background = "url(../../theme/images/tab_admin.png)";
	document.getElementById("tab2").style.background = "url(../../theme/images/tab_admin.png)";
	document.getElementById("tab3").style.background = "url(../../theme/images/tab_admin.png)";
	document.getElementById("tab4").style.background = "url(../../theme/images/tab_admin.png)";
	
	
	document.getElementById("inqui_div").style.display = "none";
	document.getElementById("curr_div").style.display = "none";
	document.getElementById("style_div").style.display = "none";
	document.getElementById("conf_div").style.display = "none";
	
	if (num == 1){
		document.getElementById("inqui_div").style.display = "block";
		document.getElementById("tab1").style.background = "url(../images/tab_admin_2.png)";

	}
	
	if (num == 2){
		document.getElementById("curr_div").style.display = "block";
		document.getElementById("tab2").style.background = "url(../images/tab_admin_2.png)";

	} 
	
	if (num == 3){
		document.getElementById("style_div").style.display = "block";
		document.getElementById("tab3").style.background = "url(../images/tab_admin_2.png)";

	} 
	
	if (num == 4){
		document.getElementById("conf_div").style.display = "block";
		document.getElementById("tab4").style.background = "url(../images/tab_admin_2.png)";

	}
	
}

function checkForm(){
		msg = trim(document.enquiryForm.comment.value);
		if(msg.search(/www/i)!=-1 || msg.search(/http/i)!=-1 || msg.search(/http/i)!=-1 || msg.search(/href/i)!=-1)
			{
				alert("\'www\', \'http://\' or \'href\' not allowed in message");
				return false;
			}
		//Name
		var name = trim(document.enquiryForm.name.value);
		if(name.length == 0)
		{
		   alert("Please enter Name");
		   document.enquiryForm.name.focus();
		   return false;
		}
		//Address
		var address_1 = trim(document.enquiryForm.address_1.value);
		if(address_1.length == 0)
		{
		   alert("Please enter Address Line - 1");
		   document.enquiryForm.address_1.focus();
		   return false;
		}
		//Country		  		  
		var country = document.enquiryForm.country.value;
		if(country.length == 0)
		{
		   alert("Please enter Country");
		   document.enquiryForm.country.focus();
		   return false;
		}
		//Email		  
		var email_1 = trim(document.enquiryForm.email_1.value);
		if(email_1.length == 0)
		{
		   alert("Please enter Email - 1");
		   document.enquiryForm.email_1.focus();
		   return false;
		}
		if(isValidEmail(email_1) == 0)
		{		   
		   document.enquiryForm.email_1.focus();
		   return false;		  
		}
		
		return true;
}


function isValidEmail(emailid){		
		var l=emailid.length;
		if(l==0)
		{
				return false;	
		}
		if(l!=0)
		{
				var a=emailid.indexOf('@');
				var d=emailid.lastIndexOf('.');
				var str1=emailid.substr(0,a);
				var str2=emailid.substr(a+1,d-a-1);
				var str3=emailid.substr(d+1,l);
				var len1=str1.length;
				var len2=str2.length;
				var len3=str3.length;
				if(a<0 || d<2)
				{
						alert ("Check for missing '@' or '.' ");
						return false;
				}
				else if (a>d)
				{
						alert ("Invalid email. Please enter correct email address");
						return false;
				}				
				if (len1<=1 || len2<=1 || len3 <=1)
				{
						alert ("Invalid email. Please enter correct email address");
						return false;
				}				
		}
		return true;
}

function trim (strVar) { 
     if(strVar.length >0)
	 {
	        while(strVar.charAt(0)==" ")  //Left Trim
			strVar=strVar.substring(1,strVar.length); 
			while(strVar.charAt(strVar.length-1)==" ")  //Right Trim
			strVar=strVar.substring(0,strVar.length-1); 			
	 } return strVar; 
}

function changeStyle(td){

td.firstChild.style.color="#146BB4";
td.style.borderLeftStyle="solid";
td.style.borderLeftWidth="2px";
td.style.borderLeftColor="#146BB4";
td.style.borderTopStyle="solid";
td.style.borderTopWidth="2px";
td.style.borderTopColor="#146BB4";
td.style.borderRightStyle="solid";
td.style.borderRightWidth="2px";
td.style.borderRightColor="#146BB4";
td.style.background="#FFFFFF";

}


function revertStyle(td){
	td.firstChild.style.color="#FFFFFF";
	td.style.borderLeftStyle="solid";
	td.style.borderLeftWidth="2px";
	td.style.borderLeftColor="#FFFFFF";
	td.style.borderTopStyle="solid";
	td.style.borderTopWidth="2px";
	td.style.borderTopColor="#FFFFFF";
	td.style.borderRightStyle="solid";
	td.style.borderRightWidth="2px";
	td.style.borderRightColor="#FFFFFF";
	td.style.background="#146BB4";
	
}
