
var whitespace = " \t\n\r";
var defaultEmptyOK = false;

// ----------------------

function LogIn(ths)
{
 if(ths.frmUser.value.length<=0)
 	{alert("El usuario es requerido.");return false;}
 if(ths.frmPassword.value.length<=0)
 	{alert("La clave es requerida.");return false;}
 ths.submit();
}

//----------------------------

function windowopen(url)
{
    if (1==1 || (!document.layers&&!document.all&&!document.getElementById))
     {
      paramstp="height=575,width=550,top=0,left=0,scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no"
      var crw=window.open(url,"",paramstp);
      if (crw.focus){crw.focus();}
      return;
     }
	 else
	 {
	 
	 alert("here");
	 }
    var winwidth=200;
    var winheight=100;
    var winreswidth=550;    //window.screen.availWidth;
    var winresheight=575;     //window.screen.availHeight;
    var LeftPosition=(winreswidth-winwidth)/2;
    var TopPosition=winresheight-winheight/2;
   
    var paramstr="left="+LeftPosition+",top="+TopPosition+",width="+winwidth+
                 ",height="+winheight+",toolbar=no,menubar=no,location=no,"+
                 "status=no,scrollbars=yes,resizable=no";
    var crw=open(url,"",paramstr);
   
    crw.resizeBy(0,-40);
   
    var resspeed=60;
    var wspeed=winreswidth/resspeed;
    var hspeed=winresheight/resspeed;
    var x=wspeed;
   
    while (x)
    {
     crw.resizeBy(x,0);
     winwidth+=x;
     LeftPosition=(winreswidth-winwidth)/2;
     TopPosition-=wspeed;
     if (LeftPosition<0) LeftPosition=0;
     if (TopPosition<0) TopPosition=0;
     crw.moveTo(LeftPosition,TopPosition);
     if (winwidth>=winreswidth) x=0;
   
    }
    crw.moveTo(0,0);
   
    var y=hspeed;
    winheight=50;
    while(y)
    {
     crw.resizeBy(0,y);
     winheight+=y;
     if (winheight>=winresheight) y=0;
    }
    crw.resizeTo(winreswidth,winresheight);
    if (crw.focus){crw.focus();}
}

//----------------------------


function openWindowPet(url) {
		 popupWin = window.open(url, 'Lavoz', 'scrollbars=yes, resizable=no, width=550, height=700')
}

//----------------------------


function submitPage(ths) {
 thepage = ths.options[ths.selectedIndex].value;
 theaction="/index.asp?pag="+thepage
 document.theForm.action = theaction;
 document.theForm.submit();
 return true;
}

//----------------------------

function reloadMe()
{
 		 window.location="/";
}

//----------------------------

function logOff()
{
 		 document.frmLogoff.submit();
}

//----------------------------

function goReg()
{
		 document.frmReg.submit();
}

//----------------------------

function goBio()
{
		// alert(document.frmBio.hdnAction.value);
		 document.frmBio.submit();
		 
}

//----------------------------

function editU()
{
		 document.frmU.submit();
}

//----------------------------

function getPass()
{		 document.frmU.hdnAction.value='pass';
		 document.frmU.submit();
}

//----------------------------

function usuregis2() {
//window.opener.opener.location.href=ROOT_FOLDER+"/index.asp?usuforma=si";
window.opener.document.frmReg.submit();
//window.opener.close();
window.close();

}



function goPost()
{
		 document.frmPost.submit();
}

//----------------------------

function usuregis() {
//window.opener.opener.location.href=ROOT_FOLDER+"/index.asp?usuforma=si";
window.opener.document.frmReg.submit();
//window.opener.close();
window.close();

}

//----------------------------

function checkForm(ths)
{
var errMsg="";

  if (ths.usuario.value.length == 0)
  {
	errMsg = errMsg + "El Apodo es requerido. \n";

  }
  else {
  var i = 1;
  var sLength = ths.usuario.value.length;
	  while ((i < sLength))
	{
	  if(ths.usuario.value.charAt(i) == " "){
	   errMsg = errMsg + "El Apodo no puede contener espacios. \n";
	   }
	  i++
	}
  }

  if (ths.email!=undefined && !isEmail(ths.email.value))
  {
	errMsg = errMsg + "El email debe ser válido. \n";
  }

 if (ths.sexo!=undefined && ths.sexo.value == -1)
  {
	errMsg = errMsg + "El sexo es requerido. \n";
  }
  if (ths.clave && ths.clave.value.length == 0)
  {
	errMsg = errMsg + "La clave es requerida. \n";

  }
  if(ths.Contenido)
  {
  if(ths.Contenido.value.length>2000)
		{
			errMsg = errMsg + "ERROR:El total de caracteres no puede ser mayor de 2000";
		}
  }

 if (errMsg != "")
  {
	 alert(errMsg);
	return false;
  }
   return true;

}

//----------------------------

function isEmail (s)
{   if (isEmpty(s))
	   if (isEmail.arguments.length == 1) return defaultEmptyOK;
	   else return (isEmail.arguments[1] == true);

	// is s whitespace?
	if (isWhitespace(s)) return false;

	// there must be >= 1 character before @, so we
	// start looking at character position 1
	// (i.e. second character)
	var i = 1;
	var sLength = s.length;

	// look for @
	while ((i < sLength) && (s.charAt(i) != "@"))
	{ i++
	}

	if ((i >= sLength) || (s.charAt(i) != "@")) return false;
	else i += 2;

	// look for .
	while ((i < sLength) && (s.charAt(i) != "."))
	{ i++
	}

	// there must be at least one character after the .
	if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
	else return true;
}

//----------------------------

function isWhitespace (s)

{   var i;

	// Is s empty?
	if (isEmpty(s)) return true;

	// Search through string's characters one by one
	// until we find a non-whitespace character.
	// When we do, return false; if we don't, return true.

	for (i = 0; i < s.length; i++)
	{
		// Check that current character isn't whitespace.
		var c = s.charAt(i);

		if (whitespace.indexOf(c) == -1) return false;
	}

	// All characters are whitespace.
	return true;
}

//----------------------------

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

//----------------------------

function checkPostForm(ths)
{
var errMsg="";

  if (ths.Titulo.value.length == 0)
  {
	errMsg = errMsg + "El Título es requerido. \n";

  }

  if (ths.Contenido.value.length == 0)
  {
	errMsg = errMsg + "El Contenido es requerido. \n";
  }

  if (ths.Contenido.value.length > 2000)
  {
	errMsg = errMsg + "El Contenido debe ser menor de 2000 caracteres. \n";
  }

 if (errMsg != "")
  {
     alert(errMsg);
	return false;
  }
   return true;

}

//--------------------------

function checkUsuForm(ths)
{
var errMsg="";

  if (ths.usuario.value.length == 0 || ths.email.value.length == 0)
  {
	errMsg = errMsg + "El Apodo y el email son requeridos. \n";

  }
  else {
      if(ths.usuario.value.length > 0){
		  var i = 1;
		  var sLength = ths.usuario.value.length;
			  while ((i < sLength))
			{
			  if(ths.usuario.value.charAt(i) == " "){
			   errMsg = errMsg + "El Apodo no puede contener espacios. \n";
			   }
			  i++
			}
      }

 	  if(ths.email.value.length > 0) {
 		if (!isEmail(ths.email.value))
  		{
			errMsg = errMsg + "El email debe ser válido. \n";
 		}
	  }

  }


 if (errMsg != "")
  {
     alert(errMsg);
	return false;
  }
   return true;

}

//-----------------------

function postThis(ths)
{
  ths.submit();
}

//-----------------------

function checkRForm(ths)
{
var errMsg = "";
  if(ths.Contenido)
  {
   if (ths.Contenido.value.length == 0)
	{
		errMsg = errMsg + "ERROR:Su respuesta no tiene contenido.";
	}
   if(ths.Contenido.value.length>2000)
	{
		errMsg = errMsg + "ERROR:El total de caracteres no puede ser mayor de 2000";
	}
	if(errMsg!="")
	{
		alert(errMsg);
		return false;
	}	
	return true;	
		
  }
}


//-----------------------
 
 function closeDiv(di)
 {
   document.getElementById(di).style.visibility='hidden';
 }
 
//-----------------------

 function checkForm2(ths)
{
  var errMsg="";

  if (ths.usuario.value.length == 0)
  {
	errMsg = errMsg + "El Apodo es requerido. \n";
  }
  else {
  var i = 1;
  var sLength = ths.usuario.value.length;
  while ((i < sLength))
	{
	  if(ths.usuario.value.charAt(i) == " "){
	   errMsg = errMsg + "El Apodo no puede contener espacios. \n";
	   }
	  i++
	}
  }
   if (ths.clave.value.length == 0)
  {
	errMsg = errMsg + "La Clave es requerida. \n";
  }

  if (errMsg != "")
	 {
	  alert(errMsg);
	  return false;
		}
  return true;
}

//-----------------------

function isAlphaNumeric(s)
{
	var num = s;
	for(var j=0; j<num.length; j++)
		{
		  var s2 = num.charAt(j);
		  var hh = parseInt(s2.charCodeAt(0));
		  if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123) || ((hh == 45) || (hh == 95) || (hh == 42)))
		  {
		  }
		else	{
             alert("Error: Caracteres aceptados para la clave son: A-Z a-z 0-9 - * _");
			 return false;
		  }
 		}
 return true;
}

//-----------------------

function checkPForm(ths)
{
var errMsg="";
  if (ths.clave1.value.length == 0 || ths.clave2.value.length == 0  || ths.clave1.value != ths.clave2.value)
  {
	errMsg = errMsg + "Favor indicar la clave nueva en los dos campos. Estas deben ser iguales. \n";
  }
  else {
 	if(!isAlphaNumeric(ths.clave1.value) || !isAlphaNumeric(ths.clave1.value)){
	   return false;
	}else { return true; }
  }
  if (errMsg != "")
  {
	 alert(errMsg);
	return false;
  }
   
}

//---------------------

function chkChar(ths)
{

	if(ths.van)
	{
		ths.van.value=ths.Contenido.value.length;
	}
}

//---------------------

function openDiv(ths)
{
	document.getElementById(ths).style.display = "block";
}

//---------------------

