	function ViewVehicle( cvin, path )
	{
		document.location = path + "/VIN/" + cvin;
		return false;
	}

	function PrintItNow()
	{
		NewWindow('/stock/print.php','print_stub','700','450','yes','center');
		return false;
	}
	function PrintCar()
	{
		if(arguments.length==1)
		{
			NewResizableWindow(arguments[0],'print_stub','700','450','yes','center');
		}
		else
		{
			NewResizableWindow('/stock/print.php?what=car-patch','print_stub','700','450','yes','center');
		}
	}
	function ChangeImage(newImgUrl)
	{
		//WaddaImage = document.getElementById("big_image");				
		
		BaraimageDiv = document.getElementById("dummy");
		BaraimageDiv.innerHTML = "";
		BaraimageDiv.style.backgroundImage = "url(/stock/images/loading.gif)";
		BaraimageDiv.style.backgroundAttachment = "scroll";
		BaraimageDiv.style.backgroundColor = "transparent";
		BaraimageDiv.style.backgroundRepeat = "no-repeat";
		BaraimageDiv.style.backgroundPosition = "center center";			
		
		BaraimageDiv.innerHTML = '<img id="big_image" src="' + newImgUrl + '">';				
	}
	function NewResizableWindow( mypage, myname, w, h, scroll, pos )
	{
		if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
		if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
		else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
		settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';
		win = window.open(mypage,myname,settings);
		return win;
	}
	function NewWindow( mypage, myname, w, h, scroll, pos )
	{
		if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
		if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
		else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
		settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
		win = window.open(mypage,myname,settings);
		return win;
	}
	function Search()
	{
		base = document.getElementById( "SearchForm" ).action;
		with( document.SearchForm )
		{
			if( Year.value != "-1" ) base += "/Year/" + Year.value;
			if( Model.value != "-1" ) base += "/Model/" + Model.value;
			if( Make.value != "-1" ) base += "/Make/" + Make.value;
			if( BodyStyle.value != "-1" ) base += "/BodyStyle/" + BodyStyle.value;
			if( psort.value != "0" ) base += "/psort/" + psort.value;
			if( ysort.value != "0" ) base += "/ysort/" + ysort.value;
			if( msort.value != "0" ) base += "/msort/" + msort.value;
			if( ksort.value != "0" ) base += "/ksort/" + ksort.value;
			if( typeof defaultYear != 'undefined' && defaultYear.value != "0" ) base += "/defaultYear/" + defaultYear.value;
			if( document.getElementById( "mly") != null )
				if( mly.value != "0" ) base += "/mly/" + mly.value;
		}
		document.location = base;
	}
	function ResetPhorm()
	{
		base = document.getElementById( "SearchForm" ).action;
		with( document.SearchForm )
		{
			if( Year.value != "-1" ) base += "/Year/" + Year.value;
			if( Model.value != "-1" ) base += "/Model/" + Model.value;
			if( Make.value != "-1" ) base += "/Make/" + Make.value;
			if( BodyStyle.value != "-1" ) base += "/BodyStyle/" + BodyStyle.value;
		}
		document.location = base;
	}
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var enableanchorlink=0 //Enable or disable the anchor link when clicked on? (1=e, 0=d)
var hidemenu_onclick=1 //hide menu when user clicks within menu? (1=yes, 0=no)

/////No further editting needed

var ie5=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function showhide(obj, e, visible, hidden){
if (ie5||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie5 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie5 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie5 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function dropdownmenu(ro, obj, e, dropmenuID){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
if (typeof dropmenuobj!="undefined") //hide previous menu
dropmenuobj.style.visibility="hidden"
clearhidemenu()
if (ie5||ns6){
obj.onmouseout=delayhidemenu
dropmenuobj=document.getElementById(dropmenuID)
if (hidemenu_onclick) dropmenuobj.onclick=function(){dropmenuobj.style.visibility='hidden'}
dropmenuobj.onmouseover=clearhidemenu
dropmenuobj.onmouseout=ie5? function(){ dynamichide(event)} : function(event){ dynamichide(event)}
showhide(dropmenuobj.style, e, "visible", "hidden")
dropmenuobj.x=getposOffset(ro, "left")-135
dropmenuobj.y=getposOffset(ro, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}
return clickreturnvalue()
}

function clickreturnvalue(){
if ((ie5||ns6) && !enableanchorlink) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie5&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function delayhidemenu(){
delayhide=setTimeout("dropmenuobj.style.visibility='hidden'",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

/****************************************************************************************************
  Copyright Dealer.com Websystems
	paymentcalculator.js
	author: ///o-o\\\
	Notes:
	History:
		created 12.29.2000
		last modified: 7.09.2007 by wick
		ported to -legacy:  08.Feb.2008, Randy Morey
****************************************************************************************************/
var calcForm;
var verbage = "Call";
var defaultRate = "6.9";

function initialize( formName ) {
	calcForm = (formName==null)?document.forms[0]:document.forms[formName];
	calcForm.rate.value=defaultRate;
	populate(calculate());
}

function initializePaymentCalculator( formName ) {
	calcForm = (formName==null)?document.forms[0]:document.forms[formName];
	var cashTrade=calcForm.cash_trade.value;
	if (cashTrade.indexOf("%") != "-1") {
		price = normalize(calcForm.price.value);
		cashTrade = Math.floor((price * ( parseInt(cashTrade) / 100) ) / 100) * 100;
		calcForm.cash_trade.value = cashTrade;
	}
	calcForm.rate.value = defaultRate || '';
}

function populate( moPay ) {
	calcForm = document.getElementById('calcForm');
	if(calcForm.rate.value=="" || calcForm.rate.value=="0.") {return;}
//	if(parseFloat(calcForm.rate.value)<=0) {return;}
	if( moPay=="0.00" && parseInt(calcForm.price.value)==0 ) {
		calcForm.cash_trade.disabled=true;
		calcForm.retail.disabled=true;
		calcForm.rate.disabled=true;
		calcForm.term.disabled=true;
		calcForm.monthlypayment.value=0;
		calcForm.monthlypayment.disabled=true;
		calcForm.price.value=verbage;
		calcForm.retail.value=verbage;
		calcForm.monthlypayment.value=verbage;
		return;
	} else if( calcForm.cash_trade.value.indexOf("-") != -1 || new Number(normalize(calcForm.cash_trade.value)) < 0 ){
		alert("Your down payment must be greater than zero.\nIf you have any questions, feel free to contact us via email.\nThank You.");
		return;
	}
	calcForm.cash_trade.disabled=false;
	calcForm.retail.disabled=false;
	calcForm.rate.disabled=false;
	calcForm.term.disabled=false;
	calcForm.monthlypayment.disabled=false;
	calcForm.monthlypayment.value = moPay;
}

function rePopulate( maxTerms )
{
	clearSelector( "term" );
	populateTerms( maxTerms );
}

var price;
var retail;
function calculate()
{
	//if(calcForm.rate.value=="" || calcForm.rate.value=="0" || calcForm.rate.value=="0.") {return;}
	calcForm = document.getElementById('calcForm');
	if(calcForm.rate.value=="" ) {return;}
	// update prices and monthly payment
	price = normalize(calcForm.price.value) - normalize(calcForm.cash_trade.value);
	retail = normalize(calcForm.retail.value) - normalize(calcForm.cash_trade.value);
	rate = calcForm.rate.value/100;
	term = calcForm.term.options[calcForm.term.selectedIndex].value;

  if( rate == 0 ){
		pay = new String(price/term);
  }
	else {
		var monthIntRate = rate / 12;
		ratePlus = eval(monthIntRate+1);
		pow = Math.pow( ratePlus, term );
		pay = new String( ( price ) / (( 1 - (1/pow)) / monthIntRate) );
	}

	//if( parseFloat(calcForm.cash_trade.value)>parseFloat( calcForm.price.value.replace(",","") ) ) {calcForm.cash_trade.value=calcForm.price.value;}
	if( pay == "NaN" ) return verbage;
	else if( pay<0) return 0;
	return format(pay);
}

function populateTerms( max,sel,interval,customTerms ) {
// in case required function params are missing
  if (!customTerms) { customTerms = ''; }
  if (!interval) { interval = 12; }

	var i = 0;
	if (customTerms != '') {
		var terms = customTerms.split(',');
		for (var j = (terms.length - 1); j >= 0 ; j--) {
			calcForm.term.options[i++] = new Option(terms[j]+' mo.',terms[j]);
		}
	}
	else {
		for (var j = max; j >= 12; (j -= interval)) {
			calcForm.term.options[i++] = new Option(j+' mo.',j);
		}
	}
	calcForm.term.value = sel;	// AFAIK, doing a value assignment works in all modern browsers
}

function clearSelector( who ) {
  // needs to cleanup all select objects below 'who'
  var start = 0;
  var end = calcForm.elements[who].options.length;
  if( end < start )
		return false;
  for( i=end; i>=start; i-- ){
		calcForm.elements[who].options[i] = null;
  }
}

function normalize( value ) {
  if( value == null || value == "" ) {
    value = 0;
  } else {
    value = value.replace(/,/, "");
    value = value.replace(/$/, "");
  }
  return value;
}


function format( str ) {
  var fraction;
	numerals = new String(str);
  index = numerals.indexOf(".");
	if( index != -1 ){
		fraction = numerals.substring( index, index+3 );
		numerals = numerals.substring( 0, index );
	}

  ln = numerals.length;
  beg = numerals.substring( 0, ln-3 );
  end = numerals.substring( ln-3 );

  retVal=beg+((ln>3)?",":"")+end+((fraction==null)?".00":fraction);

	return retVal;
}

function calculatePurchasingPower() {
	var purchasingPower;
	var monthlyPayment = calcForm.affordableMonthlyPayment.value;
	var cashTrade      = parseFloat( 0 + calcForm.cash_trade.value );
	var rate           = calcForm.rate.value / 1200;
	var term           = calcForm.term.value;

	if( rate == 0 )
		purchasingPower = ( monthlyPayment * term ) + cashTrade;
	else
		purchasingPower = monthlyPayment * ( ( 1 - ( 1 / Math.pow( 1 + rate, term ) ) ) / rate ) + cashTrade;

	return format( purchasingPower );
}

function populatePurchasingPower( moPay ) {
	if(calcForm.rate.value=="" || calcForm.rate.value=="0.") {return;}
	if( moPay=="NaN.00"  ) {
		calcForm.purchasingPower.value=0;
		calcForm.purchasingPower.disabled=true;
		calcForm.purchasingPower.value=verbage;
		return;
	} else if( calcForm.cash_trade.value.indexOf("-") != -1 || new Number(normalize(calcForm.cash_trade.value)) < 0 ){
		alert("Your down payment must be greater than zero.\nIf you have any questions, feel free to contact us via email.\nThank You.");
		return;
	}
	calcForm.purchasingPower.disabled=false;
	calcForm.purchasingPower.value = moPay;
}

function doBoth() {
	populate( calculate() );
	populatePurchasingPower( calculatePurchasingPower() );
}

function calcdisp()
{
	var divRef = document.getElementById('paymentImg');
	var mpay = document.forms['calcForm'].monthlypayment.value.toString().replace(/([\d,]{5})\.\d{2}$/,'$1');
	var mhtml = 'Your monthly installment is: $' + mpay + '.';	
	divRef.innerHTML = mhtml;
}
function isEmailValid(v)
{
	var filter=/^.+@.+\..{2,3}$/;
	return filter.test(v);
}
function checkAskAQuestionForm()
{
	with(document.askquestionform)
	{
		if(fname.value=="")
		{
			alert("Enter your first name");
			fname.focus();
			return false;	
		}
		
		if(lname.value=="")
		{
			alert("Enter your Last name");
			lname.focus();
			return false;	
		}
		
		if(email.value=="")
		{
			alert("Enter your email");
			email.focus();
			return false;	
		}
		else
		{
			if(!isEmailValid(email.value))
			{
				alert("Enter a valid email");
				email.focus();
				return false;	
			}
		}
	}
}
function GetNewOne()
{
	document.getElementById("kaap").src = "/stock/images/captcha.php?r=" + Math.random();
}