function modelChange(selectObj,type) 
{ 
  // get the index of the selected option 
   var idx = selectObj.selectedIndex; 
   // get the value of the selected option 
   var which = selectObj.options[idx].value; 
   // use the selected option value to retrieve the list of items from the modelList array 
   cList = modelList[which]; 
   // get the model select element via its known id 
   var cSelect = document.getElementById("model"); 
   // remove the current options from the country select 
   var len = cSelect.options.length; 
   while (cSelect.options.length > 0) 
   { 
     cSelect.remove(0); 
   } 
   var newOption; 
   // create new options 
   
   newOption = document.createElement("option"); 
   newOption.value = ""; 
   if (type == 1) //For searching
   {	     
     newOption.text = "ALL";
   } 
   else //For Advertisment form
   {
     newOption.text = "PLEASE SELECT";	   
   }	   
   try 
   { 
     cSelect.add(newOption);  // this will fail in DOM browsers but is needed for IE 
   } 
   catch (e) 
   { 
     cSelect.appendChild(newOption); 
   }  

   for (var i=0; i<cList.length; i++) 
   { 
     newOption = document.createElement("option"); 
     newOption.value = cList[i];  // assumes option string and value are the same 
     newOption.text = cList[i]; 
     // add the new option 
     try 
     { 
       cSelect.add(newOption);  // this will fail in DOM browsers but is needed for IE 
     } 
     catch (e) 
     { 
       cSelect.appendChild(newOption); 
     }  
   }
   newOption = document.createElement("option"); 
   newOption.value = "OTHERS";
   newOption.text = "OTHERS";
   try 
   { 
     cSelect.add(newOption);  // this will fail in DOM browsers but is needed for IE 
   } 
   catch (e) 
   { 
     cSelect.appendChild(newOption); 
   } 
}


function ChangePicture(x)
{ 
  document.photo.src = './Photo/' + x;
	
}
 
function EmailCarSeller(address){
	var data = 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width = 480, height = 380, left = 220, top = 120';
	popUp=window.open(address, '', data);
}


//Check Upload File Extension
function LimitAttach(form, file) 
{
    extArray = new Array(".jpg", ".png", ".gif", ".jpeg");	    
    allowSubmit = false;
    if (!file) return;
    while (file.indexOf("\\") != -1)
    file = file.slice(file.indexOf("\\") + 1);
    ext = file.slice(file.indexOf(".")).toLowerCase();
    for (var i = 0; i < extArray.length; i++) {
    if (extArray[i] == ext) { allowSubmit = true; break; }
    }
    if (allowSubmit) return true;
    else
    alert("Please only upload files with the following extension:  "
    + (extArray.join("  ")));
    return false;
}
  
//Convert to uppercase
function upperCase(x)
{
  var y=document.getElementById(x).value;
  document.getElementById(x).value=y.toUpperCase();
}

//Confrim Submit
function confirmSubmit()
{
var agree=confirm("Are you sure you wish to continue?");
if (agree)
	return true ;
else
	return false ;
}

//Max number of Characters allowes
function check_length(my_form,maxLen)
{
if (my_form.comment.value.length >= maxLen) {
// Alert message if maximum limit is reached.
var msg = "You have reached your maximum limit of characters allowed";
alert(msg);
// Reached the Maximum length so trim the textarea
my_form.comment.value = my_form.comment.value.substring(0, maxLen);
}
else{ // Maximum length not reached so update the value of my_text counter
my_form.charLeft.value = maxLen - my_form.comment.value.length;}
}
