function Eventos(div,nivel_estilo,estado)
{
    div.className=gruposEstilo[nivel_estilo][estado];
}

function EnlaceMenuPricipal(url,target)
{
    target=target.toLowerCase();
    if(target=='_blank')window.open(url);
    if(target=='_self')self.location.href=url;
    if(target=='_top')top.location.href=url;
    if(target=='_parent')parent.location.href=url;
}

function EnlaceMenu(url,target)
{
    target=target.toLowerCase();
    if(target=='_blank')window.open(url);
    else if(target=='_top')top.location.href=url;
    else if(target=='_parent')parent.location.href=url;
    else self.location.href=url;
}

//******************************************************************************************************************
function Imprimir(cod_area, cod_perfil, print_area, print_navegacion, print_titulo, estilos)
{	
	var pp = window.open();
	pp.document.writeln('<HTML>')
	pp.document.writeln('<HEAD><title>Vista previa</title>')
	pp.document.writeln(estilos)
	pp.document.writeln('<LINK href="/estilos/PrintStyle.css"  type="text/css" rel="stylesheet" media="print"><base target="_self">')
	pp.document.writeln('</HEAD>')
	pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0">');
	pp.document.writeln('<form  method="post">');
	pp.document.writeln(' <div id="TBL_Cabecera">');
	pp.document.writeln(' <input name="button" type="button" id="PRINT" onclick="javascript:location.reload(true);window.print();" value="Imprimir" />');
	pp.document.writeln(' <input name="button2" type="button" id="CLOSE" onclick="window.close();" value="Cerrar" />');
	pp.document.writeln(' </div>');
    pp.document.writeln(' <div id="IMP_Cabecera">');
    pp.document.writeln('   <table width="100%" border="0" cellspacing="0" cellpadding="0">');
    pp.document.writeln('     <tr>');
    pp.document.writeln('       <td style="width: 50%;"><img src="/images/'+cod_area+'/print_logo_principal.gif" /></td>');
    pp.document.writeln('       <td width="50%" align="right"><img src="/images/'+cod_area+'/'+cod_perfil+'/print_logo_derecha.gif" /></td>');
    pp.document.writeln('     </tr>');
    pp.document.writeln('   </table>');
    pp.document.writeln(' </div>');
    pp.document.writeln(' <div class="IMP_BarraGris"></div>');
    pp.document.writeln(' <div class="IMP_BarraModulo"></div>');
    pp.document.writeln(' <div class="IMP_Navegacion">'+document.getElementById(print_navegacion).innerHTML+'</div>');
    pp.document.writeln(' <div class="IMP_Titulo">'+document.getElementById(print_titulo).innerHTML+'</div>');
    pp.document.writeln(' <div style="padding-bottom:20px;" class="IMP_Contenido">'+document.getElementById(print_area).innerHTML+'</div>');
	pp.document.writeln('</form></body></HTML>');			
}	


function PrintLanguage(cod_area, cod_perfil, print_area, print_navegacion, print_titulo, estilos,print,close)
{	
	var pp = window.open();
	pp.document.writeln('<HTML>')
	pp.document.writeln('<HEAD><title>Vista previa</title>')
	pp.document.writeln(estilos)
	pp.document.writeln('<LINK href="/estilos/PrintStyle.css"  type="text/css" rel="stylesheet" media="print"><base target="_self">')
	pp.document.writeln('</HEAD>')
	pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0">');
	pp.document.writeln('<form  method="post">');
	pp.document.writeln(' <div id="TBL_Cabecera">');
	pp.document.writeln(' <input name="button" type="button" id="PRINT" onclick="javascript:location.reload(true);window.print();" value="'+ print+'" />');
	pp.document.writeln(' <input name="button2" type="button" id="CLOSE" onclick="window.close();" value="'+ close +'" />');
	pp.document.writeln(' </div>');
    pp.document.writeln(' <div id="IMP_Cabecera">');
    pp.document.writeln('   <table width="100%" border="0" cellspacing="0" cellpadding="0">');
    pp.document.writeln('     <tr>');
    pp.document.writeln('       <td style="width: 50%;"><img src="/images/'+cod_area+'/print_logo_principal.gif" /></td>');
    pp.document.writeln('       <td width="50%" align="right"><img src="/images/'+cod_area+'/'+cod_perfil+'/print_logo_derecha.gif" /></td>');
    pp.document.writeln('     </tr>');
    pp.document.writeln('   </table>');
    pp.document.writeln(' </div>');
    pp.document.writeln(' <div class="IMP_BarraGris"></div>');
    pp.document.writeln(' <div class="IMP_BarraModulo"></div>');
    pp.document.writeln(' <div class="IMP_Navegacion">'+document.getElementById(print_navegacion).innerHTML+'</div>');
    pp.document.writeln(' <div class="IMP_Titulo">'+document.getElementById(print_titulo).innerHTML+'</div>');
    pp.document.writeln(' <div style="padding-bottom:20px;" class="IMP_Contenido">'+document.getElementById(print_area).innerHTML+'</div>');
	pp.document.writeln('</form></body></HTML>');			
}	

function trim(str) {
  while (str.charAt(0) == ' ') str = str.substring(1);
  while (str.charAt(str.length - 1) == ' ') str = str.substring(0, str.length - 1);
  return str;
}

function esEmail(txt_email)
{
    txt_email.value=trim(txt_email.value);
    var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
    if (filter.test(txt_email.value)){
        return true;
    }else{
        return false;
    }
}

function consisfec(day, month, year)
{
  //month(0-11)
  var isValid = true;
  var enteredDate = new Date(year,month,day);
  if (enteredDate.getDate() != day)
  {
    isValid = false;
  }
  return isValid;
}

function alfanumericocaptcha(elm) {
var estado=true;
var longitud=0;
    if (elm !='') {
       longitud=elm.length;
       for (i=0;i<longitud;i++)
        estado = (estado &&
              (((elm.substr(i,1).toUpperCase() >= 'A') && (elm.substr(i,1).toUpperCase() <= 'Z')) || ((elm.substr(i,1) >= '0') && (elm.substr(i,1) <= '9'))));
       return estado; }
    else return false;
}

function alfanumerico(elm) {
var estado=true;
var longitud=0;
    if (elm !='') {
       longitud=elm.length;
       for (i=0;i<longitud;i++)
        estado = (estado &&
              (((elm.substr(i,1).toUpperCase() >= 'A') && (elm.substr(i,1).toUpperCase() <= 'Z')) || (elm.substr(i,1)=='-') || (elm.substr(i,1)=='_') || ((elm.substr(i,1) >= '0') && (elm.substr(i,1) <= '9'))));
       return estado; }
    else return false;
}

// Chequeando nulos y vacIos

function noVacio(elm) {
    if (elm.value == '' ||
        elm.value == null) 
    return false;
    else return true;
}
/**/
function actualizaContador(obj, max) 
{
	longitud=obj.value.length;
	if (longitud>max) obj.value=obj.value.substr(0,max);
	obj.form.Contador.value=obj.value.length;
}

function bNavegador() {
  if( navigator.appName )
  {
    if( navigator.appName == "Microsoft Internet Explorer")  return 1;
    if( navigator.appName == "Netscape")  return 2;
  }
  return 0;
}

bNombre = navigator.appName;
bVer = parseInt(navigator.appVersion);
if ( (bNombre == 'Netscape' && bVer >= 3 ) ||
    (bNombre == 'Microsoft Internet Explorer' && bVer >= 4))
     braunser = 'n3';
else braunser = 'n2';

var IE4=(document.all) && (braunser=='n3');
var anchoPantalla=(window.screen.availWidth);
function imgAct(imgNombre) {
  if (braunser == "n3")
    document.images[imgNombre].src = eval( imgNombre + "on.src" );
}

function imgInact(imgNombre) {
  if (braunser == "n3")
    document.images[imgNombre].src = eval(imgNombre + "off.src");
}

function abreVentana(pUrl, pWindowName, pWidth, pHeight, pAttrib, pCuadrante) 
{
    var anchoDisponibleVentana=window.screen.availWidth;
    var altoDisponibleVentana=window.screen.availHeight;
    // '1 si, 2 sd, 3 ii, 4 id, 5 c [pCuadrante]
    var lngX =0;
    var lngY =0;
    if (pCuadrante==1) {lngX =0;lngY=0;}
    else if (pCuadrante==2) {lngX=(anchoDisponibleVentana - pWidth -15);lngY=0;}
    else if (pCuadrante==3) {lngX=0;lngY=(altoDisponibleVentana -30 - pHeight);}
    else if (pCuadrante==4) {lngX=(anchoDisponibleVentana - pWidth -15);lngY=(altoDisponibleVentana -30 - pHeight);}
    else {lngX =((anchoDisponibleVentana - pWidth)/2);lngY = ((altoDisponibleVentana - pHeight)/2);}

    var attrib = 'left=' + lngX + ',top=' + (lngY-30) + ',';
	    attrib += 'screenX=' + lngX + ',screenY=' + lngY + ',width='+pWidth+',height='+pHeight;
	//attrib += 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,maximize=no';}
	attrib += pAttrib;
    window.open (pUrl, pWindowName, attrib);
}

function cierraventana(zero) {
window.close();
}

function RedirectPageOther(p){
	document.location.href=p;
}

function ByPassOther(p){
	parent.RedirectPageOther(p);
}

function ByPassOtherOpener(p){
    window.opener.RedirectPageOther(p);
}

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_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_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}

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 invocaPintadaJS(paramE){
document.write(paramE);
}

//When the page loads: 
function preparaObjetos() {
	if (document.getElementsByTagName) {
		var objs = document.getElementsByTagName("object"); //Get all the tags of type object in the page.
		for (i=0; i<objs.length; i++) objs[i].outerHTML = objs[i].outerHTML; //Get the HTML content of each object tag and replace it with itself.
	}
}

//When the page unloads: 
function liberaObjetos() {
	if (document.getElementsByTagName) {
		var objs = document.getElementsByTagName("object"); //Get all the tags of type object in the page.
		for (i=0; i<objs.length; i++) objs[i].outerHTML = ""; //Clear out the HTML content of each object tag to prevent an IE memory leak issue.
	}
}

function SetEstilo(obj,back,fore) {
	obj.style.backgroundColor=back;
	obj.style.color=fore;
	obj.style.cursor='hand';
}
function toggledisplay(ee) {
	if (document.getElementById) {
		e=document.getElementById(ee);
		e.style.display =(e.style.display == 'none'?'block':'none');
	} else {
		if (document.layers) {
			document.ee.display=(document.ee.display=='none'?'block':'none');
		} else {
			document.all.ee.style.display = (document.all.ee.style.visibility=='none'?'block':'none');
		}
	}
}

	
//******************************************************************************************************************
// POPUPS
//******************************************************************************************************************
function CerrarPopup(id)
{
	//var POP_ContenedorCerrar='POP_Contenedor_'+id;
	var POP_ContenedorCerrar='POP_Contenedor_1';
	var capa = document.getElementById(POP_ContenedorCerrar);
	capa.style.display = "none";
}

function ConstruirPopup(pId,pTitulo,pContenido,pAncho,pAlto,pCuadrante,pCorX,pCorY,pTransparente,pEsFlash)
{
    pTitulo = '&nbsp;';
    var div_pop=document.getElementById('POP_Contenedor_'+pId);
    
    if(div_pop.style.display == "none"){ 
	    if(pCuadrante!=6){
		    var anchoDisponibleVentana=window.screen.availWidth;
		    var altoDisponibleVentana=window.screen.availHeight;
		    // '1 si, 2 sd, 3 ii, 4 id, 5 c [pCuadrante]
		    var lngX =0;
		    var lngY =0;
		    if (pCuadrante==1) {lngX =0;lngY=0;}
		    else if (pCuadrante==2) {lngX=(anchoDisponibleVentana - pAncho -15);lngY=0;}
		    else if (pCuadrante==3) {lngX=0;lngY=(altoDisponibleVentana -30 - pAlto);}
		    else if (pCuadrante==4) {lngX=(anchoDisponibleVentana - pAncho -15);lngY=(altoDisponibleVentana -30 - pAlto);}
		    else {lngX =((anchoDisponibleVentana - pAncho)/2);lngY = ((altoDisponibleVentana - pAlto)/2);}
		    pCorX=lngX;
		    pCorY=lngY;
	    }
    	
	    var Id_Contendor='POP_Contenedor_'+pId;
    	
	    var Id_Info='POP_Contenedor_Info_'+pId;
    	var Id_Arrastrar='POP_Contenedor_Arrastrar_'+pId;
	   
		    var Id_Titulo='POP_Contenedor_Titulo_'+pId;
		    var	popupDiv='<div id="'+Id_Contendor+'" '+ (pTransparente=='true'?'class="POP_Contenedor_ST"':'class="POP_Contenedor_CT"') +'>';


				popupDiv+='<div id="'+Id_Titulo+'" class="POP_ContenedorTitulo"' + (pTransparente=='true'?'style="display:none;"':'"style="display:block;"') + '><p>'+pTitulo+'</p></div>';
				popupDiv+='<div class="POP_ContenedorCerrar"'+ (pTransparente=='true'?'style="display:none;"':'"style="display:block;"') +'><a href="javascript:CerrarPopup('+pId+')";>X</a></div>';


				popupDiv+='<div id="'+Id_Info+'" class="POP_Contenido">';


				popupDiv+='<div id="'+Id_Arrastrar+'" '+ (pTransparente=='false'?'style="display:none;"':'"style="display:block;"') +' >'+pContenido+'</div>';

				if(pTransparente=='false' ){
					popupDiv+=pContenido;					
				}
				

				popupDiv+='</div></div>';

		    document.getElementById(Id_Contendor).style.display="block";
		    document.getElementById(Id_Contendor).style.position='absolute';
 		    document.getElementById(Id_Contendor).innerHTML = popupDiv;
		    document.getElementById(Id_Info).style.height=pAlto+'px';
    		
		    if(pEsFlash=='true'){
			    document.getElementById(Id_Info).style.width=pAncho+'px';
			    document.getElementById(Id_Info).style.padding ="0px";
		    }else{
			    document.getElementById(Id_Info).style.width=pAncho-20+'px';
    			
		    }
		    document.getElementById(Id_Info).style.overflow="auto";
		    document.getElementById(Id_Contendor).style.width = pAncho+'px';
		    document.getElementById(Id_Contendor).style.left = pCorX+'px';
		    document.getElementById(Id_Contendor).style.top = pCorY+'px';
    		
	        if(pTransparente=='false'){
		        if (window.XMLHttpRequest) {
			        var alturaTitulo=document.getElementById(Id_Titulo).maxHeight;
			        document.getElementById(Id_Titulo).style.width= pAncho+'px';
		        } else {
		            var alturaTitulo=document.getElementById(Id_Titulo).offsetHeight;
			        document.getElementById(Id_Titulo).style.width= pAncho+'px';
		        }
		        var Cabecera = document.getElementById(Id_Titulo);
		        var Contenedor = document.getElementById(Id_Contendor);
		        Drag.init(Cabecera, Contenedor);
	        }else{
		        if(pEsFlash=='false'){
			        document.getElementById(Id_Contendor).style.height = pAlto+'px';
			        document.getElementById(Id_Contendor).style.border="0 none black";
			        var Arrastrar = document.getElementById(Id_Arrastrar);
			        var Contenedor = document.getElementById(Id_Contendor);
			        Drag.init(Arrastrar, Contenedor);
		    }
	    }
    }
}
-->
