
$("document").ready(function(){
	  $("a#moreinfo_link").click(function(){
        contentObj.update();
    });
});

var contentObj = {
        sourceId: "#top_content > div",
        desti: {
            id: "#content",
            hasdata: false,
            show: false
        },
        handlerId:"#moreinfo_link",
        update:function(){
            if(!this.desti.hasdata){
                $(this.sourceId).clone().appendTo(this.desti.id).css("display","block");
                this.desti.hasdata=true;   
            }else{
                $(this.desti.id).toggle(!this.desti.show);
            }
            $(this.handlerId).html(this.desti.show?"More Information":"Hide Information");
            this.desti.show = !this.desti.show;
			if(this.desti.show){
				$(this.desti.id).show();
			}else{
				$(this.desti.id).hide();
			}
			
        }
};
//for Home Page
///////////////////////// COMMON JAVASCRIPT FILE ////////////////////////////
//																		   //
// 	  COMMON JAVASCRIPT FILE FOR ALL THE SCRIPTS USED ALLOVER THE SITE     //
//																		   //
/////////////////////////////////////////////////////////////////////////////

function fixheight()
{ 
var lft=document.getElementById('leftContent').offsetHeight;
var rgt=document.getElementById('rightContent').offsetHeight;
if (lft > rgt)document.getElementById('rightContent').style.height = lft + "px";
if (rgt > lft)document.getElementById('leftContent').style.height = rgt + "px";
}
///////////////////////////////////////Setting Position of layers//////////////////
////////////////////////////////////////////////////////////////////////////////

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_reloadPage(init) {  // reloads the window if Nav4 resized.
	if (init==true) with (navigator) {
	  	if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    		document.MM_pgW=innerWidth; 
			document.MM_pgH=innerHeight; 
			onresize=MM_reloadPage; 
		}
	}
  	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) 
		location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { // gets the object by its id.
	var p,i,x;  
	if(!d) 
		d=document; 
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; 
		n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) 
		x=d.all[n]; 
	for (i=0;!x&&i<d.forms.length;i++) 
		x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) 
		x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) 
		x=d.getElementById(n); 
	return x;
}

function MM_showHideLayers() { // hides or shows layers.
  	var i,p,v,obj,args=MM_showHideLayers.arguments;
  	for (i=0; i<(args.length-2); i+=3) 
		if ((obj=MM_findObj(args[i]))!=null) { 
			v=args[i+2];
    		if (obj.style) { 
				obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; 
			}
    		obj.visibility=v;
		}
}

function MM_swapImgRestore() { // restores the mouseover images.
  	var i,x,a=document.MM_sr; 
	for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) 
		x.src=x.oSrc;
}


function MM_swapImage() { // swaps the images for mouse over effect.
  	var i,j=0,x,a=MM_swapImage.arguments; 
	document.MM_sr=new Array; 
	for(i=0;i<(a.length-2);i+=3)
   		if ((x=MM_findObj(a[i]))!=null)	{
			document.MM_sr[j++]=x; 
			if(!x.oSrc) 
				x.oSrc=x.src; 
			x.src=a[i+2];
		}
}

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;
	}
}

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 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 formatDollarzero(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") {
		//alert(sign);
		obj.value=((sign)?'':'-') + '$' + num + '.' + cents;
		//alert(obj.value);
		return true;
	}else if(temp=="$0.00"){
		//alert('djfdshfjdj')	;
		obj.value=("$0.00")
	}
	else {
		obj.value="";
		return false;
	}
}

function formatDollarNew(obj)
{
	
	//alert(obj);
	
	
	
	var num = obj.value
	num = num.toString().replace(/\$|\,/g,'');
	//alert(num);
	if(isNaN(num))
	return false;

	sign = (num == (num = Math.abs(num)));
	//alert(sign);
	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!="") {
		obj.value=((sign)?'':'-') + '$' + num + '.' + cents;
		//alert(obj.value);
		return true;
	}	
	else { //alert('3');
		obj.value="";
		return false;
	}
}


function getYears() {
   	var years = new Array(2002,2003,2004,2005)
   	for (var i = 0; i < document.serviceappointment.BestDateToDriveYear.length; i++) {
    	document.serviceappointment.BestDateToDriveYear.options[0] = null;
	}
	document.serviceappointment.BestDateToDriveYear.options[0] = new Option("years");
    timeC = new Date();
    currYear = timeC.getFullYear();
    for (var i = 0; i < years.length; i++) {
    	document.serviceappointment.BestDateToDriveYear.options[i] = new Option(years[i]);
  	}
    document.serviceappointment.BestDateToDriveYear.options[0].selected=true;
}

function alertSubmit() {
leftPos = 0;
topPos = 0;
	if (screen) {
		leftPos = (screen.width / 2) - 171;
		topPos = (screen.height / 2) - 2;
	}


	submitProcess=window.open('../process.jsp','name','height=120,width=300,left='+leftPos+',top='+topPos);

return true;
}


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;
}


function validmileage(obj)
{
	var num = obj.value;
    if(num==0)
	{
	obj.value="";
	//alert("Enter Mileage");
	return false;
	}
	else 
	{
		for(var i=0; i<obj.value.length+6; i++)
		{
				
				if(obj.value.indexOf("0")==0) 
				{
						//alert(obj.value);
						obj.value = obj.value.substring(1,obj.value.length);
			
				}
		}
	}
	return true;
}
function formatDollar1(obj)
{
	//alert(obj.value);
	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;
	var temp=((sign)?'':'-') + '$' + num + '.' + cents;
	if(temp!="$0.00")
	{
		obj.value=num;
		return true;
	}
	else
	{
		obj.value="";
		//obj.focus();
		return false;
	}
}
//-->


function formatDollar2(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))+
	num.substring(num.length-(4*i+3));
	//alert("out  "+cents);
	if(cents==00)
	{
	//alert("if  "+cents);
	var temp=((sign)?'':'-') + '' + num;
	}
	else
	{
		//alert("else  "+cents);
	var temp=((sign)?'':'-') + '' + num+ '.' + cents;
	}
	if(temp!="0.00" || temp!="00") {
				if(cents==00)
				{
			//	alert("not 00"+cents);
				obj.value=((sign)?'':'-') + '' + num;
				}
				else
				{
				//alert("00"+cents);
				obj.value=((sign)?'':'-') + '' + num + '.' + cents;
				return true;
				}
	}	
	else {
		obj.value="";
		return false;
	}
}


 
 function doreset()
{
	document.DetailedInfo.ExtColor1.value="No Color Selected";
}

/// 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);
		if(navigator.appName=="Netscape")
		{
		document.getElementById(phfield2).value=myval;
		
		}
		document.getElementById(phfield2).focus();
		
	
	//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) 
			{
//			alert ("Enter number only");
		return false;
			}
return true;			
}
 /////////////the code ends here/////////////
 
                          /* coding by GK and Selvi */
function isValidServiceAdvisor(ServiceAdvisor)
{
	if (ServiceAdvisor.selectedIndex==0)
	{
		alert("Select Service Advisor");
		ServiceAdvisor.focus();
		return false;
	}
return true;
}
						  
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;
}
  // Last Name Validation
function isValidLastName(LastName)
{
	LastName.value=removeLeadingAndTrailingChar(LastName.value);
	if ((LastName.value==""))
		{
			alert("Enter Last Name ");
			LastName.focus();
			return false;

		}
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)
{
	ph1.value=removeLeadingAndTrailingChar(ph1.value);	
	ph2.value=removeLeadingAndTrailingChar(ph2.value);	
	ph3.value=removeLeadingAndTrailingChar(ph3.value);	
		
	if(isNaN(ph1.value))
		{
			ph1.value="";
		}
	if(isNaN(ph2.value))
		{
			ph2.value="";
		}
	if(isNaN(ph3.value))
		{
			ph3.value="";
		}	
	if(ph1.value.length==3 &&ph2.value.length==3 && ph3.value.length==4) {
		ph.value="("+ph1.value+") "+ph2.value+"-"+ph3.value;
	}
	else ph.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;
	}
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 isValidNMMileage(Mileage)
{
	Mileage.value=removeLeadingAndTrailingChar(Mileage.value);
	if(isNaN(Mileage.value))
	{
		alert("Mileage should be Numeric");	
		Mileage.select();
		return false;
	}		
	return true;
}
function isValidMMileage(Mileage)
{
	Mileage.value=removeLeadingAndTrailingChar(Mileage.value);
	/*if(isNaN(Mileage.value))
	{
		alert("Mileage should be Numeric");	
		Mileage.select();
		return false;
	}
	if(Mileage.value=="")
	{
		alert("Enter Mileage");
		Mileage.value="";
		Mileage.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 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 isValidSelectInterestLevel(InterestLevel)
{
	if (InterestLevel.selectedIndex==0)
	{
		alert("Select Interest Level");
		InterestLevel.focus();
		return false;
	}
return true;
}

function isValidPriceRange(PriceRange)
{
	if (PriceRange.value=="")
	{
		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 isValidBestDateToDriveYear(BestDateToDriveYear)
{
		if(BestDateToDriveYear.selectedIndex==0)
		{
			alert("Select Best Date To Drive Year");
			BestDateToDriveYear.focus();
			return false;
		}
		return true;
}

function isValidBestDateToDriveMonth(BestDateToDriveMonth)
{
		if(BestDateToDriveMonth.selectedIndex==0)
		{
			alert("Select Best Date To Drive Month");
			BestDateToDriveMonth.focus();
			return false;
		}
return true;		
}
function isValidReference(Reference)
{
	if(Reference.selectedIndex==0)
		{
			alert("Select Reference");
			Reference.focus();
			return false;
		}
return true;		
}

//////////////////////////// Contact Us Validation /////////////////////////////////
function validatecontactus(thisForm)
{
		//alert('1');
	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(!(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;	
	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;		
	//thankYouOnSamePage(thisForm);
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;	
//thankYouOnSamePage(thisForm);
return true;
	//return true;  
}

function validateJobs1(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(!(isValidMPhone(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;
}

function setAllTextBox(thisForm)
{
	for( i = 0 ; i < thisForm.elements.length; i++ )
	{
		var elename = thisForm.elements[i].name;
		if (elename =='FirstName') 	elename.maxLength = 25;		
		if (elename =='LastName') 	elename.maxLength = 25;		
		if (elename =='Street') 	elename.maxLength = 25;		
		if (elename =='City') 	elename.maxLength = 25;		
		if (elename =='Make') 	elename.maxLength = 25;		
		if (elename =='Model') 	elename.maxLength = 25;		
		if (elename =='Trim') 	elename.maxLength = 25;		
	}
}


function calculate_loan()
{
	var a = document.loan.downpay.value;
	var b = document.loan.loanselling.value;
	var b3 = document.loan.loanmonths.value;
var dwnpaylen = a.length; 
//alert(dwnpaylen);
var x;
if((dwnpaylen>1) && (a.indexOf(0)==0))
{
	for(var i=0;i<dwnpaylen;i++)
	{
	if(a.charAt(0)==0)
		{
			a =a.substring(1,dwnpaylen);
			x =a ;
		}

	else
		break;
	}
document.loan.downpay.value = x;	
}
else if((dwnpaylen>1) && (a.indexOf(0)!=0))
{
	a = document.loan.downpay.value;
}
else
if((dwnpaylen==1) && (a.charAt(0)==0))
{
	alert("Enter proper Down payment");
	document.loan.downpay.value = "";
document.loan.loanpayment.value="";
document.loan.loantotal.value="";
	document.loan.downpay.focus();
	return false;
}


	if( b3=="")
	{
	document.loan.loanpayment.value="";
	}
	var b4 = document.loan.loaninterest.value;
	var c = parseInt(parseFloat(b) - parseFloat(a));
	if((document.loan.downpay.value !="") || (document.loan.loanselling.value!=""))
	{
		if(parseInt(document.loan.downpay.value) >= parseInt(document.loan.loanselling.value))
		{
			alert("Down Payment should be less than Selling Price");
			document.loan.downpay.select();
			return false;
		}
	}
	
	document.loan.loanamount.value = c;
     b4 = b4.substring(0,b4.length -1) / 100;
	//b4 = parseInt(b4) / 100;
	var b10 = c;
	var upper = b10 * ( b4 / 12);

	if(upper==0)  {
		document.loan.loanpayment.value=c/b3;
   		document.loan.loantotal.value=upper;


  	}
  	else {
 		var lower = 1 - ( 1 / Math.pow ( (1+ (b4 / 12)),b3) );
 		var monthly_payment = upper / lower + " ";
 		document.loan.loanpayment.value =monthly_payment.substring(0,monthly_payment.indexOf('.')) + monthly_payment.substring(monthly_payment.indexOf('.'),monthly_payment.indexOf('.')+3) ;
 		interestamount = (monthly_payment*b3) - b10;
 		interestamount = interestamount + " ";
 		document.loan.loantotal.value = interestamount.substring(0,interestamount.indexOf('.')) + interestamount.substring(interestamount.indexOf('.'),interestamount.indexOf('.')+3) ;
	}

if(upper == "NaN"){upper = "";}
if(document.loan.loanpayment.value == "Na"){document.loan.loanpayment.value = "";}
if(document.loan.loantotal.value == "Na"){document.loan.loantotal.value = "";}
if(document.loan.loanamount.value == "Na" || document.loan.loanamount.value == "NaN"){document.loan.loanamount.value = "";}
	
	if( document.loan.loanmonths.value=="")
{
	document.loan.loanpayment.value="";
}
if( document.loan.loaninterest.value=="" && document.loan.loanmonths.value=="")
{
	document.loan.loanpayment.value="";
}
	return false;
	
}

function validDate(dtfield)
{
	if(dtfield.value=="" || isNaN(dtfield.value))
	{
		alert("Enter Date ");
		dtfield.focus();
		return false;
	}
	if (dtfield.value.length<2)
	{
		if(dtfield.value == 0){
		alert("Enter valid Date");
		dtfield.focus();
		return false;
		}
		if (dtfield.value<= 9 && dtfield.value != 0)
		{
		 dtfield.value = '0' + dtfield.value;	
		}
		return false;
	}
return true;	
}

function validMonth(monfiled)
{
	if(monfiled.value=="" || isNaN(monfiled.value))
	{
		alert("Enter Month");
		monfiled.focus();
		return false;
	}
	if (monfiled.value.length<2)
	{
		
		if (monfiled.value == 0){
		alert("Enter valid Month");
		monfiled.focus();
		return false;
		}
		
		if (monfiled.value<= 9 && monfiled.value != 0)
		{
		 monfiled.value = 0 + monfiled.value;	
		}
		return false;
	}
return true;	
}
function validYear(yearfiled) {
	if(yearfiled.value=="" || isNaN(yearfiled.value))
	{
		alert("Enter Year");
		yearfiled.focus();
		return false;
	}
	if (yearfiled.value.length<4)
	{
		alert("Enter valid Year");
		yearfiled.focus();
		return false;
	}	
return true;	
}

function validateDate(dtfield, monfiled, yearfiled, mergeddate, FieldName, isLessValidationReqd) {
	if(!(validDate(dtfield))) return false;
	if(!(validMonth(monfiled))) return false;
	if(!(validYear(yearfiled))) return false;
var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');	
	var dt = new Date(yearfiled.value, (monfiled.value - 1 ), dtfield.value);
// 	alert( dt ); 	alert( dt.getDate() ); alert( dt.getMonth() ); alert( dt.getFullYear() );
	if  ( ( dt.getDate() ==  dtfield.value ) && ( dt.getMonth() + 1   == monfiled.value ) &&  ( dt.getFullYear() == yearfiled.value ) )  
	{
		
		if (isLessValidationReqd && isLessThanOrEqualCurrentDate(dt) )
		{
		alert ('Invalid ' + FieldName );
		dtfield.focus();
		return false;			
		}
		else {
		mergeddate.value = dt.getDate()+ " " +months[dt.getMonth()] + ", " + dt.getFullYear();
		return true;			
		}
	}
	else 
	{
		alert ('Invalid ' + FieldName );
		dtfield.focus();
		return false;
	}

}

function validHour(dtfield)
{
	if(dtfield.value=="" || isNaN(dtfield.value))
	{
		alert("Enter Time");
		dtfield.focus();
		return false;
	}

		if (dtfield.value <= 23 && dtfield.value >= 0)
		{
		 if (dtfield.value <= 9) dtfield.value = '0' + parseInt(dtfield.value);	
		 return true;
		}
		else
		{
		alert("Enter valid Time");
		dtfield.focus();
		return false;
		}
	
}

function validMinutes(dtfield)
{
	if(dtfield.value=="" || isNaN(dtfield.value))
	{
		alert("Enter Time");
		dtfield.focus();
		return false;
	}
		if (dtfield.value<= 59 && dtfield.value >= 0)
		{
		 if (dtfield.value <= 9) dtfield.value = '0' + parseInt(dtfield.value);	
		 return true;
		}
		else
		{		
		alert("Enter valid Time");
		dtfield.focus();
		return false;
		}
	
}

function validateTime(hrfield, minfield,  mergedtime) {
	if(!(validHour(hrfield))) return false;
	if(!(validMinutes(minfield))) return false;
	mergedtime.value = " " + hrfield.value + ":" + minfield.value ;
	return true;
}

/*function mouseoverFlash(imageElement){
	imageElement.className +='hover';
//alert(imageElement.id);
var x= imageElement.id ;
if (x.indexOf('300') > 0) x = 300;
	document.myFlash.SetVariable("rollModel", x);
}
function mouseoutFlash(imageId){
	imageId.className = imageId.className.replace('hover','');	
	document.myFlash.SetVariable("rollModel","");	
//alert(imageElement.id);

}*/



function MM_preloadImages() { // preloads the mouseover images.
  	var d=document; 
	if(d.images) { 
		if(!d.MM_p) 
			d.MM_p=new Array();
    	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 
		for(i=0; i<a.length; i++)
    		if (a[i].indexOf("#")!=0) { 
				d.MM_p[j]=new Image; 
				d.MM_p[j++].src=a[i];
			}
	}
}




/* Sellus car supported Function */
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;	
}

function embedflashhome(d1,d2,d3,d4)
{
//alert(d1);

document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" id="FlashObject1" width="'+d2+'" height="'+d3+'"><param name="movie" value="'+d1+'loopingTemplate.swf?toolkitPath='+d4+'newvehicles/selecttrim.jsp?&amp;Server='+d1+'"><param name="quality" value="high"><param name="menu" value="false"><param name="id" value="101"><param name="wmode" value="transparent"><embed wmode="transparent" src="'+d1+'loopingTemplate.swf?toolkitPath='+d4+'newvehicles/selecttrim.jsp?&amp;Server='+d1+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="FlashObject1" width="'+d2+'" height="'+d3+'"></embed></object>')	
}

function embedflash2(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="FlashObject" 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" /><param name="menu" value="false" /><embed src="'+d1+'loopingTemplate.swf" wmode="transparent" quality="high" bgcolor="#ffffff" width="100%" height="100%" name="FlashObject" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" menu="false"  /></object>')
}

/*******************Visual SEO More Info*****************************/
function moreinfo()
{
document.getElementById("content").style.display="block";
document.getElementById("moreinfodiv1").style.display="block";
document.getElementById("moreinfodiv").style.display="none";
}
function moreinfohide()
{
document.getElementById("content").style.display="none";
document.getElementById("moreinfodiv").style.display="block";
document.getElementById("moreinfodiv1").style.display="none";
}

function flashMouseDown(me) { try {flashMovie('FlashObject1').JSFlash(me, 'down')}catch(e) {};}
function mouseoverFlash(me) {try {flashMovie('FlashObject1').JSFlash(me, 'over')}catch(e) {}; }
function mouseoutFlash(me)  { try {flashMovie('FlashObject1').JSFlash(me, 'out')}catch(e) {}; }
function flashMovie(flash) { return (navigator.appName.indexOf("Microsoft") != -1) ? window[flash] : document[flash]; }