//functions for zip pop-box
var aForm = "";

function selectCity(){
//alert(aForm);
	switch(aForm) {
	case 'document.usedForm':
	var d = document.usedForm;
	var makeModelPath = "/go/buy-cars/kdcn/" + d.usedMakeSelect.options[d.usedMakeSelect.selectedIndex].text + "/";
		if(d.usedModelSelect.options[d.usedModelSelect.selectedIndex].value != "all") {
		makeModelPath += d.usedModelSelect.options[d.usedModelSelect.selectedIndex].text+"/";
		}
	break;
	case 'document.newForm':
	var d = document.newForm;
	var makeModelPath = "/go/buy-cars/kdcnu/" + d.newMakeSelect.options[d.newMakeSelect.selectedIndex].text + "/";
		if(d.newModelSelect.options[d.newModelSelect.selectedIndex].value != "") {
		makeModelPath += d.newModelSelect.options[d.newModelSelect.selectedIndex].text+"/";
		}
	break;
	case 'document.searchCPO':
	var d = document.searchCPO;
	var makeModelPath = "/go/buy-cars/kucn/" + d.mknm.options[d.mknm.selectedIndex].text + "/Certified/";
	break;
	}

	zipErrorHide();
	location.href = makeModelPath.replace(/ /g, '_');
}

function hideShowSelects(sts){
	var dropdowns = new Array("usedMakeSelect","newMakeSelect","usedModelSelect","newModelSelect","highpricerange","highpricerangeUsed");
	if(aForm == 'document.searchCPO') {
	dropdowns[5]='searchwithinused';
	document.getElementById('bttnUsed').style.visibility = sts; document.getElementById('bttnNew').style.visibility = sts;
	}
	for (i=0;i<dropdowns.length;i++){
	document.getElementById(dropdowns[i]).style.visibility = sts;
	}
}

function zipError(fm){
		if(aForm == '') aForm = "document."+ fm;
		var zErr = document.getElementById("zipError").style;
		zErr.top = '25px';
		if(location.href.indexOf('buyIndex')!=-1) {zErr.left = '1px'; zErr.top = '35px';}
		if(location.href.indexOf('buy-cars')!=-1) {zErr.left = '-5px'; zErr.top = '0px';}
		if (aForm == 'document.searchCPO') zErr.top = '180px';
		zErr.display = 'block';
		hideShowSelects('hidden');
}

function zipErrorHide(){
		document.getElementById("zipError").style.display = 'none';
		hideShowSelects('visible');
}

function submitMiniZip(){
	var frm = eval(aForm);
	frm.zc.value = document.miniZip.zip.value;
	frm = aForm.replace(/document./,"");
	zipErrorHide();
	checkZipFirst(frm);
}
