function resize(ancho,alto){
	self.resizeTo(ancho,alto); 
	LeftPosition = (screen.width) ? (screen.width-ancho)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-alto)/2 : 0;
	self.moveTo(LeftPosition,TopPosition-70);
}
function abrir_ventana_noscroll(name){
	ventana2 = window.open(name, "ventana", "width=5,height=5,dependent=yes,screenX=0,screenY=0,titlebar=no,directories=no,menubars=no,status=no,scrollbars=no,resizable=no"); 
}
function abrir_ventana(name){
	ventana = window.open(name, "ventana"+name, "width=5,height=5,dependent=yes,screenX=0,screenY=0,titlebar=no,directories=no,menubars=no,status=no,scrollbars=yes,resizable=no"); 
}

function abrir_ventana2(name,ancho,alto){
	window.name="Tope";
	window.open(name, "ventana", "width="+ancho+",height="+alto+",dependent=yes,screenX=0,screenY=0,titlebar=no,directories=no,menubars=no,status=yes,scrollbars=yes,resizable=no"); 
}

function abrir_ventana3(name,ancho,alto,mensaje){
	window.name="Tope";
	if (mensaje==1) {
		if (confirm("Esta acción actualizará los datos de los usuarios. Esta seguro de querer realizarla?")) { 
			window.open(name, "ventana", "width="+ancho+",height="+alto+",dependent=yes,screenX=0,screenY=0,titlebar=no,directories=no,menubars=no,status=no,scrollbars=yes,resizable=no"); 
		}
	}else{
		window.open(name, "ventana", "width="+ancho+",height="+alto+",dependent=yes,screenX=0,screenY=0,titlebar=no,directories=no,menubars=no,status=no,scrollbars=yes,resizable=no"); 
	}
}

function validar_todo(laforma){
	for(var i = 0; i < laforma.elements.length; i++){
		if(laforma.elements[i].value == ""){
			alert("Ingrese todos los campos requeridos como obligatorios");
			laforma.elements[i].focus();
			return false;
		}
		if(laforma.elements[i].value.indexOf ("'", 0) != -1){
			alert("Elimine las comillas!");
			laforma.elements[i].focus();
			return false;
		}
	}
	return true;
}

function validar_perdio(laforma){
	for(var i = 0; i < laforma.elements.length; i++){
		if(laforma.elements[i].value == ""){
			alert("Ingrese todos los campos requeridos como obligatorios");
			laforma.elements[i].focus();
			return false;
		}
		if(laforma.elements[i].value.indexOf ("'", 0) != -1){
			alert("Elimine las comillas!");
			laforma.elements[i].focus();
			return false;
		}
		if((laforma.elements[i].name.indexOf("mail",0)!=-1) && ((laforma.elements[i].value.indexOf('@', 0) == -1) || (laforma.elements[i].value.indexOf('.', 0) == -1))){
			alert("Ingrese una dirección de E-Mail valida");
			laforma.elements[i].focus();
			return false;
		}
	}
	return true;
}

function validar_mail(laforma){
		if(laforma.var_mail.value == ""){
			abrir_ventana_noscroll("p_mensaje.php?id_men=1");
			return false;
		}
	if(laforma.var_mail.value.indexOf ("'", 0) != -1){
		alert("Elimine las comillas!");
		laforma.var_mail.focus();
		return false;
	}
	return true;
}

function mostrar(id){
	eval(id + ".style.display=\"block\"");
}

function no_mostrar(id){
     eval(id + ".style.display =\"none\"");
}

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 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();
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function trim(sString)
{
   sTrimmedString = "";
   if (sString != "")
   {
      var iStart = 0;
      var iEnd = sString.length - 1;
      var sWhitespace = " \t\f\n\r\v";
     
      while (sWhitespace.indexOf(sString.charAt(iStart)) != -1)
      {
         iStart++;
         if (iStart > iEnd)
            break;
      }
     
      // If the string not just whitespace
      if (iStart <= iEnd)
      {
         while (sWhitespace.indexOf(sString.charAt(iEnd)) != -1)
            iEnd--;
         sTrimmedString = sString.substring(iStart,++iEnd);
      }
   }
   return sTrimmedString;
} 

function validar_nuevo_usuario(laforma){
	for(var i = 0; i < laforma.elements.length; i++){
		if(laforma.elements[i].value == "" && laforma.elements[i].name!="Observaciones"){
			alert("Ingrese todos los campos requeridos como obligatorios");
			laforma.elements[i].focus();
			return false;
		}
		if(laforma.elements[i].value.indexOf ("'", 0) != -1){
			alert("Elimine las comillas!");
			laforma.elements[i].focus();
			return false;
		}
	}
	return true;
}

function validar_forma_pub(){
	la_forma = eval("window.document.forma_usuario");
	if(la_forma.titulo.value == ""){
		alert("Ingrese el titulo, es campo requerido como obligatorio");
		la_forma.titulo.focus();
		return false;
	}
	if(la_forma.resena.value == ""){
		alert("Ingrese la reseña, es campo requerido como obligatorio");
		la_forma.resena.focus();
		return false;
	}
	if (la_forma.resena.value.length >= 255) {
		alert("La reseña solo puede contener 255 caracteres maximo.\nReduzca la cantidad de información.");
		la_forma.resena.focus();
		return false;
	}
	la_forma.submit();
}


function expandir(id) {
	var obj = objHtml(id)
	
	for (i=0; i<=document.numero_capas.Numero_Capas.value-1 ; i++) {		
		cerrar("capa_"+document.numero_capas.Nombres_Capas[i].value);
	}

	if (miNavegador.standard) {
		if (obj.style.display == "none")
		   obj.style.display = 'block'
		else
		   obj.style.display = 'none'
	}else{
		if (obj.display == "none")
		   obj.display = 'block'
		else
		   obj.display = 'none'
	} 
}

function cerrar(id) {
	var obj = objHtml(id)
	if (miNavegador.standard) {
		obj.style.display = 'none'
	}else{
		obj.display = 'none'
	}	  
}

/***Objetos globales definidos aquí**********/
function oNavegador(  ) {
	this.nombre = navigator.appName;
	this.iniciar = iniciar;
	this.IE = this.nombre.toUpperCase().indexOf('MICROSOFT') >=0;
	this.NS = this.nombre.toUpperCase().indexOf('NETSCAPE') >=0;
	this.OP = this.nombre.toUpperCase().indexOf('OPERA') >= 0;
	this.XX = !this.IE && !this.NS && !this.OP;
	this.version = this.iniciar();
	this.Verent = parseInt(this.version);
	this.standard = (this.IE && this.Verent >=5) || (this.NS && this.Verent >=6)

/* ======================================================================
	FUNCION:	iniciar( ), miembro de oNavegador
	ARGS: 		none.
	DEVUELVE:	nada
	DESCRIP:	Inicializa los valores del objeto
====================================================================== */
  function iniciar() {
  var ver = navigator.appVersion;
  if(ver+"" != "NaN")
	if (this.IE)
		{
		ver.match(/(MSIE)(\s*)([0-9].[0-9]+)/ig);
  		ver = RegExp.$3;
		}
  return ver;
  } //Termina la funcion iniciar el objeto
}

window.miNavegador = new oNavegador()
window.miNavegador.iniciar();
/*=========================================================================
FUNCION:	objHtml(n, d), 
ARGS:		n: un atributo ID del elemento que se desea encontrar
			d: documento en el que se busca
RETURN:		Referencia javascript al elemento HTML cuyo ID es el atributo n
DESCRIP:	Esta función busca un elemento HTML (un nodo) cuyo atributo ID sea igual al 
			que se pasa como primer argumento ( n ). La b´suqueda se realiza en el árbol
			que se le indique como segundo argumento, si éste no existe la busqueda se 
			realiza en document de la ventana actual. La función es recursiva.
================================================================================*/			
function objHtml(n, d) { 
  var p,i,x;  
  if(!d) d=document; 
  if (miNavegador.standard)
	  x = d.getElementById(n)	
  if(!(x=d[n]) && miNavegador.IE) 
      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=objHtml(n,d.layers[i].document); 
  return x;
}

function EW_updatecombo(obj, object_value_array, filter_value) {	
	var value = (obj.selectedIndex > -1) ? obj.options[obj.selectedIndex].value : null;
	for (var i = obj.length-1; i > 0; i--) {
		obj.options[i] = null;
	}	
	for (var j=0; j<object_value_array.length; j=j+4) {
		if (object_value_array[j+3].toUpperCase() == filter_value.toUpperCase()) {
			EW_newopt(obj, object_value_array[j], object_value_array[j+1], object_value_array[j+2]);			
		}	
	}
	EW_selectopt(obj, value);
}

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

function resize(ancho,alto){
	self.resizeTo(ancho,alto); 
	LeftPosition = (screen.width) ? (screen.width-ancho)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-alto)/2 : 0;
	self.moveTo(LeftPosition,TopPosition-70);
}
function abrir_ventana_noscroll(name){
	ventana2 = window.open(name, "ventana", "width=5,height=5,dependent=yes,screenX=0,screenY=0,titlebar=no,directories=no,menubars=no,status=no,scrollbars=no,resizable=no"); 
}
function abrir_ventana(name){
	ventana = window.open(name, "ventana"+name, "width=5,height=5,dependent=yes,screenX=0,screenY=0,titlebar=no,directories=no,menubars=no,status=no,scrollbars=yes,resizable=no"); 
}

function abrir_ventana2(name,ancho,alto){
	window.name="Tope";
	window.open(name, "ventana", "width="+ancho+",height="+alto+",dependent=yes,screenX=0,screenY=0,titlebar=no,directories=no,menubars=no,status=yes,scrollbars=yes,resizable=no"); 
}

function abrir_ventana3(name,ancho,alto,mensaje){
	window.name="Tope";
	if (mensaje==1) {
		if (confirm("Esta acción actualizará los datos de los usuarios. Esta seguro de querer realizarla?")) { 
			window.open(name, "ventana", "width="+ancho+",height="+alto+",dependent=yes,screenX=0,screenY=0,titlebar=no,directories=no,menubars=no,status=no,scrollbars=yes,resizable=no"); 
		}
	}else{
		window.open(name, "ventana", "width="+ancho+",height="+alto+",dependent=yes,screenX=0,screenY=0,titlebar=no,directories=no,menubars=no,status=no,scrollbars=yes,resizable=no"); 
	}
}

function validar_todo(laforma){
	for(var i = 0; i < laforma.elements.length; i++){
		if(laforma.elements[i].value == ""){
			alert("Ingrese todos los campos requeridos como obligatorios");
			laforma.elements[i].focus();
			return false;
		}
		if(laforma.elements[i].value.indexOf ("'", 0) != -1){
			alert("Elimine las comillas!");
			laforma.elements[i].focus();
			return false;
		}
	}
	return true;
}

function validar_perdio(laforma){
	for(var i = 0; i < laforma.elements.length; i++){
		if(laforma.elements[i].value == ""){
			alert("Ingrese todos los campos requeridos como obligatorios");
			laforma.elements[i].focus();
			return false;
		}
		if(laforma.elements[i].value.indexOf ("'", 0) != -1){
			alert("Elimine las comillas!");
			laforma.elements[i].focus();
			return false;
		}
		if((laforma.elements[i].name.indexOf("mail",0)!=-1) && ((laforma.elements[i].value.indexOf('@', 0) == -1) || (laforma.elements[i].value.indexOf('.', 0) == -1))){
			alert("Ingrese una dirección de E-Mail valida");
			laforma.elements[i].focus();
			return false;
		}
	}
	return true;
}

function validar_mail(laforma){
		if(laforma.var_mail.value == ""){
			abrir_ventana_noscroll("p_mensaje.php?id_men=1");
			return false;
		}
	if(laforma.var_mail.value.indexOf ("'", 0) != -1){
		alert("Elimine las comillas!");
		laforma.var_mail.focus();
		return false;
	}
	return true;
}

function mostrar(id){
	eval(id + ".style.display=\"block\"");
}

function no_mostrar(id){
     eval(id + ".style.display =\"none\"");
}

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 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();
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function trim(sString)
{
   sTrimmedString = "";
   if (sString != "")
   {
      var iStart = 0;
      var iEnd = sString.length - 1;
      var sWhitespace = " \t\f\n\r\v";
     
      while (sWhitespace.indexOf(sString.charAt(iStart)) != -1)
      {
         iStart++;
         if (iStart > iEnd)
            break;
      }
     
      // If the string not just whitespace
      if (iStart <= iEnd)
      {
         while (sWhitespace.indexOf(sString.charAt(iEnd)) != -1)
            iEnd--;
         sTrimmedString = sString.substring(iStart,++iEnd);
      }
   }
   return sTrimmedString;
} 

function validar_nuevo_usuario(laforma){
	for(var i = 0; i < laforma.elements.length; i++){
		if(laforma.elements[i].value == "" && laforma.elements[i].name!="Observaciones"){
			alert("Ingrese todos los campos requeridos como obligatorios");
			laforma.elements[i].focus();
			return false;
		}
		if(laforma.elements[i].value.indexOf ("'", 0) != -1){
			alert("Elimine las comillas!");
			laforma.elements[i].focus();
			return false;
		}
	}
	return true;
}

function validar_forma_pub(){
	la_forma = eval("window.document.forma_usuario");
	if(la_forma.titulo.value == ""){
		alert("Ingrese el titulo, es campo requerido como obligatorio");
		la_forma.titulo.focus();
		return false;
	}
	if(la_forma.resena.value == ""){
		alert("Ingrese la reseña, es campo requerido como obligatorio");
		la_forma.resena.focus();
		return false;
	}
	if (la_forma.resena.value.length >= 255) {
		alert("La reseña solo puede contener 255 caracteres maximo.\nReduzca la cantidad de información.");
		la_forma.resena.focus();
		return false;
	}
	la_forma.submit();
}


function expandir(id) {
	var obj = objHtml(id)
	
	for (i=0; i<=document.numero_capas.Numero_Capas.value-1 ; i++) {		
		cerrar("capa_"+document.numero_capas.Nombres_Capas[i].value);
	}

	if (miNavegador.standard) {
		if (obj.style.display == "none")
		   obj.style.display = 'block'
		else
		   obj.style.display = 'none'
	}else{
		if (obj.display == "none")
		   obj.display = 'block'
		else
		   obj.display = 'none'
	} 
}

function cerrar(id) {
	var obj = objHtml(id)
	if (miNavegador.standard) {
		obj.style.display = 'none'
	}else{
		obj.display = 'none'
	}	  
}

/***Objetos globales definidos aquí**********/
function oNavegador(  ) {
	this.nombre = navigator.appName;
	this.iniciar = iniciar;
	this.IE = this.nombre.toUpperCase().indexOf('MICROSOFT') >=0;
	this.NS = this.nombre.toUpperCase().indexOf('NETSCAPE') >=0;
	this.OP = this.nombre.toUpperCase().indexOf('OPERA') >= 0;
	this.XX = !this.IE && !this.NS && !this.OP;
	this.version = this.iniciar();
	this.Verent = parseInt(this.version);
	this.standard = (this.IE && this.Verent >=5) || (this.NS && this.Verent >=6)

/* ======================================================================
	FUNCION:	iniciar( ), miembro de oNavegador
	ARGS: 		none.
	DEVUELVE:	nada
	DESCRIP:	Inicializa los valores del objeto
====================================================================== */
  function iniciar() {
  var ver = navigator.appVersion;
  if(ver+"" != "NaN")
	if (this.IE)
		{
		ver.match(/(MSIE)(\s*)([0-9].[0-9]+)/ig);
  		ver = RegExp.$3;
		}
  return ver;
  } //Termina la funcion iniciar el objeto
}

window.miNavegador = new oNavegador()
window.miNavegador.iniciar();
/*=========================================================================
FUNCION:	objHtml(n, d), 
ARGS:		n: un atributo ID del elemento que se desea encontrar
			d: documento en el que se busca
RETURN:		Referencia javascript al elemento HTML cuyo ID es el atributo n
DESCRIP:	Esta función busca un elemento HTML (un nodo) cuyo atributo ID sea igual al 
			que se pasa como primer argumento ( n ). La b´suqueda se realiza en el árbol
			que se le indique como segundo argumento, si éste no existe la busqueda se 
			realiza en document de la ventana actual. La función es recursiva.
================================================================================*/			
function objHtml(n, d) { 
  var p,i,x;  
  if(!d) d=document; 
  if (miNavegador.standard)
	  x = d.getElementById(n)	
  if(!(x=d[n]) && miNavegador.IE) 
      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=objHtml(n,d.layers[i].document); 
  return x;
}

function EW_updatecombo(obj, object_value_array, filter_value) {	
	var value = (obj.selectedIndex > -1) ? obj.options[obj.selectedIndex].value : null;
	for (var i = obj.length-1; i > 0; i--) {
		obj.options[i] = null;
	}	
	for (var j=0; j<object_value_array.length; j=j+4) {
		if (object_value_array[j+3].toUpperCase() == filter_value.toUpperCase()) {
			EW_newopt(obj, object_value_array[j], object_value_array[j+1], object_value_array[j+2]);			
		}	
	}
	EW_selectopt(obj, value);
}

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

function cuerpo_mailmsn(){
	if (document.forma_usuario.enviar_news.value==1) {
		alert("La información colocada en el 'Cuerpo' NO será mostrada en el mail.");
	}
}

function act_des_fechas(tipo)
{
	var oCombo2, oCombo1, oCombo0, o2Combo2, o2Combo1, o2Combo0;
		
		if ((document.forma_buscar.activar_fechas.checked) && (tipo == 1))
		{
			oCombo2 = document.getElementById('fecha_desde2');
			oCombo2.disabled = false;
			oCombo1 = document.getElementById('fecha_desde1');
			oCombo1.disabled = false;
			oCombo0 = document.getElementById('fecha_desde0');
			oCombo0.disabled = false;
			
			o2Combo2 = document.getElementById('fecha_entrega2');
			o2Combo2.disabled = false;
			o2Combo1 = document.getElementById('fecha_entrega1');
			o2Combo1.disabled = false;
			o2Combo0 = document.getElementById('fecha_entrega0');
			o2Combo0.disabled = false;
		}
		else
		{
			oCombo2 = document.getElementById('fecha_desde2');
			oCombo2.disabled = true;
			oCombo1 = document.getElementById('fecha_desde1');
			oCombo1.disabled = true;
			oCombo0 = document.getElementById('fecha_desde0');
			oCombo0.disabled = true;
			
			o2Combo2 = document.getElementById('fecha_entrega2');
			o2Combo2.disabled = true;
			o2Combo1 = document.getElementById('fecha_entrega1');
			o2Combo1.disabled = true;
			o2Combo0 = document.getElementById('fecha_entrega0');
			o2Combo0.disabled = true;
		}
}