function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
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();
}
MM_reloadPage(true);
/* DETECTOR DE BROWSER */
var ACTUAL_FONTSIZE = 11;
var SMALLEST_FONTSIZE = 11;
var LARGEST_FONTSIZE = 20;

function EnviarAmigo(id)
{
	window.open("enviaramigo.asp?id="+id,"EnviarAmigo","width=490, height=435, scrollbars=no");
}
function Buscar() {
	if (document.frmPrincipal.buscador.value.length < 3) {
		alert("Ingrese por favor al menos 3 letras.");
		return;
	} else {
		document.frmResultado.Titulo.value = document.frmPrincipal.buscador.value;
		document.frmResultado.submit();
	}
}

function BuscarV2(ret) {
	//Controlamos que la si existe la variable bloquear para evitar problemas
	//Cuando hay dos formularios distintos
	bloquear  = ( typeof(bloquear) == "undefined" ) ? 0 : bloquear ;
	ret       = ( typeof(ret) == "undefined" )      ? 0 : ret ;
	if (!bloquear){
  	if (document.frmPrincipal.buscador.value.length < 3) {
  		alert("Ingrese por favor al menos 3 letras.");
  		if (ret){
        return false;
      }
  	} else {
  	  window.location = "../herramientas/buscador.php?accion=buscar&donde=1&ultimos=30&texto=" + document.frmPrincipal.buscador.value;
  	  return false;
  	}
  }
}
function Votar(idx,cantidad) {
	for (i=0;i<cantidad;i++) {
		if (document.frmPrincipal.rEncuesta[i].checked) {
			window.open("../herramientas/check_cookies.php?IdxEncuesta="+idx+"&IdxOpcion="+document.frmPrincipal.rEncuesta[i].value,"Votar","width=387,height=290,top=150,left=150");
		}
	}
}
function EncuestasResultados(idx) {
	document.frmEncuestasResultados.IdxEncuesta.value = idx;
	document.frmEncuestasResultados.submit();
}
function BuscarYahoo() {
	if (document.frmPrincipal.pYahoo.value!="") {
		window.open("http://ar.search.yahoo.com/search/ar?p="+document.frmPrincipal.pYahoo.value,"Yahoo");
	}
}
function ChangeProp(objName,x,theProp,theValue) { //v6.0
  var obj = FindObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

function masGrande() {
  ACTUAL_FONTSIZE = ACTUAL_FONTSIZE+1;
  if (ACTUAL_FONTSIZE > LARGEST_FONTSIZE) { ACTUAL_FONTSIZE = LARGEST_FONTSIZE }
  ChangeProp('texto','','style.fontSize',ACTUAL_FONTSIZE,'SPAN');
  ChangeProp('texto2','','style.fontSize',ACTUAL_FONTSIZE,'SPAN');
   //SaveActualFontSize();
  //extenderDIV();
}

function masChica() {
  ACTUAL_FONTSIZE = ACTUAL_FONTSIZE-1
  if (ACTUAL_FONTSIZE < SMALLEST_FONTSIZE) { ACTUAL_FONTSIZE = SMALLEST_FONTSIZE }
  ChangeProp('texto','','style.fontSize',ACTUAL_FONTSIZE,'SPAN');
  ChangeProp('texto2','','style.fontSize',ACTUAL_FONTSIZE,'SPAN');
  //SaveActualFontSize();
  //extenderDIV();
}

function LoadActualFontSize() {
  return;
  //NO UTILIZO LA COOKIE
  /*
  tempArray = document.cookie.split(";");
  for (tA = 0; tA < tempArray.length; tA++){
    if (tempArray[tA].indexOf('fontSize') > -1){
      fontSizeValue = tempArray[tA].split("=")
      ACTUAL_FONTSIZE = parseInt(fontSizeValue[1]);
    }
  }
  */
}

function 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.getElementById(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=FindObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function SaveActualFontSize() {
  var expire = new Date ();
  expire.setTime (expire.getTime() + (6000 * 24 * 3600000));
  expire = expire.toGMTString();
  document.cookie="fontSize="+ACTUAL_FONTSIZE+"; path=/; expires="+expire;
}
function VerAlbum(id)
{
	window.open("ver_album.asp?id="+id,"VerAlbum","width=500, height=500, scrollbars=no");
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=no,scrollbars=0,location=0,statusbar=0,status=0,menubar=0,resizable=0,width=257,height=170,left = 150,top = 150');");
}
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_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+' dirección e-mail inválida.\n';
      } else if (test!='R') { num = parseFloat(val);
        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 (num<min || max<num) errors+='- '+nm+' debe ser número desde '+min+' y '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' es necesario.\n'; }
  } if (errors) alert('Han ocurrido los siguientes errores:\n'+errors);
  document.MM_returnValue = (errors == '');
}
function finMes(nMes, nAnio){
var nRes = 0;
switch (nMes){
case '1': nRes = 31; break;
case '2': 
    //Si nAnio es Biciesto
	if (((nAnio % 4)==0) && ((nAnio % 100)!=0 || (nAnio % 400)==0)) {
 	   nRes = 29; 
	//Sino
    } else {
	   nRes = 28; 
    }
	break;
case '3': nRes = 31; break;
case '4': nRes = 30; break;
case '5': nRes = 31; break;
case '6': nRes = 30; break;
case '7': nRes = 31; break;
case '8': nRes = 31; break;
case '9': nRes = 30; break;
case '10': nRes = 31; break;
case '11': nRes = 30; break;
case '12': nRes = 31; break;
}

return nRes;
}

function valDia(nDia, nMes, nAnio){
var bOk = false;
bOk = bOk || ((nDia >= 1) && (nDia <= finMes(nMes, nAnio)));

return bOk;
}

function valMes(nMes){
var bOk = false;
bOk = bOk || ((nMes >= 1) && (nMes <= 12));
return bOk;
}

function valAno(nAno){
var bOk = true;
bOk = bOk && ((nAno.length == 2) || (nAno.length == 4));
if (bOk){
for (var i = 0; i < nAno.length; i++){
bOk = bOk && esDigito(nAno.charAt(i));
}
}
return bOk;
}
function validar_fecha(c_dia,c_mes,c_anio){
 if (c_anio.value.length != 4) {
	alert("El año debe ser de 4 dígitos");
	c_anio.focus(); 
    return false;
	//document.MM_returnValue = (errors == '');
  } 

  Dia = c_dia.options(c_dia.selectedIndex).value;
  Mes = c_mes.options(c_mes.selectedIndex).value;
  Anio = c_anio.value;
  var bOk = true;
  bOk = bOk && (valDia(Dia, Mes, Anio));
  bOk = bOk && (valMes(Mes));
  bOk = bOk && (valAno(Anio));
  if (!bOk) {
	alert("Fecha Inválida");
	c_dia.focus(); 
    return false;
	//document.MM_returnValue = (errors == '');
  }
}