// Documento JavaScript// Esta función cargará las paginasfunction llamarasincrono(url, id_contenedor){	var pagina_requerida = false	location.hash="#"+url; 
		if (window.XMLHttpRequest) {// Si es Mozilla, Safari etc		pagina_requerida = new XMLHttpRequest()			} else if (window.ActiveXObject){ // pero si es IE		try {		pagina_requerida = new ActiveXObject("Msxml2.XMLHTTP")				} 		catch (e){ // en caso que sea una versión antigua		try{		pagina_requerida = new ActiveXObject("Microsoft.XMLHTTP")		}		catch (e){}		}		}		else		return false	pagina_requerida.onreadystatechange=function(){ // función de respuesta		cargarpagina(pagina_requerida, id_contenedor,url)		}							pagina_requerida.open('GET', url, true) // asignamos los métodos open y send			pagina_requerida.send(null)	}	function cargarpagina(pagina_requerida, id_contenedor,url){	if (pagina_requerida.readyState == 4 && (pagina_requerida.status==200 || window.location.href.indexOf("http")==-1))	document.getElementById(id_contenedor).innerHTML=pagina_requerida.responseText;
	if(url=="calcula_regalo.php"){	   var etiquetaScript=document.createElement("script");	   	document.getElementsByTagName('head')[0].appendChild(etiquetaScript);	   	//var resp=pagina_requerida.responseXML;		etiquetaScript.text='function carga_regalo(){var sregalo = new SWFObject("flash/regalo3.swf", "flashregalo", "659", "434", "8", "");sregalo.addParam("wmode", "transparent");sregalo.write("c_regalo");}setTimeout("carga_regalo()",250);';	}/*	if(url=="contacto.htm"){	   var etiquetaScript=document.createElement("script");	   	document.getElementsByTagName('head')[0].appendChild(etiquetaScript);	   	//var resp=pagina_requerida.responseXML;		etiquetaScript.text='function carga_contacto(){var sregalo = new SWFObject("flash/contacto.swf", "flashcontacto", "659", "434", "8", "");sregalo.addParam("wmode", "transparent");sregalo.write("c_contacto");}setTimeout("carga_contacto()",250);';	}*/		if(  url=="serviciosenergeticos.htm" || url=="proyectos_termica.htm" || url=="proyectos_fotovoltaicos.htm" || url=="granconsumoindustrialaudi.htm" || url=="granconsumoresidencialaudi.htm" || url=="noticiaslsol2.php" || url.indexOf("noticialsol.php") != -1 ||  url.indexOf("noticialsol2.php") != -1  ||  url=="promotorassolar.htm" || url=="particularesauditorias.htm" || url=="particularestermica.htm" || url=="navesauditorias.htm" || url=="navestermica.htm" || url=="agropecuarioauditorias.htm"  || url=="agropecuariofotovoltaica.htm"  || url=="noticiastermica2.php" || url.indexOf("noticiatermica.php") != -1 || url.indexOf("noticiatermica2.php") != -1 || url=="noticiasfotovoltaica2.php" || url.indexOf("noticiafotovoltaica.php") != -1 || url.indexOf("noticiafotovoltaica2.php") != -1  || url=="granconsumoindustrialtermica.htm" || url=="granconsumoresidencialtermica.htm"  ){
		var etiquetaScript=document.createElement("script");	   	document.getElementsByTagName('head')[0].appendChild(etiquetaScript);
	   	
		//etiquetaScript.text='function ini_todo(){addEvent(window,"load",easyscroll);};setTimeout("ini_todo();",250);';
		etiquetaScript.text='setTimeout("easyscroll();",500);';
	

	}	 	}
			/* 	Easy Scroll v1.0	written by Alen Grakalic, provided by Css Globe (cssglobe.com)	please visit http://cssglobe.com/post/1495/easy-scroll-accessible-content-scroller	*/ this.easyscroll=function(){	// id of the container element 	var id = "myContent";		// movement speed	var speed = 2;		// desired height of the container element (in pixels)	var height = 310;			//alert("objHeight "+ document.getElementById('myContent').offsetHeight +"<=heigh " +height);
	//	// END CONFIG	// do not edit below this line (unless you want to of course :) )	//	var obj = document.getElementById(id);
	
		   var objHeight = obj.offsetHeight;

		ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false
	if (objHeight<=height  ){
		if (ns4){
	 	document.getElementById('fabajo').visibility="hide";		document.getElementById('barra_scroll').visibility="hide";		document.getElementById('farriba').visibility="hide";		document.getElementById('cursor').visibility="hide"; 
	 	}
	 	else if (ie4) {
	 	document.getElementById('fabajo').style.visibility="hidden";		document.getElementById('barra_scroll').style.visibility="hidden";		document.getElementById('farriba').style.visibility="hidden";		document.getElementById('cursor').style.visibility="hidden"; 		}			// document.getElementById('fabajo').style.visibility="hidden";			//document.getElementById('barra_scroll').style.visibility="hidden";			//document.getElementById('farriba').style.visibility="hidden";			//document.getElementById('cursor').style.visibility="hidden"; 			}else {
	
		if (ns4){
	 	document.getElementById('fabajo').visibility="show";		document.getElementById('barra_scroll').visibility="show";		document.getElementById('farriba').visibility="show";		document.getElementById('cursor').visibility="show"; 
	 	}
	 	else if (ie4) {
	 	document.getElementById('fabajo').style.visibility="visible";		document.getElementById('barra_scroll').style.visibility="visible";		document.getElementById('farriba').style.visibility="visible";		document.getElementById('cursor').style.visibility="visible"; 		}
	}
		obj.up = false;	obj.down = false;	obj.fast = false;
// gcr INSTALACIONES DE GRAN CONSUMO SECTOR RESIDENCIAL 	
	obj.gcr1= false;	obj.gcr2= false;
	obj.gcr3= false;
	obj.gcr4= false;
	obj.gcr5= false;
	obj.gcr6= false;	
// gcr INSTALACIONES DE GRAN CONSUMO SECTOR INDUSTRIAL 	
	obj.gcs1= false;	obj.gcs2= false;
	obj.gcs3= false;
	obj.gcs4= false;
	obj.gcs5= false;
	obj.gcs6= false;					obj.gcs7= false;					var container = document.createElement("div");	var parent = obj.parentNode;	container.id="easyscroll";	parent.insertBefore(container,obj);	parent.removeChild(obj);			//container.style.position = "relative";	container.style.position = "absolute";	container.style.height = height + "px";
	container.style.overflow = "hidden";	obj.style.position = "absolute";	obj.style.top = "0";	obj.style.left = "0";	container.appendChild(obj);		//var btns = new Array();	/*var ul = document.createElement("ul");	ul.id="easyscrollnav";	for (var i=0;i<nav.length;i++){		var li = document.createElement("li");		li.innerHTML = nav[i];		li.id = navId[i];		btns.push(li);		ul.appendChild(li);	};		parent.insertBefore(ul,container);*/	/*	btns[0].onmouseover = function(){		obj.up = true;		this.className = "over";	};	btns[0].onmouseout = function(){		obj.up = false;		this.className = "";	};			btns[1].onmouseover = function(){		obj.down = true;		this.className = "over";			};	btns[1].onmouseout = function(){		obj.down = false;		this.className = "";	};			btns[0].onmousedown = btns[1].onmousedown = function(){		obj.fast = true;	};		btns[0].onmouseup = btns[1].onmouseup = function(){		obj.fast = false;	};			btns[2].onmouseover = function(){ 				this.className = "over";	};		btns[2].onmouseout = function(){ 				this.className = "";	};			btns[2].onclick = function(){ 				obj.style.top = "0px";	};		*/				var newTop=0;	 this.start= function(){		
	   var objHeight = obj.offsetHeight;
	   //var objHeight: document.getElementById('myContent').offsetHeight;		var top = obj.offsetTop;		var fast = (obj.fast) ? 2 : 1;		if(obj.down){		 			newTop = ((objHeight+top) > height) ? top-(speed*fast) : top;				obj.style.top = newTop + "px";		};			if(obj.up){		 			newTop = (top < 0) ? top+(speed*fast) : top;			obj.style.top = newTop + "px";		};
		if(obj.gcr1){		 			obj.style.top = -197 + "px";		};
		if(obj.gcr2){		 			obj.style.top = -549 + "px";		};		if(obj.gcr3){		 			obj.style.top = -847 + "px";		};		if(obj.gcr4){		 			obj.style.top = -954 + "px";		};		if(obj.gcr5){		 			obj.style.top = -1071 + "px";		};		if(obj.gcr6){		 			obj.style.top = -1545 + "px";		};		if(obj.gcs1){		 			obj.style.top = -191 + "px";		};
		if(obj.gcs2){		 			obj.style.top = -423 + "px";		};		if(obj.gcs3){		 			obj.style.top = -706 + "px";		};		if(obj.gcs4){		 			obj.style.top = -1008 + "px";		};		if(obj.gcs5){		 			obj.style.top = -1106 + "px";		};		if(obj.gcs6){		 			obj.style.top = -1210 + "px";		};		if(obj.gcs7){		 			obj.style.top = -1670 + "px";		};ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
	if (objHeight >height  ){
		
		
					if(obj.up || obj.down || obj.gcr1 || obj.gcr2 || obj.gcr3 || obj.gcr4 || obj.gcr5 || obj.gcr6 || obj.gcs1 || obj.gcs2 || obj.gcs3 || obj.gcs4 || obj.gcs5 || obj.gcs6 || obj.gcs7) {							distancia1=height-objHeight;					porcentaje=newTop*100/distancia1;					posnew=Math.round(porcentaje*240/100);//281 es la distancia que hay entre las flechas menos el grosor de el cursor					document.getElementById('cursor').style.top=(posnew+20)+ "px";					pcursor=parseInt(document.getElementById('cursor').style.top);					// 305 es la posicion top mas alta que puede tener el cursor
					if(pcursor>260){					document.getElementById('cursor').style.top="260px";					}
					// 20 es la posicion top mas baja que puede tener el cursor					if(pcursor<20){					document.getElementById('cursor').style.top="20px";					}					 //le sumo 20 porque es la altura de la flecha superior
					 obj.gcr1=false;
					 obj.gcr2=false;
					 obj.gcr3=false;
					 obj.gcr4=false;
					 obj.gcr5=false;
					 obj.gcr6=false;
					 obj.gcs1=false;
					 obj.gcs2=false;
					 obj.gcs3=false;
					 obj.gcs4=false;
					 obj.gcs5=false;
					 obj.gcs6=false;
					 obj.gcs7=false;
			}		}
		
					};	//	obj.interval = setInterval("start()",50);
//intervalito = setInterval("start()",50);			};//// script initiates on page load. //this.addEvent = function(obj,type,fn){
	if(obj.attachEvent){		obj['e'+type+fn] = fn;		obj[type+fn] = function(){obj['e'+type+fn](window.event );}		obj.attachEvent('on'+type, obj[type+fn]);	} else {		obj.addEventListener(type,fn,false);	};};//addEvent(window,"load",easyscroll);
//---------------------------------FIN DEL EASY SCROLL	





/// MOVER CURSOR ARRASTRANDOvar cursor_activo=false;function position(event){
	var nx = event.clientX;	var ny = event.clientY;	if (parseInt(navigator.appVersion)>3) { 			if (navigator.appName=="Netscape") { 			 winW = window.innerWidth; 			 winH = window.innerHeight;			 } 			if (navigator.appName.indexOf("Microsoft")!=-1) {  			winW = document.body.offsetWidth;  			winH = document.body.offsetHeight; 			}	}	inix= Math.round(((winW - document.getElementById('cuerpo').offsetWidth)/2)+809-6);	// WinW es el ancho interno de el explorador de windows	//cuerpo.offsetWidth es el ancho del div cuerpo que contene todo	//809 es la posicion left de barra_scrool dentro de cuerpo lo hago asi porque leer style.left da problemas	//-6 es para darle un poco de margen de actuaccioLn a el cursor del raton	finx=inix+30;	//inix e finx delimitan la zona dode horizontal donde se pueden recoger datos para el scroll, ya que la fucion position se llama desde onmousemove de barra_scrool
	posicion_inicial=238;
	//posicion_inicial es las distancia que hay desde el cursor ,cuando esta arriba del todo, hasta el borde superior del cuadro del navegador
	// 4 es la mitad del cursor
	
	posicion_final=485+10;
	//posicion_final es las distancia que hay desde el curso,r cuando esta abajo del todo, hasta el borde superior del cuadro del navegador

	if(cursor_activo && ny > posicion_inicial && ny < posicion_final && nx > inix && nx < finx){		alturascroll=260;
		//alturascroll es la disntancia entre flechas		poscursor=ny-218-10; 
		//-177 es porque es posicion top de barra_scrool + la posicion top de cuerpo ya que cursor esta dentro de   barra_scrool que a su vez esta dentro de cuerpo		//-10 es por la mitad de altura de el cursor para que se mueva con la flecha apuntando al centro del cursor
		document.getElementById('cursor').style.top=poscursor+"px";
		if(poscursor>301){			document.getElementById('cursor').style.top="301px";		}
		// 305 es la posicion top mas baja que puede tener el cursor		if(poscursor<20){		  document.getElementById('cursor').style.top="20px";		}					 //le sumo 20 porque es la altura de la flecha superior
		//-177 es porque es posicion top de barra_scrool + la posicion top de cuerpo ya que cursor esta dentro de   barra_scrool que a su vez esta dentro de cuerpo		//-10 es por la mitad de altura de el cursor para que se mueva con la flecha apuntando al centro del cursor
		distanciamenu=alturascroll-document.getElementById('myContent').offsetHeight;		distancia1=240;
		//281 es la distancia que hay entre las flechas menos el grosor de el cursor		
		altura=parseInt(document.getElementById('cursor').style.top);		porcentaje2=((altura-20)*100)/alturascroll;		//20 es la altura de la primera flecha		posnew=Math.round(((distanciamenu*porcentaje2)/100));		document.getElementById('myContent').style.top=posnew+ "px";	}else{		cursor_activo=false;	}}
function activa_cursor(){	cursor_activo=true;}function desactiva_cursor(){	cursor_activo=false;	}
