<!--
//Función que abre una ventana
//@id: Parámetro identificador 
//@pag: Nombre de la Página 
function ventana_emergente(id, pag, ancho, alto)
{	
	wintop = (window.screen.height/2)-(alto/2);
	winleft = (window.screen.width/2)-(ancho/2);
	url = pag + "?id=" + id; 
	ventana = window.open(url,"ventana","toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, 	resizeable=0, top=" + wintop + ", left=" + winleft + " width=" + ancho + ", height=" + alto + "")
}

//Función que oculta un <td> o <tr> de una tabla
//@Estado_actual: 0 Si está oculto 
//				  1 Si está visible
//@id: Nombre de id del <td> o <tr>
//@frm: Nombre de la forma
function ocultar(num, id, frm)
{	
  	if (eval(frm + ".tipo.options[" + frm + ".tipo.selectedIndex].value")== "4" && num == 1){
		id.style.display = "block";
		fr = frm + ".hid_estado.value = 0";
		fr = eval(fr);	 	
	}else{		
		 id.style.display = "none";
		 fr = frm + ".hid_estado.value = 1";
		 fr = eval(fr);
	}
}


//Funciones utilizadas para crear y cargar  COOKIES
//INICIO
function setCookie(name, value, expires, path, domain, secure)
{
	  document.cookie = name + "=" + escape(value) +
	  ((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
	  ((path == null) ? "" : "; path=" + path) +
	  ((domain == null) ? "" : "; domain=" + domain) +
	  ((secure == null) ? "" : "; secure");
}

var expiration = new Date();
expiration.setTime(expiration.getTime() + 24 * 60 * 60 * 60 * 1000 * 3);

function set_cookie(login)
{
        setCookie('admin_cookie',login, expiration);
        cargar_cookie();
}

function getCookie(name)
{
  var cname = name + "=";
  var dc = document.cookie;
  if (dc.length > 0) {
    begin = dc.indexOf(cname);
    if (begin != -1){
             begin += cname.length;
             end = dc.indexOf(";", begin);
             if (end == -1) end = dc.length;
             return unescape(dc.substring(begin, end));
    }
  }
}

function cargar_cookie()
{
   formas = document.forma;
   if(getCookie('admin_cookie')){
	  formas.login.value = getCookie('admin_cookie');
	  formas.password.focus();
   }
   else{
    forma.login.focus();
   }
}
//FIN

//Efecto para cerrar un popup
var ns4 = (parent.document.layers)? true:false
var ie4 = (parent.document.all)? true:false

function cerrarVentana(){
   if (ie4){
	   parent.resizeBy(0,-15);
	   setTimeout("cerrarVentana()",20);
	   setTimeout("parent.close()",600);
   }else{
   	   parent.close();}
}

function upload(nombre_campo, rotulo, validacion, clase, pag, ancho, alto)
{	
	wintop = (window.screen.height/2)-(alto/2);
	winleft = (window.screen.width/2)-(ancho/2);
	url = pag + "?iNombre_campo=" + nombre_campo + "&iRotulo=" + rotulo + "&iValidacion=" + validacion + "&iClase=" + clase;
	ventana_upload = window.open(url,"ventana_upload","toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0,	resizeable=0, top=" + wintop + ", left=" + winleft + " width=" + ancho + ", height=" + alto + "")
}



//FUNCION QUE BUSCA DENTRO DE UN OBJETO SELECT 
//INICIO
var timerid     = null;
var matchString = "";
var mseconds    = 1000;	// Length of time before search string is reset

function shiftHighlight(keyCode,targ)
{
	keyVal      = String.fromCharCode(keyCode); // Convert ASCII Code to a string
	matchString = matchString + keyVal; // Add to previously typed characters
	elementCnt  = targ.length - 1;	// Calculate length of array -1
	for (i = elementCnt; i > 0; i--)
	{
		selectText = targ.options[i].text.toLowerCase(); // convert text in SELECT to lower case
		if (selectText.substr(0,matchString.length) == 	matchString.toLowerCase())
		{
			targ.options[i].selected = true; // Make the relevant OPTION selected
		}
	}
	clearTimeout(timerid); // Clear the timeout
	timerid = setTimeout('matchString = ""',mseconds); // Set a new timeout to reset the key press string
	return false; // to prevent IE from doing its own highlight switching
}
//FIN

//FUNCION QUE VALIDA SI EL AÑO ES BISIESTO
//INICIO
function v_fecha(vmes,vdia,vano)
{
	n_dias=31;
	if (vmes==4 || vmes==6 || vmes==9 || vmes==11){
		n_dias=30;
	}else{
		if (vmes==2){
		 	if (vano%4 == 0){
				n_dias = 29;
			}else{
				n_dias = 28;
			}
		}
	}
	if (vdia > n_dias || vdia<1){
		alert("No existe el dia "+vdia+" en el mes "+vmes);
		return 1;
	}
	return 0;
}
//FIN


//FUNCION QUE ABRE UNA VENTANA EMERGENTE
//INICIO
function abrir_popup(ruta, ancho, alto)
{
	wintop = (window.screen.height/2)-(alto/2);
	winleft = (window.screen.width/2)-(ancho/2);
	win = window.open(ruta,"ventana", "toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizeable=0, top=" + wintop + ", left=" + winleft + " width=" + ancho + ", height=" + alto + "");
	win.opener=self;
}
//FIN


//FUNCION QUE ABRE EL EDITOR EN UNA VENTANA EMERGENTE
//INICIO
function open_editor(form_name,field_name,temp_dir) {
  window.open('editor/?parent_form='+form_name+'&parent_field='+field_name+'&tmpdir='+temp_dir,'editorWindow','toolbars=no,scrollbars=yes,resizable=yes,width=750,height=500');
}
//FIN


//FUNCION QUE AJUSTA EL TAMAÑO DEL POPUP AL TAMAÑO DE LA IMAGEN
//INICIO
function auto_tamano_imagen()
{
if (document.all || document.layers);
	window.resizeTo(document.images[0].width + 30,document.images[0].height + 60);
}
//FIN


//FUNCION QUE ENVIA UN CAMPO POR POST
//INICIO
function detalle(forma, pagina, identificador)
{
	forma = eval(forma);
	forma.identificador.value = identificador;
	forma.action = pagina;
	forma.submit();	
}
//FIN

//-->