// JavaScript Document
function displayGo(){
var input = document.getElementById("lnSbmtBut");
var newInput = document.createElement('input');
newInput.type = 'submit';
newInput.name = input.name
newInput.id='lnSbmtBut';
newInput.tabIndex='2';
newInput.value = newInput.defaultValue = input.value;
newInput.onclick =function doThis1(){return getOtherDetailsForLoanAmount()};
newInput.className='btn40x19';
input.parentNode.replaceChild(newInput, input);	
}

var cssmenuids=["cssmenu1"] //Enter id(s) of CSS Horizontal UL menus, separated by commas
var csssubmenuoffset=-1 //Offset of submenus from main menu. Default is 0 pixels.

function createcssmenu2(){
for (var i=0; i<cssmenuids.length; i++){
  var ultags=document.getElementById(cssmenuids[i]).getElementsByTagName("ul")
    for (var t=0; t<ultags.length; t++){
			ultags[t].style.top=ultags[t].parentNode.offsetHeight+csssubmenuoffset+"px"
    	ultags[t].parentNode.onmouseover=function(){
					this.style.zIndex=100
    	this.getElementsByTagName("ul")[0].style.visibility="visible"
					this.getElementsByTagName("ul")[0].style.zIndex=0
    	}
    	ultags[t].parentNode.onmouseout=function(){
					this.style.zIndex=0
					this.getElementsByTagName("ul")[0].style.visibility="hidden"
					this.getElementsByTagName("ul")[0].style.zIndex=100
    	}
    }
  }
}
if (window.addEventListener)
window.addEventListener("load", createcssmenu2, false)
else if (window.attachEvent)
window.attachEvent("onload", createcssmenu2)

function alignaccGrid(n) {
	var totalRows = n;
	var rowWidth = 0;
	for(var i=0;i<totalRows;i++) {
		var curRow = "accRow"+i;
		var rowHeight = parseInt(document.getElementById(curRow).offsetHeight);
		var parantDiv = document.getElementById(curRow);
		var children = parantDiv.getElementsByTagName("div");
		for(var j=0;j<children.length;j++) {
			var alt = j%2;
			if(alt==0) {
				children[j].style.height = rowHeight+"px";
			}
		}
	}
	if((document.getElementById("admOverflow").offsetHeight) >= 210){
		rowWidth = 937;
	}
	else {
		rowWidth = 954;
	}
	for(var i=0;i<totalRows;i++) {
		var curRow = "accRow"+i;
		document.getElementById(curRow).style.width = rowWidth+"px";
	}
}

function showhidedivs(flag) {
	document.getElementById("inscomp").style.display = flag;
	document.getElementById("inspol").style.display = flag;
	document.getElementById("insexdt").style.display = flag;
	document.getElementById("inscur").style.display = flag;
	document.getElementById("insvlue").style.display = flag;
}
//Price list page
var prePan = "locPan6";
function showpricebyLocation(){
	document.pricelist.submit();
/*	var selValue = obj.options[obj.selectedIndex].value;
	var locId = "locPan"+selValue;
	var locObj = document.getElementById(locId);
	
	locObj.style.display = "block";
	document.getElementById(prePan).style.display = "none";
	prePan = locId;*/
}

function setprcListHeight(){
	var offHeight = document.getElementById("offsetDiv").offsetHeight;
	if(offHeight<=350){
		document.getElementById("mainColLst").style.height = 412+"px";
	}else{
		document.getElementById("mainColLst").style.height = "";
	}
}

/*location page code*/
function goToLocation()
{
 var goToPage = document.getElementById('cmbCity').value;
 //alert(goToPage);
  if (goToPage == 'newcars-location')
	{window.location='../newcars-location.htm';}  
  if (goToPage == 'service-location')
	{window.location='../service-location.htm';} 
  if (goToPage == 'service-bannerghatta')
	{window.location='../service-bannerghatta.htm';}
  if (goToPage == 'workshop-location')
	{window.location='../workshop-location.htm';}   
  }


function chkEligible()
{
document.frmselfemp.action = "eligible.htm";
}
function chkCorporate()
{
document.frmselfemp.action = "eligible-corporate.htm";
}
function chkSelfEmp()
{
document.frmselfemp.action = "eligible-self-employed.htm";
}
function chkLoanEmi()
{
document.frmselfemp.action = "loanemi.htm";
}
function chkFinForm()
{
document.frmselfemp.action = "finance.htm";
}

function goToFinance(goToPage)
{
 var thisPage = goToPage; 
 alert(goToPage);
  alert(window.location);
  if (goToPage == 'salaryEligible'){window.location='eligible.htm';}  
  if (goToPage == 'salaryCorporate'){window.location='../eligible-corporate.htm'}
  if (goToPage == 'salarySelfEmployed'){window.location='../eligible-self-employed.htm'}
  if (goToPage == 'loanemi'){window.location='../loanemi.htm'}
  if (goToPage == 'finance'){window.location='../finance.htm'}
  
}


function selectInstype(val) {
	if(val =="New"){
		showhidedivs("none");
	}else{
		showhidedivs("block");
	}
}

function showForm(formName) {
	
	if(formName=="loanForm"){
	var input = document.getElementById("lnSbmtBut");
	var newInput = document.createElement('input');
	newInput.type = 'button';
	newInput.id='lnSbmtBut';
	newInput.value="Go";
	input.parentNode.replaceChild(newInput, input);			
	document.getElementById("estimatColm").style.display = "none";
	setPosition();
	}else if(formName=="accessoriesForm"){
		setPosition();
	}
}
function setPosition(){
	var posL = document.getElementById("innerMain").offsetLeft + 10;
	var posT = document.getElementById("innerMain").offsetTop + 55; 

	document.getElementById("leadForm").style.display = "block";
	document.getElementById("formBox").style.display = "block";
	
	document.getElementById("leadForm").style.filter = 'alpha(opacity=70)';
	document.getElementById("leadForm").style.opacity = 0.7;

	document.getElementById("leadForm").style.left = posL +"px";
	document.getElementById("leadForm").style.top = posT +"px";
	
	document.getElementById("formBox").style.left = (posL + 45) +"px";
	document.getElementById("formBox").style.top = (posT+10) +"px";	
}
function hideDiv(formName,divname) {
	if(divname=="deal"){
		if(formName=="loanForm"){
			document.getElementById("estimatColm").style.display = "block";
			document.getElementById("leadForm").style.display = "none";
			document.getElementById("formBox").style.display = "none";
			displayGo();
	}else if(formName=="accessoriesForm"){
			document.getElementById("leadForm").style.display = "none";
			document.getElementById("formBox").style.display = "none";			
		}
	}
	else if(divname=="disc") {
		document.getElementById("disclaimDiv").style.display = "none";
		document.getElementById("ttldiv").style.display = "block";
		document.getElementById("methdiv").style.display = "block";
		document.getElementById("timediv").style.display = "block";		
	}
}

function showDisclaimer() {
	var posL = document.getElementById("formBox").offsetLeft + 137;
	var posT = document.getElementById("formBox").offsetTop + 10; 	
	document.getElementById("disclaimDiv").style.display = "block";
	document.getElementById("ttldiv").style.display = "none";
	document.getElementById("methdiv").style.display = "none";
	document.getElementById("timediv").style.display = "none";

	document.getElementById("disclaimDiv").style.left = posL +"px";
	document.getElementById("disclaimDiv").style.top = posT +"px";
}

/*Preloading image for usedcars landing*/
if (document.images)
{
	pic1= new Image(93,30); 
	pic1.src="../images/usedcars/make-model_mo.jpg"; 
	pic2= new Image(95,30); 
	pic2.src="../images/usedcars/pricerange_mo.jpg"; 
	pic3= new Image(73,30); 
	pic3.src="../images/usedcars/features_mo.jpg"; 
	pic4= new Image(132,30); 
	pic4.src="../images/usedcars/advancedsearch_mo.jpg";
}
/**/
var currentPan = "panA";
var curButn = "";
function showHidePanel(n,flag){
	var panId = "pan"+n;
	var panObj = document.getElementById(panId);
	var butObj = document.getElementById(n);
	var butName = document.getElementById(n).name;
	var divPos = (document.getElementById("contPan").offsetTop+50);
	var divLft = (document.getElementById("contPan").offsetLeft-4);
	if(flag){
		panObj.style.display = "none";
		butObj.style.width = 176+"px";
		butObj.style.borderRight = "1px solid #C4C4C4";		
		butObj.style.backgroundImage = "url(images/usedcars/"+butName+".jpg)";
		curButn = "";
	} else {
		butObj.style.width = 184+"px";	
		butObj.style.borderRight = 0+"px";
		butObj.style.backgroundImage = "url(images/usedcars/"+butName+"_mo.jpg)";
		panObj.style.display = "block";
		panObj.style.top = divPos+"px";
		panObj.style.left = divLft+"px";
		if(panId != currentPan && curButn !=""){
			document.getElementById(currentPan).style.display = "none";
			document.getElementsByName(curButn)[0].style.width = 176+"px";
			document.getElementsByName(curButn)[0].style.borderRight = "1px solid #C4C4C4";
			document.getElementsByName(curButn)[0].style.backgroundImage = "url(images/usedcars/"+curButn+".jpg)";
		}	
		curButn = butName;
	}	
	currentPan = panId;
}
function toggleButton(obj,n) {
	butName = obj.name;
	if(n==1){
		obj.style.backgroundImage = "url(images/usedcars/"+butName+".jpg)";//_mo
	}else{
		if(butName != curButn)
		obj.style.backgroundImage = "url(images/usedcars/"+butName+".jpg)";
	}
}