function nuevoAjax(){ 
	var xmlhttp=false;
	try{
		// Creacion del objeto AJAX para navegadores no IE
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
	}catch(e){
		try{
			// Creacion del objet AJAX para IE
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}catch(E){
			if (!xmlhttp && typeof XMLHttpRequest!='undefined') xmlhttp=new XMLHttpRequest();
		}
	}
	return xmlhttp; 
}

function calcularAltoPantalla(){
	if (self.innerHeight) {
		altoPantalla = parseInt(self.innerHeight);
	}else if (document.documentElement && document.documentElement.clientHeight) {
		altoPantalla = parseInt(document.documentElement.clientHeight);
	}else if (document.body.clientHeight) {
		altoPantalla = parseInt(document.body.clientHeight);
	}
	
	return altoPantalla;
}

function calcularAnchoPantalla(){
	 if (self.innerWidth) {
		anchoPantalla = parseInt(self.innerWidth);
	}else if (document.documentElement && document.documentElement.clientWidth) {
		anchoPantalla = parseInt(document.documentElement.clientWidth);
	}else if (document.body.clientWidth) {
		anchoPantalla = parseInt(document.body.clientWidth);
	}
	
	if (navigator.appVersion.indexOf("MSIE 8") != -1) anchoPantalla = anchoPantalla + 20
	
	return anchoPantalla;
}

function calcularposScroll(){
	if (navigator.appVersion.indexOf("MSIE") != -1) return document.body.parentNode.scrollTop;
	else return window.scrollY;
}

function posicionarAviso(){
	var anchoPantalla = calcularAnchoPantalla();
	var altoPantalla = calcularAltoPantalla();
	var posicionScroll = calcularposScroll();
	
	if (document.getElementById('fondoAviso').style.visibility == 'visible') {
		document.getElementById('fondoAviso').style.width = anchoPantalla + "px";
		document.getElementById('fondoAviso').style.height = altoPantalla + "px";
		document.getElementById('fondoAviso').style.top = posicionScroll + "px";
		
		document.getElementById('aviso').style.left = anchoPantalla/2 - 850/2 + "px";
		document.getElementById('aviso').style.top = "15px";
	}
}

function cargarConcesionarios(){
	var anchoPantalla = calcularAnchoPantalla();
	var altoPantalla = calcularAltoPantalla();
	var posicionScroll = calcularposScroll();
	
	document.body.className = "scrollBarHidden";
	
	document.getElementById('fondoAviso').style.width = anchoPantalla + "px";
	document.getElementById('fondoAviso').style.height = altoPantalla + "px";
	document.getElementById('fondoAviso').style.visibility = 'visible';
	document.getElementById('fondoAviso').style.top = "0px";
	
	document.getElementById('aviso').style.left = anchoPantalla/2 - 850/2 + "px";
	document.getElementById('aviso').style.top = "15px"
	
	var ap=nuevoAjax();
	ap.open("POST", "concesionarios.html", true);
	ap.onreadystatechange=function(){
		if (ap.readyState==4){ 
			window.scrollTo("0px","0px")
			document.getElementById('aviso').innerHTML = ap.responseText;
		} 
	}
	
    ap.send(null);
}

function cerrarConcesionarios(){
	document.getElementById('aviso').innerHTML = "";
	document.getElementById('fondoAviso').style.height = 10;
	document.getElementById('fondoAviso').style.width = 10;
	document.getElementById('fondoAviso').style.visibility = 'hidden';
	
	if (navigator.appVersion.indexOf("Safari") != -1) document.body.className = "scrollBarVisibleSafari";
	else document.body.className = "scrollBarVisible";
}

