//Begin auto tab script

var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode; 
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}

//  End auto tab script

// Start numerals only script
	function disableKey(e) 
		{var key; 
			if(window.event) 
	          key = window.event.keyCode;     //IE 
	     	else 
	          key = e.which;     //firefox 
	  		if((key  < 48 || key > 57)) 
	          return false; 
	     	else 
	          return true; 
		} 
// End numerals only script

// email validator
	function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
	}	
// end email validator
function swap_tab(image,swap_image){
	image.src=swap_image;
}
function swap_request(image,swap_image,this_vin){
	document.forms[4].Vin.value=this_vin;
	image.src=swap_image;
}
function qq_inv_search(pg){
	var themessage = "There was an error in your quote submission:\n ";
	if (document.getElementById('First_Name').value.length == 0){
		themessage = themessage + "\n- First Name cannot be blank!";
	}
	if (document.getElementById('Last_Name').value.length == 0){
		themessage = themessage + "\n- Last Name cannot be blank!";
	}
	if (document.getElementById('Phone_1').value.length != 3 || document.getElementById('Phone_2').value.length != 3 || document.getElementById('Phone_3').value.length != 4) {
		themessage = themessage + "\n- Phone is invalid!";
	}			
	if (echeck(document.getElementById('Email').value)==false){
		themessage = themessage + "\n- Email is invalid!";
	}
	if (themessage == "There was an error in your quote submission:\n ") {
			document.getElementById('search_quick_quote').submit();
			$('#superbox .close a').click();
	}
	else {
		alert(themessage);
  	}
}
function qq_display_search(){
	var themessage = "There was an error in your quote submission:\n ";
var	display_quick_quote = document.getElementById('display_quick_quote');
	if (display_quick_quote.First_Name.value.length == 0){
		themessage = themessage + "\n- First Name cannot be blank!";
	}
	if (display_quick_quote.Last_Name.value.length == 0){
		themessage = themessage + "\n- Last Name cannot be blank!";
	}
	if (display_quick_quote.Phone_1.value.length != 3 || display_quick_quote.Phone_2.value.length != 3 || display_quick_quote.Phone_3.value.length != 4) {
		themessage = themessage + "\n- Phone is invalid!";
	}			
	if (echeck(display_quick_quote.Email.value)==false){
		themessage = themessage + "\n- Email is invalid!";
	}
	if (themessage == "There was an error in your quote submission:\n ") {
		display_quick_quote.submit();
	}
	else {
		alert(themessage);
  	}
}
function qq_display_contact(){
var display_con = document.getElementById('display_contact');
	var themessage = "There was an error in your contact submission:\n ";
	if (display_con.First_Name.value.length == 0){
		themessage = themessage + "\n- First Name cannot be blank!";
	}
	if (display_con.Last_Name.value.length == 0){
		themessage = themessage + "\n- Last Name cannot be blank!";
	}
	if (display_con.Phone_1.value.length != 3 || display_con.Phone_2.value.length != 3 || display_con.Phone_3.value.length != 4) {
		themessage = themessage + "\n- Phone is invalid!";
	}			
	if (echeck(display_con.Email.value)==false){
		themessage = themessage + "\n- Email is invalid!";
	}
	if (themessage == "There was an error in your contact submission:\n ") {
		display_con.submit();
	}
	else {
		alert(themessage);
  	}
}
function show_All(){
	reset_tabs();
	document.getElementById('All_Options_Tab_Active').style.display="none";
	document.getElementById('All_Options_Tab_Up').style.display="block";
	document.getElementById('details_option_tab_all_title').style.display="block";
	document.getElementById('details_all_div').style.display="block";
}
function show_Safety(){
	reset_tabs();
	document.getElementById('Safety_Tab_Active').style.display="none";
	document.getElementById('Safety_Tab_Up').style.display="block";
	document.getElementById('details_option_tab_safety_title').style.display="block";
	document.getElementById('details_safety_div').style.display="block";
}
function show_Exterior(){
	reset_tabs();
	document.getElementById('Exterior_Tab_Active').style.display="none";
	document.getElementById('Exterior_Tab_Up').style.display="block";
	document.getElementById('details_option_tab_exterior_title').style.display="block";
	document.getElementById('details_exterior_div').style.display="block";
}
function show_Interior(){
	reset_tabs();
	document.getElementById('Interior_Tab_Active').style.display="none";
	document.getElementById('Interior_Tab_Up').style.display="block";
	document.getElementById('details_option_tab_interior_title').style.display="block";
	document.getElementById('details_interior_div').style.display="block";
}
function show_Installed(){
	reset_tabs();
	document.getElementById('Installed_Tab_Active').style.display="none";
	document.getElementById('Installed_Tab_Up').style.display="block";
	document.getElementById('details_option_tab_installed_title').style.display="block";
	document.getElementById('details_installed_div').style.display="block";
}
function show_Mechanical(){
	reset_tabs();
	document.getElementById('Mechanical_Tab_Active').style.display="none";
	document.getElementById('Mechanical_Tab_Up').style.display="block";
	document.getElementById('details_option_tab_mechanical_title').style.display="block";
	document.getElementById('details_mechanical_div').style.display="block";
}
function show_Misc(){
	reset_tabs();
	document.getElementById('Misc_Tab_Active').style.display="none";
	document.getElementById('Misc_Tab_Up').style.display="block";
	document.getElementById('details_option_tab_misc_title').style.display="block";
	document.getElementById('details_misc_div').style.display="block";
}
function reset_tabs(){
	document.getElementById('All_Options_Tab_Active').style.display="block";
	document.getElementById('All_Options_Tab_Up').style.display="none";
	document.getElementById('details_option_tab_all_title').style.display="none";
	document.getElementById('Safety_Tab_Active').style.display="block";
	document.getElementById('Safety_Tab_Up').style.display="none";
	document.getElementById('details_option_tab_safety_title').style.display="none";
	document.getElementById('Exterior_Tab_Active').style.display="block";
	document.getElementById('Exterior_Tab_Up').style.display="none";
	document.getElementById('details_option_tab_exterior_title').style.display="none";
	document.getElementById('Interior_Tab_Active').style.display="block";
	document.getElementById('Interior_Tab_Up').style.display="none";
	document.getElementById('details_option_tab_interior_title').style.display="none";
	document.getElementById('Installed_Tab_Active').style.display="block";
	document.getElementById('Installed_Tab_Up').style.display="none";
	document.getElementById('details_option_tab_installed_title').style.display="none";
	document.getElementById('Mechanical_Tab_Active').style.display="block";
	document.getElementById('Mechanical_Tab_Up').style.display="none";
	document.getElementById('details_option_tab_mechanical_title').style.display="none";
	document.getElementById('Misc_Tab_Active').style.display="block";
	document.getElementById('Misc_Tab_Up').style.display="none";
	document.getElementById('details_option_tab_misc_title').style.display="none";
	document.getElementById('details_all_div').style.display="none";
	document.getElementById('details_safety_div').style.display="none";
	document.getElementById('details_exterior_div').style.display="none";
	document.getElementById('details_interior_div').style.display="none";
	document.getElementById('details_installed_div').style.display="none";
	document.getElementById('details_mechanical_div').style.display="none";
	document.getElementById('details_misc_div').style.display="none";
}
function change_year(nu,this_location){
	var this_year=document.Vehicle_Search.Year.value;
	location.href="Inventory.cfm?New_Used="+nu+"&location_id="+this_location+"&Year="+this_year;
}
function change_location(nu){
	var this_location=document.Vehicle_Search.Location_ID.value;
	location.href="Inventory.cfm?New_Used="+nu+"&location_id="+this_location;
}
function change_make(nu,this_location,this_year){
	var this_make=document.Vehicle_Search.Make.value;
	location.href="Inventory.cfm?New_Used="+nu+"&location_id="+this_location+"&Year="+this_year+"&Make="+this_make;
}
function change_model(nu,this_location,this_year,this_make){
	var this_model=document.Vehicle_Search.Model.value;
	location.href="Inventory.cfm?New_Used="+nu+"&location_id="+this_location+"&Year="+this_year+"&Make="+this_make+"&Model="+this_model;
}
function change_inv_type(this_location){
	var this_type=document.Vehicle_Search.inventory_type.value;
	location.href="Inv_Action.cfm?page_action=change_inv_type&inventory_type="+this_type+"&location_id="+this_location;
}
function show_photo(div_id,photo_id,imageurl,slideshow_id) {
	var show_photo = document.getElementById(div_id).style;
	var this_photo = document.getElementById(photo_id);
	var this_slideshow = document.getElementById(slideshow_id);
	if (this_slideshow.src != "http://showroom.worlddealer.net/Photos/Inventory/coming_soon_115.jpg"){
		this_photo.src=imageurl;
		show_photo.display="block";
	}
}

function hide_photo(div_id) {
	var hide_photo = document.getElementById(div_id).style;
	hide_photo.display="none";
}

function view_details(inventory_id){
	document.getElementById('hidden_form').action="Inventory_Details.cfm?Inventory_ID="+inventory_id;
	document.getElementById('hidden_form').submit();
}
