// JavaScript Document
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_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_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.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];}
}

//******Funcion que se encarga de cambiar el background de la celda de una tabla********
function cellImg(idCell, imgName) { 
document.getElementById(idCell).style.background = "url(" + imgName + ")"; 
} 

function buscador()
{
var q		 	= formbuscar.text_search.value;
var domains		= formbuscar.domains.value;
var cof			= formbuscar.cof.value;

if (formbuscar.sitesearch[0].checked)
{ var sitesearch = formbuscar.sitesearch[0].value;
}
else
{  var sitesearch = formbuscar.sitesearch[1].value;
}
window.open('http://www.google.com/custom?q='+q+'&domains='+domains+'&cof='+cof+'&sitesearch='+sitesearch,'buscar');
}

function pop_up(url,name,width,height)
{
var izq = ((screen.availWidth/2)-(width/2))
var tope = ((screen.availHeight/2)-(height/2))
settings='top=' + tope + ',left=' + izq + ',toolbar=no,location=no,directories=no,status=no,maximize=no,resizable=no,menubar=no,scrollbars=auto,width=' + width + ',height='+ height;
window.open(url,name,settings);
}

function pop_upVer2(url,name,width,height)
{
var izq = ((screen.availWidth/2)-(width/2))
var tope = ((screen.availHeight/2)-(height/2))
settings='top=' + tope + ',left=' + izq + ',toolbar=no,location=no,directories=no,status=no,maximize=no,resizable=no,menubar=no,scrollbars=yes,width=' + width + ',height='+ height;
window.open(url,name,settings);
}

function popup(url, name, width, height)
{
settings='top=0,left=0,screenX=0,screenY=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=' + width + ',height=' + height;
window.open(url,name,settings);
}

function cerrar(){
window.close();
}

/****************************************************************************/
/***Funcion que valida que el text no sea solo espacios en blancos**********/
function isWhitespace (s)
{   var i;
    var whitespace = " \t\n\r";
    if (isEmpty(s)) return true;
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        // si el caracter en que estoy no aparece en whitespace,
        // entonces retornar falso
        if (whitespace.indexOf(c) == -1) return false;
    }
	
    return true;
}

/****************************************************************************/
/***Funcion que valida que el text no sea vacio**********/

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}
/****************************************************************************/
/***Funcion que valida las fechas de ingreso*********************************/

function validar_fechaespecial(dia,mes,ano)
{
 var resultado=true;
 var d,s;
 if ((dia!="d")&&(mes!="m")&&(ano!="a")){
   resultado=false;
  }
  return resultado;
}	

/****************************************************************************/
/***Funcion que valida que el text contenga una palabra valida**********/

function espalabra(s)
{   
	var log=true;
	var letras="abcdefghijklmnñopqrstuvwxyzáéíóúABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ -_.,1234567890"; 
	
	for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (letras.indexOf(c) == -1){ log=false;}
    }
    return log;
   
}

/****************************************************************************/
// Funcion que valida el campo Email
function ValFieMail2(theForm,theField) {
  
    var msg = "";
  apos=eval(theForm + '.' + theField + '.value.indexOf("@")');
  dotpos=eval(theForm + '.' + theField + '.value.lastIndexOf(".")');
  lastpos=eval(theForm + '.' + theField + '.value.length-1');
  chrba=eval(theForm + '.' + theField + '.value.charAt(apos-1)');
  chraa=eval(theForm + '.' + theField + '.value.charAt(apos+1)');
  chrblank=eval(theForm + '.' + theField + '.value.indexOf(" ")');
  chrcoma=eval(theForm + '.' + theField + '.value.indexOf(",")');
  chrslash=eval(theForm + '.' + theField + '.value.indexOf("/")');
  //chrbslash=eval(theForm + '.' + theField + '.value.indexOf("\")');
  chrpc=eval(theForm + '.' + theField + '.value.indexOf(";")');
  if (apos<1 || dotpos-apos<2 || lastpos-dotpos>4 || lastpos-dotpos<2
  	 || chrba == "." || chraa == "." || chrblank != -1 || chrcoma != -1
  	 || chrslash != -1 || chrpc != -1){  {
    msg = "1";
  }
    return msg;
 
}
}

//**********************************************************************
//******Función que permite ir a la sección de Comentarios**************

function ir_comentarios() 
{
  parent.parent.opener.top.location.replace('../comentarios/index.asp')
  window.parent.close();
}

//**********************************************************************
//*******Función que permite ir a el home*******************************

function ir_home() 
{
  parent.parent.opener.top.location.replace('/index.asp')
  window.parent.close();
}

//**********************************************************************
//*******Función que permite ir a una pagina externa*******************************


function goto_URL(object) {
  if (object.options[object.selectedIndex].value!='$')
  {
   window.open(object.options[object.selectedIndex].value,'windowName');   
   object.options[0].selected = true;
   return true;
   }
}


function goto_URLs(object) {
	  if (object.options[object.selectedIndex].value!='$')
  {
		window.open(object.options[object.selectedIndex].value,'windowName','scrollbars=yes,status=no,menubar=no,resizable=yes,top=20,left=100,width=550,height=400');
		object.options[0].selected = true;


    }else
		object.options[0].selected = true;
}
