

function setVisibility(id, visibility) 
	{
	document.getElementById(id).style.display = visibility;
	}
	
function validaSelEstado()
	{
	var envia=false;
	var radios = document.getElementsByName( 'estado[]' );
    for( i = 0; i < radios.length; i++ ) {
        if( radios[i].checked ) {
            //return radios[i].value;
			envia=true;
        }
    }
	if (envia)
		document.busquedaConces.submit();
	else
		alert("Selecciona un Estado");
	}
	
function validaConces()
	{
	var envia=false;
	var radios = document.getElementsByName( 'conces[]' );
    for( i = 0; i < radios.length; i++ ) {
        if( radios[i].checked ) {
			envia=true;
        }
    }
	if (envia)
		document.busquedaConces.submit();
	else
		alert("Selecciona un concesionario");
	}

function showservicio(texto,imagen,cambio)
	{
	var valor=document.getElementById( 'servicio' );
	valor.innerHTML=texto;
	var valor2=document.getElementById( imagen );
	valor2.src=cambio;
	
	}
	
function centerPopup(Input,nombre){
var fondo;
var general;
var close;
general="#"+nombre+"Contact";
fondo="#background"+nombre;
close="#"+nombre+"ContactClose";

	var pagina=getWindowData();
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	
	var popupHeight = $(general).height();
	var popupWidth = $(general).width();
	$(general).css({
		"position": "absolute",
		"top": (pagina[1]/2)-(popupHeight/2)+pagina[3]+"px",
		"left": (windowWidth/2)-(popupWidth/2) + "px"
	});
	$(fondo).css({
		"height": windowHeight
	});
	
	loadPopup(nombre);
	/*
	$(fondo).click(disablePopup(nombre));			
	$(close).click(disablePopup(nombre));*/	
}	
	

function getWindowData(){
    var widthViewport,heightViewport,xScroll,yScroll,widthTotal,heightTotal;
    if (typeof window.innerWidth != 'undefined'){
        widthViewport= window.innerWidth-17;
        heightViewport= window.innerHeight-17;
    }else if(typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth !='undefined' && document.documentElement.clientWidth != 0){
        widthViewport=document.documentElement.clientWidth;
        heightViewport=document.documentElement.clientHeight;
    }else{
        widthViewport= document.getElementsByTagName('body')[0].clientWidth;
        heightViewport=document.getElementsByTagName('body')[0].clientHeight;
    }
    xScroll=self.pageXOffset || (document.documentElement.scrollLeft+document.body.scrollLeft);
    yScroll=self.pageYOffset || (document.documentElement.scrollTop+document.body.scrollTop);
    widthTotal=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth,widthViewport);
    heightTotal=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,heightViewport);
    return [widthViewport,heightViewport,xScroll,yScroll,widthTotal,heightTotal];
}	
var popupStatus2 = 0;

function loadPopup(nombre){

var fondo;
var general;

general="#"+nombre+"Contact";
fondo="#background"+nombre;

	//loads popup only if it is disabled
	if(popupStatus2==0){
		
		$(fondo).fadeIn("slow");
		$(general).fadeIn("slow");
		popupStatus2 = 1;
	}
}

function disablePopup(nombre){
var fondo;
var general;

general="#"+nombre+"Contact";
fondo="#background"+nombre;

	//disables popup only if it is enabled
	if(popupStatus2==1){
		$(fondo).fadeOut("slow");
		$(general).fadeOut("slow");
		popupStatus2 = 0;
	}
}

function cambia(imagen,valor)
	{
	
	imagen.src="imagenes/"+valor;
	}
	
function mycarousel_itemLoadCallback(carousel, state)
{
    for (var i = carousel.first; i <= carousel.last; i++) {
        if (carousel.has(i)) {
            continue;
        }

        if (i > mycarousel_itemList.length) {
            break;
        }

        // Create an object from HTML
        var item = jQuery(mycarousel_getItemHTML(mycarousel_itemList[i-1])).get(0);

        // Apply thickbox
        tb_init(item);

        carousel.add(i, item);
    }
};

/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(item)
{
    var url_m = item.url.replace(/_s.jpg/g, '_m.jpg');
    return '<a href="' + url_m + '" title="' + item.title + '"><img src="' + item.url + '" width="75" height="75" border="0" alt="' + item.title + '" /></a>';
};

function oculta_faq(id)
	{
	if ($(id).is(":hidden")) 
		{
		$(id).slideDown("slow");
		}
	else
		{
		$(id).slideUp("slow");
		}
	}
	
function iSubmitEnter(oEvento, oFormulario){
var iAscii;

if (oEvento.keyCode)
iAscii = oEvento.keyCode;
else if (oEvento.which)
iAscii = oEvento.which;
else
return false;

if (iAscii == 13) 
	{
	if (valida_precio_inicial(oFormulario.precio.value,oFormulario.inicial.value))
		oFormulario.submit();
	}


//oFormulario.submit();

return true;
}

