// JavaScript Document
var popUpWin=0;
var popUpExtra=0;
var popUpWinS=0;
var ie4 = (document.all) ? true : false;
var ns4 = (document.layers) ? true : false;
var ns6 = (document.getElementById && !document.all) ? true : false;
var optionPage = 0

var OpcionMenuActual
function AddFav(url,titulo){
	
		if ((navigator.appName=="Microsoft Internet Explorer") && (parseInt(navigator.appVersion)>=4)) {
			window.external.AddFavorite (url,titulo);
		}
		else {
			if(navigator.appName == "Netscape")
			alert ("Presione Crtl+D para agregar "+url+" a sus Marcadores");
		}
	}                                                                                                                                                                                                                  

function muestraSelects() {
	if (document.frames[0].form) {
		if (document.frames[0].form.sel_categ) {
			document.frames[0].form.sel_categ.style.display="block"
		}
		if (document.frames[0].form.id_categoria) {
			document.frames[0].form.id_categoria.style.display="block"
		}
		if (document.frames[0].form.TipoAct) {
			document.frames[0].form.TipoAct.style.display="block"
		}
	}
}

function ocultaSelects(id) {
	if (document.frames[0].form) {
		if (document.frames[0].form.sel_categ) {
			if ((id=="mm4") || (id=="mm3")) {
					document.frames[0].form.sel_categ.style.display="none"
			}
		}
		if (document.frames[0].form.id_categoria) {
			if ((id=="mm2") || (id=="mm1")) {
					document.frames[0].form.id_categoria.style.display="none"
			}
		}
		if (document.frames[0].form.TipoAct) {
			if ((id=="mm4") || (id=="mm3")) {
					document.frames[0].form.TipoAct.style.display="none"
			}
		}
	}
	}

function QuitarSombra(id) {
	if (id==OpcionMenuActual) {
		//nada
	} else {
		document.getElementById(id).className="menu-principal-textos"
	}
}
			

function SombreaMenu(id) {
	//alert(OpcionMenuActual)
	
	
	for (i=1, m=8;i<=m; i++) {
		if (i==id) {
			if (document.getElementById(id).className!="menu-vertical-resaltado") {
				document.getElementById(id).className="menu-vertical-resaltado"
			}
		} else {
			if ((document.getElementById(i).className!="menu-vertical-resaltado") || (i!=OpcionMenuActual)) {
				document.getElementById(i).className="menu-vertical"
			}
		}
	}
}

function cargaMarco(page) {
	document.frames["apa"].location.href=page
}

function MM_showHideLayers()
{
    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 setButton(s)
{
  document.frmCity.frmAction.value = s;
  document.frmCity.submit();
}

function popUp(URLStr,x,y) 
{
    if(popUpExtra)
    {
        if(!popUpExtra.closed) popUpExtra.close();
    }
	popUpExtra = open(URLStr, 'popUpExtra', 'toolbar=0,scrollbars=0,location=0,status=no,menubar=0,resizable=0,width='+x+',height='+y);
	popUpExtra.focus;
}
function popUpWindow(URLStr, left, top, width, height)
{
    if(popUpWin)
    {
        if(!popUpWin.closed) popUpWin.close();
    }
    	popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
		popUpWin.focus();
}
function popUpWinScroll(URLStr, left, top, width, height, scrolling)
{
    if(popUpWinS)
    {
        if(!popUpWinS.closed) popUpWinS.close();
    }
    	popUpWinS = open(URLStr, 'popUpWinS', 'toolbar=no,location=no,addressbar=no,directories=no,status=no,menubar=no,scrollbars='+scrolling+',resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
		popUpWinS.focus();
}
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_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

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.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&&id.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.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];}
}

function preloadImages()
{
  if(document.images)
  {
    if(!document.imageArray) document.imageArray = new Array();
    var i,j = document.imageArray.length, args = preloadImages.arguments;
    
    for(i=0; i<args.length; i++)
    {
      if (args[i].indexOf("#")!=0)
      {
        document.imageArray[j] = new Image;
        document.imageArray[j++].src = args[i];
      }
    }
  }
}

function loadImages() {
if (document.getElementById) {  // DOM3 = IE5, NS6
document.getElementById('hidepage').style.visibility = 'hidden';
}
else {
if (document.layers) {  // Netscape 4
document.hidepage.visibility = 'hidden';
}
else {  // IE 4
document.all.hidepage.style.visibility = 'hidden';
      }
   }
}

function esDigito(sChr){
	var sCod = sChr.charCodeAt(0);
	return ((sCod > 47) && (sCod < 58));
}


function valSep(oTxt){
bOk= (oTxt.value.split("/")==oTxt.value );
return !bOk;
}

function finMes(oTxt){
var nMes = parseInt(oTxt, 10);
var nRes = 0;
switch (nMes){
case 1: nRes = 31; break;
case 2: nRes = 29; 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(oTxt,Mes){
var bOk = false;
var nDia = parseInt(oTxt,10);
bOk = bOk || ((nDia >= 1) && (nDia <= finMes(Mes)));
return bOk;
}

function valMes(oTxt){
var bOk = false;
var nMes = parseInt(oTxt, 10);
bOk = (nMes >= 1) && (nMes <= 12);
return bOk;
}

function valAno(oTxt){
var bOk = true;
var nAno = oTxt;
bOk = bOk && (nAno.length == 4);
if (bOk){
for (var i = 0; i < nAno.length; i++){
bOk = bOk && esDigito(nAno.charAt(i));
}
}
return bOk;
}

function valFecha(oTxt){
var bOk = true;
var subch=oTxt.value.split("/");

if (oTxt.value != ""){
bOk = bOk && (valSep(oTxt));
bOk = bOk && (valAno(subch[2]));
bOk = bOk && (valMes(subch[1]));
bOk = bOk && (valDia(subch[0],subch[1]));

if (!bOk){
	return false;
	}
	return true;
}
}

function uno(src,color_entrada) { 
    src.bgColor=color_entrada;src.style.cursor="hand"; 
} 
function dos(src,color_default) { 
    src.bgColor=color_default;src.style.cursor="default"; 
} 

function limiteTextArea(que,cuanto)
{
var v=que.value
if(v.length>cuanto) {
  que.value=v.substring(0,cuanto);
  alert('Sólo 255 caracteres!');
  }
//else
 // que.value=cuanto-v.length
}

function IsValidTime(timeStr) {
	var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;
	var matchArray = timeStr.match(timePat);
	if (matchArray == null) {
		return false;
	}
	hour = matchArray[1];
	minute = matchArray[2];
	second = matchArray[4];
	ampm = matchArray[6];
	if (second=="") { second = null; }
	if (ampm=="") { ampm = null }
	if (hour < 0  || hour > 23) {
		return false;
	}
	if (minute<0 || minute > 59) {
		return false;
	}
return true;
}

function confirmar(txtBorrar) {
var msg = confirm(txtBorrar);
	if (msg==true) {
		return true;
	} else {
		return false;
	}
}
// Example:
// simplePreload( '01.gif', '02.gif' ); 
function simplePreload()
{ 
  var args = simplePreload.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[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_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 isNumber(precio) {
	var valid = "0123456789,."
	var temp;
	var counter;
		counter = 0;
	for (var i=0; i<=precio.length; i++) {
		temp = "" + precio.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") {
			counter++;
//			alert(temp);
		}
	}
	if (counter>0) {
		return false
	} else {
		return true
	}
}
function isDigit(val) {
	var valid = "0123456789"
	var temp;
	var counter;
		counter = 0;
	for (var i=0; i<val.length; i++) {
		temp = "" + val.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") counter++;
	}
	if (counter>0) {
		return val
	} else {
		return val=""
	}
}
function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + num + '.' + cents);
}
function valEntry(objCur) {
	if (!isNumber(objCur.value)) {
		objCur.value = "0,00"
		alert('Dato no válido!!');
		objCur.focus()
	}
}
function currencyFormat(fld, milSep, decSep, e) {
var sep = 0;
var key = '';
var i = j = 0;
var len = len2 = 0;
var strCheck = '0123456789';
var aux = aux2 = '';
var whichCode = (window.Event) ? e.which : e.keyCode;
if (whichCode == 13) return true;  // Enter
key = String.fromCharCode(whichCode);  // Get key value from key code
if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
len = fld.value.length;
for(i = 0; i < len; i++)
if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
aux = '';
for(; i < len; i++)
if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
aux += key;
len = aux.length;
if (len == 0) fld.value = '';
if (len == 1) fld.value = '0'+ decSep + '0' + aux;
if (len == 2) fld.value = '0'+ decSep + aux;
if (len > 2) {
aux2 = '';
for (j = 0, i = len - 3; i >= 0; i--) {
if (j == 3) {
aux2 += milSep;
j = 0;
}
aux2 += aux.charAt(i);
j++;
}
fld.value = '';
len2 = aux2.length;
for (i = len2 - 1; i >= 0; i--)
fld.value += aux2.charAt(i);
fld.value += decSep + aux.substr(len - 2, len);
}
return false;
}
function ActiveOpt(opt) {
//	if (opt!=0) {
		for (i=1;i<=7;i++) {
			if (opt==i) {
				document.getElementById('menu_'+i).className="menu-actual"
			} else {
				document.getElementById('menu_'+i).className=''
				document.getElementById('menu_'+i).style.backgroundRepeat='no-repeat'
				document.getElementById('menu_'+i).style.backgroundPosition='center 0px'
			}
		}
//	}
}
function ShowDetail(id) {
	document.getElementById('menu_'+id).className = 'menu_'+id; document.getElementById('menu_'+id+'1').className = 'menu-resaltado';
}
function HideDetail(id) {
	document.getElementById('menu_'+id).style.backgroundImage = ''; document.getElementById('menu_'+id+'1').className = 'menu';ActiveOpt(optionPage)
}
function move(fbox, tbox) {
	var arrFbox = new Array();
	var arrTbox = new Array();
	var arrLookup = new Array();
	var i;
	for (i = 0; i < tbox.options.length; i++) {
		arrLookup[tbox.options[i].text] = tbox.options[i].value;
		arrTbox[i] = tbox.options[i].text;
	}
	var fLength = 0;
	var tLength = arrTbox.length;
	for(i = 0; i < fbox.options.length; i++) {
		arrLookup[fbox.options[i].text] = fbox.options[i].value;
		if (fbox.options[i].selected && fbox.options[i].value != "") {
			arrTbox[tLength] = fbox.options[i].text;
			tLength++;
		}
		else {
			arrFbox[fLength] = fbox.options[i].text;
			fLength++;
	   }
	}
	arrFbox.sort();
	arrTbox.sort();
	fbox.length = 0;
	tbox.length = 0;
	var c;
	for(c = 0; c < arrFbox.length; c++) {
		var no = new Option();
		no.value = arrLookup[arrFbox[c]];
		no.text = arrFbox[c];
		fbox[c] = no;
	}
	for(c = 0; c < arrTbox.length; c++) {
		var no = new Option();
		no.value = arrLookup[arrTbox[c]];
		no.text = arrTbox[c];
		tbox[c] = no;
	}
}
function emailCheck (emailStr) {
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	var matchArray=emailStr.match(emailPat)
	
	if (matchArray==null) {
		//alert("Email address seems incorrect (check @ and .'s)")
		return 1
	}
	
	var user=matchArray[1]
	var domain=matchArray[2]
	
		// Si el user "user" es valido 
	if (user.match(userPat)==null) {
		// Si no
		//alert("El nombre de usuario no es válido.")
		return 2
	}
	
	
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
		//alert("El dominio parece no ser válido.")
		return 3
	}
	
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) {
		//alert("El dominio debe terminar con 2 o 3 letras\nEj. .com, .es, .edu")
		return 4
	}
	
	if (len<2) {
		//alert("La dirección es erronea")
		return 5
	}
	
	// La dirección de email ingresada es Válida
	return 0;
}
function showSecc() {
	var x = document.form.dptos
	var a = document.getElementById('academico')
	var b = document.getElementById('internacional')
	var c = document.getElementById('admision')
	var z = document.form
	switch (x.options[x.selectedIndex].value) {
		case '1':
			a.style.display = 'block';
			b.style.display = 'none';
			c.style.display = 'none';
			break;
		case '9':
			a.style.display = 'none';
			b.style.display = 'block';
			c.style.display = 'none';
			break;
		case '12':
			a.style.display = 'none';
			b.style.display = 'none';
			c.style.display = 'block';
			break;
		default:	
			a.style.display = 'none';
			b.style.display = 'none';
			c.style.display = 'none';
			break;
	}
			z.secc1.options[0].selected = true;
			z.secc2.options[0].selected = true;
			z.secc3.options[0].selected = true;
			setUbicacion(x.options[x.selectedIndex].value);
}
function setCombos(idubicacion) {
	var x = document.form.dptos
	var a = document.form.secc1
	var b = document.form.secc2
	var c = document.form.secc3
	switch (idubicacion) {
		case '1':
			x.options[0].selected = true;		
			a.options[0].selected = true;		
			b.options[0].selected = true;		
			c.options[0].selected = true;		
			break;
		case '2':
			x.options[0].selected = true;		
			a.options[1].selected = true;		
			b.options[0].selected = true;		
			c.options[0].selected = true;		
			break;
		case '3':
			x.options[0].selected = true;		
			a.options[2].selected = true;		
			b.options[0].selected = true;		
			c.options[0].selected = true;		
			break;
		case '4':
			x.options[0].selected = true;		
			a.options[4].selected = true;		
			b.options[0].selected = true;		
			c.options[0].selected = true;		
			break;
		case '5':
			x.options[0].selected = true;		
			a.options[5].selected = true;		
			b.options[0].selected = true;		
			c.options[0].selected = true;		
			break;
		case '6':
			x.options[0].selected = true;		
			a.options[6].selected = true;		
			b.options[0].selected = true;		
			c.options[0].selected = true;		
			break;
		case '7':
			x.options[0].selected = true;		
			a.options[7].selected = true;		
			b.options[0].selected = true;		
			c.options[0].selected = true;		
			break;
		case '8':
			x.options[1].selected = true;		
			a.options[0].selected = true;		
			b.options[0].selected = true;		
			c.options[0].selected = true;		
			break;
		case '9':
			x.options[2].selected = true;		
			a.options[0].selected = true;		
			b.options[0].selected = true;		
			c.options[0].selected = true;		
			break;
		case '10':
			x.options[2].selected = true;		
			a.options[0].selected = true;		
			b.options[1].selected = true;		
			c.options[0].selected = true;		
			break;
		case '11':
			x.options[3].selected = true;		
			a.options[0].selected = true;		
			b.options[0].selected = true;		
			c.options[0].selected = true;		
			break;
		case '12':
			x.options[4].selected = true;		
			a.options[0].selected = true;		
			b.options[0].selected = true;		
			c.options[0].selected = true;		
			break;
		case '13':
			x.options[4].selected = true;		
			a.options[0].selected = true;		
			b.options[0].selected = true;		
			c.options[1].selected = true;		
			break;
	}
}
function abrirVentana(tipo,idprop,idfoto)
{
	if (document.getElementById("handle1")) { document.getElementById("handle1").style.visibility = "hidden" }
	if (tipo=='galeriaForos') 
		if (idprop!="") { 
			P7_autoLayers(0,'lema','galeriaForos');document.getElementById("frmGaleria").src = "galeria-de-fotos.asp?idforo="+idprop+"&idimagen="+idfoto
		} else {
			P7_autoLayers(0,'galeriaForos')
		}
	if (tipo=='registroUsuarios') { P7_autoLayers(0,'lema','registroUsuarios');document.getElementById("frmGaleria").src = "registro.asp" }
	if (tipo=='perfilUsuarios') { P7_autoLayers(0,'lema','perfilUsuarios');document.getElementById("frmPerfil").src = "perfil.asp?idusuario="+idprop }
	if (tipo=='agregarComentario') { P7_autoLayers(0,'lema','agregarComentario');document.getElementById("frmComentario").src = "comentar.asp?identrada="+idprop }
}


function cerrarVentanaff(tipo)
{
	if (document.getElementById("handle1")) { document.getElementById("handle1").style.visibility = "visible" }
	if (tipo=='galeriaForos') P7_autoLayers(0,'lema');
	if (tipo=='registroUsuarios') P7_autoLayers(0,'lema');
	if (tipo=='perfilUsuarios') P7_autoLayers(0,'lema');
	if (tipo=='agregarComentario') P7_autoLayers(0,'lema');
	
}

function cerrarVentana(tipo)
{
	if (document.getElementById("handle1")) { document.getElementById("handle1").style.visibility = "visible" }
	if (tipo=='galeriaForos') { P7_autoLayers(0,'lema') }
	if (tipo=='registroUsuarios') { P7_autoLayers(0,'lema');document.getElementById("frmGaleria").src = ""}
	if (tipo=='perfilUsuarios') { P7_autoLayers(0,'lema');document.getElementById("frmPerfil").src = ""}
	if (tipo=='agregarComentario') { P7_autoLayers(0,'lema');document.getElementById("frmComentario").src = ""}
}

function logoutBlog() {
	if (confirm("Está a punto de cerrar su sesión en el Blog del Director\nNo podrá publicar comentarios si se desconecta. Está seguro(a)?")) document.getElementById("_procBlog").src="_proc.usuariosblog.asp?logout=true"
}
function newPassBlog() {
	if (confirm("Al generar una nueva clave ésta sustituye a la anterior.\nConsérvela o no podrá acceder a publicar comentarios.\nEstá seguro(a)?")) document.getElementById("_procRegistro").src="_proc.usuariosblog.asp?newPass=true"
}
<!--

