
	function Privilegios(fileBrowser){
		try {
			//UniversalFileRead
			//UniversalXPConnect
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
			//alert(fileBrowser.value);
		} catch (e) {
			//alert('Unable to access local files due to browser security settings. To overcome this, follow these steps: (1) Enter "about:config" in the URL field; (2) Right click and select New->Boolean; (3) Enter "signed.applets.codebase_principal_support" (without the quotes) as a new preference name; (4) Click OK and try loading the file again.');
			//alert("CATH--");
		}
		return fileBrowser.value;
	}

var propiedades = 'status=no,menubar=no,toolbar=no,directories=0,width=400,height=400,top=40,left=40,scrollbars=no,location=0,resizable=0';
//var propiedades = 'status=yes,menubar=yes,toolbar=yes,directories=0,width=600,height=600,top=40,left=40,scrollbars=no,location=0,resizable=0';
var propiedades2 = 'status=yes,menubar=yes,toolbar=yes,directories=0,width=600,height=600,top=40,left=40,scrollbars=no,location=0,resizable=0';


//Funciones de Jquery para desactivar todos los controles
function disabledAllAudit(){
	$(document).ready(function(){
		
		$(":input").attr("disabled",true); 
		$(":input[@type='hidden']").attr("disabled",false);
		//excepciones
		$(":input[@name='mascara_cod_grupo']").attr("disabled",false);
		$(":input[@name='buscar_leyes']").attr("disabled",false);
		$(":input[@name='frase']").attr("disabled",false);
		
	});
	
}
function enabledAllAudit(){
	$(document).ready(function(){
		$(":input").removeAttr("disabled");
	});
}
//Fin funciones Jquery




function abrirventana(url,cual){
	visor = window.open(url,'visor_1',propiedades+cual);
}

//FORMULARIOS MACROMEDIA-------------------------------------------------------------------------------
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 correo electrónico.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' debe ser un número.\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+' debe ser un número entre '+min+' y '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' es un campo obligatorio.\n'; }
  } if (errors) alert('Por favor, corrija los siguientes errores para enviar el formulario:\n\n'+errors);
  document.MM_returnValue = (errors == '');
}
//FORMULARIOS MACROMEDIA-------------------------------------------------------------------------------

function control_formulario(formula,accion,target,cadena)
{
	if (target==1)
	{
		document.forms[formula].target="_blank";
	}
	if (accion=='reset')
	{
		document.forms[formula].reset();
	}
	if (accion=='enviar')
	{
		document.forms[formula].submit(); 
	}
}

function marca_envia(formula,campo,valor)
{
		document.forms[formula].elements[campo].value=valor;
		document.forms[formula].submit();
}



function traslada_combo(formula,campo_origen,campo_destino)
{
		var antes = '';
		var valor = '';
		var j=0;
		antes=document.forms[formula].elements[campo_destino].value;
		//Recorremos array de campo origen para pasar el valor a campo destino
		for(i=0;i<document.forms[formula].elements[campo_origen].length;i++){
				if (document.forms[formula].elements[campo_origen][i].selected)
					{ j=i; break; } 	
		}
		if (document.forms[formula].elements[campo_origen][j].value!="") 
		{		
			valor=document.forms[formula].elements[campo_origen][j].value;
			if (antes!="")
			{ antes = antes + ';'; }
			antes = antes + valor;
			
			if(antes != "NULL"){
				document.forms[formula].elements[campo_destino].value=antes;	
			}
			
		}
}

function traslada_combo_texto(formula,campo_origen,campo_destino)
{
		var antes = '';
		var valor = '';
		var j=0;
		
		antes=document.forms[formula].elements[campo_destino].value;
		//Recorremos array de campo origen para pasar el valor a campo destino
		for(i=0;i<document.forms[formula].elements[campo_origen].length;i++){
				if (document.forms[formula].elements[campo_origen][i].selected)
					{ j=i; break; } 	
		}
		if (document.forms[formula].elements[campo_origen][j].value!="") 
		{		
			valor=document.forms[formula].elements[campo_origen][j].text;
			if (antes!="")
			{ antes = antes + ';'; }
			antes = antes + valor;
			document.forms[formula].elements[campo_destino].value=antes;
		}
}

function traslada_combo_simple(formula,campo_origen,campo_destino)
{
		var antes = '';
		var valor = '';
		var j=0;
		//antes=document.forms[formula].elements[campo_destino].text;
		//Recorremos array de campo origen para pasar el valor a campo destino
		for(i=0;i<document.forms[formula].elements[campo_origen].length;i++)
		{
				if (document.forms[formula].elements[campo_origen][i].selected)
					{ j=i; break; } 	
		}
		if (document.forms[formula].elements[campo_origen][j].value!="") 
		{		
			valor=document.forms[formula].elements[campo_origen][j].text;
			antes = valor;
			document.forms[formula].elements[campo_destino].value=antes;
		}
}


var pro = 'status=yes,menubar=no,toolbar=no,directories=0,width=750,height=525,top=40,left=40,scrollbars=no,location=0,resizable=0';

function ampliarTexto(formu,caja,titulo,texto){

		out = "\n"; // reemplazar el salto de linea
		add = "|"; // por un caracter inusual
		temp = "" + texto;	
		temp2 = "";
		while (temp.indexOf(out)>-1) {
			pos= temp.indexOf(out);
			temp = "" + (temp.substring(0, pos) + add + 
			temp.substring((pos + out.length), temp.length));
		}
		
		out = "\""; // reemplazar la comilla doble
		add = "~"; // por un caracter inusual
		while (temp.indexOf(out)>-1) {
			pos= temp.indexOf(out);
			temp = "" + (temp.substring(0, pos) + add + 
			temp.substring((pos + out.length), temp.length));
		}
		
		out = "\'"; // reemplazar la comilla simple
		add = "¬"; // por un caracter inusual
		while (temp.indexOf(out)>-1) {
			pos= temp.indexOf(out);
			temp = "" + (temp.substring(0, pos) + add + 
			temp.substring((pos + out.length), temp.length));
		}
		milista = temp.split("|");
		for(i=0;i<milista.length; i++){
			if(milista[i].length > 1){
					temp2 = temp2 + milista[i];
			}
		}
	
		document.forms.editor_texto.formu.value=formu;
		document.forms.editor_texto.caja.value=caja;
		document.forms.editor_texto.titulo.value=titulo;		
		document.forms.editor_texto.texto.value=temp;
		document.forms.editor_texto.submit();
}

function figurasHabituales(formu,caja1,titulo,texto1,caja2,texto2){

		out = "\n"; // reemplazar el salto de linea
		add = "|"; // por un caracter inusual
		temp = "" + texto1;	
		temp2 = "" + texto2;
		while (temp.indexOf(out)>-1) {
			pos= temp.indexOf(out);
			temp = "" + (temp.substring(0, pos) + add + 
			temp.substring((pos + out.length), temp.length));
		}
		
		while (temp2.indexOf(out)>-1) {
			pos= temp2.indexOf(out);
			temp2 = "" + (temp2.substring(0, pos) + add + 
			temp2.substring((pos + out.length), temp2.length));
		}		
		
		out = "\""; // reemplazar la comilla doble
		add = "~"; // por un caracter inusual
		while (temp.indexOf(out)>-1) {
			pos= temp.indexOf(out);
			temp = "" + (temp.substring(0, pos) + add + 
			temp.substring((pos + out.length), temp.length));
		}
		
		while (temp2.indexOf(out)>-1) {
			pos= temp2.indexOf(out);
			temp2 = "" + (temp2.substring(0, pos) + add + 
			temp2.substring((pos + out.length), temp2.length));
		}		
		
		out = "\'"; // reemplazar la comilla simple
		add = "¬"; // por un caracter inusual
		while (temp.indexOf(out)>-1) {
			pos= temp.indexOf(out);
			temp = "" + (temp.substring(0, pos) + add + 
			temp.substring((pos + out.length), temp.length));
		}
		
		while (temp2.indexOf(out)>-1) {
			pos= temp2.indexOf(out);
			temp2 = "" + (temp2.substring(0, pos) + add + 
			temp2.substring((pos + out.length), temp2.length));
		}		
		
		/*
		milista = temp.split("|");
		for(i=0;i<milista.length; i++){
			if(milista[i].length > 1){
					temp2 = temp2 + milista[i];
			}
		}
		*/
			
		document.forms.figuras_habituales.formu.value=formu;
		document.forms.figuras_habituales.caja1.value=caja1;
		document.forms.figuras_habituales.titulo.value=titulo;		
		document.forms.figuras_habituales.texto1.value=temp;
		document.forms.figuras_habituales.caja2.value=caja2;		
		document.forms.figuras_habituales.texto2.value=temp2;		
		document.forms.figuras_habituales.submit();
}


function limpiar_inputs(formula,campo)
{
		document.forms[formula].elements[campo].value="";
}	


//--------------------------------

function limita(field) {
	//alert("entro en limita");
  if (field.maxlength) {
    maxLength = eval(field.maxlength);
    if (field.value.length > maxLength) {
	  alert("Has superado el tamaño máximo permitido (" + maxLength + " caracteres)" ); 	
      field.value = field.value.substring(0,maxLength);
    }
  }
}

//--------------------------------

function limita2(field,longitud) {
  //if (field.maxlength) {
   // maxLength = eval(field.maxlength);
    maxLength = eval(longitud);
    if (field.value.length > maxLength) {
	  alert("Ha superado el número de carateres permitido (" + longitud + ")"); 	
      field.value = field.value.substring(0,maxLength);
    }
 // }
}



//--------------------------------Javascript para mostrar flash con IE y Firefox
function eci_ToObject(id) {
		if(document.layers){
			return (document.layers[id])?eval(document.layers[id]):null;
		}
		else if(document.all && !document.getElementById){
			return (eval("window."+id))?eval("window."+id):null;
		}
		else if(document.getElementById && document.body.style) {
			return (document.getElementById(id))?eval(document.getElementById(id)):null;
		}
	}
  
function eci_FlashWrite(miEMswf, miEMcreativewidth, miEMcreativeheight, miEMwmode, miEMbgcolor, miID){
	var emswf = miEMswf; 
	var emcreativewidth = miEMcreativewidth;
	var emcreativeheight = miEMcreativeheight;
	var emwmode = miEMwmode;
	var embgcolor = miEMbgcolor;
	
	ntcode = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='"+ emcreativewidth +"' height='"+ emcreativeheight +"' id='"+ miID +"'>";
	ntcode +="<param name='movie' value='" + emswf + "'>";
	ntcode +="<param name='quality' value='high'>";
	ntcode +="<param name='bgcolor' value='#" + embgcolor +"'>";
	ntcode +="<param name='wmode' value='"+ emwmode +"'>";
	ntcode +="<param name='menu' value='false'>";
	ntcode +="<embed src='" + emswf + "' quality='high' wmode='" + emwmode + "' width='" + emcreativewidth + "' height='" + emcreativeheight + "' bgcolor='#" + embgcolor +"' type='application/x-shockwave-flash' menu='false' name='"+ miID +"' swLiveConnect='true'></embed></object>";
  	document.write(ntcode);
}

function eci_FlashInnerHTML(htmlElementId,code){
  var x=eci_ToObject(htmlElementId);
  if(x){
    if(document.getElementById||document.all){
      x.innerHTML='';
      x.innerHTML=code;
      }
    else if(document.layers){
      x.document.open();
      x.document.write(code);
      x.document.close();
      }
  }
}

//-----------------------------------------------------------------------------------------


