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 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_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 MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function HyperWarp( lpszUrl )
{
	window.opener.location.href=lpszUrl;
	window.focus();
}

function HyperWarpPopUp( pUrlPopUp )
{
	var varUrl	=new String( window.opener.location );

	sConector	=( varUrl.indexOf( "?" )==-1 )?"?":"&";
	sConector2	=( varUrl.indexOf( "?" )!=-1 )?"&":"?";

	if ( varUrl.match("pUrlPopUp")!=null )
		varUrl		=varUrl.replace( sConector2+"pUrlPopUp="+pUrlPopUp, "" );	
	
	sUrl		=varUrl+sConector+"pUrlPopUp="+pUrlPopUp;

	window.opener.location.href=sUrl;
}

/*------------------------------------------------------------
	Document Text Sizer- Copyright 2003 - Taewook Kang.  All rights reserved.
	Coded by: Taewook Kang (txkang.REMOVETHIS@hotmail.com)
	Web Site: http://txkang.com
	Script featured on Dynamic Drive (http://www.dynamicdrive.com)
	
	Please retain this copyright notice in the script.
	License is granted to user to reuse this code on 
	their own website if, and only if, 
	this entire copyright notice is included.
--------------------------------------------------------------*/

//Specify affected tags. Add or remove from list:
var tgs = new Array( 'div','td','tr');

//Specify spectrum of different font sizes:
var szs = new Array( '10px','11px','14px' );
var startSz = 1;
function ts( trgt,inc ) {
	if (!document.getElementById) return
	var d = document,cEl = null,sz = startSz,i,j,cTags;
	
	sz += inc;
	if ( sz < 0 ) sz = 0;
	if ( sz > 2 ) sz = 2;
	startSz = sz;
		
	if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];

	cEl.style.fontSize = szs[ sz ];

	for ( i = 0 ; i < tgs.length ; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ];

}

if (inc==0) {
	for ( i = 0 ; i < tgs.length ; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = '9px';
	}
}

if (inc==1) {
	for ( i = 0 ; i < tgs.length ; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = '11px';
	}
}
if (inc==2) {
	for ( i = 0 ; i < tgs.length ; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = '13px';
	}
}

}


/*
function ts( trgt,inc ) {
	if (!document.getElementById) return
	var d = document,cEl = null,sz = startSz,i,j,cTags;
	
	sz += inc;
	if ( sz < 0 ) sz = 0;
	if ( sz > 2 ) sz = 2;
	startSz = sz;
		
	if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];

	cEl.style.fontSize = szs[ sz ];

	for ( i = 0 ; i < tgs.length ; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
	}

	if (inc==2) {
		for ( i = 0 ; i < tgs.length ; i++ ) {
			cTags = cEl.getElementsByTagName( tgs[ i ] );
			for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = 11;
		}
	}
}

/*
function ts( trgt,inc ) {
	if (!document.getElementById) return
	var d = document,cEl = null,sz = startSz,i,j,cTags;
	
	sz += inc;
	if ( sz < 0 ) sz = 0;
	if ( sz > 2 ) sz = 2;
	startSz = sz;
		
	if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];

	cEl.style.fontSize = szs[ sz ];

	for ( i = 0 ; i < tgs.length ; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
	}

if (inc==-1) {
	
	for ( i = 0 ; i < tgs.length ; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = '9px';
	}
}

if (inc==2) {
	for ( i = 0 ; i < tgs.length ; i++ ) {
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = '11px';
	}
}

if (inc==1) {
	for ( i = 0 ; i < tgs.length ; i++ ) { 
		cTags = cEl.getElementsByTagName( tgs[ i ] );
		for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = '13px';
	}
}

}
/*Funciones para el buscador*/
/*
function validarBuscar( objForm )
{
	if (trim(objForm.edtClave.value)=="")
	{
		alert("Debe ingresar el término a buscar.");
		objForm.edtClave.focus();
		return false;
	}
	if(objForm.edtClave.value.length<3)
	{
		alert("Debe ingresar un término no menor a 3 caracteres.");
		objForm.edtClave.focus();
		return false;
	}	

	return true;
}


function abrirPopBusqueda( objForm )
{
	envioClave	=objForm.edtClave.value;
	
	if ( validarBuscar( objForm ) )
	{
		var objVentana	=window.open("../content/pop_busqueda.php?edtClave="+envioClave+"&accion=buscar", "pop_busqueda","resizable=1,scrollbars=yes,width=782,height=440");
		objVentana.focus();
	}
}
*/

function validarBuscar( objForm )
{
	if (trim(objForm.q.value)=="")
	{
		alert("Debe ingresar el término a buscar.");
		objForm.q.focus();
		return false;
	}
	if(objForm.q.value.length<3)
	{
		alert("Debe ingresar un término no menor a 3 caracteres.");
		objForm.q.focus();
		return false;
	}	

	return true;
}

function abrirPopBusqueda()
{
	objForm	=document.frmBuscador;

	envioClave	= encodeURI(objForm.q.value);
	cx			="013989897972511377973:yolthxko4s8";
	cof			="FORID:11";

	if ( validarBuscar( objForm ) )
	{
		//var objVentana	=window.open("../content/pop_busqueda.php?q="+envioClave+"&cx="+cx+"&cof="+cof, "Buscar","resizable=1,scrollbars=yes,location=1,toolbar=1,width=782,height=440");
		var destino = "../content/pop_busqueda.php?q="+envioClave+"&cx="+cx+"&cof="+cof;
		location.href = destino;
		
		//window.location="../content/pop_busqueda.php?q="+envioClave+"&cx="+cx+"&cof="+cof;

	}
}

function buscarContenido( e, objForm )
{
	var keynum
	if(window.event) // IE
	{
		keynum = e.keyCode
	}else if(e.which) // Netscape/Firefox/Opera
	{
		keynum = e.which
	}
	
	if (keynum==13)	
	{
		abrirPopBusqueda( objForm );		
		e.returnValue = false;	
	}else{
//		return checkStringAlfaNumerico(objForm.edtClave.value);
		return checkStringAlfaNumerico(objForm.q.value);
	}
	return false;
}

function YB_bookmarkSite(url, title){
    if(ie)
		window.external.AddFavorite(url, title);
	else 
		window.sidebar.addPanel(title, url, "");
}

function isIE(){
	var browserType=navigator.userAgent;
	if (browserType.indexOf("MSIE")==-1)
		return false;
	else
		return true;
}
/**** function para ingreso en la pagina de intranet */
function loginProd()
{
  var u = "";
  var i = "";
  var s = "";
  var r = "";
  var param = "";
  var a = "Ingresar";
  var ruta = "http://campusvirtual.pucp.edu.pe/login?accion=";
  var d, w;
  var nw="1";
  var diAux = "di=es";

  if (arguments[0] && typeof arguments[0] == "object" ) {
    for(var n in arguments[0]) {
      if (n=="r") {r=arguments[0][n];}
      else if (n=="nw") {nw=arguments[0][n];}
      else if (n=="di") { if (arguments[0][n]=="en") { diAux = "di=en"; } else if (arguments[0][n]=="pt") { diAux = "di=pt"; } }
      else if (n=="a" && arguments[0][n]=="IngresarRNU" ) {a="IngresarRNU";}
      else if (n=="a" && arguments[0][n]=="IngresarRDU" ) {a="IngresarRDU"; ruta = "/e?accion=";}
      else { param += "&" + n + "=" + (n!="u"?arguments[0][n]:arguments[0][n].replace(/\&/g, "PucpAmpersand").replace(/\?/g, "PucpQuestion")); }
    }
    param += "&" + diAux;
  } else {
    if (arguments[0]) { u = arguments[0]; }
    if (arguments[1]) { i = arguments[1]; }
    if (arguments[2]) { s = arguments[2]; }
    if (arguments[3]) { r = arguments[3]; }
    param = "&u=" + u.replace(/\&/g, "PucpAmpersand").replace(/\?/g, "PucpQuestion") + "&i=" + i + "&s=" + s;
  }

  if (nw == "0") { 
    top.location.href=ruta + a + param;  
  } else {
    d = new Date();
    w=window.open(ruta + a + param, "login" + d.valueOf(), "location=no,status=yes,resizable=yes,toolbar=yes,scrollbars=yes,top=0,left=0,width=790,height=520", 1 );  
    if (r == "1") { return w; }
  }

}

/** fin de la funcion intranet **/

function getMensajeTexto(  ){
	var texto = '¿Desea hacer de la Pontificia Universidad Católica su página de inicio?' +'\n';
	    texto += 'Arrastre el enlace hasta su botón de inicio para hacer de la PUCP su página de inicio.';	
	alert( texto );	 
}

function mensaje( bNavegador , ruta ){
	if( bNavegador ) { 
		url = '<a href="javascript:void(0);" onClick="this.style.behavior=\'url(#default#homepage)\';';
		url += 'this.setHomePage(\''+ruta+'\');">Haga de esta su p&aacute;gina de inicio</a>';
		document.write( url ); 
	}else{ 
		 url = '<a href="'+ruta+'" onClick="getMensajeTexto(); return false;">Haga de esta su p&aacute;gina de inicio</a>';
		// alert(url);
		document.write( url ); 
	}		
}
/** fin de la funcion intranet **/

