﻿// JavaScript Document
<!--
/* Buscar en esta pagina - por Juan Carlos Seltmann (jseltmann@e-ventos.info) */

var NS4 = (document.layers);    // que buscador?
var IE4 = (document.all);
var win = window;    // ventana a buscar.
var n   = 0;
function findInPage(str) {
var txt, i, found;
if (str == "")
return false;
// Buscar la proxima ocurrencia de la cadena en la pagina, volver al comienzo
// de la pagina si es necesario.
if (NS4) {
// Buscar conincidencia comenzando desde la posicion acutual. Si no encuentra, vuelve a la 
// primer coincidencia.
if (!win.find(str))
while(win.find(str, false, true))
n++;
else
n++;
// Si no encuentra en esta direccion, presenta el mensaje.
if (n == 0)
alert("No encontrado.");
}
if (IE4) {
txt = win.document.body.createTextRange();
// Buscar la proxima conincidencia hacia arriba.
for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
txt.moveStart("character", 1);
txt.moveEnd("textedit");
}
// Si encuentra, marca y conduce hacia la cadena encontrada.
if (found) {
txt.moveStart("character", -1);
txt.findText(str);
txt.select();
txt.scrollIntoView();
  n++;
  }
// si no encuentra, comienza desde arriba y busca la proxima coincidencia.

else {
if (n > 0) {
n = 0;
findInPage(str);
}
// Si no encuentra en ninguna parte, presenta el mensaje.
else
alert("No encontrado.");
}
}
return false;
}

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_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&&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];}
}
//Comienza Ticker
addEvent(window, "load", init);

function init() {
	if (document.getElementById) {
		tck = document.getElementById("ticker");
		if (tck.getElementsByTagName("div").length > 0) {
			actual = 0;
			step = 2;
			speed = 15;
			delay = 1000;
			news = new Array();
			// build an array of news - eg every seperate div provided in the div with
			// id = "all". 
			for (i = 0; i < tck.getElementsByTagName("div").length; i++) {
				news[i] = tck.getElementsByTagName("div")[i];
				news[i].style.left = tck.offsetWidth;
			}
			// start the news rolling ....
			rollNews();
			// add listeners for when mouse goes over tck to stop and when it leaves 
			// tck to start again
			addEvent(tck, "mouseover", stopNews);
			addEvent(tck, "mouseout", rollNews);
		}
	}
}

function rollNews() {
	// move left edge to left a bit
	news[actual].style.left = parseInt(news[actual].style.left) - step + "px";
	
	if (parseInt(news[actual].style.left) == tck.offsetWidth % step) {
		// if that movement hasnt taken us off the edge of the div then wait
		// a bit and move it again.
		tick = setTimeout("rollNews()",delay);
	}
	else {
		// if it has taken us over the edge then move to the next item in news array
		if (parseInt(news[actual].style.left) <= 0-news[actual].offsetWidth) {
			actual++;
			// if at end of array then knock it back to start
			if (actual == news.length) {actual = 0;}
			news[actual].style.left = tck.offsetWidth;
		}
		// wait a bit and try again.
		tick = setTimeout("rollNews()",speed);
	}
}

function stopNews() {
	clearTimeout(tick);
}

function addEvent(obj, evType, fn){
  if (obj.addEventListener){
    obj.addEventListener(evType, fn, true);
    return true;
  } else if (obj.attachEvent){
	var r = obj.attachEvent("on"+evType, fn);
    return r;
  } else {
	return false;
  }
}
//fin Ticker
var winheight=350;
var winwidth=750;
var pop=null;
step=1;
function popswindows(url,name,width,height) 
{
if (!document.all)
 {
  if (!document.layers)
   {
    paramstp="height="+height+",width="+width+",top=20"+
    ",left=20,scrollbars=no,location=no"+
    ",directories=no,status=no,menubar=no,toolbar=no,resizable=no"
    pop=window.open(url,name,paramstp);
    if (pop.focus){pop.focus();}
    return;
    }
   else
   {
    LeftPosition=(screen.width)?(screen.width-width)/2:100;
    TopPosition=(screen.height)?(screen.height-height)/2:100;
    paramstp="height="+height+",width="+width+",top="+TopPosition+
    ",left="+LeftPosition+",scrollbars=no,location=no"+
    ",directories=no,status=no,menubar=no,toolbar=no,resizable=no"
    pop=window.open(url,name,paramstp);
    loadpos=height/2-40
        if(pop.focus){pop.focus();} 
    return;
   } 
 } 
   LeftPosition=(screen.width)?(screen.width-width)/2:100;
  TopPosition=(screen.height)?(screen.height-height)/2:100;
  paramstp="height="+winheight+",width="+winwidth+",top="+TopPosition+
  ",left="+LeftPosition+",scrollbars=no,location=no"+
  ",directories=no,status=no,menubar=no,toolbar=no,resizable=no"
  pop=window.open(url,name,paramstp);
 x = y = step
var z = 1;

while (z < 40) {
pop.resizeBy (x, y)
z++;
}
 if(pop.focus){pop.focus();} 
}

//Para los menus de navegación rápida e idiomas
function irA(menu){window.location.href = menu.options[menu.selectedIndex].value;}

//seleccion de buscador
function buscaren()
{
ingreso = new String()

ingreso = this.formulario.q.value
if (ingreso.length == 0)
{ alert("Por favor ingrese una palabra para comenzar la búsqueda.")
return false
}

ingreso = this.formulario.buscador.value
if (ingreso.match("aca"))
{ findInPage(this.formulario.q.value) 
return false
}
if (ingreso.match("e-ventos"))
{ this.formulario.searWords.value = this.formulario.q.value 
formulario.action = "search.php"
return true
}
if (ingreso.match("sitio"))
{ this.formulario.sitesearch.value = "www.e-ventos.info" 
formulario.action = "search-google.php"
return true
}
if (ingreso.match("google"))
{ this.formulario.sitesearch.value = "" 
formulario.action = "search-google.php"
return true
}
return true
}
//fin seleccion de buscador

//-->
