function Ajax(url,f,loading){var intentos=0;var self;var indicemodal=0;this.xmlDoc=null;this.url=url?url:null;this.f=f?f:null;this.loading=loading?loading:null;this.loaderror=null;this.running=false;this.id=Math.random();this.init=function(){if(window.XMLHttpRequest){this.xmlDoc=new XMLHttpRequest();this.xmlDoc.onreadystatechange=check}else{if(window.ActiveXObject){this.xmlDoc=new ActiveXObject("Microsoft.XMLHTTP");if(this.xmlDoc){this.xmlDoc.onreadystatechange=check}}else{alert("Tu navegador no puede soportar el script")}}};this.run=function(run_url,run_f,run_loading){this.url=run_url?run_url:this.url;this.f=run_f?run_f:this.f;this.loading=run_loading?run_loading:this.loading;this.init();this.running=true;if(this.loading!=null){if(typeof(self.loading)=="function"){self.loading()}else{eval(self.loading)}}eval(this.loading);try{this.xmlDoc.open("GET",this.url,true);this.xmlDoc.send(null)}catch(e){checkerror()}};function check(){if(self.xmlDoc.readyState==4){if(self.xmlDoc.status==200){self.running=false;if(typeof(self.f)=="function"){self.f()}else{eval(self.f)}intentos=0}else{checkerror()}}}function checkerror(){self.running=false;if(self.loaderror!=null){if(typeof(self.loaderror)=="function"){self.loaderror()}else{eval(self.loaderror)}}else{if(intentos<3){if(confirm("Ha ocurrido un error de comunicación con el servidor. ¿Desea reintentar?")){intentos++;self.run()}else{intentos=0;self.errorLabel("ERROR: No se ha podido establecer comunicaci&oacute;n con el servidor.")}}else{intentos=0;self.errorLabel("Error de comunicaci&oacute;n con el servidor.\nPor favor, vuelva a intentarlo pasados unos minutos.")}}return}var label;var modal2Html="";this.hideTimeout=2;this.errorTimeout=5;this.showLabel=function(msg){crearEtiqueta();label.style.color="#000";label.style.background="#FD6";label.innerHTML=msg;label.style.display=""};this.hideLabel=function(msg){if(msg){crearEtiqueta();label.style.color="#FFF";label.style.background="#093";label.innerHTML=msg;setTimeout(function(){if(document.getElementById("_ajax_label")){document.body.removeChild(document.getElementById("_ajax_label"))}},this.hideTimeout*1000)}else{if(document.getElementById("_ajax_label")){document.body.removeChild(document.getElementById("_ajax_label"))}}};this.errorLabel=function(msg){crearEtiqueta();label.style.color="#FFF";label.style.background="#C30";label.innerHTML=msg;setTimeout(function(){if(document.getElementById("_ajax_label")){document.body.removeChild(document.getElementById("_ajax_label"))}},this.errorTimeout*1000)};this.showModal=function(html){indicemodal++;bgTrans();var idventana="_ajax_modalcontent_"+this.id+"_"+indicemodal;if(!document.getElementById(idventana)){var modalcontent=document.createElement("DIV");modalcontent.style.cssText="position:absolute; left: 0px; top: 0px; width: 100%; height: 100%; z-index:"+((1000*indicemodal)+1)+";";modalcontent.id=idventana;document.body.appendChild(modalcontent)}document.getElementById(idventana).innerHTML='<table border="0" width="100%" height="100%" align="center"><tr><td align="center"><div class="modalstyle">'+html+"</div></td></tr></table>";document.getElementById(idventana).style.top=getScrollY()};this.showModalFade=function(html){this.showModal(html);fadeIn(document.getElementById("_ajax_modalcontent_"+this.id+"_"+indicemodal),10)};this.showModalURL=function(url,ancho,alto){this.showModal('<iframe name="frame_ajax" width="'+ancho+'" height="'+alto+'" scrolling="no" src="'+url+'" frameborder="no"></iframe>')};this.showModalPopup=function(html){modal2Html=html;indicemodal++;bgTrans();if(!document.getElementById("_ajax_modal2_"+this.id+"_"+indicemodal)){var modal=document.createElement("DIV");modal.style.cssText="position: absolute; z-index:"+((1000*indicemodal)+1)+"; left: -45px; width: 15px; height: 15px; border: 1px solid #469dbe;";modal.style.top=getScrollY()+15+"px";modal.id="_ajax_modal2_"+this.id+"_"+indicemodal;document.body.appendChild(modal)}modal2mover()};this.hideModal=function(){visionCombos("visible");if(document.getElementById("_ajax_modal2_"+this.id+"_"+indicemodal)){document.body.removeChild(document.getElementById("_ajax_modal2_"+this.id+"_"+indicemodal));document.body.removeChild(document.getElementById("_ajax_trans_"+this.id+"_"+indicemodal));indicemodal--}else{if(document.getElementById("_ajax_modalcontent_"+this.id+"_"+indicemodal)){document.body.removeChild(document.getElementById("_ajax_modalcontent_"+this.id+"_"+indicemodal));document.body.removeChild(document.getElementById("_ajax_trans_"+this.id+"_"+indicemodal));indicemodal--}}if(indicemodal>0&&document.getElementById("_ajax_modalcontent_"+this.id+"_"+indicemodal)){document.getElementById("_ajax_modalcontent_"+this.id+"_"+indicemodal).style.top=getScrollY()}};this.hideModalFade=function(){if(document.getElementById("_ajax_modal2_"+this.id+"_"+indicemodal)){fadeOut(document.getElementById("_ajax_modal2_"+this.id+"_"+indicemodal),90)}else{if(document.getElementById("_ajax_modalcontent_"+this.id+"_"+indicemodal)){fadeOut(document.getElementById("_ajax_modalcontent_"+this.id+"_"+indicemodal),90)}}};function crearEtiqueta(){if(document.getElementById("_ajax_label")){label=document.getElementById("_ajax_label")}else{label=document.createElement("SPAN");label.style.cssText="position: absolute; right:0px; padding: 2px 20px 2px 20px; font-family: arial; font-size: 13px; font-weight: bold; z-index: 99";label.id="_ajax_label";document.body.appendChild(label)}label.style.top=getScrollY()}function modal2mover(){var modal=document.getElementById("_ajax_modal2_"+self.id+"_"+indicemodal);if(modal.style.left!="30px"){modal.style.left=parseInt(modal.style.left.replace("px",""))+5+"px";setTimeout(function(){modal2mover()},1)}else{setTimeout("document.getElementById('_ajax_modal2_"+self.id+"_"+indicemodal+'\').style.background="#FF850D"',100);setTimeout("document.getElementById('_ajax_modal2_"+self.id+"_"+indicemodal+'\').style.background="#FFF"',200);setTimeout("document.getElementById('_ajax_modal2_"+self.id+"_"+indicemodal+'\').style.background="#FF850D"',300);setTimeout("document.getElementById('_ajax_modal2_"+self.id+"_"+indicemodal+'\').style.background="#FFF"',400);setTimeout("document.getElementById('_ajax_modal2_"+self.id+"_"+indicemodal+'\').style.background="#FF850D"',500);setTimeout("document.getElementById('_ajax_modal2_"+self.id+"_"+indicemodal+'\').style.background="#FFF"',600);setTimeout(function(){modal2resize()},700)}}function modal2resize(){var modal=document.getElementById("_ajax_modal2_"+self.id+"_"+indicemodal);if(modal.style.width!=415+"px"){modal.style.width=parseInt(modal.style.width.replace("px",""))+40+"px";modal.style.height=parseInt(modal.style.height.replace("px",""))+10+"px";setTimeout(function(){modal2resize()},20)}else{modal.style.background="url(http://www.facilisimo.com/mensajes/expocasa/images/logo.gif) no-repeat top center #FFF";modal.style.height="auto";modal.innerHTML='<div style="margin: 50px 0 15px 0; text-align: center;">'+modal2Html+"</p>"}}function bgTrans(){if(!document.getElementById("_ajax_trans_"+self.id+"_"+indicemodal)){var modal=document.createElement("DIV");if(document.all){modal.style.filter="Alpha(Opacity=80)"}else{modal.style.opacity="0.8"}var altura=document.documentElement.scrollHeight;modal.style.position="absolute";modal.style.height=altura+"px";modal.style.top="0px";modal.style.left="0px";modal.style.zIndex=1000*indicemodal;modal.style.width="100%";modal.className="ajax_trans";modal.id="_ajax_trans_"+self.id+"_"+indicemodal;document.body.appendChild(modal);visionCombos("hidden")}}function fadeIn(ventana,opacidad){if(document.all){ventana.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+opacidad+")"}else{if(opacidad>=100){ventana.style.MozOpacity="1.00"}else{ventana.style.MozOpacity="."+opacidad}}if(opacidad<100){if(document.all){setTimeout(function(){fadeIn(ventana,opacidad+10)},1)}else{setTimeout(function(){fadeIn(ventana,opacidad+25)},1)}}}function fadeOut(ventana,opacidad){if(document.all){ventana.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+opacidad+")"}else{ventana.style.MozOpacity="."+opacidad}if(opacidad>0){if(document.all){setTimeout(function(){fadeOut(ventana,opacidad-10)},1)}else{setTimeout(function(){fadeOut(ventana,opacidad-25)},1)}}else{self.hideModal()}}function visionCombos(opcion){if(document.all){if(indicemodal<=1){var arr=document.getElementsByTagName("select")}else{if(document.getElementById("_ajax_modal2_"+self.id+"_"+(indicemodal-1))){var arr=document.getElementById("_ajax_modal2_"+self.id+"_"+(indicemodal-1)).getElementsByTagName("select")}else{if(document.getElementById("_ajax_modalcontent_"+self.id+"_"+(indicemodal-1))){var arr=document.getElementById("_ajax_modalcontent_"+self.id+"_"+(indicemodal-1)).getElementsByTagName("select")}}}for(i=0;i<arr.length;i++){arr[i].style.visibility=opcion}}var arr_obj=document.getElementsByTagName("object");for(i=0;i<arr_obj.length;i++){arr_obj[i].style.visibility=opcion}}function getScrollY(){var scrollY=0;if(document.documentElement&&document.documentElement.scrollTop){scrollY=document.documentElement.scrollTop}else{if(document.body&&document.body.scrollTop){scrollY=document.body.scrollTop}else{if(window.pageYOffset){scrollY=window.pageYOffset}else{if(window.scrollY){scrollY=window.scrollY}}}}return scrollY}self=this};