function Ocultar(Seccion){ 
    Seccion.style.display = "none";
}

function checkUncheckThis(thisState, cbGroup)
{
	for (i = 0; i < cbGroup.length; i++)
	{
		cbGroup[i].checked = false;
	}
	thisState.checked = true;
}

function displayMenuFoot(liMenu)
{	
	if ((browser == 'IE 7') || (browser == 'IE 6')){ 
	}
	else
	{
		document.getElementById('liAutos').onmouseout();	
		document.getElementById('liSuvs').onmouseout();	
		document.getElementById('liCrossOvers').onmouseout();
		document.getElementById('liCamiones').onmouseout();
		document.getElementById('liTodos').onmouseout();		
		}
	document.getElementById(liMenu).onmouseover();
}
function footCompra()
{
	displayMenuFoot('liTodos');	
}
function todosGo(destino)
{
	var subSecc = document.location.hash.substring(1)	
	if(subSecc != '')
	{
		destino = destino + subSecc + '/';
	}
	window.location.href = destino;
}
function goLivePerson(){
	window.open('http://server.iad.liveperson.net/hc/21026524/?cmd=file&file=visitorWantsToChat&site=21026524&referrer='+document.location,'chat21026524','width=472,height=320');
}	
function pers_1_upPrices(transacc,lista)
{
	if(document.getElementById('precioT'))
		document.getElementById('precioT').innerHTML = transacc;	
	if(document.getElementById('precioL'))
		document.getElementById('precioL').innerHTML = lista;			
}
function car_photoUp(photo,Versions,idColor,txt,thu,tipo)
{
	document.getElementById('photoModel').src = photo;
	if(document.getElementById('photoVersions') && Versions != '')
		document.getElementById('photoVersions').innerHTML = Versions;	
	if(tipo == 'EXT')
	{
		var divsCont = document.getElementById('divsColorInts');
		var divs = divsCont.getElementsByTagName('div');
		for(var i = 0; i< divs.length; i++)
			divs[i].style.display = 'none';
		if(Versions != '')
			document.getElementById('div_colorInt_' + idColor).style.display = 'block';
		//para personaliza
		if(document.getElementById('idColorExt'))
			document.getElementById('idColorExt').value = idColor;
		if(document.getElementById('txtColorExt'))
			document.getElementById('txtColorExt').value = txt;
		if(document.getElementById('thuColorExt'))
			document.getElementById('thuColorExt').value = thu;			
		if(document.getElementById('configCompleted'))
			document.getElementById('configCompleted').innerHTML = '';			
		if(document.getElementById('btnSiguientePers'))
			document.getElementById('btnSiguientePers').style.display = 'none';	
		document.getElementById('espacio').innerHTML = '';
	}
	else if(tipo == 'INT')
	{
		//para personaliza
		if(document.getElementById('idColorInt'))
			document.getElementById('idColorInt').value = idColor;
		if(document.getElementById('txtColorInt'))
			document.getElementById('txtColorInt').value = txt;
		if(document.getElementById('thuColorInt'))
			document.getElementById('thuColorInt').value = thu;						
		//if(document.getElementById('t'))
		//	document.getElementById('t').value = 'B';
		document.getElementById('espacio').innerHTML = '<br><br>';
		if(document.getElementById('configCompleted'))
			document.getElementById('configCompleted').innerHTML = '¡ Tu configuraci&oacute;n est&aacute; lista !';		
		if(document.getElementById('btnSiguientePers'))
			document.getElementById('btnSiguientePers').style.display = 'block';			
	}
}
function displayGaleria(tipo)
{
	if(document.getElementById('divConoceloGaleria').style.display == 'none')
	{
		document.getElementById('divConoceloInfo').style.display = 'none';
		document.getElementById('divConoceloGaleria').style.display = 'block';
		if(tipo == 'INT')
			muestraOculta('interior,exterior','interior','currenP','galeriaP');
		if(tipo == 'EXT')
			muestraOculta('interior,exterior','exterior','currenP','galeriaP');
	}
	else
	{
		document.getElementById('divConoceloInfo').style.display = 'block';
		document.getElementById('divConoceloGaleria').style.display = 'none';		
	}
}
/* fichaTecnica */
function muestraOcultaT(galeria, actual,claseactual,claseswitch){
	var galer = galeria.split(",");
	for(i=0;i<galer.length; i++){
		document.getElementById(galer[i]+'p').className = claseswitch;
	}
	document.getElementById(actual+'p').className = claseactual;
}

function getDataTec(key, idVersion)
{
	var container_div = $('dataTechnicalVehicle');
	new Ajax.Request('/vehicles/especifications/popfichatecnicaDisplay.asp?idModel='+key+'&idVersion='+idVersion, {
		method: 'get',
		onCreate: function() {
			container_div.update('<div id="loading"><br>&nbsp;<br>&nbsp;<br>&nbsp;<br>&nbsp;<br>&nbsp;<br>&nbsp;</div>');
		},
		onSuccess: function(transport) {
			container_div.update(transport.responseText);
		}
	});
}
/* POPUP */
function popup(direccion, pantallacompleta, herramientas, direcciones, estado, barramenu, barrascroll, cambiatamano, ancho, alto, izquierda, arriba, sustituir){ 
 var opciones = "fullscreen=" + pantallacompleta + 
			 ",toolbar=" + herramientas + 
			 ",location=" + direcciones + 
			 ",status=" + estado + 
			 ",menubar=" + barramenu + 
			 ",scrollbars=" + barrascroll + 
			 ",resizable=" + cambiatamano + 
			 ",width=" + ancho + 
			 ",height=" + alto + 
			 ",left=" + izquierda + 
			 ",top=" + arriba; 
 var ventana = window.open(direccion,"venta",opciones,sustituir); 
}

function contacto()
{
	popup('/popUps/contacto.asp', 0, 0, 0, 0, 0, 1, 1, 400, 300, 1, 1, 0);	
	}
function opinion()
{
	popup('/popUps/opinion.asp', 0, 0, 0, 0, 0, 0, 1, 850, 550, 1, 1, 0);	
	}	
function bolsaTrabajo()
{
	popup('/popUps/bolsaTrabajo.asp', 0, 0, 0, 0, 0, 1, 1, 400, 300, 1, 1, 0);	
	}		
function compara(par1,par2)
{
	popup('/compara/beginCompareIndex.asp?FordVID='+par1+'&vesionname='+par2, 0, 0, 0, 0, 0, 1, 1, 850, 550, 1, 1, 0);	
	}	
function upEnganche(selPerc,PriceNF)
{
	var porcentaje = selPerc.options[selPerc.selectedIndex].value;
	var enganche = PriceNF * porcentaje/100;
	document.getElementById("enganche").value = formatCurrency(enganche);
	}
function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
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));
return (((sign)?'':'-') + '$' + num + '.' + cents);
}

function upPorcentaje(txtEngan,PriceNF,downPayment)
{
	var enganche = txtEngan.value;
	var porcentaje = Math.round(enganche / PriceNF * 100);	
	var financia70 = (PriceNF*70)/100;
	if(enganche < downPayment)
	{
		alert('El enganche no puede ser menor a $' + downPayment);
		txtEngan.value = downPayment;
		porcentaje = Math.round(downPayment / PriceNF * 100);
	}	
	if(enganche > financia70)
	{
		alert('El enganche no puede ser mayor a $' + financia70);
		txtEngan.value = financia70;
		porcentaje = 70;
	}
	//sel
	var	SelectObject = document.getElementById("porcentaje");
	for(index = 0;index < SelectObject.length; index++) 
	{
		if(SelectObject[index].value == porcentaje)
			SelectObject.selectedIndex = index;
	}	
}	
function numbersonly(myfield, e, dec)
{
	var key;
	var keychar;
	
	if (window.event)
	   key = window.event.keyCode;
	else if (e)
	   key = e.which;
	else
	   return true;
	keychar = String.fromCharCode(key);
	
	// control keys
	if ((key==null) || (key==0) || (key==8) || 
		(key==9) || (key==13) || (key==27) )
	   return true;
	
	// numbers
	else if ((("0123456789").indexOf(keychar) > -1))
	   return true;
	
	// decimal point jump
	else if (dec && (keychar == "."))
	   {
	   myfield.form.elements[dec].focus();
	   return false;
	   }
	else
	   return false;
}
function valBusqueda()
{
	var busqueda = document.getElementById("buscar").value;
	if(busqueda.length > 2)
	{
		return true;
	}
	else
	{
		document.getElementById("buscar").focus();
		return false;
	}
}
function chkMailPers()
{
	document.getElementById("chkMail").value = '1';
	document.formPers.submit();
}
