///////////////////////// 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//////////////////

function embedflashHeader(d1,d2,d3,d4,d5,d6,d7)
{
//alert(d4)
document.getElementById('flash-home').innerHTML = 
'<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+'index.swf?toolkitPath='+d4+'research/virtual-brochure.jsp&amp;modelXml='+d5+'&amp;assetspath='+d6+'&amp;skinXml='+d7+'"><param name="quality" value="high"><param name="menu" value="false"><param name="id" value="101"><param name="wmode" value="transparent"><embed wmode="transparent" allowScriptAccess="always" src="'+d1+'index.swf?toolkitPath='+d4+'research/virtual-brochure.jsp&amp;modelXml='+d5+'&amp;assetspath='+d6+'&amp;skinXml='+d7+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="FlashObject1" width="'+d2+'" height="'+d3+'"><param name="allowScriptAccess" value="always" /> </embed></object>' ;
}


function embedflashHeadernew(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="FlashObject" width="'+d2+'" height="'+d3+'"><param name="movie" value="'+d1+'index.swf?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+'index.swf?Server='+d1+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="FlashObject" width="'+d2+'" height="'+d3+'"></embed></object>')	
}

/*OpenX Code*/

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 sample()
{alert('here');}

// ---- Why Buy? - Text Rotation Strats -----//
var howOften = 2; 
var current = 0;
var ns6 = document.getElementById&&!document.all; 

var quotations = new Array()
quotations[0]= "10 year, 100,000 mile warranty on every new Audi vehicle purchase"
quotations[1]= "5 year, 24-hour roadside assistance"
quotations[2]= "Rick Case Rewards membership � earn points with the purchase of any vehicle, service, parts and accessories.  This will save you hundreds, even thousands towards future purchases at any Rick Case location"

function rotater() {
    if(document.layers) {
        document.whyBuyScrolling.document.write(quotations[current]);
        document.whyBuyScrolling.document.close();
    }
    if(ns6)document.getElementById("whyBuyScrolling").innerHTML=quotations[current]
        if(document.all)
            whyBuyScrolling.innerHTML=quotations[current];

    current = (current==quotations.length-1) ? 0 : current + 1;
    setTimeout("rotater()",howOften*2000);
}

// ---- Why Buy? - Text Rotation End -----//


function smallthankyou(pagetype)
{
if(pagetype=='')
	{
		startListinner();
	}
}

startListinner = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");

for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];

//alert(navRoot.childNodes.length);
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
if(typeof(this.getElementsByTagName('ul')[0]) == 'object')
showiframe(this.getElementsByTagName('ul')[0],'Divcommercial');
/*for(var obj in ) {
	alert(obj + ' ' + node.getElementsByTagName('span')[obj] );
}*/
  }
  node.onmouseout=function() {
  this.className=this.className.replace(" over", "");
hideiframe('Divcommercial');
   }

   }
  }
 }
}

function flashload()
{
//alert("Flash is loading");
flashMovie('FlashLObject').JSFlashload('Load','true');
}

function flashMovie(flash) { return (navigator.appName.indexOf("Microsoft") != -1) ? window[flash] : document[flash]; }
 function showiframe(d1,d2)
 {
// var div=document.getElementById(d1);
 var div=d1;
 var frame=document.getElementById(d2);
//alert(d2);
//div.style.border ='1px solid #FF0000';
	var w = frame.style.width = div.offsetWidth;
    var h = frame.style.height = div.offsetHeight;
    var t = frame.style.top = div.parentNode.parentNode.parentNode.offsetTop + div.parentNode.offsetHeight;
    var l = frame.style.left = div.parentNode.offsetLeft;
//div.style.width=w;
	if(d1.id=='aboutusdiv')
	{
		w= frame.style.width = div.offsetWidth -20;
	}

div.style.zIndex = 2;
//alert('Id' + div.id +'Width' + w + 'Height' +h+ 'Top'+t+'Left'+l);
//frame.style.border ='1px solid #00FF00';
    var brow=navigator.appName;
	if(brow=="Netscape")
	{
		frame.style.display = 'none';
	} else if(brow=="Microsoft Internet Explorer") {
	frame.style.display = 'block';	
	}
	
//var inf  = 'Class : '+div.className + ' Id: '+ div.id; 
//trace(inf);
//	if((div.id=='virbroc'))
//	{
//		alert("hi");
//		Myshowiframe(('ul')[0],'Divcommercial');
//	}

 }

function Myhideiframe(d3)
 {
 var d1=document.getElementById(d3);
 d1.style.display='none';
 }
 
function setime(d1,d2)
{
var ttt = setTimeout(function() { Myshowiframe(d1,d2) } , 3000);

}
function trace(info) {
	document.getElementById('testing').innerHTML += info; 
}
 function Myshowiframe(d1,d2)
 {
for(var i=0; i<=30000; i++){}
 var div=document.getElementById(d1);
 var frame=document.getElementById(d2);
	 frame.style.width = div.currentStyle.width;
     frame.style.height =div.parentNode.parentNode.parentNode.childNodes[0].offsetHeight;
     frame.style.top = div.parentNode.offsetTop + div.parentNode.parentNode.parentNode.offsetHeight;
     frame.style.left = div.parentNode.parentNode.parentNode.offsetLeft;
 

//	frame.style.width = div.offsetWidth;
//    frame.style.height = div.offsetHeight;
//    frame.style.top = div.offsetTop;
//    frame.style.left = div.offsetLeft;
//alert('Id ' + div.id + 'Width' + frame.style.width + 'Height' +frame.style.height+ 'Top'+frame.style.top+'Left'+frame.style.left);
var xxxx =  'Id ' + div.id + 'Width' +div.style.width + 'Height' +frame.style.height+ 'Top'+frame.style.top+'Left'+frame.style.left ;
trace(xxxx.toString());

frame.style.border ='1px solid #ff0000';
var brow=navigator.appName;
	if(brow=="Netscape")
	{
		frame.style.display = 'none';
	} else if(brow=="Microsoft Internet Explorer") {
	frame.style.display = 'block';	
	}
 }
function overColor(myheader)
	{
		
document.getElementById(myheader).className='header_main_linksjs';
	}
function outColor(myheader)
	{
document.getElementById(myheader).className='header_main_links';
}
var mySubmitData = "<span style='background-color:#1E448B; height:15px; color:#FFFFFF;  text-align:right;'>&nbsp;&nbsp; Processing Your Request.. Please Wait...&nbsp;&nbsp; </span>";
//var mySubHeaderData = "<img src=\"../images/subheaders/thank_you.jpg\"   title=\"Thank You\" alt=\"Thank You\" >";

function embedflashhomeBanner(d1,d2,d3)
{

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="FlashObject" width="'+d2+'" height="'+d3+'"><param name="movie" value="'+d1+'banner.swf"><param name="quality" value="high"><param name="menu" value="false"><param name="wmode" value="transparent"><embed wmode="transparent" src="'+d1+'banner.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="FlashObject" width="'+d2+'" height="'+d3+'"></embed></object>')	
}


function embedflashvideo(d1,d2,d3)
{

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="FlashObject" width="'+d2+'" height="'+d3+'"><param name="movie" value="'+d1+'flv_player.swf"><param name="quality" value="high"><param name="menu" value="false"><param name="wmode" value="transparent"><embed wmode="transparent" src="'+d1+'flv_player.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="FlashObject" width="'+d2+'" height="'+d3+'"></embed></object>')	
}
//////////////////////////////////////Setting Position of layers stop///////////////////

function thirdParty(site_thirdyparty){
	confirmMessage = "The content for this page is provided by http://" + site_thirdyparty + ", which is an independent third party website.";
	confirmMessage1 = "You are now leaving this website and entering http://" + site_thirdyparty + ", which is an independent third party website.";
 var myConfirm = confirm (confirmMessage);
if (myConfirm)  return true;
else  return false;
}

//////////////////////////////////////////////////////////////////////////////////

function hideMe(obj){
	obj.style.visibility='hidden';
	return true;
}

function showMe(obj){
	obj.style.visibility='visible';
	return true;
}

/////////////////////////////////////////////////////////////////////////////////

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;
	}
}

//////////////////////////// Data Entry Validation /////////////////////////////////
function validnumber1()
	{
		if ((event.keyCode <= 47 || event.keyCode > 57) && event.keyCode !=13) 
			event.returnValue = false;
	}
function validnumber(event)
	{
			if ((event.keyCode <= 47 || event.keyCode > 57) && event.keyCode !=13) 
			event.returnValue = false;
	}

function alphanumeric1()
	{
	
	if (event.keyCode==46 || event.keyCode==126) 
			event.returnValue = false; 
		if ((event.keyCode >=33 && event.keyCode <=47) || (event.keyCode >=58  &&  event.keyCode <=64) || (event.keyCode >=91 && event.keyCode <=96 ) ||(event.keyCode >=123 && event.keyCode <=127 ) ) 
			event.returnValue = false; 
	}
function alphanumeric(obj)
{

if (event.keyCode==46 || event.keyCode==126 || event.keyCode==32) 
		event.returnValue = false; 
	if ((event.keyCode >=33 && event.keyCode <=47) || (event.keyCode >=58  &&  event.keyCode <=64) || (event.keyCode >=91 && event.keyCode <=96 ) ||(event.keyCode >=123 && event.keyCode <=127 ) ) 
		event.returnValue = false; 

}

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 a()
{
alert(event.keyCode);	
}

function a(x,z)
{
var y=document.getElementById(z).value
	if (x==46 || x==126) 
		event.returnValue = false; 
	if (((x > 32 && x < 48) || (x > 57 && x < 65) || (x > 90 && x < 97) || (x > 45 && x <= 57)))
		document.getElementById(z).value=y.substring(0,y.length -1);
		
}

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 validPhoneCheck()
{
	if(event.keyCode == 46) 
		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 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(a=="")
{
	a=0;
}
//alert(a);

	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 calculate_lease() {
	var c3 = document.lease.leasemonths.value;
	var c5 = document.lease.leasefinance.value;	
	var c6 = document.lease.leaseselling.value;
	var c9 = document.lease.leaseresidual.value;
	c5 = parseInt(c5)/100;
	c3 = parseInt(c3);
	c9 = parseInt(c9)/100;
	document.lease.leaseamount.value=document.lease.leaseselling.value - document.lease.Downpay.value;
	var c10 = document.lease.leaseamount.value;
	c10 = parseInt(c10);	
	var monthly_payment = ((c10 - (c9 * c10))/c3 + (c5/24) * (c10 + (c9 * c10)));
	monthly_payment = monthly_payment + " ";
	if(monthly_payment.indexOf('.')!="-1") {
		var num=monthly_payment.substring(monthly_payment.indexOf('.')+3,monthly_payment.indexOf('.')+4)
		var n
		if(num <= 5) {
			n=monthly_payment.substring(monthly_payment.indexOf('.')+1,monthly_payment.indexOf('.')+3)
		}
		if(num > 5) {
			n=monthly_payment.substring(monthly_payment.indexOf('.')+1,monthly_payment.indexOf('.')+3);
			n=parseInt(n)+1;
		}
	}
	else {
		n=monthly_payment.substring(monthly_payment.indexOf('.')+1,monthly_payment.indexOf('.')+4)
	}
	document.lease.leasepayment.value =(monthly_payment.substring(0,monthly_payment.indexOf('.')+1)) + n;
	document.lease.leasefinancial.value = c9 * c10;
	var leasefact = c5 / 24;
	document.lease.leasefactors.value = leasefact;
	return false;
}


function SelectFromArray(selectCtrl, itemArray, goodPrompt, badPrompt, defaultItem) {
var i, j;
var prompt;
// empty existing items
for (i = selectCtrl.options.length; i >= 0; i--) {
selectCtrl.options[i] = null; 
}
prompt = (itemArray != null) ? goodPrompt : badPrompt;
if (prompt == null) {
j = 0;
}
else {
selectCtrl.options[0] = new Option(prompt);
j = 1;
}
if (itemArray != null) {
// add new items
for (i = 0; i < itemArray.length; i++) {
selectCtrl.options[j] = new Option(itemArray[i][0]);
if (itemArray[i][1] != null) {
selectCtrl.options[j].value = itemArray[i][1]; 
}
j++;
}
// select first item (prompt) for sub list
selectCtrl.options[0].selected = true;
   }
}

function checkMake() {
	if(document.getElementById("paraMake").value=="Mercury") { 
		document.getElementById("Make").options[1].selected=true; 
		SelectFromArray(document.getElementById("Model"), model[0]);
	}
	if(document.getElementById("paraMake").value=="Ford") { 
		document.getElementById("Make").options[2].selected=true;
		SelectFromArray(document.getElementById("Model"), model[1]);
	}
	
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
function checktime()
{		
		var time = document.ScheduleService.AppoinTime.selectedIndex;
		var thisday = document.ScheduleService.textDay.value;
		
		//var time2 = document.ScheduleService.AppoinTimeAlter.selectedIndex;
		//var thisday2 = document.ScheduleService.textDayAlter.value;
		if(document.ScheduleService.AppoinTime.options[time].value=="Closed")
		{
			alert(" Sorry, our Service operations are closed on "+thisday+".\n Please select any other working date.");
			document.ScheduleService.ReqDate.focus();
            return false;

		}/* else if(document.ScheduleService.AppoinTimeAlter.options[time2].value=="Closed")
		{
			alert(" Sorry, our Service operations are closed on "+thisday2+".\n Please select any other working date.");
			document.ScheduleService.ReqDateAlter.focus();
            return false;
			
		}
else if (document.ScheduleService.ReqDate == document.ScheduleService.ReqDateAlter){
if(time.value==time2.value && thisday == thisday2 && document.ScheduleService.AppoinTime.options[time].value == document.ScheduleService.AppoinTimeAlter.options[time2].value )
		{
		
		alert("Selected Time and Alternate Time are same");
		
		}
}	*/
}
function checktimeTestDrive()
{		
		var time = document.Test_Drive.AppoinTime.selectedIndex;
		var thisday = document.Test_Drive.textDay.value;
		
		if(document.Test_Drive.AppoinTime.options[time].value=="Closed")
		{
			alert(" Sorry, our Service operations are closed on "+thisday+".\n Please select any other working date.");
			document.Test_Drive.ReqDate.focus();
            return false;

		}
}
function checktime2()
{		
		var time = document.ScheduleService.AppoinTime.selectedIndex;
		var thisday = document.ScheduleService.textDay.value;
		if(document.ScheduleService.AppoinTime.options[time].value=="Closed")
		{
			alert(" Sorry, our Collision operations are closed on "+thisday+".\n Please select any other working date.");
			document.ScheduleService.ReqDate.focus();
            return false;

		}
		if(document.ScheduleService.AppoinTime.options[time].value=="Date?")
		{
			alert(" Sorry, You have not Selected Any Date. Select Date First ");
			document.ScheduleService.ReqDate.focus();
            return false;
		}		
}


/* function populate(objForm,selectIndex) {
    timeA = new Date(objForm.BestDateToDriveYear.options[objForm.BestDateToDriveYear.selectedIndex].text, objForm.BestDateToDriveMonth.selectedIndex,1);
    timeDifference = timeA - 86400000;
    timeB = new Date(timeDifference);
    var daysInMonth = timeB.getDate();
    for (var i = 0; i < objForm.BestDateToDriveDay.length; i++) {
	    objForm.BestDateToDriveDay.options[0] = null;
	}
    for (var i = 0; i < daysInMonth; i++) {
    	objForm.BestDateToDriveDay.options[i] = new Option(i+1);
  	}
    document.serviceappointment.BestDateToDriveDay.options[0].selected = true;
} */


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 txtbox() {
	if(document.serviceappointment.timepick[2].checked==true) {
		document.serviceappointment.timeother.disabled=false;
	}
	if(document.serviceappointment.timepick[2].checked==false) {
		document.serviceappointment.timeother.value="";
		document.serviceappointment.timeother.disabled=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;
}


//-->11111
function myvalidnumbercal(e)
{
var mykey = window.event ? e.keyCode : e.which;
		if ((mykey <= 47 || mykey > 57) && mykey !=13 && mykey !=0 && mykey != 8 && mykey != 46) 
			{
//			alert ("Enter number only");
		return false;
			}
return true;			
}


function extractNumber(obj, decimalPlaces, allowNegative)
{
	var temp = obj.value;
	
	// avoid changing things if already formatted correctly
	var reg0Str = '[0-9]*';
	if (decimalPlaces > 0) {
		reg0Str += '\\.?[0-9]{0,' + decimalPlaces + '}';
	} else if (decimalPlaces < 0) {
		reg0Str += '\\.?[0-9]*';
	}
	reg0Str = allowNegative ? '^-?' + reg0Str : '^' + reg0Str;
	reg0Str = reg0Str + '$';
	var reg0 = new RegExp(reg0Str);
	if (reg0.test(temp)) return true;

	// first replace all non numbers
	var reg1Str = '[^0-9' + (decimalPlaces != 0 ? '.' : '') + (allowNegative ? '-' : '') + ']';
	var reg1 = new RegExp(reg1Str, 'g');
	temp = temp.replace(reg1, '');

	if (allowNegative) {
		// replace extra negative
		var hasNegative = temp.length > 0 && temp.charAt(0) == '-';
		var reg2 = /-/g;
		temp = temp.replace(reg2, '');
		if (hasNegative) temp = '-' + temp;
	}
	
	if (decimalPlaces != 0) {
		var reg3 = /\./g;
		var reg3Array = reg3.exec(temp);
		if (reg3Array != null) {
			// keep only first occurrence of .
			//  and the number of places specified by decimalPlaces or the entire string if decimalPlaces < 0
			var reg3Right = temp.substring(reg3Array.index + reg3Array[0].length);
			reg3Right = reg3Right.replace(reg3, '');
			reg3Right = decimalPlaces > 0 ? reg3Right.substring(0, decimalPlaces) : reg3Right;
			temp = temp.substring(0,reg3Array.index) + '.' + reg3Right;
		}
	}
	
	obj.value = temp;
}

function checkNumber(Ttemp,objectname)
{ 
///Added by Prem to add percentage symbol
	var name="";
	var i;
	name=name+Ttemp.substring(i,i+1);
	
	if( !((Ttemp.substring(i,i+1) >= 0) && (Ttemp.substring(i,i+1) <= 9)) && !(Ttemp.substring(i,i+1)=='%'))
		{
		 no=name.length-1;
		}
		var t= Ttemp.length-1;
		for(i=0; i <= t; i++)
		{
		var iCharCode = Ttemp.charCodeAt(i);
		if(i==t && iCharCode==46)
		{
		Ttemp=Ttemp.replace(".", "")
		}
		}
		if(objectname=="loaninterest" && !(Ttemp.substring(Ttemp.length-1)=='%') )
		{
			if(Ttemp.value=='.' || Ttemp.indexOf('.%')>=0 )
			{
				document.loan.loaninterest.value = Ttemp+'00%';
			}
			else if(Ttemp!="." && Ttemp!="") 
			{
			document.loan.loaninterest.value = Ttemp + '%' ;
			}
		}
		
			
 	 return true;
}

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;
	}
}

//Internet Fleet text effects starts
function showOff1()
{
document.getElementById('qa1').bgColor="#fff8ff"
document.getElementById('qa2').bgColor="#efe7de"
document.getElementById('qa3').bgColor="#efe7de"
document.getElementById('qa4').bgColor="#efe7de"
}
function showOff2()
{
document.getElementById('qa1').bgColor="#efe7de"
document.getElementById('qa2').bgColor="#fff8ff"
document.getElementById('qa3').bgColor="#efe7de"
document.getElementById('qa4').bgColor="#efe7de"
}function showOff3()
{
document.getElementById('qa1').bgColor="#efe7de"
document.getElementById('qa2').bgColor="#efe7de"
document.getElementById('qa3').bgColor="#fff8ff"
document.getElementById('qa4').bgColor="#efe7de"
}
function showOff4()
{
document.getElementById('qa1').bgColor="#efe7de" 
document.getElementById('qa2').bgColor="#efe7de"
document.getElementById('qa3').bgColor="#efe7de"
document.getElementById('qa4').bgColor="#fff8ff"
}

//Internet Fleet text effects ends

/* function populate1(objForm,selectIndex) {

    timeA = new Date(objForm.BestDateToDriveYear.options[objForm.BestDateToDriveYear.selectedIndex].text, objForm.BestDateToDriveMonth.selectedIndex,1);
    timeDifference = timeA - 86400000;
    timeB = new Date(timeDifference);
    var daysInMonth = timeB.getDate();
    for (var i = 0; i < objForm.BestDateToDriveDay.length; i++) {
	    objForm.BestDateToDriveDay.options[0] = null;
	}
    for (var i = 0; i < daysInMonth; i++) {
    	objForm.BestDateToDriveDay.options[i] = new Option(i+1);
  	}
    document.TestDrive.BestDateToDriveDay.options[0].selected = true;
} */


/* function getYears1() {
   	var years = new Array(2002,2003,2004,2005)
   	for (var i = 0; i < document.TestDrive.BestDateToDriveYear.length; i++) {
    	document.TestDrive.BestDateToDriveYear.options[0] = null;
	}
	document.TestDrive.BestDateToDriveYear.options[0] = new Option("years");
    timeC = new Date();
    currYear = timeC.getFullYear();
    for (var i = 0; i < years.length; i++) {
    	document.TestDrive.BestDateToDriveYear.options[i] = new Option(years[i]);
  	}
    document.TestDrive.BestDateToDriveYear.options[0].selected=true;
} */

function txtbox1() {
	if(document.TestDrive.timepick[2].checked==true) {
		document.TestDrive.timeother.disabled=false;
	}
	if(document.TestDrive.timepick[2].checked==false) {
		document.TestDrive.timeother.value="";
		document.TestDrive.timeother.disabled=true;
	}
}
/////The script for showing menu over input components//////
 function hideiframe1(d3)
 {
 var d1=document.getElementById(d3);
 d1.style.display='none';
 }
 
function showiframe1(d1,d2)
 {
 var hght=0;
 var div=document.getElementById(d1);
 var frame=document.getElementById(d2);
  	var fw = div.offsetWidth;
  	var fh = div.offsetHeight;
	frame.style.width = fw+"px";
    frame.style.height = fh+"px";	
    frame.style.top = div.style.top;
    frame.style.left = div.style.left;	
    var brow=navigator.appName;
	frame.style.display = 'block';	
 }
 ///////////////////////////////////////
 
 function doreset()
{
	document.DetailedInfo.ExtColor1.value="No Color Selected";
}

function MM_setTextOfTextfield(objName,x) { //v3.0
	var obj = MM_findObj(objName); if (obj) obj.disabled = false;obj.focus();
}

 /// 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) 
			{
//			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;
}

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)
{
	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;
	}
	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 isValidNMZip(Zip)
{
	Zip.value=removeLeadingAndTrailingChar(Zip.value);
	if(Zip.value!=""){
	if(Zip.value.length!=5)
	{
		alert("Enter valid Zip. It should be 5 characters Length");
		Zip.focus();
		return false;
	}
	}
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 isValidMMMileage(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 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 isValidSelectCondition(Condition)
{
	if(Condition.selectedIndex==0)
	{
		alert("Select Overall Condition");
		Condition.focus();
		return false;
	}
return true;
}
function isValidSelectBankloan(Bankloan)
{
	if(Bankloan.selectedIndex==0)
	{
		alert("Select Bank Loan");
		Bankloan.focus();
		return false;
	}
return true;
}
function isValidSelectDriveTrian(DriveTrian)
{
	if(DriveTrian.selectedIndex==0)
	{
		alert("Selct Drive Train");
		DriveTrian.focus();
		return false;
	}
	return true;
}

function isValidSelectUpholstery(Upholstery)
{
	if(Upholstery.selectedIndex==0)
	{
		alert("Select Upholstery");
		Upholstery.focus();
		return false;
	}
	return true;
}

function isValidSelectEngineCondition(EngineCondition)
{
	if(EngineCondition.selectedIndex==0)
	{
		alert("Select Engine Condition");
		EngineCondition.focus();
		return false;
	}
	return true;
}

function isValidSelectTransCondition(TransCondition)
{
	if(TransCondition.selectedIndex==0)
	{
		alert(" Select Transmission Condition");
		TransCondition.focus();
		return false;
	}
	return true;
}
function isValidSelectExteriorCondition(ExteriorCondition)
{
	if(ExteriorCondition.selectedIndex==0)
	{
		alert(" Select Exterior Condition");
		ExteriorCondition.focus();
		return false;
	}
	return true;
}
function isValidSelectInteriorCondition(InteriorCondition)
{
	if(InteriorCondition.selectedIndex==0)
	{
		alert(" Select Interior Condition");
		InteriorCondition.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 isValidPriceRangenew(PriceRange)
{
	if (PriceRange.value=="" || PriceRange.value=="Price")
	{
		alert("Enter Price Range");
		PriceRange.focus();
		return false;
	}
	if (!formatDollar(PriceRange) ) 
	{
		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;		
}

function validatefinanceapply(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,' Phone '))) return false;
return true;
}
function validatefinanceapply_price(thisForm)
{
	if(!(isValidFirstName(thisForm.FirstName2))) return false;
	if(!(isValidLastName(thisForm.LastName2))) return false;
	if(!(isValidEmail(thisForm.Email2))) return false;
	if(!(isValidMPhone(thisForm.OffPhone5,thisForm.OffPhone6,thisForm.OffPhone7,thisForm.OffPhone,' Phone '))) return false;
return true;
}
function validatefinanceapplycoupon(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,' Phone '))) return false;
	couponThankYouOnSamePage(thisForm);
return false;
}
//////////////////////////// Order Parts Validation /////////////////////////////////
function validateorderpart(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;
//	alert('1');	
	if(!(isValidCity(thisForm.City))) return false;	
	if(!(isValidZip(thisForm.Zip))) return false;	
	if(!(isValidEmail(thisForm.Email))) return false;
//		alert('1');
	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(!(isValidMakeYear(thisForm.MakeYear))) return false;	
	if(!(isValidMake(thisForm.Make))) return false;
	if(!(isValidModel(thisForm.Model))) return false;
	if(!(isValidNMTrim(thisForm.Trim))) return false;
	if(!(isValidNMMileage(thisForm.Mileage))) return false;
//	alert('1');
	if(!(isValidMVIN(thisForm.VIN))) return false;	
//	alert('1');
	if(!(isValidNMComments(thisForm.Comments))) return false;	
//		alert('2');
	//thankYouOnSamePage(thisForm);
return true;
}
//////////////////////////// TradeinApraisal Validation /////////////////////////////////
function validatetradeinappraisal(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,' 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(!(isValidNMTrim(thisForm.Trim))) return false;
	if(!(isValidMMileage(thisForm.Mileage))) return false;	
	if(!(isValidNMColor(thisForm.Color))) return false;	
	if(!(isValidMVIN(thisForm.VIN))) return false;	
	if(!(isValidSelectTransmission(thisForm.Transmission))) return false;
	if(!(isValidPayoff(thisForm.Payoff))) return false;
	if(!(isValidValue(thisForm.Value))) return false;
	if(!(isValidNMComments(thisForm.Comments))) return false;	
return true;
}
//////////////////////////// Quick trade value /////////////////////////////////
function validatequickvaluetrade(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;		
	if(!(isValidMVIN(thisForm.VIN))) return false;	
	if(!(isValidMMMileage(thisForm.Mileage))) return false;	
	if(!(isValidSelectCondition(thisForm.Condition))) return false;
	if(!(isValidSelectBankloan(thisForm.Bankloan))) return false;
	if(!(isValidPayoff(thisForm.Payoff))) return false;
	if(!(isValidNMComments(thisForm.Comments))) return false;	
return true;
}
//////////////////////////// Optional VIN trade /////////////////////////////////
function validateoptionalvintrade(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(!(isValidNMZip(thisForm.Zip))) 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(!(isValidMakeYear(thisForm.MakeYear))) return false;	
	if(!(isValidMake(thisForm.Make))) return false;
	if(!(isValidModel(thisForm.Model))) return false;
	if(!(isValidNMVIN(thisForm.VIN))) return false;
	if(!(isValidSelectDriveTrian(thisForm.DriveTrian))) return false;
	if(!(isValidSelectUpholstery(thisForm.Upholstery))) return false;
	if(!(isValidSelectEngineCondition(thisForm.EngineCondition))) return false;
	if(!(isValidSelectTransCondition(thisForm.TransCondition))) return false;
	if(!(isValidSelectExteriorCondition(thisForm.ExteriorCondition))) return false;
	if(!(isValidSelectInteriorCondition(thisForm.InteriorCondition))) return false;
	if(!(isValidSelectBankloan(thisForm.Bankloan))) return false;
	if(!(isValidNMComments(thisForm.Comments))) return false;	
return true;
}
//////////////////////////// Quick Quote Validation /////////////////////////////////
function validatequickquote(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,' 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(!(isValidSelectBox(thisForm.vehicletype, 'Vehicle Type'))) return false;	
	var m1= (document.getElementById("vehicletype").value);
	//alert(m1);
	if (m1=="Used")
		{
			if(!(isValidMake1(thisForm.Make1))) return false;
			if(!(isValidModel1(thisForm.Model1))) return false;
			if(!(isValidTrim1(thisForm.Trim1))) return false;
		
		}else if (m1=="New"){ 
			if(!(isValidSelectMake(thisForm.Make))) return false; 
			if(!(isValidSelectModel(thisForm.Model))) return false;
			if(!(isValidSelectTrim(thisForm.Trim))) return false;
			
			}	
	//if(!(isValidSelectBox(thisForm.vehicletype, 'Vehicle Type'))) return false;	
	//if(!(isValidMake(thisForm.Make))) return false;
	if(!(isValidModel(thisForm.Model))) return false;
	if(!(isValidTrim(thisForm.Trim))) return false; */
	// Trim Validation
	if(!(isValidPriceRangenew(thisForm.PriceRange))) return false;
	if(!(isValidSelectInterestLevel(thisForm.InterestLevel))) return false;	
return true;
}

//////////////////////////// Used Quick Quote Validation  /////////////////////////////////
function validatequickquoteused(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,' Day Phone '))) return false;
	if(!(isValidNMPhone(thisForm.ResPhone1,thisForm.ResPhone2,thisForm.ResPhone3,thisForm.ResPhone,' Evening Phone '))) return false;
	
	if(!(isValidMake1(thisForm.Make1))) return false;
	if(!(isValidModel1(thisForm.Model1))) return false;
	if(!(isValidTrim1(thisForm.Trim1))) return false;	
	if(!(isValidPriceRangenew(thisForm.PriceRange))) 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;
}
////////////////////////////////Join Our Mailing List ///////////////////////////

function validatemailinglist(thisForm)
{
	
	if(!(isValidEmail(thisForm.Email))) return false;
    return true;
}

function validatepreownedquickquote(thisForm)
{//alert('here');
	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(!(isValidMakePreOwned(thisForm.Make))) return false;
	if(!(isValidModelPreOwned(thisForm.Model))) return false;
	if(!(isValidTrimPreOwned(thisForm.Trim))) return false; 
	// Trim Validation
	if(!(isValidPriceRange(thisForm.PriceRange))) return false;
	if(!(isValidSelectInterestLevel(thisForm.InterestLevel))) return false;	
return true;
}


function validatefindforme(thisForm)
{
	if(!(isValidSelTitle(thisForm.Title))) return false;
	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(!(isValidNMPhone(thisForm.ResPhone1,thisForm.ResPhone2,thisForm.ResPhone3,thisForm.ResPhone,' Evening Phone '))) return false;		
	if(!(isValidEmail(thisForm.Email))) return false;
	if(thisForm.vehtype[0].checked==true)
	{
		thisForm.type.value='New';
	}
	else
	{
		thisForm.type.value='Used';
	}
	if(!(isValidMakeYear(thisForm.MakeYear))) return false;	
	if(!(isValidMake(thisForm.Make))) return false;
	if(!(isValidModel(thisForm.Model))) return false;
	if(!(isValidTrim(thisForm.Trim))) return false; 
	if(!(isValidTextBox(thisForm.Color,'Color'))) return false;	
//thankYouOnSamePage(thisForm);
return true;
}


function validateestimate(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,' 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(!(isValidMake(thisForm.Make))) return false;
	if(!(isValidModel(thisForm.Model))) return false;
	if(!(isValidTrim(thisForm.Trim))) return false; 
	// Trim Validation
	if(!(isValidPriceRange(thisForm.PriceRange))) return false;
	if(!(isValidSelectInterestLevel(thisForm.InterestLevel))) return false;	
//thankYouOnSamePage(thisForm);
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;
}

function validateMoreInfoNew(thisForm)
{
		//alert('1');
	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 validateMoreInfoNewM(thisForm)
{
		//alert('1');
	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(!(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 validateQuickQuoteHome(thisForm)
{
		//alert('1');
	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(!(isValidSelectModel(thisForm.Model))) 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;		
	//thankYouOnSamePage(thisForm);
return true;
}

//////////////////////////////////////////// validate Collision appointment ////////////////
function validatecollisionapp(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,' 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(!(isValidNMTrim(thisForm.Trim))) return false;
	if(!(isValidNMMileage(thisForm.Mileage))) return false;
	
	if(!(isValidRequestDate2(thisForm.ReqDate))) return false;
	if(!(isValidAppointmentTime(thisForm.AppoinTime))) return false;

	if(!(isValidNMComments(thisForm.Comments))) return false;	
	//thankYouOnSamePage(thisForm);
return true;
}


function isValidMakePreOwned(Make)
{
	Make.value=removeLeadingAndTrailingChar(Make.value);
	if(Make.value=="" || Make.value=="Make")
	{
		alert("Enter Make");
		Make.focus();
		return false;
	}	
return true;
}
function isValidModelPreOwned(Model)
{
	Model.value=removeLeadingAndTrailingChar(Model.value);
	if(Model.value=="" || Model.value=="Model")
	{
		alert("Enter Model");
		Model.focus();
		return false;
	}	
return true;
}
function isValidTrimPreOwned(Trim)
{
	Trim.value=removeLeadingAndTrailingChar(Trim.value);
	if(Trim.value=="" || Trim.value=="Trim")
	{
		alert("Enter Trim");
		Trim.focus();
		return false;
	}	
return true;
}

function isValidRequestDate1(ReqDate)
{
	if(ReqDate.selectedIndex==0)
	{
		alert("Select Alternate Date to schedule an Appointment");
		ReqDate.focus();
		return false;
	}	
return true;
}
function isValidAppointmentTime1(AppoinTime)
{
	if (AppoinTime.selectedIndex==0 )
	{
		alert("Select Alternate Drop Off Time");
		AppoinTime.focus();
		return false;
	}
	if (AppoinTime.options[1].value=="Closed" )
	{
		checktime();
		return false;
	}
return true;	
}
function isValidAppointmentalternate(d1,d2,d3,d4)
{
	if( d1.options[d1.selectedIndex].value==d3.options[d3.selectedIndex].value && d2.options[d2.selectedIndex].value==d4.options[d4.selectedIndex].value)
	{
	alert("Select Alternate Drop Off Time");
	d4.focus();
	return false;
	}
	return true;
}
///////////////////////////////////Collision Appontment//////////////////////////
/*function validatecollisionappointment(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,' Day Phone '))) return false;
	if(!(isValidModel(thisForm.Model))) return false;
	if(!(isValidTrim(thisForm.Trim))) return false; 
	if(!(isValidNMMileage(thisForm.Mileage))) return false;
	if(!(isValidRequestDate(thisForm.ReqDate))) return false;
	if(!(isValidAppointmentTime(thisForm.AppoinTime))) return false;
	if(!(isValidServiceAdvisor(thisForm.ServiceAdvisor))) return false;
	if(!(isValidNMComments(thisForm.Comments))) return false;	
	//thankYouOnSamePage(thisForm);
return true;
}*/
//////////////////////////// Order Parts Validation /////////////////////////////////
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(!(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(!(isValidMakeYear(thisForm.MakeYear))) return false;	
	if(!(isValidMake(thisForm.Make))) return false;
	if(!(isValidModel(thisForm.Model))) return false;
	//if(!(isValidNMTrim(thisForm.Trim))) return false;
	if(!(isValidNMMileage(thisForm.Mileage))) return false;
	if(!(isValidMVIN(thisForm.VIN))) return false;	
	if(!(isValidNMComments(thisForm.Comments))) return false;	
//	thankYouOnSamePage(thisForm);
return true;
}

//////////////////////////// Body Shop /////////////////////////////////
function validatebodyshop(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,' 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(!(isValidNMTrim(thisForm.Trim))) return false;
	if(!(isValidNMMileage(thisForm.Mileage))) return false;
	/* if(!(isValidMVIN(thisForm.VIN))) return false;	 */
	if(!(isValidNMColor(thisForm.Color))) return false;	
	if(!(isValidNMComments(thisForm.Comments))) return false;	
//	thankYouOnSamePage(thisForm);
return true;
}

//////////////////////////// Schedule Services Validation 
//////////////////////////// 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(!(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(!(isValidResume(thisForm.resume))) 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;
		}
	//thankYouOnSamePage(thisForm);
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;			    		
	
/*	if(!(isValidNMComments(thisForm.FirstName))) return false;	
	if(!(isValidNMComments(thisForm.LastName))) return false;	
	if(!(isValidNMComments(thisForm.Email))) return false;	
	if(!(isValidNMPhone(thisForm.OffPhone1,thisForm.OffPhone2,thisForm.OffPhone3,thisForm.OffPhone))) return false;
	if(!(isValidNMPhone(thisForm.ResPhone1,thisForm.ResPhone2,thisForm.ResPhone3,thisForm.ResPhone))) return false;	*/		    		

//smallThankYouOnSamePage(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;  
}
//////////////////////////// Ask a Tech Validation /////////////////////////////////
function validateaskatech(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(!(isValidMPhone(thisForm.ResPhone1,thisForm.ResPhone2,thisForm.ResPhone3,thisForm.ResPhone,' Home Phone '))) return false;			    		
	if(!(isValidNMPhone(thisForm.OffPhone1,thisForm.OffPhone2,thisForm.OffPhone3,thisForm.OffPhone,' Work Phone '))) return false;
	if(!(isValidNMPhone(thisForm.MobPhone1,thisForm.MobPhone2,thisForm.MobPhone3,thisForm.MobPhone,' Mobile Phone '))) return false;
	if(!(isValidEmail(thisForm.Email))) return false;
	if(!(isValidEmail(thisForm.Confirm_Email))) return false;	
	if(thisForm.Email.value!=thisForm.Confirm_Email.value)
	{
		alert("E-mail and Confirm E-mail were not Equal");
		thisForm.Confirm_Email.select();
		return false;
	}
	if(!(isValidMakeYear(thisForm.MakeYear))) return false;	
	if(!(isValidMake(thisForm.Make))) return false;
	if(!(isValidModel(thisForm.Model))) return false;
	if(!(isValidMVIN(thisForm.VIN))) return false;	
	if(!(isValidNMMileage(thisForm.Mileage))) return false;		
	if(!(isValidNMComments(thisForm.Comments))) return false;	
	return true;
}
//////////////////////////// Recall Validation /////////////////////////////////
function validaterecall(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(!(isValidMPhone(thisForm.ResPhone1,thisForm.ResPhone2,thisForm.ResPhone3,thisForm.ResPhone,' Day Phone '))) return false;			    		
	if(!(isValidNMPhone(thisForm.OffPhone1,thisForm.OffPhone2,thisForm.OffPhone3,thisForm.OffPhone))) return false;
	if(!(isValidNMPhone(thisForm.MobPhone1,thisForm.MobPhone2,thisForm.MobPhone3,thisForm.MobPhone))) return false;
	if(!(isValidEmail(thisForm.Email))) 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;	
}	
//	 							Recall Validation 
function validatedetailedinfo(thisForm) {
	if(!(isValidSelTitle(thisForm.Title))) return false;
	if(!(isValidFirstName(thisForm.Name))) return false;
	if(!(isValidEmail(thisForm.Email))) return false;
	if(!(isValidZip(thisForm.Zip))) 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;  
}
//								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;
}
/////////////////////////////// Test Drive validation /////////////////////////

//////////////////////////////Customer Survey/////////////////////////////////////////
function validatecustomersurvey(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,' 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(!(isValidNMComments(thisForm.Comments))) return false;
	return true;
}
//////////////////////////////Customer Survey/////////////////////////////////////////
function validatebuyers(thisForm)
{		
	if(!(isValidSelTitle(thisForm.Title))) return false;	
	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;
	if(!(isValidMake(thisForm.Make))) return false;
	if(!(isValidModel(thisForm.Model))) return false;
	if(!(isValidMakeYear(thisForm.MakeYear))) return false;	
	if(!(isValidNMComments(thisForm.Comments))) return false;
	return true;
}
//////////////////////////////Extended Service/////////////////////////////////////////
function validateextededservice(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,' 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(!(isValidNMTrim(thisForm.Trim))) return false;
	if(!(isValidNMMileage(thisForm.Mileage))) return false;	
	if(!(isValidMVIN(thisForm.VIN))) return false;	
	if(!(isValidNMComments(thisForm.Comments))) return false;	
	return true;
}
function validateprayer_request(thisForm)
{	
	if(!(isValidSelTitle(thisForm.Title))) return false;
	if(!(isValidFirstName(thisForm.FirstName))) return false;
	if(!(isValidEmail(thisForm.Email))) return false;
	if(!(isValidMPhone(thisForm.ResPhone1,thisForm.ResPhone2,thisForm.ResPhone3,thisForm.ResPhone,' Phone '))) return false;
	if(!(isValidNMComments(thisForm.prayer_request))) return false;	
	thankYouOnSamePage(thisForm);
return false;
}

function getFormValues(thisForm)
{
	var strfrmval ='';
	for( i = 0 ; i < thisForm.elements.length; i++ )
	{

		var elename = thisForm.elements[i].name;
		var eledata = thisForm.elements[i].value;
		var eletype = thisForm.elements[i].type;
		
		if ( eletype == 'radio' ) {
			if ( thisForm.elements[i].checked ) {
				strfrmval += elename+ '=' + eledata+ '&' ;
				//alert(eledata);
			}
		}
		else {
		strfrmval += elename+ '=' + eledata+ '&' ;
		}
	}
	strfrmval = strfrmval.substr(0, strfrmval.length-1);
	return strfrmval;	
}

function GetHTTPRequest() {
	var xmlHTTP = false ;
	if (window.XMLHttpRequest) {
		try {
		  xmlHTTP = new XMLHttpRequest();
		} catch (e) {
		 xmlHTTP = false;
		}
	  } else if (window.ActiveXObject) {
		// For Internet Explorer on Windows
		try {
		  xmlHTTP = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		  try {
			xmlHTTP = new ActiveXObject("Microsoft.XMLHTTP");
		  } catch (e) {
			xmlHTTP = false;
		  }
		}
	  }
return xmlHTTP;
}
function clientSideInclude4Param(id, url, method,  postval, pagetype) {
	
 // For Safari, Firefox, and other non-MS browsers
  var req = GetHTTPRequest();
  var element = document.getElementById(id);
  if (req) {
    // Synchronous request, wait till we have it all
	if (method.toUpperCase() == 'POST') {
    req.open(method, url, true);
	req.onreadystatechange = function() { mycallback(req, element, pagetype); } ;
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    req.send(postval); }
	if (method.toUpperCase() == 'GET') {
    req.open(method, url+'?'+postval, true);
	req.onreadystatechange = function() { mycallback(req, element, pagetype); } ;
    req.send(null); }	
 //   element.innerHTML = req.responseText;
  }
  else {
    element.innerHTML =    "Sorry, your browser does not support " +   "XMLHTTPRequest objects. This page requires " +     "Internet Explorer 5 or better for Windows, " + "or Firefox for any system, or Safari. Other " +       "compatible browsers may also exist.";
  }
}
function thankYouOnSamePage(thisForm) 
{

	var myFormData = getFormValues(thisForm) ;
	document.getElementById('submitbuttontable').innerHTML = mySubmitData;
		//alert ( myFormData );
	clientSideInclude4Param('centerBg','../cthankyoumesseges/mythankyou.jsp','POST',myFormData,'big');
}
function  mycallback(myreq, myelement, mypagetype)
{
	 
	if (myreq.readyState == 4 )
	{
//		alert('Thanks For Visiting...');
	 myelement.innerHTML = myreq.responseText;	
	 if(mypagetype == 'big') 
	 	{
		document.getElementById('subheaderimage').className = 'thankyousubheader';
		document.getElementById('subheaderimage').title = 'Thank You';
		//document.getElementById('subheaderimage').innerHTML = mySubHeaderData;
	 	}
	 if(mypagetype == 'coupon') {
	 document.getElementById('myindicate').innerHTML = ' ';	
	 document.getElementById('couponcontent').style.verticalAlign = 'top';
	 }
	}
}
function moreInfoOnSamePage(myFormData) 
{	
	clientSideInclude4Param('MoreInfoInner', '../onlinespecials/mymoreinfo.jsp', 'POST', myFormData,'small');
	document.getElementById('MoreInfoInner').style.display='block';		
}
function smallThankYouOnSamePage(thisForm) 
{
	var myFormData = getFormValues(thisForm) ;
	document.getElementById('moreinfosubmitbuttonTD').innerHTML = mySubmitData;
	clientSideInclude4Param('moreInfoCenterBg','../onlinespecials/morethankyou.jsp','POST',myFormData,'small');
}
function couponThankYouOnSamePage(thisForm) 
{
	var myFormData = getFormValues(thisForm) ;
	document.getElementById('MySubmitCoupon').innerHTML = mySubmitData;
	clientSideInclude4Param('couponcontent','../cthankyoumesseges/mythankyou.jsp','POST',myFormData,'coupon');
	
}
function closediv(divName){
	//document.getElementById(divName).innerHTML=''; 	
		document.getElementById(divName).style.display='none';
}
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 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 isLessThanOrEqualCurrentDate(dt) {
	var currentDate = new Date();
    if ( dt <= currentDate )
		return true;
	else 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 Test_MM_showHideLayers_old(myid, myval) {
	var divlist = new Array('newcarsdiv','preowneddiv','specialsdiv','servicediv','researchdiv','financediv','aboutusdiv');
	var i, v, obj;
	for (i=0;i<divlist.length;i++)
	{
		if ((obj=MM_findObj(divlist[i]))!=null) 
		{	
			if ( divlist[i] == myid )  v = myval;	else 	v = 'hide';	
			if (obj.style) { 
				obj=obj.style;
				v=(v=='show')?'visible':((v=='hide')?'hidden':v); 
			}
    		obj.visibility=v;
		}

	}
}*/
/*function Test_MM_showHideLayers(myid, myval) {
	
	var divlist = new Array('newcarsdiv','preowneddiv','specialsdiv','servicediv','researchdiv','bodyshopdiv','financediv','aboutusdiv','homehomediv');
	var i, v, obj;	
	
	

	for (i=0;i<divlist.length;i++)
	{
		if ((obj=MM_findObj(divlist[i]))!=null) 
		{	
		
			if ( divlist[i] == myid )  {
				v = myval;	
				var newid = divlist[i].substr(0, divlist[i].length-3);
				//alert( newid );
				if (v=='show')
					{ 
					if (document.getElementById(newid).className.search('hover') == -1 ) 
					document.getElementById(newid).className += 'hover' ; 
					}
				else 
					document.getElementById(newid).className = document.getElementById(newid).className.replace('hover','');
			}
			else { 
				v = 'hide';	
			}
			
			
			if (obj.style) { 
				obj=obj.style;
				v=(v=='show')?'visible':((v=='hide')?'hidden':v); 
			}
    		obj.visibility=v;
		}

	}
		if(myval == 'show')  Myshowiframe(myid,'DivCommercial'); 	else Myhideiframe('DivCommercial');	

}
function Myhideiframe(d3)
 {
 var d1=document.getElementById(d3);
 d1.style.display='none';
 }
 
 function Myshowiframe(d1,d2)
 {
	 
 var div=document.getElementById(d1);
 var frame=document.getElementById(d2);
	frame.style.width = div.offsetWidth;
    frame.style.height = div.offsetHeight;
    frame.style.top = div.offsetTop;
	//alert(div.style.top);
    frame.style.left = div.offsetLeft;
    var brow=navigator.appName;
	if(brow=="Netscape")
	{
		frame.style.display = 'none';
	} else if(brow=="Microsoft Internet Explorer") {
	frame.style.display = 'block';	
	}
 }*/

function Test_MM_showHideLayershome(myid, myval) {
	var divlist = new Array('homenewcarsdiv','homepreowneddiv','homespecialsdiv','homeservicediv','homeresearchdiv','homebodyshopdiv','homefinancediv','homeaboutusdiv','homehomediv');
	var i, v, obj;
	for (i=0;i<divlist.length;i++)
	{
		if ((obj=MM_findObj(divlist[i]))!=null) 
		{	
			if ( divlist[i] == myid )  {
				v = myval;	
				var newid = divlist[i].substr(0, divlist[i].length-3);
				//alert( newid );
				if (v=='show')
					document.getElementById(newid).className += 'hover' ;
				else 
					document.getElementById(newid).className = document.getElementById(newid).className.replace('hover','');
			}
			else { 
				v = 'hide';	
			}
			
			
			if (obj.style) { 
				obj=obj.style;
				v=(v=='show')?'visible':((v=='hide')?'hidden':v); 
			}
    		obj.visibility=v;
		}

	}
	
}

function Submenu_MM_showHideLayers(myid, myval) {
	//alert('called' + myid + myval);
	var divlist = new Array('selectamodeldiv', 'virtualbrouchurediv','vehiclereviewdiv');
	var parentdivlist = new Array('newcarsdiv','researchdiv','researchdiv');
	var i, v, obj;
	for (i=0;i<divlist.length;i++)
	{
		if ((obj=MM_findObj(divlist[i]))!=null) 
		{	v = myval;	
		
				if (obj.style) { 
					obj=obj.style;
					v=(v=='show')?'visible':((v=='hide')?'hidden':v); 
					}
				if ( divlist[i] == myid ) {
				//	alert('found' + myid + myval + v);
					obj.visibility=v;
					Test_MM_showHideLayers(parentdivlist[i] ,myval)
				}
		}

	}
}


/*function Test_MM_ChangeMouseOverImage(imageId, eventType)
{
	var imagelist = new Array('newcarsimg','preownedimg','specialsimg','serviceimg','researchimg','financeimg','aboutusimg'); 
	var i, v, obj;
	for (i=0;i<imagelist.length;i++)
	{
		if ((obj=MM_findObj(imagelist[i]))!=null) 
		{	
			if ( imagelist[i] == imageId ) 
			{
				var currentSrc = obj.src;
				alert('Under Process');
				
			}
		}
	}	
}*/

function makeCenterAligned( mypos ) {
	var divlist = new Array('newcarsdiv','preowneddiv','specialsdiv','servicediv','researchdiv','financediv','aboutusdiv');
	var leftpos = new Array(2, 94, 184 ,315, 383, 447, 511);
	for (i=0;i<divlist.length;i++)
	{
		document.getElementById(divlist[i]).style.left= mypos + leftpos[i];
	}
	
}
/* Home Page */
function mouseoverFlash(imageElement){
var x= imageElement;
	document.myFlash.SetVariable("rollModel", x);
}
function mouseoutFlash(imageId){
	document.myFlash.SetVariable("rollModel","");	

}

function writeFlash(path, delay, make, modelString, divid)
{
//alert(path);
//alert(modelString);

var cont = '<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="myFlash" width="436" height="238"><param name="movie" value="' + path+ 'loopingTemplate.swf?path=' + path+ '&make=' + make+ '&timedelay=' + delay+ '&modelString=' + modelString+ '&rollModel="><param name="quality" value="high"><param name="menu" value="false"><param name="wmode" value="transparent"><embed wmode="transparent" src="' + path+ 'loopingTemplate.swf?path=' + path+ '&timedelay=' + delay+ '&make=' + make+ '&modelString=' + modelString+ '&rollModel=" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="myFlash" width="436" height="238"></embed></object>' ;
document.getElementById('flash_file').innerHTML = cont;
}


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];
			}
	}
}



/* Parts/Service Issue / Problem on New Type */
function getPartsServicePath(CouponId, ImageElementId) {
  var req = GetHTTPRequest();
  var element = document.getElementById(ImageElementId);
  if (req) {
    req.open('GET', 'setImageCoupon.jsp?CouponId='+CouponId, true);
	req.onreadystatechange = function() { PartsServiceCB(req, element); } ;
    req.send(null); 
	}	
 }
function  PartsServiceCB(myreq, myelement) {
	if (myreq.readyState == 4 )
	{
//		alert(myreq.responseText);
		myelement.src= myreq.responseText;
//		myelement.alt= myreq.responseText;
	}
}

function load()
 {
document.getElementById('cars').style.display="block";
document.getElementById('trucks').style.display="none";
}

function fun1()
{
document.getElementById('cars').style.display="block";
document.getElementById('trucks').style.display="none";
}
function fun2()
{
document.getElementById('cars').style.display="none";
document.getElementById('trucks').style.display="block";
}

/* 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;
}

/* Sell Us Ur Car */
function validatesellusyourcar(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,' 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(!(isValidTrim(thisForm.Trim))) return false;
	if(!(isValidTextBox(thisForm.Color,'Color'))) return false;	
	
	if(!(isValidTextBox(thisForm.TotalTobeFinance,'Total to be Finance'))) return false;	
	if(!(isValidSelectBox(thisForm.Tradein,'Trade-in'))) return false;		
	if(!(isValidMVIN(thisForm.VIN))) return false;	
	if(!(isValidSelectTransmission(thisForm.Transmission))) return false;
	if(!(isValidSelectBox(thisForm.OriginallyPurchased, 'Originally Purchased'))) return false;		
	if(!(isValidSelectBox(thisForm.HaveYouServicedYourCarHere, 'Have You Serviced Your Car Here'))) return false;		
	if(!(isValidSelectBox(thisForm.AnyAccidentsPaintwork, 'Any Accidents/Paintwork'))) return false;		
	if(!(isValidPayoff(thisForm.Payoff))) return false;
	if(!(isValidSelectBox(thisForm.VehicleTitle, 'Vehicle Title'))) return false;		
	
//	if(!(isValidValue(thisForm.Value))) return false;
	//if(!(isValidNMComments(thisForm.TradeComments))) return false;	
	//thankYouOnSamePage(thisForm);
return true;
}
function validatecustomrreferal(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(!(isValidNMComments(thisForm.Comments))) return false;	
	thankYouOnSamePage(thisForm);
return false;
}

/* Parts/Service Issue / Problem on New Type */
function getPartsServicePath(CouponId, ImageElementId) {
  var req = GetHTTPRequest();
  var element = document.getElementById(ImageElementId);
  if (req) {
    req.open('GET', 'setImageCoupon.jsp?CouponId='+CouponId, true);
	req.onreadystatechange = function() { PartsServiceCB(req, element); } ;
    req.send(null); 
	}	
 }
function  PartsServiceCB(myreq, myelement) {
	if (myreq.readyState == 4 )
	{
//		alert(myreq.responseText);
		myelement.src= myreq.responseText;
//		myelement.alt= myreq.responseText;
	}
}



/*function load()
 {
document.getElementById('maketabsdodgeouter').style.display="block";
document.getElementById('maketabsjeepouter').style.display="none";

}

function fun1()
{
document.getElementById('maketabsdodgeouter').style.display="block";
document.getElementById('maketabsjeepouter').style.display="none";
document.getElementById('flash_file').innerHTML = flashInner ; 

}
function fun2()
{
document.getElementById('maketabsdodgeouter').style.display="none";
document.getElementById('maketabsjeepouter').style.display="block";
document.getElementById('flash_file').innerHTML = flashInner ; 

}

function dynamicFlashAndTabMouseOverEffects(path, delay, make, modelString, divid ) {
var tabArray = new Array('maketabsdodgeouter', 'maketabsjeepouter', 'maketabschryslerouter');
for (var i=0; i < tabArray.length; i++)
	{
		if ( divid == tabArray[i] ) document.getElementById(tabArray[i]).style.display="block";
		else document.getElementById(tabArray[i]).style.display="none";
	}
var flashInner = '<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="myFlash" width="452" height="215"><param name="movie" value="' + path+ 'loopingTemplate.swf?path=' + path+ '&make=' + make+ '&timedelay=' + delay+ '&modelString=' + modelString+ '&rollModel="><param name="quality" value="high"><param name="menu" value="false"><param name="wmode" value="transparent"><embed wmode="transparent" src="' + path+ 'loopingTemplate.swf?path=' + path+ '&timedelay=' + delay+ '&make=' + make+ '&modelString=' + modelString+ '&rollModel=" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="myFlash" width="452" height="215"></embed></object>';
document.getElementById('flash_file').innerHTML = flashInner ; 
return;
}
*/
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;	
}

////////////////////////////////////Find it for Me//////////////////////////////////////////////
function validatefindit(thisForm) 
{	
	//if(!(isValidTitle(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;	
	if(!(isValidMakeYear(thisForm.MakeYear))) return false;	
	if(!(isValidMake(thisForm.Make))) return false;
	if(!(isValidModel(thisForm.Model))) return false;
	if(!(isValidTrim(thisForm.Trim))) return false; 
	if(!(isValidTextBox(thisForm.Color,'Color'))) return false;	
	if(!(isValidNMComments(thisForm.Comments))) return false;				
	return true; 
}

//////////////////////////// FLEET PROGRAM OVERVIEW Validation /////////////////////////////////
function validatefleetprogramoverview(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(!(isValidMPhone(thisForm.OffPhone1,thisForm.OffPhone2,thisForm.OffPhone3,thisForm.OffPhone,' Day Phone '))) return false;
	if(!(isValidEmail(thisForm.Email))) return false;
	if(!(isValidNMPhone(thisForm.ResPhone1,thisForm.ResPhone2,thisForm.ResPhone3,thisForm.ResPhone,' Evening Phone '))) return false;	
		//thankYouOnSamePage(thisForm);
return true;
}

function validatecarfinder(thisForm)
{		
	
	if(!(isValidSelTitle(thisForm.Title))) return false;
	if(!(isValidFirstName(thisForm.FirstName))) return false;
	if(!(isValidLastName(thisForm.LastName))) return false;
	if(!(isValidMPhone(thisForm.OffPhone1,thisForm.OffPhone2,thisForm.OffPhone3,thisForm.OffPhone,' Home Phone '))) return false;
	if(!(isValidEmail(thisForm.Email))) return false;

} 

function validatenewsletter(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,' Phone '))) return false;
} 


function embedflash(d1,d2,d3)
{
	//alert(d1);
	//alert(d2);
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="FlashObject" width="'+d2+'" height="'+d3+'"><param name="movie" value="'+d1+'loopingTemplate.swf"><param name="quality" value="high"><param name="menu" value="false"><param name="wmode" value="transparent"><embed wmode="transparent" src="'+d1+'loopingTemplate.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="FlashObject" width="'+d2+'" height="'+d3+'"></embed></object>')	
}

/* Rent a Car */

function checkValidDate(thisDate, condition)
{
	var sel_date = thisDate.value;
	var dArray = splitDateString(sel_date);
	
	var sel_Month = parseInt(dArray[0], 10) - 1;
	var sel_Day = parseInt(dArray[1], 10);
	var sel_Year = parseInt(dArray[2], 10);
	
	var selected_date = new Date(sel_Year, sel_Month, sel_Day);
	var today = new Date();
	if ( condition == 'lesser') { 
		if(today >= selected_date)
		{
			alert('Selected date is less than the current date');
			thisDate.focus();
			displayDatePicker(thisDate.name);  
			return false;
		}
	}
	if ( condition == 'greater') { 
		if(today <= selected_date)
		{
			alert('Selected date is greater than the current date');
			thisDate.focus();
			displayDatePicker(thisDate.name);  
			return false;
		}
	}	
	return true;
}
function checkValidTime(thisTime, disp)
{
	if (thisTime.selectedIndex==0)
	{
		alert("Select "+ disp);
		thisTime.focus();
		return false;
	}
return true;
}
function validaterentacar(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,'Best Phone Number'))) return false;
  	if(thisForm.PickDate.value == "")	
	{ 
		alert('Select Pick up Date'); 
		thisForm.PickDate.focus(); 
		displayDatePicker('PickDate');  
		return false; 
	}
	if(!(checkValidDate(thisForm.PickDate,'lesser'))) return false;	
	if(!(checkValidTime(thisForm.PickTime, 'Pick up Time'))) return false;	
	if(!(thisForm.DropDate.value == "")) { if(!(checkValidDate(thisForm.DropDate,'lesser'))) return false; }	
	//if(!(thisForm.ExpDate.value == "")) { if(!(checkValidDate(thisForm.ExpDate,'lesser'))) return false; }	
	//if(!(thisForm.DOB.value == "")) { if(!(checkValidDate(thisForm.DOB,'greater'))) return false; }
	//if(!(isValidNMDOB(thisForm.DobMonth,thisForm.DobDate,thisForm.DobYear,thisForm.DOB))) return false;
	var DobMonth = thisForm.DobMonth.options[thisForm.DobMonth.selectedIndex].text;
	var DobDate = thisForm.DobDate.options[thisForm.DobDate.selectedIndex].text;
	var DobYear = thisForm.DobYear.options[thisForm.DobYear.selectedIndex].text;
	thisForm.DOB.value=DobMonth+"-"+DobDate+"-"+DobYear;

	//thankYouOnSamePage(thisForm);
	
return true;
}

function populate2(d4)
{
	//alert(d3);
	//alert(d4);
	var day=0;
	if(d4!="")
	{
	
	if(d4=='January')
	{
	day=31;	
	}
	if(d4=='February')
	{
	day=29; 
	}
	if(d4=='March')
	{
	day=31;	
	}
	if(d4=='April')
	{
	day=30;	
	}
	if(d4=='May')
	{
	day=31;	
	}
	if(d4=='June')
	{
	day=30;	
	}
	if(d4=='July')
	{
	day=31;	
	}
	if(d4=='August')
	{
	day=31;	
	}
	if(d4=='September')
	{
	day=30;	
	}
	if(d4=='October')
	{
	day=31;	
	}
	if(d4=='November')
	{
	day=30;	
	}
	if(d4=='December')
	{
	day=31;	
	}
	
	}
	if(day!=0)
	{
		day=day+1;
		
	document.RentACar.DobDate.options.length=0;	
		
	document.RentACar.DobDate.options[0]=new Option("Date");	
	for(j=1;j<day;j++)
	{
	document.RentACar.DobDate.options[j]=new Option(j);		
	}
	}

}

function formatDollarNew(obj)
{
	var num = obj.value
	num = num.toString().replace(/\$|\,/g,'');
	//alert(num);
	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!="") {
		obj.value=((sign)?'':'-') + '$' + num + '.' + cents;
		//alert(obj.value);
		return true;
	}	
	else {
		obj.value="";
		return false;
	}
}
//////////////////////////// Schedule Services Validation 
function validatescheduleservice(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,' 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(!(isValidNMTrim(thisForm.Trim))) return false; */
	if(!(isValidNMMileage(thisForm.Mileage))) 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(!(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(!(isValidMakeYear(thisForm.MakeYear))) return false;	
	if(!(isValidMake(thisForm.Make))) return false;
	if(!(isValidModel(thisForm.Model))) return false;
	if(!(isValidNMTrim(thisForm.Trim))) return false;
	if(!(isValidNMMileage(thisForm.Mileage))) return false;	
	if(!(isValidRequestDate(thisForm.ReqDate))) return false;
	if(!(ValidateAppointmentTimeBodyShop(thisForm.AppoinTime))) return false;
	if(!(isValidNMComments(thisForm.Comments))) return false;	
return true;
}

function validatesetuptestdrive(thisForm)
{
	if(!(isValidSelTitle(thisForm.Title))) return false;
	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(!(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(!(isValidSelectModel(thisForm.Model))) return false;
	if(!(isValidSelectTrim(thisForm.Trim))) return false;	
	//if(!(isValidPriceRange(thisForm.PriceRange))) return false;
	if(!(isValidSelectInterestLevel(thisForm.InterestLevel))) return false;	
	if(!(isValidRequestDate(thisForm.ReqDate))) return false;
	if(!(ValidateAppointmentTime(thisForm))) 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]$/;
		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;
	//var formName = formname;
	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;
	}
//	var optedInputTime = formatOptedInputTime(document.ScheduleService.AppoinTime,document.ScheduleService.apm);
	if (!appointmentTimeAvailibility(timeRange.value, optedTime.value + amOrPm.value)) {
		alert("Enter timings within the range specified")
		thisForm.AppoinTime.focus();
		return false;
	}
	else {
		//alert("scheduled");
		return true;
	}
	return false;
}

/*
function formatOptedInputTime(optedInputTime,optedAmPm){
	//1:45 > 01:45, 1:4 > 01:40, 12 > 12:00,
	var formatedInputTime = optedInputTime.value;
	if(formatedInputTime.indexOf(":")== "1"){
		formatedInputTime = "0"+formatedInputTime;
	}
	if(formatedInputTime.indexOf(":")== "2" && formatedInputTime.length == "4" ){
		formatedInputTime = formatedInputTime+"0";
	}
	return formatedInputTime+document.ScheduleService.apm.value;
}
*/
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 valid1(thisobj)
{

	if(!(ValidateAppointmentTimeTest(document.Test_Drive.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 ******************************/

function validtimeformatdrive(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.Test_Drive.AppoinTime.focus();
			return false;
		}
		else validCharAppdrive(thisobj);
	}
return true;
}

function ValidateAppointmentTimeTest(thisobj)
{ 
	var k =validtimeformatdrive(thisobj);
	
	if(document.Test_Drive.AppoinTime.value=="")
	{ 
	alert("Please Enter Appointment Time");
		document.Test_Drive.AppoinTime.focus();
		return false;
	}
	if(document.Test_Drive.apm.selectedIndex==0)
	{
		alert("Please Select either AM/PM");
		document.Test_Drive.apm.focus();
		return false;
	} 
	if(k) {
	
		var a =document.Test_Drive.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.Test_Drive.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.Test_Drive.AppoinTime.focus();
								return false;
							}
						 }
						else{ 
						alert("Please select within the range specified above");
						document.Test_Drive.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.Test_Drive.AppoinTime.focus();
								return false;
							}
						}
						else if(t1<1200)
						{
							if((opt<t1)  || (opt>=1200))
							{
								alert("Enter timings within the range specified above");
								document.Test_Drive.AppoinTime.focus();
								return false;
							}
						}
					}
					else
					{
						if((t2<1200) && !(opt>=1200))
						{
							if(opt>t2)
							{
								alert("Enter timings within the range specified above");
								document.Test_Drive.AppoinTime.focus();
								return false;
							}
						}						
					}
				}
			else if((document.Test_Drive.timecanboptd.value!="Closed") || (document.Test_Drive.timecanboptd.value!="CLOSED") || (document.Test_Drive.timecanboptd.value!="closed"))
			{
				alert("Enter Timings to be scheduled for");
				document.Test_Drive.AppoinTime.focus();
				return false;
			}
			else
			{	alert("Sorry, Service not available on the selected date!");
				document.Test_Drive.AppoinTime.focus();
				return false;
			}
			return true;
	}
	else
	{
		return false;
	}
}
function validCharAppdrive(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);
	//alert("mins"+optmins); alert("mins"+optminsx+" "+optminsy);
	//var apm = ""
	//if(b.indexOf("AM")>0){apm="AM";}else{apm="PM";}
				if(((isNaN(opthrs[0])) || (isNaN(opthrs[1]))) &&(opthrs.indexOf(":")>0))
					{
						opthrs='0'+opthrs;		
					}
					if(opthrs>12)
					{
						alert("Enter proper timings");
						document.Test_Drive.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.Test_Drive.AppoinTime.focus();
									return false;
								}
								if(opthrs.indexOf(":")>0)
								{
								thisobj.value=opthrs+optmins;	
								}
								else
								thisobj.value=opthrs+":"+optmins;
	}
return true;
}



/******************* 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);
	//alert("mins"+optmins); alert("mins"+optminsx+" "+optminsy);
	//var apm = ""
	//if(b.indexOf("AM")>0){apm="AM";}else{apm="PM";}
				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;
}

/*********************************************** Finance Form validatation ****************************************************/

function validateFinance(FinanceForm)
{
	if (FinanceForm.FirstName.value=="" )
	{
		alert("Enter First Name");
		FinanceForm.FirstName.focus();
		return false;
	}
	if (FinanceForm.FirstName.value!="")
		{
			  FinanceForm.FirstName.value=removeLeadingAndTrailingChar(FinanceForm.FirstName.value);
			  if(FinanceForm.FirstName.value.length=="0")
			     { 
					alert("Enter First Name");
					FinanceForm.FirstName.focus();
					return false;	
				 }
		}
	
	if (FinanceForm.LastName.value=="" )
	{
		alert("Enter Last Name");
		FinanceForm.LastName.focus();
		return false;
	}
	if (FinanceForm.LastName.value!="")
		{
			  FinanceForm.LastName.value=removeLeadingAndTrailingChar(FinanceForm.LastName.value);
			  if(FinanceForm.LastName.value.length=="0")
			     { 
					alert("Enter Last Name");
					FinanceForm.LastName.focus();
					return false;	
				 }
	}
		/*if (FinanceForm.DobDate.value.length<1)
		{
			alert("Enter Date Of Birth");
			FinanceForm.DobDate.focus();
			return false;
		}
	
		if (FinanceForm.DobDate.value<=0 || FinanceForm.DobDate.value>31)
		{
			alert("Enter Vaild Date");
			FinanceForm.DobDate.focus();
			return false;
		}
		if (FinanceForm.DobMonth.value.length<1)
		{
			alert("Enter Date Of Birth");
			FinanceForm.DobMonth.focus();
			return false;
		}
		if (FinanceForm.DobMonth.value<=0 || FinanceForm.DobMonth.value>12)
		{
			alert("Enter Vaild Month");
			FinanceForm.DobMonth.focus();
			return false;
		}
		if (FinanceForm.DobYear.value.length<4)
		{
			alert("Enter Date Of Birth");
			FinanceForm.DobYear.focus();
			return false;
		}
		if (FinanceForm.DobYear.value<=1900 || FinanceForm.DobYear.value>2000)
		{
			alert("Enter Vaild Year");
			FinanceForm.DobYear.focus();
			return false;
		}*/
		
	if (FinanceForm.Address.value!="")
	{
	  FinanceForm.Address.value=removeLeadingAndTrailingChar(FinanceForm.Address.value);
	}
	if (FinanceForm.City.value!="")
	{
	  FinanceForm.City.value=removeLeadingAndTrailingChar(FinanceForm.City.value);
	}
	
	/*if (FinanceForm.Street.value=="" )
	{
		alert("Enter Street");
		FinanceForm.Street.focus();
		return false;
	}
	if (FinanceForm.Street.value!="")
		{
			  FinanceForm.Street.value=removeLeadingAndTrailingChar(FinanceForm.Street.value);
			  if(FinanceForm.Street.value.length=="0")
			     { 
					alert("Enter Street");
					FinanceForm.Street.focus();
					return false;	
				 }
	}
	if (FinanceForm.City.value=="" )
	{
		alert("Enter City");
		FinanceForm.City.focus();
		return false;
	}
	if (FinanceForm.City.value!="")
		{
			  FinanceForm.City.value=removeLeadingAndTrailingChar(FinanceForm.City.value);
			  if(FinanceForm.City.value.length=="0")
			     { 
					alert("Enter City");
					FinanceForm.City.focus();
					return false;	
				 }
	}*/
	
	if (FinanceForm.State.selectedIndex==0)
	{
		alert("Select State");
		FinanceForm.State.focus();
		return false;
	}
	if (FinanceForm.Zip.value=="")
	{
		alert("Enter Zip Code ");
		FinanceForm.Zip.focus();
		return false;
	}

	if(FinanceForm.Zip.value.length<5)
	{
		alert("Enter Five Digit Zip Code");
		FinanceForm.Zip.focus();
		return false;
	}
		
	if (FinanceForm.Email.value=="" )
	{
		alert("Enter E-mail ID");
		FinanceForm.Email.focus();
		return false;
	}
	if (FinanceForm.Email.value!="" && !validemail(FinanceForm.Email.value))
		{ 
			alert("Enter Valid E-mail ID");
			FinanceForm.Email.focus();
			return false;		
		}
	
	if (FinanceForm.OffPhone1.value.length<3)
		{
			alert("Enter Day Phone Number");
			FinanceForm.OffPhone1.focus();
			return false;
		}
		if (FinanceForm.OffPhone2.value.length<3)
		{
			alert("Enter Day Phone Number");
			FinanceForm.OffPhone2.focus();
			return false;
		}
		if (FinanceForm.OffPhone3.value.length<4)
		{
			alert("Enter Day Phone Number");
			FinanceForm.OffPhone3.focus();
			return false;
		}
		
		if(!(isNonMandValidPhone(FinanceForm.ResPhone1,FinanceForm.ResPhone2,FinanceForm.ResPhone3,FinanceForm.ResPhone,'Evening Phone'))) return false;
		
	if (FinanceForm.SSN.value=="")
	{
		alert("Enter Social Security Number");
		FinanceForm.SSN.focus();
		return false;
	}
	if (FinanceForm.SSN.value.length<9)
	{
		alert("Enter valid Social Security Number");
		FinanceForm.SSN.focus();
		return false;
	}
	if (FinanceForm.AnnualIncome.value!="" && !formatDollar(FinanceForm.AnnualIncome) ) 
	{
		alert("Enter Valid Annual Income");
		FinanceForm.AnnualIncome.select();
		return false;
	}
	if (parseFloat(FinanceForm.AnnualIncome.value)==0)
	{
		alert("Enter Valid Annual Income");
		FinanceForm.AnnualIncome.select();
		return false;
	}
	
	
	if (FinanceForm.Comments.value!="")
		{
			  FinanceForm.Comments.value=removeLeadingAndTrailingChar(FinanceForm.Comments.value);
		}
	
	if(document.FinanceForm.OffPhone1.value.length==3 && document.FinanceForm.OffPhone2.value.length==3 && document.FinanceForm.OffPhone3.value.length==4) {
			document.FinanceForm.OffPhone.value="("+document.FinanceForm.OffPhone1.value+") "+document.FinanceForm.OffPhone2.value+"-"+document.FinanceForm.OffPhone3.value;
		}

	if(document.FinanceForm.ResPhone1.value.length==3 && document.FinanceForm.ResPhone2.value.length==3 && document.FinanceForm.ResPhone3.value.length==4)
	{
		document.FinanceForm.ResPhone.value="("+document.FinanceForm.ResPhone1.value+") "+document.FinanceForm.ResPhone2.value+"-"+document.FinanceForm.ResPhone3.value;
	}
/*	if(document.FinanceForm.DobDate.value.length==2 && document.FinanceForm.DobMonth.value.length==2 && document.FinanceForm.DobYear.value.length==4)
	{
		document.FinanceForm.DOB.value="("+document.FinanceForm.DobDate.value+") "+document.FinanceForm.DobMonth.value+"-"+document.FinanceForm.DobYear.value;
	}*/
		
	return true;	
}


function mytabvalidateDOB(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 ==2) && (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;
}

///////////////////// non mandatory //////////////

function isNonMandValidPhone(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 isNonMandValidZip(Zip)
	{
		Zip.value=removeLeadingAndTrailingChar(Zip.value);
		if((Zip.value != "") && (Zip.value.length<5)){
		alert("Zip Should be Five Digits");
		Zip.focus();
		Zip.select();
		return false;
		}
		return true;
		
	}


function disableMonth(obj1,obj2){

       if(document.getElementById(obj1).value == "10+"){

                   document.getElementById(obj2).length = 1;

       }else{

                   document.getElementById(obj2).length = 12;

                   for(i=0;i<12;i++){

                   document.getElementById(obj2).options[i] = new Option(i,i);

       }

 }

}

/************************* Finance Appliction Ends ******************************/

/********************************* Special Needs Finance Appliction ****************************/

 
 function validateSpecialFinance(SpecialFinanceForm)
{
	
	if (SpecialFinanceForm.FirstName.value=="" )
	{
		alert("Enter First Name");
		SpecialFinanceForm.FirstName.focus();
		return false;
	}
	if (SpecialFinanceForm.FirstName.value!="")
	{
	  SpecialFinanceForm.FirstName.value=removeLeadingAndTrailingChar(SpecialFinanceForm.FirstName.value);
	  if(SpecialFinanceForm.FirstName.value.length=="0")
	     { 
			alert("Enter First Name");
			SpecialFinanceForm.FirstName.focus();
			return false;	
		 }
	}
	if (SpecialFinanceForm.LastName.value=="" )
	{
		alert("Enter Last Name");
		SpecialFinanceForm.LastName.focus();
		return false;
	}
	if (SpecialFinanceForm.LastName.value!="")
	{
	  SpecialFinanceForm.LastName.value=removeLeadingAndTrailingChar(SpecialFinanceForm.LastName.value);
	  if(SpecialFinanceForm.LastName.value.length=="0")
	     { 
			alert("Enter Last Name");
			SpecialFinanceForm.LastName.focus();
			return false;	
		 }
	}
	if (SpecialFinanceForm.Address.value!="")
	{
	  SpecialFinanceForm.Address.value=removeLeadingAndTrailingChar(SpecialFinanceForm.Address.value);
	}
	if (SpecialFinanceForm.City.value!="")
	{
	  SpecialFinanceForm.City.value=removeLeadingAndTrailingChar(SpecialFinanceForm.City.value);
	}
	if (SpecialFinanceForm.Zip.value=="")
	{
		alert("Enter Zip Code ");
		SpecialFinanceForm.Zip.focus();
		return false;
	}
	if(SpecialFinanceForm.Zip.value.length<5)
	{
		alert("Enter Five Digit Zip Code");
		SpecialFinanceForm.Zip.focus();
		return false;
	}		
	if (SpecialFinanceForm.Email.value=="" )
	{
		alert("Enter E-mail ID");
		SpecialFinanceForm.Email.focus();
		return false;
	}
	if (SpecialFinanceForm.Email.value!="" && !validemail(SpecialFinanceForm.Email.value))
	{ 
		alert("Enter Valid E-mail ID");
		SpecialFinanceForm.Email.focus();
		return false;		
	}
	
	if (SpecialFinanceForm.OffPhone1.value.length<3)
	{
		alert("Enter Day Phone Number");
		SpecialFinanceForm.OffPhone1.focus();
		return false;
	}
	if (SpecialFinanceForm.OffPhone2.value.length<3)
	{
		alert("Enter Day Phone Number");
		SpecialFinanceForm.OffPhone2.focus();
		return false;
	}
	if (SpecialFinanceForm.OffPhone3.value.length<4)
	{
		alert("Enter Day Phone Number");
		SpecialFinanceForm.OffPhone3.focus();
		return false;
	}
	if(!(isNonMandValidPhone(SpecialFinanceForm.ResPhone1,SpecialFinanceForm.ResPhone2,SpecialFinanceForm.ResPhone3,SpecialFinanceForm.ResPhone,'Evening Phone'))) return false;
	if (SpecialFinanceForm.DobYear.selectedIndex==0)
	{
		alert("Select Year");
		SpecialFinanceForm.DobYear.focus();
		return false;
	}
	if (SpecialFinanceForm.DobMonth.selectedIndex==0)
	{
		alert("Select Month");
		SpecialFinanceForm.DobMonth.focus();
		return false;
	}
	if (SpecialFinanceForm.DobDate.selectedIndex==0)
	{
		alert("Select Date");
		SpecialFinanceForm.DobDate.focus();
		return false;
	}
	if (SpecialFinanceForm.SSN.value=="")
	{
		alert("Enter Social Security Number");
		SpecialFinanceForm.SSN.focus();
		return false;
	}
	if (SpecialFinanceForm.SSN.value.length<9)
	{
		alert("Enter valid Social Security Number");
		SpecialFinanceForm.SSN.focus();
		return false;
	}
	if (SpecialFinanceForm.AnnualIncome.value!="" && !formatDollar(SpecialFinanceForm.AnnualIncome) ) 
	{
		alert("Enter Valid Annual Income");
		SpecialFinanceForm.AnnualIncome.select();
		return false;
	}
	if (parseFloat(SpecialFinanceForm.AnnualIncome.value)==0)
	{
		alert("Enter Valid Annual Income");
		SpecialFinanceForm.AnnualIncome.select();
		return false;
	}
	if (SpecialFinanceForm.YearsAtCurrResidence.selectedIndex=="0" && SpecialFinanceForm.MonthAtCurrResidence.selectedIndex=="0")
	{
		alert("Select Time at Current Residence");
		SpecialFinanceForm.YearsAtCurrResidence.focus();
		return false;
	}
	
	if (SpecialFinanceForm.MakeYear.value!="")
	{
		if(SpecialFinanceForm.MakeYear.value.length<4)
		{
			alert("Enter Four Digit Year");
			SpecialFinanceForm.MakeYear.select();
			return false;
		}
		if (SpecialFinanceForm.MakeYear.value <=1960 || SpecialFinanceForm.MakeYear.value >2015)
		{
			alert("Please Enter Valid Year");
			SpecialFinanceForm.MakeYear.select();
			return false;
		}
	}
	if (SpecialFinanceForm.Make.value!="")
		{
			  SpecialFinanceForm.Make.value=removeLeadingAndTrailingChar(SpecialFinanceForm.Make.value);
		}
	if (SpecialFinanceForm.Model.value!="")
		{
			  SpecialFinanceForm.Model.value=removeLeadingAndTrailingChar(SpecialFinanceForm.Model.value);
		}
	if (SpecialFinanceForm.OtherMake.value!="")
		{
			  SpecialFinanceForm.OtherMake.value=removeLeadingAndTrailingChar(SpecialFinanceForm.OtherMake.value);

		}
	if (SpecialFinanceForm.OtherModel.value!="")
		{
			  SpecialFinanceForm.OtherModel.value=removeLeadingAndTrailingChar(SpecialFinanceForm.OtherModel.value);
		}
		
	if (SpecialFinanceForm.TradeYear.value!="")
	{
		if(SpecialFinanceForm.TradeYear.value.length<4)
		{
			alert("Enter Four Digit Year");
			SpecialFinanceForm.TradeYear.select();
			return false;
		}
		if (SpecialFinanceForm.TradeYear.value <=1960 || SpecialFinanceForm.TradeYear.value >2009)
		{
			alert("Please Enter Valid Year");
			SpecialFinanceForm.TradeYear.select();
			return false;
		}
	}
	if (SpecialFinanceForm.TradeMake.value!="")
		{
			  SpecialFinanceForm.TradeMake.value=removeLeadingAndTrailingChar(SpecialFinanceForm.TradeMake.value);
		}
	if (SpecialFinanceForm.TradeModel.value!="")
		{
			  SpecialFinanceForm.TradeModel.value=removeLeadingAndTrailingChar(SpecialFinanceForm.TradeModel.value);
		}
	if (SpecialFinanceForm.TradeOtherMake.value!="")
		{
			  SpecialFinanceForm.TradeOtherMake.value=removeLeadingAndTrailingChar(SpecialFinanceForm.TradeOtherMake.value);
		}
	if (SpecialFinanceForm.TradeOtherModel.value!="")
		{
			  SpecialFinanceForm.TradeOtherModel.value=removeLeadingAndTrailingChar(SpecialFinanceForm.TradeOtherModel.value);
		}
	if (SpecialFinanceForm.VIN.value!="")
		{
			  SpecialFinanceForm.VIN.value=removeLeadingAndTrailingChar(SpecialFinanceForm.VIN.value);
		if(SpecialFinanceForm.VIN.value.length!=17)
	{
		alert("Enter valid VIN. It should be 17 characters Length");
		SpecialFinanceForm.VIN.focus();
		return false;
	}  
		}
	if (parseFloat(SpecialFinanceForm.Mileage.value)==0)
	{
		alert("Enter Valid Mileage");
			SpecialFinanceForm.Mileage.select();
			return false;
	}
	if(isNaN(SpecialFinanceForm.Mileage.value))
	{
		alert("Enter Valid Mileage");
			SpecialFinanceForm.Mileage.select();
			return false;
	}
	
	if (SpecialFinanceForm.BuyLease.selectedIndex==0)
	{
		alert("Select Buy/Lease");
		SpecialFinanceForm.BuyLease.focus();
		return false;
	}
	if (SpecialFinanceForm.AmountFinancing.value!="" && !formatDollar(SpecialFinanceForm.AmountFinancing) ) 
	{
			alert("Enter Valid Financing Amount");
			SpecialFinanceForm.AmountFinancing.select();
			return false;
	}
	if (parseFloat(SpecialFinanceForm.AmountFinancing.value)==0)
	{
		alert("Enter Valid Financing Amount");
			SpecialFinanceForm.AmountFinancing.select();
			return false;
	}
	if (SpecialFinanceForm.CashDown.value!="" && !formatDollar(SpecialFinanceForm.CashDown) ) 
	{
			alert("Enter Valid Cash Down Payment");
			SpecialFinanceForm.CashDown.select();
			return false;
	}
	if (parseFloat(SpecialFinanceForm.CashDown.value)==0)
	{
		alert("Enter Valid Cash Down Payment");
			SpecialFinanceForm.CashDown.select();
			return false;
	}
	if (SpecialFinanceForm.MonthlyPayment.value!="" && !formatDollar(SpecialFinanceForm.MonthlyPayment) ) 
	{
			alert("Enter Valid Monthly Payment");
			SpecialFinanceForm.MonthlyPayment.select();
			return false;
	}
	if (parseFloat(SpecialFinanceForm.MonthlyPayment.value)==0)
	{
		alert("Enter Valid Monthly Payment");
			SpecialFinanceForm.MonthlyPayment.select();
			return false;
	}
	
////* Employer Infomation *////

	if (SpecialFinanceForm.EmpStatus.selectedIndex==0)
	{
		alert("Select Employment Status");
		SpecialFinanceForm.EmpStatus.focus();
		return false;
	}
	if (SpecialFinanceForm.Emp_Occupation.value!="")
		{
			  SpecialFinanceForm.Emp_Occupation.value=removeLeadingAndTrailingChar(SpecialFinanceForm.Emp_Occupation.value);
		}
	
	if(!(isNonMandValidPhone(SpecialFinanceForm.EmpPhone1,SpecialFinanceForm.EmpPhone2,SpecialFinanceForm.EmpPhone3,SpecialFinanceForm.EmpPhone,'Business Phone'))) return false;
	
	if (SpecialFinanceForm.EmployerIncome.value!="" && !formatDollar(SpecialFinanceForm.EmployerIncome) ) 
	{
			alert("Enter Valid Salary");
			SpecialFinanceForm.EmployerIncome.select();
			return false;
	}
	if (parseFloat(SpecialFinanceForm.EmployerIncome.value)==0)
	{
		alert("Enter Valid Salary");
			SpecialFinanceForm.EmployerIncome.select();
			return false;
	}
	if (SpecialFinanceForm.credit_Employer.value=="")
	{
		alert("Enter Employer Name");
		SpecialFinanceForm.credit_Employer.focus();
		return false;
	}
	if (SpecialFinanceForm.credit_Employer.value!="")
		{
			SpecialFinanceForm.credit_Employer.value=removeLeadingAndTrailingChar(SpecialFinanceForm.credit_Employer.value);
			if(SpecialFinanceForm.credit_Employer.value.length=="0")
			     { 
				    alert("Enter Employer Name");
					SpecialFinanceForm.credit_Employer.value="";
					return false;	
				 }
		}
	if (SpecialFinanceForm.Emp_YearsAtCurrResidence.selectedIndex=="0" && SpecialFinanceForm.Emp_MonthAtCurrResidence.selectedIndex=="0")
	{
		alert("Select Time at Employer");
		SpecialFinanceForm.Emp_YearsAtCurrResidence.focus();
		return false;
	}
	if (SpecialFinanceForm.SalaryType.selectedIndex==0)
	{
		alert("Select Salary Type");
		SpecialFinanceForm.SalaryType.focus();
		return false;
	}
	if (SpecialFinanceForm.AdditionalIncome.value!="" && !formatDollar(SpecialFinanceForm.AdditionalIncome) ) 
	{
			alert("Enter Valid Additional Income");
			SpecialFinanceForm.AdditionalIncome.select();
			return false;
	}
	if (parseFloat(SpecialFinanceForm.AdditionalIncome.value)==0)
	{
		alert("Enter Valid Additional Income");
			SpecialFinanceForm.AdditionalIncome.select();
			return false;
	}
	if (SpecialFinanceForm.AdditionalSource.value!="")
		{
			  SpecialFinanceForm.AdditionalSource.value=removeLeadingAndTrailingChar(SpecialFinanceForm.AdditionalSource.value);
		}
	
	if (SpecialFinanceForm.Comments.value!="")
		{
			  SpecialFinanceForm.Comments.value=removeLeadingAndTrailingChar(SpecialFinanceForm.Comments.value);
		}
////* Phone Numbers *////	
	
	if(document.SpecialFinanceForm.ResPhone1.value.length==3 && document.SpecialFinanceForm.ResPhone2.value.length==3 && document.SpecialFinanceForm.ResPhone3.value.length==4)
	{
		document.SpecialFinanceForm.ResPhone.value="("+document.SpecialFinanceForm.ResPhone1.value+") "+document.SpecialFinanceForm.ResPhone2.value+"-"+document.SpecialFinanceForm.ResPhone3.value;
	}
	
	if(document.SpecialFinanceForm.OffPhone1.value.length==3 && document.SpecialFinanceForm.OffPhone2.value.length==3 && document.SpecialFinanceForm.OffPhone3.value.length==4)
	{
			document.SpecialFinanceForm.OffPhone.value="("+document.SpecialFinanceForm.OffPhone1.value+") "+document.SpecialFinanceForm.OffPhone2.value+"-"+document.SpecialFinanceForm.OffPhone3.value;
	}
	if(document.SpecialFinanceForm.EmpPhone1.value.length==3 && document.SpecialFinanceForm.EmpPhone2.value.length==3 && document.SpecialFinanceForm.EmpPhone3.value.length==4)
	{
		document.SpecialFinanceForm.EmpPhone.value="("+document.SpecialFinanceForm.EmpPhone1.value+") "+document.SpecialFinanceForm.EmpPhone2.value+"-"+document.SpecialFinanceForm.EmpPhone3.value;
	}
	if(document.SpecialFinanceForm.DobMonth.selectedIndex!=0 && document.SpecialFinanceForm.DobDate.selectedIndex!=0 && document.SpecialFinanceForm.DobYear.selectedIndex!=0) 
	{
		document.SpecialFinanceForm.DOB.value = document.SpecialFinanceForm.DobYear.value+"/"+document.SpecialFinanceForm.DobMonth.value+"/"+document.SpecialFinanceForm.DobDate.value;
	}
	

////* Jonit Finance *////

if(SpecialFinanceForm.JointYes.checked)
{
	if (SpecialFinanceForm.JointAppName.value=="" )
	{
		alert("Enter Joint Applicant's First Name");
		SpecialFinanceForm.JointAppName.focus();
		return false;
	}
	if (SpecialFinanceForm.JointAppName.value!="")
	{
	  SpecialFinanceForm.JointAppName.value=removeLeadingAndTrailingChar(SpecialFinanceForm.JointAppName.value);
	  if(SpecialFinanceForm.JointAppName.value.length=="0")
	     { 
			alert("Enter Joint Applicant's First Name");
			SpecialFinanceForm.JointAppName.focus();
			return false;	
		 }
	}
	if (SpecialFinanceForm.JointAppLastName.value=="" )
	{
		alert("Enter Joint Applicant's Last Name");
		SpecialFinanceForm.JointAppLastName.focus();
		return false;
	}
	if (SpecialFinanceForm.JointAppLastName.value!="")
	{
	  SpecialFinanceForm.JointAppLastName.value=removeLeadingAndTrailingChar(SpecialFinanceForm.JointAppLastName.value);
	  if(SpecialFinanceForm.JointAppLastName.value.length=="0")
	     { 
			alert("Enter Joint Applicant's Last Name");
			SpecialFinanceForm.JointAppLastName.focus();
			return false;	
		 }
	}
	if (SpecialFinanceForm.JointAddress.value!="")
	{
	  SpecialFinanceForm.JointAddress.value=removeLeadingAndTrailingChar(SpecialFinanceForm.JointAddress.value);
	}
	if (SpecialFinanceForm.JointAppCity.value!="")
	{
	  SpecialFinanceForm.JointAppCity.value=removeLeadingAndTrailingChar(SpecialFinanceForm.JointAppCity.value);
	}
	if (SpecialFinanceForm.JointAppZip.value=="")
	{
		alert("EnterJoint Applicant's Zip Code ");
		SpecialFinanceForm.JointAppZip.focus();
		return false;
	}
	if(SpecialFinanceForm.JointAppZip.value.length<5)
	{
		alert("Enter Five Digit Zip Code");
		SpecialFinanceForm.JointAppZip.focus();
		return false;
	}		
	if (SpecialFinanceForm.JointAppEmailID.value=="" )
	{
		alert("Enter Joint Applicant's E-mail ID");
		SpecialFinanceForm.JointAppEmailID.focus();
		return false;
	}
	if (SpecialFinanceForm.JointAppEmailID.value!="" && !validemail(SpecialFinanceForm.JointAppEmailID.value))
	{ 
		alert("Enter Valid E-mail ID");
		SpecialFinanceForm.JointAppEmailID.focus();
		return false;		
	}
	
	if (SpecialFinanceForm.JointOffPhone1.value.length<3)
	{
		alert("Enter Joint Applicant's Day Phone Number");
		SpecialFinanceForm.JointOffPhone1.focus();
		return false;
	}
	if (SpecialFinanceForm.JointOffPhone2.value.length<3)
	{
		alert("Enter Joint Applicant's Day Phone Number");
		SpecialFinanceForm.JointOffPhone2.focus();
		return false;
	}
	if (SpecialFinanceForm.JointOffPhone3.value.length<4)
	{
		alert("Enter Joint Applicant's Day Phone Number");
		SpecialFinanceForm.JointOffPhone3.focus();
		return false;
	}
	
	if(!(isNonMandValidPhone(SpecialFinanceForm.JointResPhone1,SpecialFinanceForm.JointResPhone2,SpecialFinanceForm.JointResPhone3,SpecialFinanceForm.JointResPhone,'Evening Phone'))) return false;
	
	if (SpecialFinanceForm.JointDobYear.selectedIndex==0)
	{
		alert("Select Year");
		SpecialFinanceForm.JointDobYear.focus();
		return false;
	}
	if (SpecialFinanceForm.JointDobMonth.selectedIndex==0)
	{
		alert("Select Month");
		SpecialFinanceForm.JointDobMonth.focus();
		return false;
	}
	if (SpecialFinanceForm.JointDobDate.selectedIndex==0)
	{
		alert("Select Date");
		SpecialFinanceForm.JointDobDate.focus();
		return false;
	}
	if (SpecialFinanceForm.JointAppSSN.value=="")
	{
		alert("Enter Social Security Number");
		SpecialFinanceForm.JointAppSSN.focus();
		return false;
	}
	if (SpecialFinanceForm.JointAppSSN.value.length<9)
	{
		alert("Enter valid Social Security Number");
		SpecialFinanceForm.JointAppSSN.focus();
		return false;
	}
	if (SpecialFinanceForm.JointAnnualIncome.value!="" && !formatDollar(SpecialFinanceForm.JointAnnualIncome) ) 
	{
		alert("Enter Valid Annual Income");
		SpecialFinanceForm.JointAnnualIncome.select();
		return false;
	}
	if (parseFloat(SpecialFinanceForm.JointAnnualIncome.value)==0)
	{
		alert("Enter Valid Annual Income");
		SpecialFinanceForm.JointAnnualIncome.select();
		return false;
	}
	if (SpecialFinanceForm.JointAppHouseYear.selectedIndex=="0" && SpecialFinanceForm.JointAppHouseMonths.selectedIndex=="0")
	{
		alert("Select Time at Current Residence");
		SpecialFinanceForm.JointAppHouseYear.focus();
		return false;
	}

////* Joint Employer Infomation *////

	if (SpecialFinanceForm.JointEmpStatus.selectedIndex==0)
	{
		alert("Select Employment Status");
		SpecialFinanceForm.JointEmpStatus.focus();
		return false;
	}
	if (SpecialFinanceForm.JointOccupation.value!="")
		{
			  SpecialFinanceForm.JointOccupation.value=removeLeadingAndTrailingChar(SpecialFinanceForm.JointOccupation.value);
		}
		
	if(!(isNonMandValidPhone(SpecialFinanceForm.JointEmpPhone1,SpecialFinanceForm.JointEmpPhone2,SpecialFinanceForm.JointEmpPhone3,SpecialFinanceForm.JointEmpPhone,'Business Phone'))) return false;
	
	if (SpecialFinanceForm.Joint_EmployerIncome.value!="" && !formatDollar(SpecialFinanceForm.Joint_EmployerIncome) ) 
	{
			alert("Enter Valid Salary");
			SpecialFinanceForm.Joint_EmployerIncome.select();
			return false;
	}
	if (parseFloat(SpecialFinanceForm.Joint_EmployerIncome.value)==0)
	{
		alert("Enter Valid Salary");
			SpecialFinanceForm.Joint_EmployerIncome.select();
			return false;
	}
	if (SpecialFinanceForm.JointAppEmployer.value=="")
	{
		alert("Enter Employer Name");
		SpecialFinanceForm.JointAppEmployer.focus();
		return false;
	}
	if (SpecialFinanceForm.JointAppEmployer.value!="")
		{
			SpecialFinanceForm.JointAppEmployer.value=removeLeadingAndTrailingChar(SpecialFinanceForm.JointAppEmployer.value);
			if(SpecialFinanceForm.JointAppEmployer.value.length=="0")
			     { 
				    alert("Enter Employer Name");
					SpecialFinanceForm.JointAppEmployer.value="";
					return false;	
				 }
		}
	if (SpecialFinanceForm.JointAppEmployerYear.selectedIndex=="0" && SpecialFinanceForm.JointAppEmployerMonths.selectedIndex=="0")
	{
		alert("Select Time at Employer");
		SpecialFinanceForm.JointAppEmployerYear.focus();
		return false;
	}
	if (SpecialFinanceForm.JointSalaryType.selectedIndex==0)
	{
		alert("Select Salary Type");
		SpecialFinanceForm.JointSalaryType.focus();
		return false;
	}
	if (SpecialFinanceForm.JointAdditionalIncome.value!="" && !formatDollar(SpecialFinanceForm.JointAdditionalIncome) ) 
	{
			alert("Enter Valid Additional Income");
			SpecialFinanceForm.JointAdditionalIncome.select();
			return false;
	}
	if (parseFloat(SpecialFinanceForm.JointAdditionalIncome.value)==0)
	{
		alert("Enter Valid Additional Income");
			SpecialFinanceForm.JointAdditionalIncomes.select();
			return false;
	}
	if (SpecialFinanceForm.JointAdditionalSource.value!="")
		{
			  SpecialFinanceForm.JointAdditionalSource.value=removeLeadingAndTrailingChar(SpecialFinanceForm.JointAdditionalSource.value);
		}
	
	if (SpecialFinanceForm.JointAppComments.value!="")
		{
			  SpecialFinanceForm.JointAppComments.value=removeLeadingAndTrailingChar(SpecialFinanceForm.JointAppComments.value);
		}
	
	
////* Phone Numbers *////

	if(document.SpecialFinanceForm.JointOffPhone1.value.length==3 && document.SpecialFinanceForm.JointOffPhone2.value.length==3 && document.SpecialFinanceForm.JointOffPhone3.value.length==4) 
	{
		document.SpecialFinanceForm.JointOffPhone.value="("+document.SpecialFinanceForm.JointOffPhone1.value+") "+document.SpecialFinanceForm.JointOffPhone2.value+"-"+document.SpecialFinanceForm.JointOffPhone3.value;
	}
	if(document.SpecialFinanceForm.JointResPhone1.value.length==3 && document.SpecialFinanceForm.JointResPhone2.value.length==3 && document.SpecialFinanceForm.JointResPhone3.value.length==4)
	{
		document.SpecialFinanceForm.JointResPhone.value="("+document.SpecialFinanceForm.JointResPhone1.value+") "+document.SpecialFinanceForm.JointResPhone2.value+"-"+document.SpecialFinanceForm.JointResPhone3.value;
	}
	if(document.SpecialFinanceForm.JointEmpPhone1.value.length==3 && document.SpecialFinanceForm.JointEmpPhone2.value.length==3 && document.SpecialFinanceForm.JointEmpPhone3.value.length==4)
	{
		document.SpecialFinanceForm.JointEmpPhone.value="("+document.SpecialFinanceForm.JointEmpPhone1.value+") "+document.SpecialFinanceForm.JointEmpPhone2.value+"-"+document.SpecialFinanceForm.JointEmpPhone3.value;
	}
	if(document.SpecialFinanceForm.JointDobMonth.selectedIndex!=0 && document.SpecialFinanceForm.JointDobDate.selectedIndex!=0 && document.SpecialFinanceForm.JointDobYear.selectedIndex!=0) 
	{
		document.SpecialFinanceForm.JointDOB.value = document.SpecialFinanceForm.JointDobYear.value+"/"+document.SpecialFinanceForm.JointDobMonth.value+"/"+document.SpecialFinanceForm.JointDobDate.value;
	}
}
	
 return true;		
	
}



function populate(d3,d4)
{
	//alert(d3);
	//alert(d4);
	var day=0;
	if(d4!="")
	{
	
	if(d4=='January')
	{
	day=31;	
	}
	if(d4=='February')
	{
	day=(d3 % 4 == 0) ? 29 : 28; 
	}
	if(d4=='March')
	{
	day=31;	
	}
	if(d4=='April')
	{
	day=30;	
	}
	if(d4=='May')
	{
	day=31;	
	}
	if(d4=='June')
	{
	day=30;	
	}
	if(d4=='July')
	{
	day=31;	
	}
	if(d4=='August')
	{
	day=31;	
	}
	if(d4=='September')
	{
	day=30;	
	}
	if(d4=='October')
	{
	day=31;	
	}
	if(d4=='November')
	{
	day=30;	
	}
	if(d4=='December')
	{
	day=31;	
	}
	
	}
	if(day!=0)
	{
		day=day+1;
		
	document.SpecialFinanceForm.DobDate.options.length=0;	
		
	document.SpecialFinanceForm.DobDate.options[0]=new Option("Date");	
	for(j=1;j<day;j++)
	{
	document.SpecialFinanceForm.DobDate.options[j]=new Option(j);		
	}
	}

}
function populate_joint(d3,d4)
{
	//alert(d3);
	//alert(d4);
	var day=0;
	if(d4!="")
	{
	
	if(d4=='January')
	{
	day=31;	
	}
	if(d4=='February')
	{
	day=(d3 % 4 == 0) ? 29 : 28; 
	}
	if(d4=='March')
	{
	day=31;	
	}
	if(d4=='April')
	{
	day=30;	
	}
	if(d4=='May')
	{
	day=31;	
	}
	if(d4=='June')
	{
	day=30;	
	}
	if(d4=='July')
	{
	day=31;	
	}
	if(d4=='August')
	{
	day=31;	
	}
	if(d4=='September')
	{
	day=30;	
	}
	if(d4=='October')
	{
	day=31;	
	}
	if(d4=='November')
	{
	day=30;	
	}
	if(d4=='December')
	{
	day=31;	
	}
	
	}
	if(day!=0)
	{
		day=day+1;
		
	document.SpecialFinanceForm.JointDobDate.options.length=0;	
		
	document.SpecialFinanceForm.JointDobDate.options[0]=new Option("Date");	
	for(j=1;j<day;j++)
	{
	document.SpecialFinanceForm.JointDobDate.options[j]=new Option(j);		
	}
	}

}

/********************************* Special Needs Finance Appliction Ends*******************************/
/**************** Finance DOB  ****************************/
function populate(ctrl1, ctrl2, ctrl3) {
		ind1=document.getElementById(ctrl1).selectedIndex;
		ind2=document.getElementById(ctrl2).selectedIndex;
		val1=document.getElementById(ctrl1).options[ind1].value;
		if(ind1==0) {
			document.getElementById(ctrl2).selectedIndex=0;
			document.getElementById(ctrl3).selectedIndex=0;
		}
		else if(ind2==0) {
			document.getElementById(ctrl3).selectedIndex=0;			
		}
		else if(!isNaN(val1)) {
			leap=val1%4;
			if(ind2==2) {
				if(leap==0) {
					document.getElementById(ctrl3).length=30;
					document.getElementById(ctrl3).options[0].text="Date";
					document.getElementById(ctrl3).options[0].value="Date";
					for(i=1;i<30;i++) {
						document.getElementById(ctrl3).options[i].text=i;
						document.getElementById(ctrl3).options[i].value=i;
					}
				} else {
					document.getElementById(ctrl3).length=29;
					document.getElementById(ctrl3).options[0].text="Date";
					document.getElementById(ctrl3).options[0].value="Date";
					for(i=1;i<29;i++) {
						document.getElementById(ctrl3).options[i].text=i;
						document.getElementById(ctrl3).options[i].value=i;
					}					
				}
			} else if (ind2==1||ind2==3||ind2==5||ind2==7||ind2==8||ind2==10||ind2==12) {
				document.getElementById(ctrl3).length=32;
				document.getElementById(ctrl3).options[0].text="Date";
				document.getElementById(ctrl3).options[0].value="Date";
				for(i=1;i<32;i++) {
					document.getElementById(ctrl3).options[i].text=i;
					document.getElementById(ctrl3).options[i].value=i;
				}	
			} else if (ind2==4||ind2==6||ind2==9||ind2==11) {
				document.getElementById(ctrl3).length=31;
				document.getElementById(ctrl3).options[0].text="Date";
				document.getElementById(ctrl3).options[0].value="Date";
				for(i=1;i<31;i++) {
					document.getElementById(ctrl3).options[i].text=i;
					document.getElementById(ctrl3).options[i].value=i;
				}	
			}
		}
}
/***********************Ends******************************/
/*******************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";
}
