
function cmay(txt) {
var lst='á,&#xE1;,Á,&#xC1;,é,&#xE9;,É,&#xC9;,í,&#xED;,Í,&#xCD;,ó,&#xF3;,Ó,&#xD3;,ú,&#xFA;,Ú. &#xDA;,ñ,&#xF1;,Ñ,&#xD1;';lst=lst.split(',');
for(var i=0;i<lst.length;i+=2) {
		if (txt.indexOf(lst[i+1])!=-1) txt=rStr(txt,lst[i+1],lst[i]);
	}
	return txt;
}
					
function nav(eid,par){//alert(eid+' >> '+n+' >> '+l);
	if (eid!='Email') eval('tex=bck_'+eid); else tex='';
	//if (tex=='') alert('SI'); else alert('NO')
	if (tex=='') updTxt(eid,par); else divTxt.innerHTML="<table width=450 align=center><tr><td>"+tex+"</td></tr></table>";
	if (eid!='Email') eval('tex='+eid+'.innerHTML'); else var tex=eid;
	window.status = "Visualizando contenido de ::: " + tex;

}	// end nav()			
	
/*	 ----------------------------------- Helper routines in client-side script content  ----------------------------------- */
 
//Locally declared client-side function to return properly formed reference to page element
function el(id){
	if(document.all){
		return document.all[id];
	}else{
		return document.getElementById(id);
	}
}	// end el()	

function getOffsetTop (el) { 
var ot = el.offsetTop; 
while((el = el.offsetParent) != null) 
	ot += el.offsetTop; 
	alert(ot)//ot+=60;
	return ot; 
}

function deco(txt) {
var lst=new Array('&gt;','>','&lt;','<','&quot;','"','&amp;','&');
for (var i=0;i<lst.length;i+=2) {
	txt=rStr(txt,lst[i],lst[i+1]);
	}
return txt;
}

var http_request = false;
var Get_http_response;

            function alertContents() {

                if (http_request.readyState == 4) {
                    if (http_request.status == 200) {
								Get_http_response=http_request.responseText;
  								if (Get_http_response.indexOf("error '800")!=-1) 
  									alert('Ha habido un problema en la pagina\n=======================\n\n'+Get_http_response);
  								else {
	  								//alert(Get_http_response);
									var res=deco(Get_http_response);
									//alert(res)
									//eval('bck_'+varUpd+'=res');
									divTxt.innerHTML="<table width=450 align=center><tr><td>"+res+"</td></tr></table>";
  									}
                    	} 
                    else {
                        alert('Ha habido un problema en la conexion ('+http_request.responseText+')...');
                    }
                }
					//hidebox();
			     }

var varUpd='';

function updTxt(id,lv,nm) {//alert(id+' >> '+lv)
varUpd=id;
http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
   http_request = new XMLHttpRequest();
   if (http_request.overrideMimeType) {
       http_request.overrideMimeType('text/xml');
      }
   } else if (window.ActiveXObject) { // IE
      try {
          http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
           try {
              http_request = new ActiveXObject("Microsoft.XMLHTTP");
               } catch (e) {}
          }
     }
	if (!http_request) {
	  alert("No se puede crear la instancia XMLHTTP");
	  return false;
	}
	http_request.onreadystatechange = alertContents;
	http_request.open('POST','inc/gendata.asp?id='+id, true);
	if (lv!=null) {
		http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	   http_request.setRequestHeader("Content-length", lv.length);
	   http_request.setRequestHeader("Connection", "close");            	 
	   http_request.send(lv);
		}
	else
		http_request.send(null);
}

function rStr(inputString, fromString, toString) {
   // Goes through the inputString and replaces every occurrence of fromString with toString
   var temp = inputString;
   if (fromString == "") {
      return inputString;
   }
   if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop
      var midStrings = new Array("~", "`", "_", "^", "#");
      var midStringLen = 1;
      var midString = "";
      // Find a string that doesn't exist in the inputString to be used
      // as an "inbetween" string
      while (midString == "") {
         for (var i=0; i < midStrings.length; i++) {
            var tempMidString = "";

            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
            if (fromString.indexOf(tempMidString) == -1) {
               midString = tempMidString;
               i = midStrings.length + 1;
            }
         }
      } // Keep on going until we build an "inbetween" string that doesn't exist
      // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + midString + toTheRight;
      }
      // Next, replace the "inbetween" string with the "toString"
      while (temp.indexOf(midString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(midString));
         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;

      }
   } // Ends the check to see if the string being replaced is part of the replacement string or not
   return temp; // Send the updated string back to the user
} // Ends the "replaceSubstring" function

function validateform(form)
{
	if ( (form.buscar.value.length == 0) ) 
	{
		alert("Ha ocurrido el Siguiente Error:\n -La cadena de búsqueda no puede ser nula.");
		return false;
	}
	else {
		return true;
	}
}
function validateform1(form)
{
	if ( (form.enc1.value.length == 0) ) 
	{
		alert("Ha ocurrido el Siguiente Error:\n -Debes elegir uno de las dos opciones.");
		return false;
	}
	else {
		return true;
	}
}
function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' debe ser una dirección de email.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' no puede ser nulo.\n'; }
  } if (errors) alert('Ha Ocurrido el Siguiente Error:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
//MM_reloadPage(true);

var day=month=myweekday=dat="";
mydate = new Date();
myday = mydate.getDay();
mymonth = mydate.getMonth();
myweekday= mydate.getDate();
myyear = mydate.getYear();

lday=new Array(" Domingo, "," Lunes, "," Martes, "," Miercoles, "," Jueves, "," Viernes, "," Sabado, ");
lmonth=new Array("Enero ","Febrero ","Marzo ","Abril ","Mayo ","Junio ","Julio ","Agosto ","Septiembre ","Octubre ","Noviembre ","Diciembre ");

day = lday[myday]; 
month = lmonth[mymonth];

dat=day + myweekday + " de " + month + " de " + myyear;

///********************************

function validate() {
var form=document.data;
var er="",lx="Remitir="+escape(form.Remitir.value)+"&";
if (form.Nombre.value=="")	er+="\n - Nombre esta vacio"; else lx+="Nombre="+escape(form.Nombre.value)+"&";
if (form.Apellidos.value=="")	er+="\n - Apellidos esta vacio"; else lx+="Apellidos="+escape(form.Apellidos.value)+"&";
if (form.Telefono.value=="")	er+="\n - Telefono esta vacio"; else lx+="Telefono="+escape(form.Telefono.value)+"&";
//if (form.Pais.value=="")	er+="\n - Pais esta vacio"; else lx+="Pais="+escape(form.Pais.value)+"&";
if (form.Ciudad.value=="")	er+="\n - Ciudad esta vacio"; else lx+="Ciudad="+escape(form.Ciudad.value)+"&";
if (form.Email.value=="")	er+="\n - Email  esta vacio"; else lx+="Email="+escape(form.Email.value)+"&";
if (!IsEmail(data.Email.value)) 	er+="\n - Dirección de Correo Inválido \n"; 
if (er=="")
  {
 var langx=document.getElementById('Langx');lx+="Comentarios="+escape(form.Comentarios.value)+"&Lang="+langx.value;
  data.action="index.asp?Action=Email";
  data.submit();
//alert('OK')
  }
else { alert('Error en los siguintes Campos\n'+'=================='+er);return false;}

}

function IsEmail(sMail)
  {
    var iLastPos = sMail.length - 1;
    for (var iPos = 0; iPos <= iLastPos; iPos++)
      if (sMail.charAt(iPos) < "!" || sMail.charAt(iPos) > "~")
        return false;
      iPos = sMail.indexOf("@");
      if (iPos < 1 || iLastPos == iPos || sMail.charAt(iLastPos) == "." || sMail.indexOf("@", iPos + 1) >= 0 || sMail.indexOf(".", iPos + 1) < iPos + 2)
         return false;
      return true;
  }

function getOffsetLeft (el) { 
 var ol = el.offsetLeft; 
while ((el = el.offsetParent) != null) 
ol += el.offsetLeft; 
return ol; 
} 
function getOffsetTop (el) { 
var ot = el.offsetTop; 
while((el = el.offsetParent) != null) 
ot += el.offsetTop; 
ot+=18;
return ot; 
} 

function findCoordinates() { 
//var tableLeft = getOffsetLeft(table);
var tableTop1 = getOffsetTop(menuTable); 
var tableTop2 = getOffsetTop(menuTable2); 
//alert(tableTop1 + ':' + tableTop2); 
smenu.style.height=tableTop1-tableTop2;
//document.getElementById('firma').style.left= tableLeft; 
//document.getElementById('firma').style.top= tableTop;  
}  

//*********************************//
var browserdetect="ie"

function slowhigh(which2){
imgobj=which2
browserdetect=which2.filters? "ie" : typeof which2.style.MozOpacity=="string"? "mozilla" : ""
instantset(baseopacity)
highlighting=setInterval("gradualfade(imgobj)",50)
}

function slowlow(which2){
cleartimer()
instantset(baseopacity)
}

function instantset(degree){
if (browserdetect=="mozilla")
imgobj.style.MozOpacity=degree/100
else if (browserdetect=="ie")
imgobj.filters.alpha.opacity=degree
}

function cleartimer(){
if (window.highlighting) clearInterval(highlighting)
}

function gradualfade(cur2){
if (browserdetect=="mozilla" && cur2.style.MozOpacity<1)
cur2.style.MozOpacity=Math.min(parseFloat(cur2.style.MozOpacity)+0.1, 0.99)
else if (browserdetect=="ie" && cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=10
else if (window.highlighting)
clearInterval(highlighting)
}

//*****************************************//

function montre(id,ind) {
var vx=vy=0,d = document.getElementById(id);
menu.style.visibility='visible';
if (id=='smenu2') {vx=100;vy=40;}
menu.style.top=getOffsetTop(document.getElementById('mx'+ind))+vy;
menu.style.left=getOffsetLeft(document.getElementById('mx'+ind))+vx;
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
if (d) {d.style.display='block';}
}

var timer;
var brwsVer=parseInt(navigator.appVersion);

function hideSubMenu(){
	if (brwsVer>=4) {
		if (document.all) 
			document.getElementById('smenu1').style.display='none';
		 else 
			document.smenu1.display='none';
	}
}


function hover(obj){
  if(document.all){
    UL = obj.getElementsByTagName('ul');
    //menu.offsetHeight=38;
    if(UL.length > 0){
      sousMenu = UL[0].style;
      if(sousMenu.display == 'none' || sousMenu.display == ''){
        sousMenu.display = 'block';
      }else{
        sousMenu.display = 'none';
      }
    }
  }
}

function setHover(){
  LI = document.getElementById('menu').getElementsByTagName('li');
  nLI = LI.length;
  for(i=0; i < nLI; i++){
    LI[i].onmouseover = function(){
      hover(this);
    }
    LI[i].onmouseout = function(){
      hover(this);
    }
  }
}

// fxde

var slideShowSpeed = 100
var crossFadeDuration = 100
var Pic = new Array()
//Pic[0] = 'img_idm/gallery/nuevos1.jpg'
var t
var j = 0
var p = Pic.length

var preLoad = new Array();pxL();

function pxL() {
	for (i = 0; i < p; i++){
	   preLoad[i] = new Image()
	   preLoad[i].src = Pic[i]
	}
}

function runSlideShow(){
	if (p>0) {slideShowSpeed = tiempo_slider;
	   if (document.all){
	      document.images.SlideShow.style.filter="blendTrans(duration=2)"
	      document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
	      document.images.SlideShow.filters.blendTrans.Apply()      
	   }
	   //alert(j+' >> '+preLoad[j].src)
	   document.images.SlideShow.src = preLoad[j].src
	   if (document.all){
	      document.images.SlideShow.filters.blendTrans.Play()
	   }
	   j = j + 1
	   if (j > (p-1)) j=0
	  }    
   t = setTimeout('runSlideShow()', slideShowSpeed);
}
