﻿function FP_preloadImgs() {//v1.0
 var d=document,a=arguments; if(!d.FP_imgs) d.FP_imgs=new Array();
 for(var i=0; i<a.length; i++) { d.FP_imgs[i]=new Image; d.FP_imgs[i].src=a[i]; }
}

function FP_swapImg() {//v1.0
 var doc=document,args=arguments,elm,n; doc.$imgSwaps=new Array(); for(n=2; n<args.length;
 n+=2) { elm=FP_getObjectByID(args[n]); if(elm) { doc.$imgSwaps[doc.$imgSwaps.length]=elm;
 elm.$src=elm.src; elm.src=args[n+1]; } }
}

function FP_getObjectByID(id,o) {//v1.0
 var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById) el=o.getElementById(id);
 else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
 if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
 for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return el; }
 f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
 for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el) return el; } }
 return null;
}

function redireciona(){
	location="http://www.salesianolins.br";
}

	var max_engines = 30;
	var snark_string = "palavra";
	
	function MakeArray(n) {
	   for (var i = 1; i <= n; i++) {
	     this[i] = 0;
	   }
	   this.maxlen = n;
	   this.len = 0;
	   return this;
	}
	var engs = MakeArray(max_engines);
	function find_substring(needle, haystack) {
	   var i, needlen = needle.length, haylen = haystack.length;
	   for (i=0; i<=haylen-needlen; i++) {
	      if (needle == haystack.substring(i,i+needlen))
	        return i;
	   }
	   return false;
	}
	function Engine(name, opts, home, search) {
	  var snark = find_substring(snark_string, search);
	  this.name = name;
	  this.opts = opts;
	  this.home = home;
	  this.pre_snark = search.substring(0,snark);
	  this.post_snark= search.substring(snark+snark_string.length, search.length);
	}
	function Add(name, opts, home, search) {
	  engs.len++;
	  if (engs.len <= engs.maxlen) {
	    engs[engs.len] = new Engine(name, opts, home, search)
	  }
	  else {
	    alert("Melhor aumentar max_engines: " + engs.len + ">" + engs.maxlen)
	  }
	}
	

	Add("Google", "selected",
   "http://www.google.com/",
   "http://www.google.com/search?q=palavra&restrict=Portugu%EAs" );

	Add("AltaVista", "",
	   "http://www.altavista.com/",
	   "http://www.altavista.com/cgi-bin/query?pg=q&kl=XX&q=palavra&search=Search" );
	Add("Aonde?", "",
	   "http://www.aonde.com/",
	   "http://www.aonde.com/cgi/consulta.cgi?keys=palavra&search_type=and&x=29&y=9" );
	Add("Cad&ecirc;?", "",
	   "http://www.cade.com.br/",
	   "http://busca.cade.com.br/scripts/engine.exe?p1=palavra&p2=1&p3=1" );
	Add("Yahoo-BR", "",
	   "http://br.yahoo.com/",
	   "http://br.busca.yahoo.com/search/br?p=palavra" );
	Add("Exite", "",
	   "http://www.exite.com/",
	   "http://search.excite.com/search.gw?search=palavra" );
	Add("Hotbot", "",
	   "http://www.hotbot.com/",
	   "http://www.hotbot.com/?SW=web&SM=MC&MT=palavra" );
	Add("Infoseek", "",
	   "http://www.infoseek.com/",
	   "http://www.infoseek.com/Titles?qt=palavra" );
	Add("Lycos", "",
	   "http://www.lycos.com/",
	   "http://www.lycos.com/cgi-bin/pursuit?query=palavra" );
	Add("MetaCrawler", "",
	   "http://www.metacrawler.com/",
	   "http://www.metacrawler.com/cgi-bin/nph-metaquery?method=0&type=Fast+Search&sort=relevance&Itarget=window&useFrames=1&iface=int1&general=palavra" );
	Add("Surf", "",
	   "http://www.surf.com.br/",
	   "http://www.surf.com.br/x/busca.cgi?keys=palavra" );
	Add("Yahoo!", "",
	   "http://www.yahoo.com/",
	   "http://ink.yahoo.com/bin/query?p=palavra&z=2&hc=0&hs=0" );
	Add("Yahooligans!", "",
	   "http://www.yahooligans.com/",
	   "http://search.yahooligans.com/search/ligans?p=palavra" );
	Add("WebCrawler", "",
	   "http://www.webcrawler.com/",
	   "http://www.webcrawler.com/cgi-bin/WebQuery?mode=summaries&maxHits=25&searchText=palavra" );
	Add("WhoWhere", "",
	   "http://www.whowhere.com/",
	   "http://www.lycos.com/cgi-bin/pursuit?cat=lycos&query=palavra&x=37&y=10" );
	Add("Zeek!", "",
	   "http://www.zeek.com.br/",
	   "http://busca.zeek.com.br/busca/busca.cfm?p=palavra" );

function HandleForm(form) {
	form.submit();  // This fixes a Netscape 2.0b6a bug.
	var i, oldq=form.palavra.value, newq="";
	for (i=0; i<oldq.length; i++) {  // compress [ ]+ into \+
		var thischar = oldq.charAt(i);
		if (thischar != ' ')
	      newq += thischar;
	    else if (lastchar != ' ')
	      newq += '+';
	    lastchar = thischar;
	}
	var eng = engs[1+form.service.selectedIndex];
	var janela = window.open() ;
	janela.location.href = newq ? eng.pre_snark + newq + eng.post_snark : eng.home;
}

function openSlideShow(pId) {
	eval("page" + pId + " = window.open('slideshow.php?cod_evento=" + pId + "', 'SlideShow', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=550');");
}

function openSlideShowPrincipal(pId) {
	eval("page" + pId + " = window.open('eventos/slideshow.php?cod_evento=" + pId + "', 'SlideShow', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=550');");
}
