//---------- function textsizer ----------//
var min=8;
var max=18;
function increaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 13;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
}
function decreaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 13;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }   
}
//---------- function buscador ----------//
function Send() {
	var url = "http://www.elhistoriador.com.ar/buscador.php?searWords=" + searWords.value;
	window.location.replace(url);
}
//---------- function print ----------//
function printWindow() {
bV = parseInt(navigator.appVersion);
if (bV >= 4) window.print();
}
//---------- function abrir popup ----------//
var win = null;
function newWindow(mypage,myname,w,h,features) {
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  if (winl < 0) winl = 0;
  if (wint < 0) wint = 0;
  var settings = 'height=' + h + ',';
  settings += 'width=' + w + ',';
  settings += 'top=' + wint + ',';
  settings += 'left=' + winl + ',';
  settings += features;
  win = window.open(mypage,myname,settings);
  win.window.focus();
}
//---------- function popup foto ----------//
function MM_openBrWindow(theURL,winName,features) { //zirucweb 1.0
             window.open(theURL,winName,features);
}
function verimagen(FileName)
{
	var ventanaimagen = window.open("", "newWindow",                 "location=no,menubar=no,resizable=no,scrollbars=no,status=no,width=300,height=600");
	ventanaimagen.document.writeln("<html>");
	ventanaimagen.document.writeln("<HEAD>");
	ventanaimagen.document.writeln("<TITLE>El Historiador</TITLE>");
	ventanaimagen.document.writeln("<script>");
	ventanaimagen.document.writeln("function setSize()");
	ventanaimagen.document.writeln("{");
	ventanaimagen.document.writeln("var img = window.document.images[0];");
	ventanaimagen.document.writeln("window.resizeTo(img.width+10, img.height+30);");
	ventanaimagen.document.writeln("}");
	ventanaimagen.document.writeln("</SCRIPT>");
	ventanaimagen.document.writeln("</HEAD>");
	ventanaimagen.document.writeln('<BODY marginheight=0 marginwidth=0 topmargin=0 leftmargin=0                 onClick="window.close()" onLoad="setSize();">');
	ventanaimagen.document.writeln('<IMG SRC="'+FileName+'" BORDER=0>');
	ventanaimagen.document.writeln("</BODY>");
	ventanaimagen.document.writeln("</HTML>");
	ventanaimagen.document.close();
} 
//---------- function fecha ----------//
function fechaHoy(){
date = new Date();
diaSem = date.getDay();
diaN = date.getDate();
diaN=diaN+" &middot; ";
mes = date.getMonth();
ano=date.getFullYear();
var meses = new Array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
var dias = new Array("Domingo", "Lunes", "Martes", "Mi&eacute;rcoles", "Jueves", "Viernes", "S&aacute;bado");
document.write(dias[diaSem]+"&nbsp;|&nbsp;"+diaN+" "+meses[mes]+" &middot; "+ano);
}
//---------- function a&ntilde;o actual ----------//
function anoActual(){
date = new Date();
ano = date.getFullYear();
document.write(ano);
}
//---------- function form compra ----------//
function validatecompra()
{
	if(trim(document.formulario.cantidad.value) == "")
	{
		alert("Por favor, ingrese una cantidad");
		document.formulario.cantidad.focus();
		return false;
	}
	if(trim(document.formulario.nombre.value) == "")
	{
		alert("Por favor, ingrese su nombre");
		document.formulario.nombre.focus();
		return false;
	}
	if(trim(document.formulario.ciudad.value) == "")
	{
		alert("Por favor, ingrese una ciudad");
		document.formulario.ciudad.focus();
		return false;
	}
	if(trim(document.formulario.provincia.value) == "")
	{
		alert("Por favor, ingrese una provincia");
		document.formulario.provincia.focus();
		return false;
	}
	if(trim(document.formulario.txtemail.value) == "")
	{
		alert("Por favor, ingrese su Email");
		document.formulario.txtemail.focus();
		return false;
	}
	if( !isEmail(document.formulario.txtemail.value) )
	{
		alert("Por favor, ingrese su Email");
		document.formulario.txtemail.focus();
		document.formulario.txtemail.select();
		return false;
	}

	document.formulario.cansend.value=1;

	return true;
}
function isEmail(emailstr)
{
	dotchar = emailstr.indexOf(".");
	atchar = emailstr.indexOf("@");
	dotlast = emailstr.lastIndexOf(".");
	spacechar = emailstr.indexOf(" ");
	len = emailstr.length;
	if( (dotchar == -1) || (atchar == -1) || (spacechar != -1) || (dotlast < atchar) || (dotlast == len - 1) )
	{
		return false;
	}
	else
	{
		return true;
	}
}
function trim(str)
{
ch = '';
for(i=0;i<str.length;i++)
{
	cha = str.charAt(i);
	if(cha != ' ')
	{
		ch = ch + cha;
	}
}
return ch;
}
//---------- function suscribir ----------//
function validatesuscripcion()
{
	if(trim(document.formulario.txtemail.value) == "")
	{
		alert("Por favor, ingrese su Email");
		document.formulario.txtemail.focus();
		return false;
	}
	if( !isEmail(document.formulario.txtemail.value) )
	{
		alert("Por favor, ingrese su Email");
		document.formulario.txtemail.focus();
		document.formulario.txtemail.select();
		return false;
	}

	document.formulario.cansend.value=1;

	return true;
}
function isEmail(emailstr)
{
	dotchar = emailstr.indexOf(".");
	atchar = emailstr.indexOf("@");
	dotlast = emailstr.lastIndexOf(".");
	spacechar = emailstr.indexOf(" ");
	len = emailstr.length;
	if( (dotchar == -1) || (atchar == -1) || (spacechar != -1) || (dotlast < atchar) || (dotlast == len - 1) )
	{
		return false;
	}
	else
	{
		return true;
	}
}
function trim(str)
{
ch = '';
for(i=0;i<str.length;i++)
{
	cha = str.charAt(i);
	if(cha != ' ')
	{
		ch = ch + cha;
	}
}
return ch;
}
//---------- function form enviaramigo ----------//
function validate()
{
	if(trim(document.formulario.nombre.value) == "")
	{
		alert("Por favor, ingrese su nombre");
		document.formulario.nombre.focus();
		return false;
	}
	if(trim(document.formulario.amigo.value) == "")
	{
		alert("Por favor, ingrese el nombre de su amigo");
		document.formulario.amigo.focus();
		return false;
	}
	if(trim(document.formulario.txtemail.value) == "")
	{
		alert("Por favor, ingrese su email");
		document.formulario.txtemail.focus();
		return false;
	}
	if( !isEmail(document.formulario.txtemail.value) )
	{
		alert("Por favor, ingrese su email");
		document.formulario.txtemail.focus();
		document.formulario.txtemail.select();
		return false;
	}
	if(trim(document.formulario.sendemail.value) == "")
	{
		alert("Por favor, ingrese el email de su amigo");
		document.formulario.sendemail.focus();
		return false;
	}
	if( !isEmail(document.formulario.sendemail.value) )
	{
		alert("Por favor, ingrese el email de su amigo");
		document.formulario.sendemail.focus();
		document.formulario.sendemail.select();
		return false;
	}
	if(trim(document.formulario.mensaje.value) == "")
	{
		alert("Por favor, ingrese su mensaje");
		document.formulario.mensaje.focus();
		return false;
	}

	document.formulario.cansend.value=1;

	return true;
}
function isEmail(emailstr)
{
	dotchar = emailstr.indexOf(".");
	atchar = emailstr.indexOf("@");
	dotlast = emailstr.lastIndexOf(".");
	spacechar = emailstr.indexOf(" ");
	len = emailstr.length;
	if( (dotchar == -1) || (atchar == -1) || (spacechar != -1) || (dotlast < atchar) || (dotlast == len - 1) )
	{
		return false;
	}
	else
	{
		return true;
	}
}
function trim(str)
{
ch = '';
for(i=0;i<str.length;i++)
{
	cha = str.charAt(i);
	if(cha != ' ')
	{
		ch = ch + cha;
	}
}
return ch;
}
//---------- function ver foto ----------//
var offsetfrommouse=[15,15]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration=0; //duration in seconds image should remain visible. 0 for always.
var currentimageheight = 300;	// maximum image size.

var currentimagewidth = 200;	// maximum image size.
var timer;

function gettrailobj(){
if (document.getElementById)
return document.getElementById("preview_div").style
else if (document.all)
return document.all.trailimagid.style
}

function gettrailobjnostyle(){
if (document.getElementById)
return document.getElementById("preview_div")
else if (document.all)
return document.all.trailimagid
}


function truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}


function hidetrail(){	
	gettrailobj().display= "none";
	document.onmousemove=""
	gettrailobj().left="-500px"
	clearTimeout(timer);
}

function showtrail(imagename,title,showthumb){
	i = imagename
	t = title
	s = showthumb
	timer = setTimeout("show('"+i+"',t,s);",200);
}
function show(imagename,title,showthumb){
        var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth - offsetfrommouse[0]
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

if((navigator.userAgent.indexOf("Firefox")!=-1 || (navigator.userAgent.indexOf("Opera")==-1 && navigator.appVersion.indexOf("MSIE")!=-1)) && (docwidth>650 && docheight>500)){

	document.onmousemove=followmouse; 
	
	newHTML = '<div class="border_preview"><div id="loader_container"><div id="loader"><div align="center">Cargando imagen...</div><div id="loader_bg"><div id="progress"> </div></div></div></div>';
	newHTML = newHTML + '<h2 class="title_h2">' + title + '</h2>'
	if (showthumb > 0){
    newHTML = newHTML + '<div align="center" style="padding: 8px 10px 17px 10px;"><img onload="javascript:remove_loading();" src="' + imagename + '" border="0"></div>';
}

	newHTML = newHTML + '</div>';
	if(navigator.userAgent.indexOf("Firefox")==-1){	newHTML = newHTML+'<iframe src="about:blank" scrolling="no" frameborder="0" width="390" height="390"></iframe>';}

	gettrailobjnostyle().innerHTML = newHTML;

	gettrailobj().display="block";

}

function followmouse(e){

	var xcoord=offsetfrommouse[0]
	var ycoord=offsetfrommouse[1]

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth - offsetfrommouse[0]
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

	if (typeof e != "undefined"){
		if (docwidth - e.pageX < currentimagewidth){

		if(navigator.userAgent.indexOf("Firefox")!=-1)	{xcoord = e.pageX - xcoord - currentimagewidth + 2*offsetfrommouse[0]} else{ xcoord = e.pageX - xcoord - currentimagewidth + 6*offsetfrommouse[0] ;} // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < (currentimageheight + 110)){
			ycoord += e.pageY - Math.max(0,(110 + currentimageheight + e.pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += e.pageY;
		}

	} else if (typeof window.event != "undefined"){
		if (docwidth - event.clientX < currentimagewidth){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - currentimagewidth + 2*offsetfrommouse[0]; // Move to the left side of the cursor
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (currentimageheight + 110)){
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,(110 + currentimageheight + event.clientY - docheight));
		} else {
			ycoord += truebody().scrollTop + event.clientY;
		}
	}

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-offsetfrommouse[0]
	var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)
		if(ycoord < 0) { ycoord = ycoord*-1; }
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"
}
}
//---------- function frase larga ----------//
function more(nro){
	if (document.getElementById("txtAll_" + nro).style.display == "none"){
		document.getElementById("txtAll_" + nro).style.display  = "";
		document.getElementById("txtShort_" + nro).style.display  = "none";
	} else {
		document.getElementById("txtAll_" + nro).style.display  = "none";
		document.getElementById("txtShort_" + nro).style.display  = "";	
	}
}
function s_show(){return false}
function s_hide(){return false}
if(window.event+''=='undefined')event=0