function ValidaDominio(cade){
  var cad=cade;
  var indice=cad.lastIndexOf(".");
  var arroba=cad.lastIndexOf("@");
  longpunto=cad.length;
  if ((indice==longpunto-3 || indice==longpunto-4 && indice!=arroba+1))
     return true
  else
     return false

}


function CheckMail(cadena) {
var plant = /[^\w^@^\.^-]+/gi
if (plant.test(cadena))
     alert(cadena + " contains wrong characters.")
else{
     plant =/(^\w+)(@{1})([\w\.-]+$)/i
     if (plant.test(cadena) && ValidaDominio(cadena)){
  
         return true 
     }
     else 
         return false
    } 
}


function trim(s)
{
  var idx  = 0;
  var idxf = 0;
  var str  = String(s);

  while (str.charAt(idx) == " " && idx < str.length)
    idx++;

  if (idx == str.length)
    str = "";
  else {
    str  = str.substring(idx,str.length);
    idxf = str.length - 1;

    while(str.charAt(idxf) == " ")
      idxf--;

    str = str.substring(0, idxf + 1);
  }

  return str;
}


function isAGoodString( string )
{
	if (!string) return false;
	var badChars = "*|,\":<>[]{}`\';()@&$#%";
	for (var i = 0; i < string.length; i++) {
		if (badChars.indexOf(string.charAt(i)) != -1)
			return false;
	}
	return true;
}

function CheckEmail( string )
{
	if (!string) return false;
	if (!isAGoodString(string) == false) return false;
	if (string.search(/^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-\w]*[0-9a-zA-Z])*\.)+[a-zA-Z]{2,9})$/) == -1)
		return false;			
	return true;
}


// whitespace characters
var whitespace = " \t\n\r";

// Check whether string s is empty.

function isEmpty(s)
{
	return ((s == null) || (s.length == 0))
}

// Returns true if string s is empty or 
// whitespace characters only.

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 EsLetras(Dato){
   var CadenaLetras="ABCDEFGHIJKLMNOPQRSTUVWXYZÑÁÉÍÓÚ ";
   var EsteCaracter;
   var Contador=0;
   Dato=Dato.toUpperCase();
   for (var i=0; i<Dato.length; i++) {
      EsteCaracter = Dato.substring(i, i+1);
      if(CadenaLetras.indexOf(EsteCaracter) != -1)
         Contador ++;
}
if (Contador == Dato.length && Contador != 0) {
   //Todos los caracteres son Letras!
   return true
}
  else
     return false
}

function EsNumero(Dato){
   var CadenaNumeros="0123456789";
   var EsteCaracter;
   var Contador=0;
   for (var i=0; i< Dato.length; i++) {
      EsteCaracter = Dato.substring(i, i+1);
      if(CadenaNumeros.indexOf(EsteCaracter) != -1)
         Contador ++;
}
if (Contador == Dato.length && Contador != 0) {
   //Todos los caracteres son números!
   return true
}
  else
     return false
}


function esnumerofono(Dato)
	{ var cadenanumeros="0123456789-()";
	  var estecaracter;
	  var contador=0;
	  
	  for(var i=0; i < Dato.length; i++)
	  {  estecaracter=Dato.substring(i,i+1);
	  	 if (cadenanumeros.indexOf(estecaracter) != -1)
		    contador++;
	  }	
	  if (contador == Dato.length) 
	     //Todos los caracteres son números con -
		     return 1;
			   // telefono valido
		else
		  return 0;
		  // en caso se ingrese una cadena de letras 
	}

function IsOkString(d){
d=trim(d)
if(d.length>0)
  return true;
else
  return false;
}

//Funciones para la escritura de Cokies
//*************************************
function enviarCookie(nombre, contenido, vencimiento) {
    document.cookie = nombre + "=" + escape(contenido) +
                      ((vencimiento == null) ? "" : ("; expires=" + vencimiento.toGMTString()))
}

function leerCookie(nombre) {
    galleta = nombre + "=";
    if (document.cookie.length > 0) {
        principio = document.cookie.indexOf(galleta);
        if (principio != -1) {
            principio += galleta.length;
            fin = document.cookie.indexOf(";", principio);
            if (fin == -1)
                fin = document.cookie.length;
            return unescape(document.cookie.substring(principio,fin));
        }
    }
}



function VentanaZoom(Ancho, Alto, strSrcImage){
	var wint  = (screen.height-Alto)/2;
	var winl  = (screen.width-Ancho)/2;
	var settings  ='height='+Alto+',';
		settings +='width='+Ancho+',';
		settings +='top='+wint+',';
		settings +='left='+winl+',';
		settings +='resizable=no';
	window.status="Cargando ventana";
	var Ventana = window.open("", "miVentana", settings);
	Ventana.document.open();

	Ventana.document.writeln(
			"<html>" +
			"<head><title>Zoom de imágenes</title>"+
			"<link rel='stylesheet' type='text/css' href='css/Estilos.css'>" + 
			"</head><body bgcolor='#000000'>" +
			"<center><img src='" + strSrcImage + "'></center><br><center><input type='button' value='Cerrar' class='clsButton' onclick='window.close();'></center></body></html>");

	window.status="Se vcargó la imagen con éxito";
}


function WindowZoom(Ancho, Alto, strSrcImage){
	var wint  = (screen.height-Alto)/2;
	var winl  = (screen.width-Ancho)/2;
	var settings  ='height='+Alto+',';
		settings +='width='+Ancho+',';
		settings +='top='+wint+',';
		settings +='left='+winl+',';
		settings +='resizable=yes';
	var Ventana = window.open("", "miVentana", settings);
	Ventana.document.open();

	Ventana.document.writeln(
			"<html>" +
			"<head><title>Zoom</title>"+
			"<link rel='stylesheet' type='text/css' href='estilos/theguidecardstyle.css'>" + 
			"</head><body bgcolor='#000000' topmargin='0' leftmargin='0' marginheight='0' marginwidth='0'>" +
			"<center><img src='" + strSrcImage + "'></center></body></html>");

	window.status="Listo. Ventana cargada.";
}


//************************F I N******************************************
//***********************************************************************                   