<!--
/////////////////////////////////////////////////////////////////////////////
setFormat(document.formatoFechaCalendario);
setMonthNames(document.enero, document.febrero, document.marzo, document.abril, document.mayo, document.junio, document.julio, document.agosto, document.septiembre, document.octubre, document.noviembre, document.diciembre);
setDayNames(document.domingo, document.lunes, document.martes, document.miercoles, document.jueves, document.viernes, document.sabado);
setLinkNames("[ " + document.tex_cerrar + " ]", "[ " + document.tex_borrar + " ]");
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////
//// Funciones de checkbox de listado ////////////
retardo = new Array();
var ocultar
var empezar = true
window.onload = function() {
	empezar = true
}
function muestra_retarda(ind){
	 if (empezar){
		clearTimeout(retardo[ind])
	 }
}
function xDef() {
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}
function oculta_retarda(capa){
 if (empezar){
	 
	var ocultar = capa
	clearTimeout(retardo[capa]);
	retardo[capa] = setTimeout("xHide('" + ocultar + "')",1000)
 }
}
function xHide(e) {
	//var e = document.getElementById(e);
  if(!(e=document.getElementById(e))) return;
  if(e.style && xDef(e.style.display)) e.style.display='none';
}
function buscarTagEntreHijos(src, tag)
{
	if(src.hasChildNodes()){
		for(i=0;i<src.childNodes.length;i++){
			//alert(src.childNodes[i].nodeName + ' -> ' + tag);
			if(src.childNodes[i].nodeName == tag){
				return src.childNodes[i];
				break;
			}else{
				nodoHijo = buscarTagEntreHijos(src.childNodes[i], tag);
				if(nodoHijo){
					return nodoHijo;
				}
			}
		}
	}else{
		return false;
	}
}

function buscarCampoTodos(formName)
{
	losInputs = document.forms[formName].getElementsByTagName('INPUT');
	for(i=0;i<losInputs.length;i++){
		if(losInputs[i].id.substr(0,5) == 'todos'){
			return losInputs[i];
		}
	}
	return false;
}

function trOver(src, styleOver, styleSelected)
{
	if(src.className != styleSelected){
		src.className = styleOver;
	}
}

function trOut(src, styleNormal, styleSelected)
{
	if(src.className != styleSelected){
		src.className = styleNormal;
	}
}

function trClickMenu(src)
{
	tagA = buscarTagEntreHijos(src, 'A');
	if(tagA){
		window.location=tagA.href;
		//window.top.location=tagA.href; /// para ir al frame superior
	}
}



//// fin funciones de checkbox de listado ////////////
//////////////////////////////////////////////////////
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

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 openBrWindow(theURL,winName,features) { //v2.0
   self.name = "CMSMain";
   window.open(theURL,winName,features);
}

function FE_rusure(msg, object, href){
	question = confirm(msg + '\t\t\n\n' + object)
	if (question !="0"){
		location.href = href;
	}
}

function FE_validateForm() { //v4.0

   var i,p,q,nm,test,num,min,max,errors='',args=FE_validateForm.arguments;
   for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.id; if ((val=val.value)!="") {
      if (test.indexOf('isDate')!=-1) { // fecha

		var fmt = document.formatoFecha;

		var parte = fmt.split(fmt.charAt(1));
		var patron = '^';
		if(val.indexOf('/') != -1){
			var fecha = val.split('/');	var sep = '/';
		}else if(val.indexOf('-') != -1){
			var fecha = val.split('-');	var sep = '-';
		}else{
			var fecha = val.split('.'); var sep = '\.';
		}
		for(j=0;j<parte.length;j++){
			if(parte[j] == 'd' || parte[j] == 'm' || parte[j] == 'M' || parte[j] == 'F'){
				patron += '\(\\d{1,2}\)';
				if(parte[j] == 'd'){
					dia = fecha[j];
				}else{
					mes = fecha[j] - 1;
				}
			}else if(parte[j] == 'Y'){
				patron += '\(\\d{4}\)';
				anio = fecha[j];
			}else if(parte[j] == 'y'){
				patron += '\(\\d{2}\)';
				anio = fecha[j];
			}
			if(j < (parte.length-1)){
				patron += sep;
			}
		}
		patron += '$';

		var arrFecha=val.match(patron);
		if(arrFecha){

			var myDate=new Date(anio,mes,dia);
			if(myDate.getFullYear()!=anio||myDate.getDate()!=dia||myDate.getMonth()!=mes){
				errors+='* ' + nm + ' ' + document.msg_valid_debeSerFecha + '\n';
			}

		}else{
			errors+='* ' + nm + ' ' + document.msg_valid_debeSerFecha + '\n';
		}

	  } else if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='* '+nm+' ' + document.msg_valid_debeSerEmail + '\n';
      } else if (test.indexOf('isEqual')!=-1) { p=test.indexOf('isEqual');
	  	valorIgualar = test.substring(p+8);
		valorIgualar = MM_findObj(valorIgualar);
		valorIgualar = valorIgualar.value;
		//alert(valorIgualar);
		if(val != valorIgualar){
			errors += '* ' + document.msg_valid_passDebeSerIguales + '\n';
		}
	  } else if (test!='R') {
        if (isNaN(val)) errors+='* '+nm+' ' + document.msg_valid_debeSerNumero + '\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if ((val*1)<(min*1) || (max*1)<(val*1)) errors+='* '+nm+' ' + document.msg_valid_debeSerNumeroEnt + ' '+min+' ' + document.tex_y + ' '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '* '+nm+' ' + document.msg_valid_obligatorio + '\n'; }
   } if (errors) alert(document.msg_valid_ocurrieronErrores + '\t\t\t\t\n\n'+errors);
    document.returnValue = (errors == '');

}
function clearText(thefield){
	if (thefield.defaultValue==thefield.value)
	thefield.value = ""
}


function mailAntiSpam(usuario, dominio)
{
	//var usuario = "nombre_de_usuario"
	//var dominio = "dominio.com"
	document.write("<a href=\"mailto:" + usuario + "@" + dominio + "\" style=\"text-decoration:none\">" + usuario + "@" + dominio + "</a>")
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function BrowserDetect() {
   var ua = navigator.userAgent.toLowerCase(); 

   // browser engine name
   this.isGecko       = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
   this.isAppleWebKit = (ua.indexOf('applewebkit') != -1);

   // browser name
   this.isKonqueror   = (ua.indexOf('konqueror') != -1); 
   this.isSafari      = (ua.indexOf('safari') != - 1);
   this.isOmniweb     = (ua.indexOf('omniweb') != - 1);
   this.isOpera       = (ua.indexOf('opera') != -1); 
   this.isIcab        = (ua.indexOf('icab') != -1); 
   this.isAol         = (ua.indexOf('aol') != -1); 
   this.isIE          = (ua.indexOf('msie') != -1 && !this.isOpera && (ua.indexOf('webtv') == -1) ); 
   this.isMozilla     = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
   this.isFirefox     = (ua.indexOf('firefox/') != -1 || ua.indexOf('firebird/') != -1);
   this.isNS          = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && !this.isOpera && !this.isSafari && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
   
   // spoofing and compatible browsers
   this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
   this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);
   
   // rendering engine versions
   this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
   this.equivalentMozilla = ( (this.isGecko) ? parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) ) : -1 );
   this.appleWebKitVersion = ( (this.isAppleWebKit) ? parseFloat( ua.substring( ua.indexOf('applewebkit/') + 12) ) : -1 );
   
   // browser version
   this.versionMinor = parseFloat(navigator.appVersion); 
   
   // correct version number
   if (this.isGecko && !this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('/', ua.indexOf('gecko/') + 6) + 1 ) );
   }
   else if (this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
   }
   else if (this.isIE && this.versionMinor >= 4) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
   }
   else if (this.isKonqueror) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
   }
   else if (this.isSafari) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('safari/') + 7 ) );
   }
   else if (this.isOmniweb) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('omniweb/') + 8 ) );
   }
   else if (this.isOpera) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera') + 6 ) );
   }
   else if (this.isIcab) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab') + 5 ) );
   }
   
   this.versionMajor = parseInt(this.versionMinor); 
   
   // dom support
   this.isDOM1 = (document.getElementById);
   this.isDOM2Event = (document.addEventListener && document.removeEventListener);
   
   // css compatibility mode
   this.mode = document.compatMode ? document.compatMode : 'BackCompat';

   // platform
   this.isWin    = (ua.indexOf('win') != -1);
   this.isWin32  = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
   this.isMac    = (ua.indexOf('mac') != -1);
   this.isUnix   = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
   this.isLinux  = (ua.indexOf('linux') != -1);
   
   // specific browser shortcuts
   this.isNS4x = (this.isNS && this.versionMajor == 4);
   this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
   this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
   this.isNS4up = (this.isNS && this.versionMinor >= 4);
   this.isNS6x = (this.isNS && this.versionMajor == 6);
   this.isNS6up = (this.isNS && this.versionMajor >= 6);
   this.isNS7x = (this.isNS && this.versionMajor == 7);
   this.isNS7up = (this.isNS && this.versionMajor >= 7);
   
   this.isIE4x = (this.isIE && this.versionMajor == 4);
   this.isIE4up = (this.isIE && this.versionMajor >= 4);
   this.isIE5x = (this.isIE && this.versionMajor == 5);
   this.isIE55 = (this.isIE && this.versionMinor == 5.5);
   this.isIE5up = (this.isIE && this.versionMajor >= 5);
   this.isIE6x = (this.isIE && this.versionMajor == 6);
   this.isIE6up = (this.isIE && this.versionMajor >= 6);
   
   this.isIE4xMac = (this.isIE4x && this.isMac);
}

var browser = new BrowserDetect();

function XHConn()
{
  var xmlhttp, bComplete = false;
  try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
  catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
  catch (e) { try { xmlhttp = new XMLHttpRequest(); }
  catch (e) { xmlhttp = false; }}}
  if (!xmlhttp) return null;
  this.connect = function(sURL, sMethod, sVars, fnDone)
  {
    if (!xmlhttp) return false;
    bComplete = false;
    sMethod = sMethod.toUpperCase();

    try {
      if (sMethod == "GET")
      {
        xmlhttp.open(sMethod, sURL+"?"+sVars, true);
        sVars = "";
      }
      else
      {
        xmlhttp.open(sMethod, sURL, true);
        xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
        xmlhttp.setRequestHeader("Content-Type",
          "application/x-www-form-urlencoded");
      }
      xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState == 4 && !bComplete)
        {
          bComplete = true;
          fnDone(xmlhttp);
        }};
      xmlhttp.send(sVars);
    }
    catch(z) { return false; }
    return true;
  };
  return this;
}
function getAbsoluteElementPosition(element) {
  if (typeof element == "string")
    element = document.getElementById(element)
    
  if (!element) return { top:0,left:0 };
  
  var y = 0;
  var x = 0;
  while (element.offsetParent) {
    x += element.offsetLeft;
    y += element.offsetTop;
    element = element.offsetParent;
  }
  return {top:y,left:x};
}
function xShow(e) {
  if(!(e=document.getElementById(e))) return;
  if(e.style && xDef(e.style.display)) e.style.display='block';
}
function showSubCatmenu(cat,status,pos,div1,div2,offX,offY,orY){
	
	var posi = getAbsoluteElementPosition(document.getElementById(pos));
	var left=posi.left+offX;
	if(BrowserDetect.browser=="Firefox" && orY=="top"){
		var top=posi.top;
	}else if(BrowserDetect.browser=="Firefox"){
		var top=(posi.top+offY)-5;
	}else if((BrowserDetect.browser=="Opera" || BrowserDetect.browser=="Safari") && orY=="top"){
		var top=(posi.top+offY)-4;	
	}else{
		var top=posi.top+offY-5;
	}
	//alert(div1);
	theObjects=document.getElementsByName(div1);
	if (empezar){
		for (var i = 0; i < theObjects.length; i++) {
			var laid=div2+i;
			//alert(laid);
			if(cat==i){
				//alert(document.getElementById(laid).offsetHeight);
				document.getElementById(laid).style.left = left + 'px';
				xShow(laid);
				if(orY=='top'){
					top=top-(document.getElementById(laid).offsetHeight);
				}
				document.getElementById(laid).style.top  = top+'px';
			}else{
				xHide(laid);
			}
		}
		clearTimeout(retardo[laid])
	}
}
function showSubCatmenufixed(status){

	pos = findPos('encabezado');
	pos = pos.toString();
	//alert(pos);
	var posi=pos.split(",");
	if(!padding)var padding=180;
	
	//theObjects=document.getElementsByName('rama');
	//alert(document.getElementById('men_0').style.visibility);
	//for (var i = 0; i < theObjects.length; i++) {
		var laid='menu_s';
		//alert(posi[0]);
		//if(cat==i){
			d=parseInt(posi[0])+parseInt(padding);
			document.getElementById(laid).style.left = d+'px';
			document.getElementById(laid).style.top  = '5px';
			document.getElementById(laid).style.display = status;
		//}else{
		//	document.getElementById(laid).style.display = 'none';
		//}
	//}
}
function showSubCatmenuIdioma(cat,status,pos,div1,div2){
	pos = findPos(pos);
	pos = pos.toString();
	var posi=pos.split(",");
	theObjects=document.getElementsByName(div1);
	//alert(document.getElementById('men_idioma0').style.visibility);
	//alert("estos"+theObjects.length);
	for (var i = 0; i < theObjects.length; i++) {
		var laid=div2+i;
		if(cat==i){
			d=parseInt(posi[1])-10;
			//className
			//document.getElementById(laid).style.left = posi[0]+'px';
			//document.getElementById(laid).style.top  = d+'px';
			document.getElementById(laid).style.display = status;
		}else{
			//document.getElementById('men_idioma'+i).style.visibility = 'hidden';
			document.getElementById(laid).style.display = 'none';
		}
	}
}

function findPos(obj) {
	var elob=document.getElementById(obj);
	//alert(obj);
	var curleft = curtop = 0;
	if (elob.offsetParent) {
		curleft = elob.offsetLeft
		curtop = elob.offsetTop
		while (elob = elob.offsetParent) {
			curleft += elob.offsetLeft
			curtop += elob.offsetTop
		}
	}
	return [curleft,curtop];
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function show_lay(id_lay,id_cat,accion,ub,campo){
	lay=document.getElementById(id_lay);
	pos = findPos(ub);
	pos = pos.toString();
	var posi=pos.split(",");
	d=parseInt(posi[1])+25;
	lay.style.left = posi[0]+'px';
	lay.style.top  = d+'px';
	
	var myConn = new XHConn();
	
	lay.style.display="block";
	self.scrollTo(0, 0);
	myConn.connect("menu.php", "POST", "id_cat="+id_cat+"&id_lay="+id_lay+"&accion="+accion+"&campo="+campo,funcLayExito);
	lay.innerHTML = "<div><div align='right'><a href=\"javascript:ocultar_lay(\'"+id_lay+"\')\"><img src=\'../images/cruz.png\' border=\'0\'/></a></div></div><div><img src=\'../images/loading.gif\' width=\'27\' height=\'27\' /></div>";

}
var funcLayExito = function (oXML)
{
		var mensaje=oXML.responseText.split("[_VSD_]");
		//alert(mensaje[0]);
		if(mensaje[1]==''){
			window.opener.location.reload();
			window.close();
		}
	document.getElementById(mensaje[0]).innerHTML = mensaje[1];
	document.getElementById(mensaje[0]).scrollTop += document.tamanioscroll;
}
function cargar_campo(elcampo,valor){
	document.getElementById(elcampo).value=valor;
}

function ocultar_lay(layer){
	document.getElementById(layer).innerHTML = "";
	document.getElementById(layer).style.display="none";
}
function mostrar_bases(){
	if(document.getElementById('bases').style.visibility == 'hidden'){
		document.getElementById('bases').style.visibility = 'visible';
		document.getElementById('bases').style.display = 'block';
	}else{
		document.getElementById('bases').style.visibility = 'hidden';
		document.getElementById('bases').style.display = 'none';
	}
}



function Popup(url,name,width,height,resize,scroll) {
	var dialogWin = new Object();
	dialogWin.width = width;
	dialogWin.height = height;
	if (navigator.appName == "Netscape") {
		dialogWin.left = window.screenX + ((window.outerWidth - dialogWin.width) / 2);
		dialogWin.top = window.screenY + ((window.outerHeight - dialogWin.height) / 2);
		var attr = 'screenX=' + dialogWin.left + ',screenY=' + dialogWin.top + ',resizable=' + resize + ',width=' + dialogWin.width + ',height=' + dialogWin.height + ',scrollbars=' + scroll + ',menubar=no,location=no,toolbar=no,status=no,directories=no';
	} else if (document.all) {
		dialogWin.left = (screen.width - dialogWin.width) / 2;
		dialogWin.top = (screen.height - dialogWin.height) / 2;
		var attr = 'left=' + dialogWin.left + ',top=' + dialogWin.top + ',resizable=' + resize + ',width=' + dialogWin.width + ',height=' + dialogWin.height + ',scrollbars=' + scroll + ',menubar=no,location=no,toolbar=no,status=no,directories=no';
	}
	window.open(url,name,attr);
}
//-->
////////////////////////// scripts layer Voz ////////////////////////////
function setVariables_voz() { 
if (navigator.appName == "Netscape") { 
v_voz=".top="; 
dS_voz="document."; 
sD_voz=""; 
y_voz="window.pageYOffset"; 
} 
else { 
v_voz=".pixelTop="; 
dS_voz=""; 
sD_voz=".style"; 
y_voz="document.body.scrollTop"; 
} 
} 
function checkLocation_div_voz() { 

object_voz="object_voz1"; 
yy_voz=eval(y_voz); 
eval(dS_voz+object_voz+sD_voz+v_voz+yy_voz); 
setTimeout("checkLocation_div_voz()",10); 
} 
////////////////////////// FIN scripts layer Voz ////////////////////////////
