/* funciones varias */

FONT_ACTUAL = 10;
FONT_SMALLEST = 8;
FONT_LARGEST = 20;

//-----------------------------------------------------------------------------------
function AbrirPop(nombre,ancho,alto) 
//-----------------------------------------------------------------------------------
{
dat = 'width=' + ancho + ',height=' + alto + ',left=0,top=0,toolbar=0,menubar=no,status=no,scrollbars=yes,resize=no';
	centrar(window.open(nombre,'',dat), ancho, alto)
}

//-----------------------------------------------------------------------------------
function centrar(ventana, ancho, alto)
//-----------------------------------------------------------------------------------
// centrar ventana
{
  var x = (screen.width - ancho)/2;
  var y = (screen.height - alto)/2;
  ventana.moveTo(x, y);
}


//-----------------------------------------------------------------------------------
function AntiSpam1 (user,host)
//-----------------------------------------------------------------------------------
{
document.write("<a href=\"mailto:"+user+"@"+host+"\">"+user+"@"+host+"</a>");
}

//-----------------------------------------------------------------------------------
function AntiSpam2 (user,host, descripcion) 
//-----------------------------------------------------------------------------------
{
document.write("<a href=\"mailto:"+user+"@"+host+"\">"+descripcion+"</a>");
}


//-----------------------------------------------------------------------------------
function Fecha () 
//-----------------------------------------------------------------------------------
{
// fecha en formato Viernes, 28/07/06
diaName = new Array (
	"Domingo","Lunes", "Martes", "Mi&eacute;rcoles", "Jueves", "Viernes", "S&acute;bado" 
	)

now = new Date
var months=new Array(13);
months[1]="01";
months[2]="02";
months[3]="03";
months[4]="04";
months[5]="05";
months[6]="06";
months[7]="07";
months[8]="08";
months[9]="09";
months[10]="10";
months[11]="11";
months[12]="12";
var time=new Date();
var lmonth=months[time.getMonth() + 1];
var date=time.getDate();
var year=time.getYear();

if (year < 2000)    //
	year = year + 1900; //

document.write(diaName[now.getDay()]+ ", ");
document.write(+ date + "/");
document.write(lmonth + "/" + year);
// End -->
}


//-----------------------------------------------------------------------------------
function Fecha_Larga () 
//-----------------------------------------------------------------------------------
{
// fecha en formato Viernes 28 de Julio de 2006 
diaName = new Array (
	"Domingo","Lunes", "Martes", "Mi&eacute;rcoles", "Jueves", "Viernes", "S&aacute;bado" 
	)

mesName = new Array (
	"Enero","Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio","Agosto","Setiembre","Octubre","Noviembre","Diciembre" 
	)

now = new Date

var time=new Date();
var date=time.getDate();
var year=time.getYear();if (year < 2000)    //
	year = year + 1900; //

document.write(diaName[now.getDay()]+ " ");
document.write(date + " de ");
document.write(mesName[now.getMonth()]+ " de " + year);
// End -->
}



//-----------------------------------------------------------------------------------
function SumaFontSize (id, incremento) 
//-----------------------------------------------------------------------------------
{
FONT_ACTUAL = FONT_ACTUAL+incremento;
if (FONT_ACTUAL > FONT_LARGEST) FONT_ACTUAL = FONT_LARGEST;

document.getElementById(id).style.fontSize = FONT_ACTUAL + "px";
}


//-----------------------------------------------------------------------------------
function RestaFontSize(id, incremento) {
//-----------------------------------------------------------------------------------
FONT_ACTUAL = FONT_ACTUAL-incremento;
if (FONT_ACTUAL < FONT_SMALLEST) FONT_ACTUAL = FONT_SMALLEST;

document.getElementById(id).style.fontSize = FONT_ACTUAL + "px";
}

//-----------------------------------------------------------------------------------
function RestablecerFontSize(id) {
//-----------------------------------------------------------------------------------
FONT_ACTUAL = 10;
document.getElementById(id).style.fontSize = FONT_ACTUAL + "px";
}



//-----------------------------------------------------------------------------------
function Titulares_Elpais () {
//-----------------------------------------------------------------------------------
	  <!--
	  document.write('<span class="titulo_feed_elpais"><strong>ELPAIS.es | Titulares de Ciencia, Tecnolog&iacute;a y Humanidades<\/strong><\/span><br\/>');
	  document.write('<div class="fondo_resultados_elpais">');
	  if (a_noticias == null || a_noticias.length == 0) {
	        document.write('<center>No hay noticias del feed solicitado<\/center>');
	  } else {
		for (var i = 0; i < 10; i++) {
			document.write('<a href');
			document.write('="' + a_noticias[i].link + '" target="_blank" class="titular_elpais">');
			document.write(a_noticias[i].title + '<\/a><br\/>');
			document.write('<span class="autor_elpais">');
			document.write(a_noticias[i].autor);
				
		 	var date = new Date(a_noticias[i].pubdate);
			date.setHours(date.getHours() - (date.getTimezoneOffset() / 60 ));
			document.write(' &nbsp;' + date.toString() + '<\/span>');
			document.write('<br\/><br\/>');
	    	}
	   }
	   document.write('<\/div>');				   
	   // -->
}


//-----------------------------------------------------------------------------------
function Favoritos ()
//-----------------------------------------------------------------------------------
{
if ((navigator.appName=="Microsoft Internet Explorer") && (parseInt(navigator.appVersion)>=4)) {
   var url="http://www.reducativa.com/";
   var titulo="Portal Reducativa";
   window.external.AddFavorite(url,titulo);
} else {
  if(navigator.appName == "Netscape")
   alert ("Presione Crtl+D para agregar este sitio en sus Favoritos");
}
}


/* by E Michael Brandt of ValleyWebDesigns.com - Please leave these comments intact.
   version 3.0.4  
*/
//-----------------------------------------------------------------------------------
function JustSoPicWindow(imageName,imageWidth,imageHeight,alt,bgcolor,hugger,hugMargin) {
//-----------------------------------------------------------------------------------
	if (bgcolor=="") {
		bgcolor="#FFFFFF";
	}
	var adj=10
	var w = screen.width;
	var h = screen.height;
	var byFactor=1;

	if(w<740){
	  var lift=0.90;
	}
	if(w>=740 & w<835){
	  var lift=0.91;
	}
	if(w>=835){
	  var lift=0.93;
	}
	if (imageWidth>w){	
	  byFactor = w / imageWidth;			
	  imageWidth = w;
	  imageHeight = imageHeight * byFactor;
	}
	if (imageHeight>h-adj){
	  byFactor = h / imageHeight;
	  imageWidth = (imageWidth * byFactor);
	  imageHeight = h; 
	}
	   
	var scrWidth = w-adj;
	var scrHeight = (h*lift)-adj;

	if (imageHeight>scrHeight){
  	  imageHeight=imageHeight*lift;
	  imageWidth=imageWidth*lift;
	}

	var posLeft=0;
	var posTop=0;

	if (hugger == "hug image"){
	  if (hugMargin == ""){
	    hugMargin = 0;
	  }
	  var scrHeightTemp = imageHeight - 0 + 2*hugMargin;
	  if (scrHeightTemp < scrHeight) {
		scrHeight = scrHeightTemp;
	  } 
	  var scrWidthTemp = imageWidth - 0 + 2*hugMargin;
	  if (scrWidthTemp < scrWidth) {
		scrWidth = scrWidthTemp;
	  }
	  
	  if (scrHeight<100){scrHeight=100;}
	  if (scrWidth<100){scrWidth=100;}

	  posTop =  ((h-(scrHeight/lift)-adj)/2);
	  posLeft = ((w-(scrWidth)-adj)/2);
 	}

	if (imageHeight > (h*lift)-adj || imageWidth > w-adj){
		imageHeight=imageHeight-adj;
		imageWidth=imageWidth-adj;
	}
	posTop = parseInt(posTop);
	posLeft = parseInt(posLeft);		
	scrWidth = parseInt(scrWidth); 
	scrHeight = parseInt(scrHeight);
	
	var agt=navigator.userAgent.toLowerCase();
	if (agt.indexOf("opera") != -1){
	  var args= new Array();
	  args[0]='parent';
	  args[1]=imageName;
	  var i ; document.MM_returnValue = false;
	  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
	} else {
	newWindow = window.open("vwd_justso.htm","newWindow","width="+scrWidth+",height="+scrHeight+",left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor='+bgcolor+' onBlur="self.close()" onClick="self.close()">');  
	newWindow.document.write('<table width='+imageWidth+' border="0" cellspacing="0" cellpadding="0" align="center" height='+scrHeight+' ><tr><td>');
	newWindow.document.write('<img src="'+imageName+'" width='+imageWidth+' height='+imageHeight+' alt="Hacer click para cerrar ventana" >'); 
	newWindow.document.write('</td></tr></table></body></html>');
	newWindow.document.close();
	newWindow.focus();
	}
}


//-----------------------------------------------------------------------------------
function fncBorracampofile() 
//-----------------------------------------------------------------------------------
{
capa = window.capaarchivo;
varHTML = '';
capa.innerHTML = varHTML;
//varHTML += '<input name="archivo" type="file" id="archivo">';

varHTML += '<INPUT type="file" name="archivo" id="archivo" required="1" onblur="javascript:LimitAttach(this);" class="estiloform" />';

capa.innerHTML = varHTML;
}


//-----------------------------------------------------------------------------------
function esIE30() {
//-----------------------------------------------------------------------------------
/* Funcion que devuelve TRUE si el navegador es Internet Explorer o FALSE si es otro
*/
var browserType=navigator.userAgent;
if (browserType.indexOf("MSIE") == -1)
   return false;
else
   return true;
}

//-----------------------------------------------------------------------------------
function LimitAttach (tField) {
//-----------------------------------------------------------------------------------
/* Función que limita el tipo de archivo a enviarse por mail
*/
   file = tField.value;
   extArray = new Array("doc","rtf","txt","pdf","zip","rar", "ppt");
   allowSubmit = false;
   if (!file) return true;

   while (file.indexOf("\\") != -1)
	file = file.slice(file.indexOf("\\") + 1);

   while (file.indexOf(".") != -1)
	file = file.slice(file.indexOf(".") + 1);

   ext = file.toLowerCase();

   for (var i = 0; i < extArray.length; i++) {
	if (extArray[i] == ext) { 
	   allowSubmit = true;
	   break;
	}
   }

   if (!allowSubmit) {
	if (esIE30())
	   fncBorracampofile();
	else
   	   tField.value="";

	alert("Solo puede enviar archivos del tipo: " + (extArray.join("  ")) + "\nPor favor seleccione otro archivo");
	return true;
   } else {
	return false;
   }

}




//-----------------------------------------------------------------------------------
function LimitAttach2 (form, file) {
//-----------------------------------------------------------------------------------
/* NO LA ESTOY USANDO
   en el form se llama 
   onclick = "LimitAttach2(this.form, this.form.archivo.value)"
*/
extArray = new Array(".doc",".rtf",".txt",".pdf",".zip",".rar", ".ppt");
allowSubmit = false;
if (!file) return;
while (file.indexOf("\\") != -1)
file = file.slice(file.indexOf("\\") + 1);
ext = file.slice(file.indexOf(".")).toLowerCase();
for (var i = 0; i < extArray.length; i++) {
if (extArray[i] == ext) { allowSubmit = true; break; }
}
if (allowSubmit) {
	form.submit(); }
else {
	alert("Se permiten únicamente archivos con la extensión: " 
+ (extArray.join("  ")) + "\nPor favor, seleccione otro archivo "
+ "e intente de nuevo.");
	return false;
}
}

