function activar(boton)
{	
	txt = eval(boton+"on");
	document.getElementById(boton).innerHTML=txt;
	eval ("document.getElementById('"+boton+"').className = 'botonon'");
}

function pulsar(boton)
{	
	txt = eval(boton+"off");
	document.getElementById(boton).innerHTML=txt;
	eval ("document.getElementById('"+boton+"').className = 'pulsado'");
}

function foco(enlace)
{
	if (enlace.blur) enlace.blur();
}

function rollover(encima, objeto)
{
	if (encima)
		objeto.className = 'rollover';
	else
		objeto.className = 'botonon';
}

function desactivar(boton)
{	
	txt = eval(boton+"off");
	document.getElementById(boton).innerHTML=txt;
	eval ("document.getElementById('"+boton+"').className = 'botonoff'");
}

function enfocar(formulario,campo)
{
	eval("document."+formulario+"."+campo+".focus()");
}

function asignar(formulario,campo,valor)
{
	eval('document.'+formulario+'.'+campo+'.value="'+valor+'"');
}

function comprueba(formulario,campo,texto)
{
	var formu = eval('document.'+formulario+'.'+campo+'.value');
	if (formu=="")
	{
		alert("Falta el campo: " + texto);
		//alert(texto);
		enfocar(formulario,campo)
		return false;
	}
	else
		return true;
}


function borra(obj)
{
		obj.value="";
		obj.className ="text"
}

function CalPop2(sInputName)
{
	window.open('/calpop/Calendar.asp?N=' + escape(sInputName) + '&DT=' + escape(window.eval(sInputName).value), 'CalPop', 'scrollbars=no,status=no,resizable=no,titlebar=no,directories=no,hotkeys=no,menubar=no,location=no,personalbar=no,toolbar=no,width=290,height=165');
}

function CalPop(sInputName)
{
	window.open('/calpop/calendario.asp?N=' + escape(sInputName) + '&DT=' + escape(window.eval(sInputName).value), 'CalPop', 'scrollbars=no,status=no,resizable=no,titlebar=no,directories=no,hotkeys=no,menubar=no,location=no,personalbar=no,toolbar=no,width=238,height=307');
}

function navega(popurl,w,h)
{
//	x = (screen.width-w)/2;
//	y = (screen.height-h)/2;
	var y = 80;
	var x = 150;
//	var carac = 'scrollbars=yes,status=yes,resizable=yes,titlebar=no,directories=no,menubar=no,location=yes,personalbar=no,toolbar=no,width=600,height=330,left='+x+',top='+y
	var carac = 'scrollbars=yes,status=yes,resizable=yes,titlebar=yes,directories=yes,menubar=yes,location=yes,personalbar=yes,toolbar=yes,location=yes,width='+w+',height='+h+',left='+x+',top='+y
	window.open(popurl,'',carac);
}

function navegacen(popurl,w,h)
{
	x = (screen.width-w)/2;
	y = (screen.height-h)/2;
	var carac = 'scrollbars=yes,status=yes,resizable=yes,titlebar=yes,directories=yes,menubar=yes,location=yes,personalbar=yes,toolbar=yes,location=yes,width='+w+',height='+h+',left='+x+',top='+y
	window.open(popurl,'',carac);
}


function abrirventana(popurl,w,h){
	var y=((screen.height-h)/2)-40;
	var x=(screen.width-w)/2;
	var winpops=window.open(popurl,"","width="+w+",height="+h+",scrollbars=no,")
	winpops.moveTo(x,y);
}

function abrirventanaRef(popurl,w,h){
//	alert(window.top.width);
	var y=(h/2)-40;
	var x=(screen.width-w)/2;
	var winpops=window.open(popurl,"","width="+w+",height="+h+",scrollbars=no,")
	winpops.moveTo(x,y);
}


function abreDocumento(popurl,w,h){
	x = (screen.width-w)/2;
	y = (screen.height-h)/2;
	var carac = 'title=Curriculum Vitae, scrollbars=no,status=no,resizable=yes,titlebar=no,directories=no,menubar=no,location=no,personalbar=no,toolbar=no,width='+w+',height='+h+',left='+x+',top='+y
	var windoc=window.open(popurl,"",carac)
	windoc.moveTo(x,y);
}


function abrirventana_b(popurl,w,h){
	var y=((screen.height-h)/2)-40;
	var x=(screen.width-w)/2;
	var carac = 'scrollbars=no,status=no,resizable=no,titlebar=no,directories=no,menubar=no,location=no,personalbar=no,toolbar=no,width='+w+',height='+h+',left='+x+',top='+y;
	var winpops=window.open(popurl,"",carac)
	winpops.moveTo(x,y);
}

function abreDialog(popurl,w,h){
	//x1 = (screen.width-800)/2;
	//x = x1 + (595/2);
	altura = h-mod_alto;  //pq se le mete barra de estado
	ancho = w-mod_ancho;
	x = (screen.width-w)/2;
	y = (screen.height-h)/2;
	window.showModalDialog(popurl,'','help:no;dialogHeight:'+altura+'px;dialogWidth:'+ancho+'px;status:yes;scroll:no;dialogLeft:'+x+'px;dialogTop:'+y+'px;');
}

function abrePdf(popurl,w,h){
	//x1 = (screen.width-800)/2;
	//x = x1 + (595/2);
	altura = h-mod_alto;  //pq se le mete barra de estado
	ancho = w-mod_ancho;
	x = (screen.width-w)/2;
	y = (screen.height-h)/2;
	window.showModalDialog(popurl,'','help:no;dialogHeight:'+altura+'px;dialogWidth:'+ancho+'px;status:no;scroll:yes;dialogLeft:'+x+'px;dialogTop:'+y+'px;');
}

function trim(cadena)
{
	return(ltrim(rtrim(cadena)))
}

function ltrim(cadena)
{
	xcad = cadena
	if (xcad.substring(0,1) != " ")
		return xcad
	else
		return ltrim(xcad.substring(1,xcad.length))
}

function rtrim(cadena)
{
	xcad = cadena
	if (xcad.substring(xcad.length-1,xcad.length) != " ")
		return xcad
	else
		return rtrim(xcad.substring(0,xcad.length-1))
}

function left(cadena, n) {
	var lcad
	if (n>=cadena.length)
		lcad=cadena
	else
		lcad = cadena.substring(0,n)
	return lcad
}

function right(cadena, n) {
	var rcad
	if (n>=cadena.lenght)
		rcad=cadena
	else
		rcad = cadena.substring((cadena.length)-n,cadena.length)
	return rcad
}


function abrirAyuda(popurl,texto,w,h){
//	alert(popurl);
	w = 591;
	h = 493;
	x = (screen.width-w)/2;
	y = (screen.height-h)/2;
	var winpops=window.open("ayuda/help.asp?p="+popurl+"&t="+texto,"ayuda","width="+w+",height="+h+"")
	winpops.moveTo(x,y);
}


function click() {
	if (event.button==2) {
		alert ('Este boton esta desabilitado.')
	}
}

function mueveReloj(){ 
	
    momentoActual = new Date() 
    hora = momentoActual.getHours() 
    minuto = momentoActual.getMinutes() 
    segundo = momentoActual.getSeconds() 

    str_segundo = new String (segundo) 
    if (str_segundo.length == 1) 
       segundo = "0" + segundo 

    str_minuto = new String (minuto) 
    if (str_minuto.length == 1) 
       minuto = "0" + minuto 

    str_hora = new String (hora) 
    if (str_hora.length == 1) 
       hora = "0" + hora 

    horaImprimible = hora + ":" + minuto + ":" + segundo 

    //document.form_reloj.reloj.value = horaImprimible 
	MM_setTextOfLayer('capahora','',horaImprimible);

    setTimeout("mueveReloj()",1000) 
} 


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);

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_setTextOfLayer(objName,x,newText) { //v4.01
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (document.layers) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}

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 MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_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 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 isDate(fecha)	{
	var fecia = new Array();
	var diasmeses = new Array();
	diasmeses[1] = 31;
	diasmeses[2] = 28;	
	diasmeses[3] = 31;
	diasmeses[4] = 30;
	diasmeses[5] = 31;
	diasmeses[6] = 30;
	diasmeses[7] = 31;
	diasmeses[8] = 31;
	diasmeses[9] = 30;
	diasmeses[10] = 31;
	diasmeses[11] = 30;
	diasmeses[12] = 31;

	fecia = fecha.split("/")
	var dia = fecia[0]
	var mes = fecia[1]
	var anio = fecia [2]
	if (bisiesto(anio)) 
		diasmeses[2] = 29;

	var Tentativa = new Date(anio,mes-1,dia) 

	dia = (fecia[0]) * 1
	mes = (fecia[1]) * 1
	anio = (fecia[2]) * 1


	if (isNaN(Tentativa)) 
		return false; 
	else {
		if ((mes<13) && (dia <= diasmeses[mes]) && (anio <= 9999))
			return true;
		else 
			return false;
	}
}

function bisiesto(anio) {
	if ((anio % 400 == 0) || ((anio % 4 ==0) && (anio % 100 != 0)))
		return true;
	else
		return false;
}


function abreVideoFlv(popurl,w,h){
	alto = h +20  //pq se le mete barra de estado
	ancho = w;
	x = 0+(screen.width-w)/2;
	y = -20+(screen.height-h)/2;
	alto = alto - mod_alto;
	ancho = ancho - mod_ancho;

	window.showModalDialog(popurl,'','help:no;dialogHeight:'+alto+'px;dialogWidth:'+ancho+'px;status:yes;scroll:no;dialogLeft:'+x+'px;dialogTop:'+y+'px;');
}

function abreCuriosidades(url)
{
	var ancho = 520-mod_ancho;
	var alto = 275-mod_alto;
//	alert(alto);
	wglosario=window.showModalDialog(url,"","scroll:no;help:no;status:yes;resizable:no;dialogWidth:"+ancho+"px;dialogHeight:"+alto+"px");
	return false;
}
//document.onmousedown=click


function horaValida(hora) {
	var hor = hora
	posdospuntos=hor.lastIndexOf(":")
	if (posdospuntos==-1) {
		return false
	} else {
		lahora=hor.substring(0,posdospuntos)
		minutos=hor.substring(posdospuntos+1,hor.length)
		if (isNaN(lahora) || lahora=='') 
			return false
		else
			if ((lahora>23) || (lahora<0)) return false
		if (isNaN(minutos) || minutos=='') 
			return false
		else
			if ((minutos>59) || (minutos<0)) return false
	}
	return true
}

var ie7 = false;
var mod_ancho;
var mod_alto;
function detectarIE7() {
	if (typeof document.documentElement.style.maxHeight != "undefined") {
		// IE 7, mozilla, safari, opera 9
		ie7=true;
		mod_ancho=6;
		mod_alto=50;
	} 
	else {
		ie6 = true;
		mod_ancho = 0;
		mod_alto = 0;
	}

}

detectarIE7();
