///////////////////////// COMMON JAVASCRIPT FILE ////////////////////////////
//																		   //
// 	  COMMON JAVASCRIPT FILE FOR ALL THE SCRIPTS USED ALLOVER THE SITE     //
//																		   //
/////////////////////////////////////////////////////////////////////////////



//for Home Page
function fixheight()
{ 
var lft=document.getElementById('mainContentLeft').offsetHeight;
var rgt=document.getElementById('mainContentRight').offsetHeight;
if (lft > rgt)document.getElementById('mainContentRight').style.height = lft + "px";
if (rgt > lft)document.getElementById('mainContentLeft').style.height = rgt + "px";
}
///////////////////////////////////////Setting Position of layers//////////////////

/**** OpenX Home Page Banner Code ****/
/** adbanner('source','width','height','zoneid',refresh); **/
function adbanner(ox1,ox2,ox3,ox4,ox5)
{
document.write('<iframe id="ab2f256a" name="ab2f256a" src="http://ads.izmocars.com/www/delivery/afr.php?refresh='+ox5+'&amp;zoneid='+ox4+'&amp;source='+ox1+'&amp;cb=INSERT_RANDOM_NUMBER_HERE" framespacing="0" frameborder="no" scrolling="no" width="'+ox2+'" height="'+ox3+'" allowtransparency="true"><a href="http://ads.izmocars.com/www/delivery/ck.php?n="aef32349"&amp;cb=INSERT_RANDOM_NUMBER_HERE" target="_blank"><img src="http://ads.izmocars.com/www/delivery/avw.php?zoneid='+ox4+'&amp;source='+ox1+'&amp;cb=INSERT_RANDOM_NUMBER_HERE&amp;n=aef32349" border="0" alt="" /></a></iframe>');
}

function flashload()
{
flashMovie('FlashLObject').JSFlashload('Load','true');
}

function flashMovie(flash) { return (navigator.appName.indexOf("Microsoft") != -1) ? window[flash] : document[flash]; } 

function embedflashhome(d1)
{
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100%" height="100%" id="FlashObject1" align="middle"><param name="allowScriptAccess" value="always" /><param name="movie" value="'+d1+'loopingTemplate.swf" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" /><embed src="'+d1+'loopingTemplate.swf" wmode="transparent" quality="high" bgcolor="#ffffff" width="100%" height="100%" name="FlashObject1" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>')
}
/////////////////////////////////////////////////////////////////////////////////

var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
			// Handle all the the FSCommand messages in a Flash movie
			function fscommand_DoFSCommand(command, args) 
			{
				document.DetailedInfo.ExtColor.value=args;
				document.DetailedInfo.ExtColor1.value=args;
				document.DetailedInfo.IntColor.value=command;
			}

// Hook for Internet Explorer 
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<SCRIPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('Sub fscommand_FSCommand(ByVal command, ByVal args)\n');
	document.write('  call fscommand_DoFSCommand(command, args)\n');
	document.write('end sub\n');
	document.write('</SCRIPT\> \n');
}
function MM_openBrWindow(theURL,winName,features) { // pop opens a browser window
  	window.open(theURL,winName,features);
}

function dot(obj)
{
	if (event.keyCode==190 || event.keyCode==110)
	{

var i=0;j=0;text="";total="";
var len=obj.value.length;
for(i=0;i<len;i++)
{
	text=obj.value.charAt(i);
	if(text==".")
	{
		j=j+1;
	}
	if(j>1){text='';}
	total=total+text;
}
obj.value=total;
	}
}

//////////////////////////// Data Entry Validation /////////////////////////////////

function validalphanumeric(e) 
	{
	var mykey = window.event ? e.keyCode : e.which; 	
		if (mykey==46 || mykey==126) { return false; }
		if (((mykey > 32 && mykey < 48) || (mykey > 57 && mykey < 65) || (mykey > 90 && mykey < 97) || (mykey > 122 && mykey <= 127))){ return false; }
	return true;
}
function validalphabet(e) 
	{
	var mykey = window.event ? e.keyCode : e.which; 	
		if (mykey==46 || mykey==126) { 	return false; }		
		if (((mykey > 32 && mykey < 48) || (mykey > 57 && mykey < 65) || (mykey > 90 && mykey < 97) || (mykey > 45 && mykey <= 57))){ return false; }return true;
} 

function validnumber(FinanceForm)
{	
	if(event.keyCode==47 || event.keyCode==126) 
		event.returnValue = false;
	if ((event.keyCode <= 45 || event.keyCode > 57) && event.keyCode !=13) 
		event.returnValue = false; 
}

function validemail(mailStr)
{
	var matchStr=mailStr;
 	var isValid = (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(matchStr));

	if(isValid) 
	{
 		return true;
	}
	else
	{
		return false;
	}
} 

function isValidState(State)
{
	
	if ((State.selectedIndex==0))
		{
			alert("Select State");
			State.focus();
			return false;

		}
return true;
}

function tabvalidatePhone(phfield1,phfield2)
{
	if(document.getElementById(phfield1).value.length==3) 
		document.getElementById(phfield2).focus();
}
 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////

function formatDollar(obj)
{
	var num = obj.value
	num = num.toString().replace(/\$|\,/g,'');
	
	if(isNaN(num))
	return false;

	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	//alert(num);
	num.substring(num.length-(4*i+3));
	var temp=((sign)?'':'-') + '$' + num + '.' + cents;
	if(temp!="$0.00") {
		obj.value=((sign)?'':'-') + '$' + num + '.' + cents;
		//alert(obj.value);
		return true;
	}	
	else {
		obj.value="";
		return false;
	}
}
function removeLeadingAndTrailingChar(inputString)
{
	var removeChar = " ";
	var returnString = inputString;
	if (removeChar.length)
   		{
		  while(''+returnString.charAt(0)==removeChar)
			{
			  returnString=returnString.substring(1,returnString.length);
			}
    	  while(''+returnString.charAt(returnString.length-1)==removeChar)
	 	    {
	  	      returnString=returnString.substring(0,returnString.length-1);
			} 
		}
		return returnString;
}



 /// My ValidNumber & TabValidationForPhoneNumbers with Cross Browser Compatiblity
var myphfield1;
var myphfield2;
var myval;
function mytabvalidatePhone(p1,p2,e)
{
  phfield1 = p1;
  phfield2 = p2;
var mykey = window.event ? e.keyCode : e.which;
if ((mykey <= 47 || mykey > 57) && mykey !=13 && mykey !=0 && mykey != 8) 
	{
	myval=""
//	alert ("Enter number only");
	return false;
	}
	if( (document.getElementById(phfield1).value.length==3) && (mykey > 47 && mykey <= 57) )
	{
	myval= String.fromCharCode(mykey);
	setTimeout("document.getElementById(phfield2).focus(); if(document.getElementById(phfield1).value.length < 3) { setTimeout('document.getElementById(phfield1).focus();  document.getElementById(phfield1).value=myval;  ',10); } else { document.getElementById(phfield2).value=myval; } ",10);
	}
return true;
}

function myvalidnumber(e)
{
var mykey = window.event ? e.keyCode : e.which;
		if ((mykey <= 47 || mykey > 57) && mykey !=13 && mykey !=0 && mykey != 8) 
			{
			return false;
			}
return true;			
}
 /////////////the code ends here/////////////
 
						  
function isValidSelTitle(Title)
{
/*	if (Title.selectedIndex==0)
	{
		alert("Select Title");
		Title.focus();
		return false;
	}*/
return true;
}						  
// First Name Validation
function isValidFirstName(FirstName)
{
	FirstName.value=removeLeadingAndTrailingChar(FirstName.value);
	if ((FirstName.value==""))
		{
			alert("Enter First Name ");
			FirstName.focus();
			return false;
		}
return true;
}

function isValidNMFirstName(FirstName)
{
	FirstName.value=removeLeadingAndTrailingChar(FirstName.value);	
return true;
}

  // Last Name Validation
function isValidLastName(LastName)
{
	LastName.value=removeLeadingAndTrailingChar(LastName.value);
	if ((LastName.value==""))
		{
			alert("Enter Last Name ");
			LastName.focus();
			return false;

		}
return true;
}
function isValidNMLastName(LastName)
{
	LastName.value=removeLeadingAndTrailingChar(LastName.value);
	return true;
}


// Email Validation

function isValidEmail(Email)
{
	if (Email.value=="")
	{
		alert("Enter E-mail Id");
		Email.focus();
		return false;
	}

	if (Email.value!="" && !validemail(Email.value))
	{ 
		alert("Enter Valid E-mail Id");
		Email.focus();
		return false;		
	}
return true;
}
 // Mandatory Phone Validation
 function isValidMPhone(ph1,ph2,ph3,ph,phtype)
 {
	if (phtype == undefined)  { phtype =' Phone '  ; }
	ph1.value=removeLeadingAndTrailingChar(ph1.value);	
	ph2.value=removeLeadingAndTrailingChar(ph2.value);	
	ph3.value=removeLeadingAndTrailingChar(ph3.value);

	if(isNaN(ph1.value))
		{
			alert(phtype +" should be Numeric");	
			ph1.select();
			return false;
		}
	if(isNaN(ph2.value))
		{
			alert(phtype +" should be Numeric");	
			ph2.select();
			return false;
		}
	if(isNaN(ph3.value))
		{
			alert(phtype +" should be Numeric");	
			ph3.select();
			return false;
		}		

	if (ph1.value.length<3)
	{
		alert("Enter " + phtype);
		ph1.focus();
		return false;
	}
	if (ph2.value.length<3)
	{
		alert("Enter " + phtype);
		ph2.focus();
		return false;
	}
	if (ph3.value.length<4)
	{
		alert("Enter " + phtype);
		ph3.focus();
		return false;
	}	
	if(ph1.value.length==3 &&ph2.value.length==3 && ph3.value.length==4) {
		ph.value="("+ph1.value+") "+ph2.value+"-"+ph3.value;
	}
return true;
 }
function isValidNMPhone(ph1,ph2,ph3,ph, typ)
{
	var a = ph1.value=removeLeadingAndTrailingChar(ph1.value);	
	var b = ph2.value=removeLeadingAndTrailingChar(ph2.value);	
	var c = ph3.value=removeLeadingAndTrailingChar(ph3.value);	
	var merged = a+''+b+''+c;
	if(merged.length>0 && merged.length<10) {
		alert('Invalid '+ typ);
		if(a.length!=3) ph1.select();
		else if(b.length!=3) ph2.select();
		else ph3.select();
		return false;
	}
	if(ph1.value.length==3 &&ph2.value.length==3 && ph3.value.length==4) {
		ph.value="("+ph1.value+") "+ph2.value+"-"+ph3.value;
	}
return true;
}

function isValidStreet(Street)
 {
	 if (Street.value!="")
	{
		  Street.value=removeLeadingAndTrailingChar(Street.value);
	}
return true;
 }
function isValidCity(City)
 {
	 if (City.value!="")
	{
		  City.value=removeLeadingAndTrailingChar(City.value);
	}
return true;
 }
function isValidZip(Zip)
{
	Zip.value=removeLeadingAndTrailingChar(Zip.value);		
	if(isNaN(Zip.value))
	{
		alert("Zip Code should be Numeric");	
		Zip.select();
		return false;
	}			
	if (Zip.value=="")
	{
		alert("Enter Zip Code");
		Zip.focus();
		return false;
	}
	if(Zip.value.length<5)
	{
		alert("Enter Five Digit Zip Code");
		Zip.focus();
		return false;
	}		
return true;
}

function isValidMakeYear(MakeYear)
{
	MakeYear.value=removeLeadingAndTrailingChar(MakeYear.value);
	
	if(isNaN(MakeYear.value))
	{
		alert("Make Year should be Numeric");	
		MakeYear.select();
		return false;
	}		
	
	if(MakeYear.value=="")
	{
		alert("Enter Make Year");
		MakeYear.focus();
		return false;
	}
	if(MakeYear.value.length<4)
	{
		alert("Enter Four Digit Make Year");
		MakeYear.focus();
		return false;
	}
	if (MakeYear.value <=1960 || MakeYear.value >2015)
		{
			alert("Please Enter Valid Year");
			MakeYear.focus();
			return false;
		}
return true;	
}

function isValidMake(Make)
{
	Make.value=removeLeadingAndTrailingChar(Make.value);
	if(Make.value=="")
	{
		alert("Enter Make");
		Make.focus();
		return false;
	}	
return true;
}
function isValidModel(Model)
{
	Model.value=removeLeadingAndTrailingChar(Model.value);
	if(Model.value=="")
	{
		alert("Enter Model");
		Model.focus();
		return false;
	}	
return true;
}
function isValidTrim(Trim)
{
	Trim.value=removeLeadingAndTrailingChar(Trim.value);
	if(Trim.value=="")
	{
		alert("Enter Trim");
		Trim.focus();
		return false;
	}	
return true;
}
function isValidNMTrim(Trim)
{
 Trim.value=removeLeadingAndTrailingChar(Trim.value);
 return true;
}

function isValidNMVIN(VIN)
{
	VIN.value=removeLeadingAndTrailingChar(VIN.value);
	if(VIN.value!=""){
	if(VIN.value.length!=17)
	{
		alert("Enter valid VIN. It should be 17 characters Length");
		VIN.focus();
		return false;
	}
	}
return true;	
}
function isValidMVIN(VIN)
{
	VIN.value=removeLeadingAndTrailingChar(VIN.value);
	if(VIN.value=="")
	{
		alert("Enter VIN");
		VIN.focus();
		return false;
	}
	if(VIN.value.length!=17)
	{
		alert("Enter valid VIN. It should be 17 characters Length");
		VIN.focus();
		return false;
	}
return true;	
}
function isValidNMComments(Comments)
{
	Comments.value=removeLeadingAndTrailingChar(Comments.value);
 return true;
}
function isValidMComments(Comments)
{
	Comments.value=removeLeadingAndTrailingChar(Comments.value);
	if(Comments.value=="")
	{
		alert("Enter Comments");
		Comments.focus();
		return false;
	}
 return true;
}
function isValidNMColor(Color)
{
	Color.value=removeLeadingAndTrailingChar(Color.value);
 return true;
}


function isValidPayoff(Payoff)
{
	if(Payoff.value=="")
	{
		alert("Enter Payoff Amount");
		Payoff.focus();
		return false;
	}
	if (Payoff.value!="" && !formatDollar(Payoff))
	{ 
		alert("Enter Valid Payoff Amount");
		Payoff.focus();
		return false;		
	}
 return true;
}
function isValidValue(Value)
{
	if(Value.value=="")
	{
		alert("Enter Value Amount");
		Value.focus();
		return false;
	}
	if (Value.value!="" && !formatDollar(Value))
	{ 
		alert("Enter Valid Value Amount");
		Value.focus();
		return false;		
	}
 return true;
}

function isValidSelectTransmission(Transmission)
{
	if(Transmission.selectedIndex==0)
	{
		alert("Select Transmission");
		Transmission.focus();
		return false;
	}
return true;
}

function isValidSelectMake(Make)
{
	if (Make.selectedIndex==0)
	{
		alert("Select Make");
		Make.focus();
		return false;
	}
return true;
}

function isValidSelectModel(Model)
{
	if (Model.selectedIndex==0)
	{
		alert("Select Model");
		Model.focus();
		return false;
	}
return true;
}
function isValidSelectTrim(Trim)
{
	if (Trim.selectedIndex==0)
	{
		alert("Select Trim");
		Trim.focus();
		return false;
	}
return true;
}
function isValidMake1(Make1)
{
	Make1.value=removeLeadingAndTrailingChar(Make1.value);
	if(Make1.value=="" || Make1.value=="Make")
	{
		alert("Enter Make");
		Make1.focus();
		return false;
	}	
return true;
}
function isValidModel1(Model1)
{
	Model1.value=removeLeadingAndTrailingChar(Model1.value);
	if(Model1.value=="" || Model1.value=="Model")
	{
		alert("Enter Model");
		Model1.focus();
		return false;
	}	
return true;
}
function isValidTrim1(Trim1)
{
	Trim1.value=removeLeadingAndTrailingChar(Trim1.value);
	if(Trim1.value=="" || Trim1.value=="Trim")
	{
		alert("Enter Trim");
		Trim1.focus();
		return false;
	}	
return true;
}
function isValidSelectInterestLevel(InterestLevel)
{
	if (InterestLevel.selectedIndex==0)
	{
		alert("Select Interest Level");
		InterestLevel.focus();
		return false;
	}
return true;
}

function isValidPriceRange(PriceRange)
{
	if (PriceRange.value=="" || PriceRange.value=="Price")
	{
		alert("Enter Price Range");
		PriceRange.focus();
		return false;
	}
	if ( PriceRange.value!="" && !formatDollar(PriceRange) ) 
	{
		alert("Enter Valid Price Range");
		PriceRange.focus();
		return false;
	}
	if (PriceRange.value==".")
	{
		alert("Enter Valid Price Range");
		PriceRange.focus();
		return false;
	}
return true;	
}



function isValidRequestDate(ReqDate)
{
	if(ReqDate.selectedIndex==0)
	{
		alert("Select Date to schedule an Appointment");
		ReqDate.focus();
		return false;
	}	
return true;
}
function isValidRequestDate2(ReqDate)
{
	if(ReqDate.selectedIndex==0)
	{
		alert("Select Date to schedule an Collision Appointment");
		ReqDate.focus();
		return false;
	}	
return true;
}

function isValidAppointmentTime(AppoinTime)
{
	if (AppoinTime.selectedIndex==0 )
	{
		alert("Select Drop Off Time");
		AppoinTime.focus();
		return false;
	}
	if (AppoinTime.options[1].value=="Closed" )
	{
		checktime();
		return false;
	}
return true;	
}

function isValidContacttype(Contacttype)
{
	if (Contacttype.selectedIndex==0 )
	{
		alert("Select heard about our website");
		Contacttype.focus();
		return false;
	}
	
return true;	
}
//

function isValidJobType(JobType)
{
	JobType.value=removeLeadingAndTrailingChar(JobType.value);
	if (JobType.value=="")
	{
		alert("Enter Job Type ");
		JobType.focus();
		return false;
	}
return true;		
}

function isValidJobTitle(JobTitle)
{
	JobTitle.value=removeLeadingAndTrailingChar(JobTitle.value);
	if (JobTitle.value=="")
	{
		alert("Enter Job Title ");
		JobTitle.focus();
		return false;
	}
return true;		
}

function isValidResume(resume)
{
	resume.value=removeLeadingAndTrailingChar(resume.value);
	if (resume.value=="")
	{
		alert("Enter Resume ");
		resume.focus();
		return false;
	}
return true;		
}

function isValidBestTimeToDrive(BestTimeToDrive)
{
		if(BestTimeToDrive.selectedIndex==0)
		{
			alert("Select Best Time To Drive");
			BestTimeToDrive.focus();
			return false;
		}
		return true;
}
function isValidAMPM(AMPM)
{
		if(AMPM.selectedIndex==0)
		{
			alert("Select AM or PM");
			AMPM.focus();
			return false;
		}
return true;		
}
function isValidReference(Reference)
{
	if(Reference.selectedIndex==0)
		{
			alert("Select Reference");
			Reference.focus();
			return false;
		}
return true;		
}

function validatequickquote(thisForm)
{
	if(!(isValidFirstName(thisForm.FirstName))) return false;
	if(!(isValidLastName(thisForm.LastName))) return false;
	if(!(isValidStreet(thisForm.Street))) return false;
	if(!(isValidCity(thisForm.City))) return false;	
	if(!(isValidEmail(thisForm.Email))) return false;
	if(!(isValidNMPhone(thisForm.OffPhone1,thisForm.OffPhone2,thisForm.OffPhone3,thisForm.OffPhone,' Day Phone '))) return false;
	if(!(isValidNMPhone(thisForm.ResPhone1,thisForm.ResPhone2,thisForm.ResPhone3,thisForm.ResPhone,' Evening Phone '))) return false;
	if(!(isValidSelectMake(thisForm.Make))) return false; 
	if(!(isValidSelectModel(thisForm.Model))) return false;
	if(!(isValidSelectTrim(thisForm.Trim))) return false;	
	if(!(isValidSelectInterestLevel(thisForm.InterestLevel))) return false;	
return true;
}
function validatenewcars(thisForm)
{
	if(!(isValidNMFirstName(thisForm.FirstName))) return false;
	if(!(isValidNMLastName(thisForm.LastName))) return false;
	if(!(isValidNMPhone(thisForm.OffPhone1,thisForm.OffPhone2,thisForm.OffPhone3,thisForm.OffPhone,' Day Phone '))) return false;
	if(!(isValidEmail(thisForm.Email))) return false;
	
	return true;
}
function validatepartscoupon(thisForm)
{
	if(!(isValidNMFirstName(thisForm.FirstName))) return false;
	if(!(isValidNMLastName(thisForm.LastName))) return false;
	if(!(isValidMPhone(thisForm.OffPhone1,thisForm.OffPhone2,thisForm.OffPhone3,thisForm.OffPhone,' Day Phone '))) return false;
	if(!(isValidEmail(thisForm.Email))) return false;
	
	return true;
}
////////////////////////////////Join Our Mailing List ///////////////////////////

function validatemailinglist(thisForm)
{
	
	if(!(isValidEmail(thisForm.Email))) return false;
    return true;
}

//////////////////////////// Contact Us Validation /////////////////////////////////
function validatecontactus(thisForm)
{
	if(!(isValidSelTitle(thisForm.Title))) return false;
	if(!(isValidFirstName(thisForm.FirstName))) return false;
	if(!(isValidLastName(thisForm.LastName))) return false;
	if(!(isValidStreet(thisForm.Street))) return false;
	if(!(isValidCity(thisForm.City))) return false;	
	if(!(isValidZip(thisForm.Zip))) return false;	
	if(!(isValidEmail(thisForm.Email))) return false;
	if(!(isValidNMPhone(thisForm.OffPhone1,thisForm.OffPhone2,thisForm.OffPhone3,thisForm.OffPhone,' Day Phone '))) return false;
	if(!(isValidNMPhone(thisForm.ResPhone1,thisForm.ResPhone2,thisForm.ResPhone3,thisForm.ResPhone,' Evening Phone '))) return false;	
	if(!(isValidNMPhone(thisForm.Fax1,thisForm.Fax2,thisForm.Fax3,thisForm.Fax,' Fax '))) return false;
	if(!(isValidReference(thisForm.Reference))) return false;		
	if(!(isValidNMComments(thisForm.Comments))) return false;		
return true;
}

function validateMoreInfoNew(thisForm)
{
	if(!(isValidFirstName(thisForm.FirstName))) return false;
	if(!(isValidLastName(thisForm.LastName))) return false;
	if(!(isValidEmail(thisForm.Email))) return false;
	if(!(isValidMPhone(thisForm.OffPhone1,thisForm.OffPhone2,thisForm.OffPhone3,thisForm.OffPhone,' Day Phone '))) return false;
	if(!(isValidNMPhone(thisForm.ResPhone1,thisForm.ResPhone2,thisForm.ResPhone3,thisForm.ResPhone,' Evening Phone '))) return false;		
	return true;
}

function validateMoreInfo_coupons(thisForm)
{
	if(!(isValidFirstName(thisForm.FirstName))) return false;
	if(!(isValidLastName(thisForm.LastName))) return false;
	if(!(isValidEmail(thisForm.Email))) return false;
	if(!(isValidNMPhone(thisForm.OffPhone1,thisForm.OffPhone2,thisForm.OffPhone3,thisForm.OffPhone,' Phone '))) return false;
		
	return true;
}


///////////////////////////////// Validate Contact Parts ///////////////////////////////////

function validatecontactparts(thisForm)
{
		//alert('1');
	if(!(isValidSelTitle(thisForm.Title))) return false;
	if(!(isValidFirstName(thisForm.FirstName))) return false;
	if(!(isValidLastName(thisForm.LastName))) return false;	
	if(!(isValidEmail(thisForm.Email))) return false;
	if(!(isValidNMPhone(thisForm.OffPhone1,thisForm.OffPhone2,thisForm.OffPhone3,thisForm.OffPhone,' Day Phone '))) return false;
	if(!(isValidNMComments(thisForm.Comments))) return false;		
return true;
}



function validateorderparts(thisForm)
{		

	if(!(isValidSelTitle(thisForm.Title))) return false;
	if(!(isValidFirstName(thisForm.FirstName))) return false;
	if(!(isValidLastName(thisForm.LastName))) return false;
	if(!(isValidStreet(thisForm.Street))) return false;
	if(!(isValidCity(thisForm.City))) return false;	
	if(!(isValidZip(thisForm.Zip))) return false;	
	if(!(isValidEmail(thisForm.Email))) return false;
	if(!(isValidNMPhone(thisForm.OffPhone1,thisForm.OffPhone2,thisForm.OffPhone3,thisForm.OffPhone,' Day Phone '))) return false;
	if(!(isValidNMPhone(thisForm.ResPhone1,thisForm.ResPhone2,thisForm.ResPhone3,thisForm.ResPhone,' Evening Phone '))) return false;
	if(!(isValidMakeYear(thisForm.MakeYear))) return false;	
	if(!(isValidMake(thisForm.Make))) return false;
	if(!(isValidModel(thisForm.Model))) return false;
	if(!(isValidNMMileage(thisForm.Mileage))) return false;
	if(!(isValidMVIN(thisForm.VIN))) return false;	
	if(!(isValidNMComments(thisForm.Comments))) return false;	
return true;
}
//////////////////////////// Job Validation /////////////////////////////////
function validateJobs(thisForm)
{
	if(!(isValidSelTitle(thisForm.Title))) return false;
	if(!(isValidFirstName(thisForm.FirstName))) return false;
	if(!(isValidLastName(thisForm.LastName))) return false;
	if(!(isValidStreet(thisForm.Street))) return false;
	if(!(isValidCity(thisForm.City))) return false;	
	if(!(isValidZip(thisForm.Zip))) return false;	
	if(!(isValidEmail(thisForm.Email))) return false;
	if(!(isValidNMPhone(thisForm.OffPhone1,thisForm.OffPhone2,thisForm.OffPhone3,thisForm.OffPhone,' Phone '))) return false;			    		
	if(!(isValidJobType(thisForm.jobtype))) return false;
	if(!(isValidJobTitle(thisForm.jobtitle))) return false;
	if (thisForm.Browse.value=="")
		{
			alert("Upload Resume");
			thisForm.Browse.focus();
			return false;
		}
var d4=thisForm.Browse.value.substring(thisForm.Browse.value.lastIndexOf("."),thisForm.Browse.value.length);
		
		if(!(d4==".txt" || d4==".rtf" || d4==".doc"|| d4==".pdf"))
		{
		alert("File format not supported");
		thisForm.Browse.focus();
		return false;
		}
return true;
}

//////////////////////////////////// Email Us ////////////////////////////////////

function validateEmailUs(thisForm)
{
	if(!(isValidSelTitle(thisForm.Title))) return false;
	if(!(isValidFirstName(thisForm.FirstName))) return false;
	if(!(isValidLastName(thisForm.LastName))) return false;
	if(!(isValidEmail(thisForm.Email))) return false;
	if(!(isValidNMComments(thisForm.Comments))) return false;
return true;
}


//////////////////////////// Moreinfo Validation /////////////////////////////////
function validatemoreinfo(thisForm) {
	if(!(isValidSelTitle(thisForm.Title))) return false;
	if(!(isValidFirstName(thisForm.FirstName))) return false;
	if(!(isValidLastName(thisForm.LastName))) return false;
	if(!(isValidEmail(thisForm.Email))) return false;
	if(!(isValidMPhone(thisForm.OffPhone1,thisForm.OffPhone2,thisForm.OffPhone3,thisForm.OffPhone,' Day Phone '))) return false;
	if(!(isValidNMPhone(thisForm.ResPhone1,thisForm.ResPhone2,thisForm.ResPhone3,thisForm.ResPhone,' Evening Phone '))) return false;			    		
return true;
}
//								Inventory
function validateinventory(thisForm) 
{
	if(!(isValidSelTitle(thisForm.Title))) return false;
	if(!(isValidFirstName(thisForm.FirstName))) return false;
	if(!(isValidLastName(thisForm.LastName))) return false;
	if(!(isValidEmail(thisForm.Email))) return false;
	if(!(isValidMPhone(thisForm.ResPhone1,thisForm.ResPhone2,thisForm.ResPhone3,thisForm.ResPhone,' Phone '))) return false;
	if(!(isValidState(thisForm.State))) return false;
	if(!(isValidZip(thisForm.Zip))) return false;	
return true;
}

//								E - Brouchure 
function validate_ebrochure(thisForm)
{
	if(!(isValidSelTitle(thisForm.Title))) return false;
	if(!(isValidFirstName(thisForm.FirstName))) return false;
	if(!(isValidLastName(thisForm.LastName))) return false;
	if(!(isValidEmail(thisForm.Email))) return false;	
	if(!(isValidMPhone(thisForm.OffPhone1,thisForm.OffPhone2,thisForm.OffPhone3,thisForm.OffPhone,' Day Phone '))) return false;
	if(!(isValidMPhone(thisForm.ResPhone1,thisForm.ResPhone2,thisForm.ResPhone3,thisForm.ResPhone,' Evening Phone '))) return false;			    		
	if(!(isValidNMPhone(thisForm.MobPhone1,thisForm.MobPhone2,thisForm.MobPhone3,thisForm.MobPhone))) return false;
	if(!(isValidSelectModel(thisForm.Model))) return false;
	if(!(isValidSelectTrim(thisForm.Trim))) return false;	    
	return true;
}

function closediv(divName){
	//document.getElementById(divName).innerHTML=''; 	
		document.getElementById(divName).style.display='none';
}

function mouseoverFlash(imageElement){
var x= imageElement;
	document.myFlash.SetVariable("rollModel", x);
}
function mouseoutFlash(imageId){
	document.myFlash.SetVariable("rollModel","");	

}

function isValidSelectBox(MySelectBox, MsgText)
{
	if (MySelectBox.selectedIndex==0)
	{
		alert("Select "+ MsgText);
		MySelectBox.focus();
		return false;
	}
return true;
}						  
// First Name Validation
function isValidTextBox(MyTextBox, MsgText)
{
	MyTextBox.value=removeLeadingAndTrailingChar(MyTextBox.value);
	if ((MyTextBox.value==""))
		{
			alert("Enter "+ MsgText);
			MyTextBox.focus();
			return false;
		}
return true;
}


function validatenumber(e) 
{
	var mykey = window.event ? e.keyCode : e.which; 
	
	if ((mykey <= 47 || mykey > 57) && mykey !=13 && mykey !=0 && mykey != 8) 
	
	{ 
	//alert ("Enter number only"); 
	return false; 
	} 
	return true;
	}

function validalphabet(e) 
	{
	var mykey = window.event ? e.keyCode : e.which; 

		if (mykey==46 || mykey==126) 
		{ 
			return false; 
		}
		
		if (((mykey > 32 && mykey < 48) || (mykey > 57 && mykey < 65) || (mykey > 90 && mykey < 97) || (mykey > 45 && mykey <= 57)))
		{ 
			return false; 
		}
	return true;
	}

function reversetabphone(f1,f2,e)
{
	phone1 = f1;
    phone2 = f2;
    var mykey = window.event ? e.keyCode : e.which;
 
 if (mykey == 8 || mykey == 46 ) 
	{
	if( document.getElementById(phone2).value.length ==0)
	   {
		document.getElementById(phone1).focus();
		document.getElementById(phone1).value=document.getElementById(phone1).value;
	   }
	}
	
}
function isValidTitle(Title)
{
	if (Title.selectedIndex==0 )
	{
		alert("Select Title");
		Title.focus();
		return false;
	}
return true;	
}

//////////////////////////// Schedule Services Validation 
function validatescheduleservice(thisForm) 
{	
	if(!(isValidFirstName(thisForm.FirstName))) return false;
	if(!(isValidLastName(thisForm.LastName))) return false;
	if(!(isValidZip(thisForm.Zip))) return false;	
	if(!(isValidEmail(thisForm.Email))) return false;
	if(!(isValidNMPhone(thisForm.OffPhone1,thisForm.OffPhone2,thisForm.OffPhone3,thisForm.OffPhone,' Day Phone '))) return false;
	if(!(isValidNMPhone(thisForm.ResPhone1,thisForm.ResPhone2,thisForm.ResPhone3,thisForm.ResPhone,' Evening Phone '))) return false;			    		
	if(!(isValidMakeYear(thisForm.MakeYear))) return false;	
	if(!(isValidMake(thisForm.Make))) return false;
	if(!(isValidModel(thisForm.Model))) return false;
	if(!(isValidRequestDate(thisForm.ReqDate))) return false;
	if(!(ValidateAppointmentTime(thisForm))) return false;
	if(!(isValidNMComments(thisForm.Comments))) return false;	
return true;
}

function validatebodyshopappointment(thisForm) 
{	
	if(!(isValidFirstName(thisForm.FirstName))) return false;
	if(!(isValidLastName(thisForm.LastName))) return false;
	if(!(isValidEmail(thisForm.Email))) return false;
	if(!(isValidNMPhone(thisForm.OffPhone1,thisForm.OffPhone2,thisForm.OffPhone3,thisForm.OffPhone,' Day Phone '))) return false;
	if(!(isValidMakeYear(thisForm.MakeYear))) return false;	
	if(!(isValidMake(thisForm.Make))) return false;
	if(!(isValidModel(thisForm.Model))) return false;
	if(!(isValidRequestDate(thisForm.ReqDate))) return false;
	if(!(ValidateAppointmentTimeBodyShop(thisForm.AppoinTime))) return false;
	if(!(isValidNMComments(thisForm.Comments))) return false;	
return true;
}
function validatetimeformat(thisobj){
	var y = thisobj.value;
	if(thisobj.value!=""){
		var x = /^[01][0-9]:[0-5][0-9]$/;
		return x.test(y) ? true : false;
	}
	return false;
}
function validateAppointment(thisForm){
	if(!(ValidateAppointmentTime(thisForm)))return false;
}
function ValidateAppointmentTime(thisForm){
	var timeRange = thisForm.timecanboptd;
	var optedTime = thisForm.AppoinTime;
	var amOrPm = thisForm.apm;
	if (timeRange.value.toUpperCase() == "CLOSED") {
		alert("Sorry, service is not available on the selected day, please select some other day!");
		thisForm.ReqDate.focus();
		return false;
	}
	if(optedTime.value == "" || optedTime.value == "hh:mm" ){
			alert("Please enter timings");
			thisForm.AppoinTime.focus();
			return false;
	}else if (!validatetimeformat(optedTime)){
			alert("Please Enter Correct time");
			thisForm.AppoinTime.focus();
			return false;
	}
	if (amOrPm.selectedIndex == 0) {
		alert("Please Select either AM/PM");
		thisForm.apm.focus();
		return false;
	}
	if (!appointmentTimeAvailibility(timeRange.value, optedTime.value + amOrPm.value)) {
		alert("Enter timings within the range specified")
		thisForm.AppoinTime.focus();
		return false;
	}
	else {
		return true;
	}
	return false;
}

function appointmentTimeAvailibility(timeRange,optedInputTime){
		var startHours = timeRange.substr(0,2);
		var startMins = timeRange.substr(timeRange.indexOf(":")+1,2);
		var endHours = timeRange.substr(timeRange.indexOf("-")+2,2);
		var endMins = timeRange.substr(timeRange.lastIndexOf(":")+1,2);
		var optedHours = optedInputTime.substr(0,2);
		var optedMins = parseInt(optedInputTime.substr(optedInputTime.indexOf(":")+1,2));
		var startTimeinMins = (timeRange.substr(timeRange.indexOf(":")+4,2).toUpperCase() == "AM") ? parseInt(startHours != "12" ? startHours * 60 : "0") + parseInt(startMins) : parseInt((startHours != "12") ? startHours * 60: "0") + parseInt(startMins) + parseInt("719");		
		var endTimeinMins = (timeRange.substr(timeRange.lastIndexOf(":")+4,2).toUpperCase() == "AM") ? parseInt(endHours != "12" ? endHours * 60 : "0") + parseInt(endMins) : parseInt((endHours != "12") ? endHours * 60: "0") + parseInt(endMins) + parseInt("719");
		var optedTimeinMin = (optedInputTime.substr(optedInputTime.length-2,2).toUpperCase() == "AM")? parseInt((optedHours != "12")? optedHours * 60: "0") + parseInt(optedMins) : parseInt((optedHours != "12") ? optedHours * 60: "0") + parseInt(optedMins)+ parseInt("719");
		if(optedTimeinMin >= startTimeinMins && optedTimeinMin <= endTimeinMins){
			return true;
		}
		return false;
}




function valid(thisobj)
{
	if(!(ValidateAppointmentTime(document.ScheduleService.AppoinTime)))return false;
}

function valid2(thisobj)
{

	if(!(ValidateAppointmentTimeBodyShop(document.BodyShop.AppoinTime)))return false;
}


function validTimeChar(e)
{
var mykey = window.event ? e.keyCode : e.which;
//alert(mykey	);
	if ((mykey <= 47 || mykey >58 ) && mykey!=45 && mykey!=8 && mykey!=9 && mykey!=127 && mykey!=15 && mykey!=13 && mykey!=0) 
			{
		return false;
			}
return true;			
}

/******************* Schedule a Test Drive ******************************/
/******************* Body shop ******************************/

function validtimeformatbodyshop(thisobj)
{
	var y = thisobj.value;
	//alert(y);
	if(y!="")
	{
		var x = /^[0-9]{1,2}:[0-9]{1,2}$/;
		if(!(x.test(y)))
		{
			alert("Please enter timings like this [10:00]");
			document.BodyShop.AppoinTime.focus();
			return false;
		}
		else validCharAppbodyshop(thisobj);
	}
return true;
}

function ValidateAppointmentTimeBodyShop(thisobj)
{ 
	var k =validtimeformatbodyshop(thisobj);
	
	if(document.BodyShop.AppoinTime.value=="")
	{ 
	alert("Please Enter Appointment Time");
		document.BodyShop.AppoinTime.focus();
		return false;
	}
	if(document.BodyShop.apm.selectedIndex==0)
	{
		alert("Please Select either AM/PM");
		document.BodyShop.apm.focus();
		return false;
	} 
	if(k) {
	
		var a =document.BodyShop.timecanboptd.value;
		var ahrs = a.substr(0,2);
		var amins = a.substr(a.indexOf(":")+1,2);
		var ahrs2 = a.substr(a.indexOf("-")+2,2);
		var amins2 = a.substr(a.lastIndexOf(":")+1,2);
		var apm1="";
		var apm2="";
		apm1=a.substr(a.indexOf(":")+4,2);
		apm2=a.substr(a.lastIndexOf(":")+4,2);
	var t1 = ahrs+amins;
	var t2 = ahrs2+amins2;
	
		var b = thisobj.value;
		var c = document.BodyShop.apm;
		if((a!="Closed") && (b!="") )
		{
		var opthrs = b.substr(0,2);
		var optmins = b.substr(b.indexOf(":")+1,2);
	var opt = opthrs+optmins;

					if(apm1==apm2)
					{ 
						if(c.value==apm1)
						{
							if((opt<t1) || (opt>t2))
							{
								alert("Enter timings within the range specified above");
								document.BodyShop.AppoinTime.focus();
								return false;
							}
						 }
						else{ 
						alert("Please select within the range specified above");
						document.BodyShop.AppoinTime.focus();
						return false;
						}				
					}
							
				if(c.value=="AM")
					{
						//if((t1>=1200) && (opt<t1))
						if((t1>=1200))
						{
							if(!((opt>=t1)&& (opt<1259)))
							{
								alert("Enter timings within the range specified above");
								document.BodyShop.AppoinTime.focus();
								return false;
							}
						}
						else if(t1<1200)
						{
							if((opt<t1)  || (opt>=1200))
							{
								alert("Enter timings within the range specified above");
								document.BodyShop.AppoinTime.focus();
								return false;
							}
						}
					}
					else
					{
						if((t2<1200) && !(opt>=1200))
						{
							if(opt>t2)
							{
								alert("Enter timings within the range specified above");
								document.BodyShop.AppoinTime.focus();
								return false;
							}
						}						
					}
				}
			else if((document.BodyShop.timecanboptd.value!="Closed") || (document.BodyShop.timecanboptd.value!="CLOSED") || (document.BodyShop.timecanboptd.value!="closed"))
			{
				alert("Enter Timings to be scheduled for");
				document.BodyShop.AppoinTime.focus();
				return false;
			}
			else
			{	alert("Sorry, Service not available on the selected date!");
				document.BodyShop.AppoinTime.focus();
				return false;
			}
			return true;
	}
	else
	{
		return false;
	}
}
function validCharAppbodyshop(thisobj)
{
	var b = thisobj.value;
	var c = "";

	if(b!="")
	{
	var opthrs = b.substr(0,2);
	var optmins = b.substr(b.indexOf(":")+1,2);
	var optminsx = b.substr(b.indexOf(":")+1,1);
	var optminsy = b.substr(b.indexOf(":")+2,1);
				if(((isNaN(opthrs[0])) || (isNaN(opthrs[1]))) &&(opthrs.indexOf(":")>0))
					{
						opthrs='0'+opthrs;		
					}
					if(opthrs>12)
					{
						alert("Enter proper timings");
						document.BodyShop.AppoinTime.focus();
						return false;
					}
					
					 if((optminsx<6)&&(optminsy=='0'))
					{
						optmins=optminsx+'0';
					}
					
					else if(optmins=="00")
					{
						optmins='00';
					}
					else if(optminsx=='0' && (optminsy<6))
					{
						optmins='0'+optminsy;
					}
					else if(optminsx<6)
					{
						optmins=optminsx+optminsy;
					}
					else if((optminsx=='6') ||(optminsx>'6') &&(optmins.length==1))
					{
						optmins='0'+optminsx;
					}
					else if(optminsx=='0' && ((optminsy>6) || (optminsy==6)))
					{
						optmins=optmins;
					}
					else if((optmins.length=='1')&&(optminsx<6))
					{
					optmins =optmins+'0';
					 }
					 else if((optmins.length=='1')&&(optminsx>6))
					{
					optmins ='0'+optmins;
					 }
					 else if(optmins='0')
							 {
								 optmins="00";
							 }
					 if(optmins<60)
						{
							optmins=optmins;
						}
								if(optmins>60)
								{
									alert("Enter proper minutes");
									document.BodyShop.AppoinTime.focus();
									return false;
								}
								if(opthrs.indexOf(":")>0)
								{
								thisobj.value=opthrs+optmins;	
								}
								else
								thisobj.value=opthrs+":"+optmins;
	}
return true;
}
/***********************Ends******************************/
/******************* Visual SEO More Info *****************************/
function SEOmoreinfo()
{
	document.getElementById("SEOcontent").style.display="block";
	document.getElementById("moreinfoSEOmo").style.display="block";
	document.getElementById("moreinfoSEO").style.display="none";
}
function SEOmoreinfohide()
{
	document.getElementById("SEOcontent").style.display="none";
	document.getElementById("moreinfoSEO").style.display="block";
	document.getElementById("moreinfoSEOmo").style.display="none";
}
/*********************** Ends ******************************/
/***********************Quick Links Arrow & border******************************/
function quicklink2() {
var quickInter = document.getElementById('quicklink').getElementsByTagName('li');
var quickstore = quickInter.length;
	interImg = quickInter[quickstore-1]
	//interImg.style.border='0px';
	//interImg.style.width='250px';
	
	for (var i=0; i<quickstore; i++){
		quickInter[i].getElementsByTagName("a")[0].innerHTML = '&raquo;&nbsp;&nbsp;' + quickInter[i].getElementsByTagName("a")[0].innerHTML;
	}
}
/*********************End Quick Links Arrow & border***************************/

/////////// New Vehicle Specials

function validatenewcar(thisForm)
{
	if(!(isValidFirstName(thisForm.FirstName))) return false;
	if(!(isValidLastName(thisForm.LastName))) return false;
	if(!(isValidMPhone(thisForm.OffPhone1,thisForm.OffPhone2,thisForm.OffPhone3,thisForm.OffPhone,' Day Phone '))) return false;
	if(!(isValidEmail(thisForm.Email))) return false;
	
	return true;
}

/*-------- Home Page --*/
function video_play(videoID1,videoID2,videoID3){
document.getElementById(videoID1).style.display="block";
document.getElementById(videoID2).style.display="none";
document.getElementById(videoID3).style.display="none";
}
function quickLinkChangeOver(changeColor, changeClickColor, Txtcolor) 
{ 
if(document.getElementById(changeColor+'_Normal')){
	document.getElementById(changeColor+'_Normal').className = changeColor+'Mo';
   	document.getElementById(changeClickColor+'_Link').style.color = "#FFF";
	document.getElementById(Txtcolor).style.color = "#FFF";
}

}
function quickLinkChangeOut(changeColor, changeClickColor, Txtcolor)
{
if(document.getElementById(changeColor+'_Normal')){
document.getElementById(changeColor+'_Normal').className = changeColor; 
document.getElementById(changeClickColor+'_Link').style.color = "#FFF";
document.getElementById(Txtcolor).style.color = "#FFF";

}
}


function flashMouseDown(me) { flashMovie('FlashObject1').JSFlash(me, 'down');}
function mouseoverFlash(me) { flashMovie('FlashObject1').JSFlash(me, 'over'); }
function mouseoutFlash(me) { flashMovie('FlashObject1').JSFlash(me, 'out'); }
function flashMovie(flash) { return (navigator.appName.indexOf("Microsoft") != -1) ? window[flash] : document[flash]; }

function moreinfo2()
{
document.getElementById("contentAbsolute").style.display="block";
document.getElementById("moreinfodiv1").style.display="block";
document.getElementById("moreinfodiv").style.display="none";
}
function moreinfohide2()
{
document.getElementById("contentAbsolute").style.display="none";
document.getElementById("moreinfodiv").style.display="block";
document.getElementById("moreinfodiv1").style.display="none";
}