function init(){

	sfHover();
	//outLinks();
	//terres();
	//initZoom();
	//getSurveyLinks();	


//&&&&&&&&&&&&&&&&&&&&&&&&&&&&
//rel=zoom ready for lightbox&
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&

//prototype test stuff below
if($('busline')){hideBusTimetables('busline');}
if($('webMap')){theBigOne();}
}

window.onload = init;

function theBigOne(){



var branches = document.getElementsByClassName('branch');
var heights = new Array();
//text some bucles
for (var i=0;i<branches.length;i++){
	heights[i] = branches[i].offsetHeight;
}
var lemax = heights.max();
branches.each( function(branch){branch.style.height=lemax + "px";});
//var elmax = branches.max();
//alert(elmax.class);
//alert(elmax.style.height);
//branches.each( function(branch){branch.style.height=elmax.style.height;});
}

function hideBusTimetables(elto){
var timetables = getElementsByClassName(document,'div','bus_timetable');
var hides = $A(timetables);
	hides.each(function(node){node.style.display='none';});
}

function sfHover() {
if(document.getElementById("nav")){
		var sfEls = document.getElementById("nav").getElementsByTagName("li");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
}


















//OLD STUFF
function getSurveyLinks(){
	var pap = document.getElementById('encuestas');
	if (pap){
		var listItems = document.getElementsByTagName('a');
		for (var i=0; i<listItems.length; i++){
			if (listItems[i].id.match("link_")){
				hide(listItems[i]);
				listItems[i].onclick = function(){show(this)};
			}
		}//for
	}//if
}
function hide(elto){
	var aux = elto.id.split("_");
	if(elto.className == "first"){
	document.getElementById("block_"+aux[1]).style.display="block";
	elto.className ="current";
	}else{
	document.getElementById("block_"+aux[1]).style.display="none";
	}
}
function show(elto){
	elto.href="#";
	//currents off
		var links = document.getElementsByTagName('a');
		for(var j=0; j<links.length;j++){
			if (links[j].className == "current"){
			links[j].className="visitable";
			}
		}
	//containers out
		var containers = document.getElementsByTagName('div');
		for(var i=0;i<containers.length;i++){
			if(containers[i].id.match("block_")){
				containers[i].style.display="none";
			}
		}
	var aux = elto.id.split("_");
	document.getElementById("block_"+aux[1]).style.display="block";
	elto.className="current";
}

//zoom images
function initZoom()
{
if (!document.getElementsByTagName){ return; }
	var anchors = document.getElementsByTagName("a");
	// loop through all anchor tags
	for (var i=0; i<anchors.length; i++){
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && (anchor.getAttribute("rel") == "zoom")){
			anchor.onclick = function () {window.open(this.href);return false;}
		}
	}
}

function outLinks(){
var GKO = (navigator.userAgent.toLowerCase().indexOf('gecko')!=-1);
var links = document.getElementsByTagName('a');
	for (var i=0; i < links.length; i++){
	if(links[i].className=="outLink" || links[i].getAttribute("rel") == "external"){
		if (GKO) links[i].setAttribute('onclick', 'window.open(this.href);return false;');
		else links[i]['onclick']= new Function('window.open(this.href);return false;');
		}
	if(links[i].className=="pop"){
		if (GKO) links[i].setAttribute('onclick', 'window.open(this.href,"popup","width=500,height=350,toolbar=0,menubar=0,location=0,resizable=1");return false;');
		else links[i]['onclick']= new Function('window.open(this.href,"popup","width=500,height=350,toolbar=0,menubar=0,location=0,resizable=0");return false;');
		}
	}
}

function terres(){
var W3CDOM = (document.createElement && document.getElementsByTagName && document.setAttribute);
var trs = document.getElementsByTagName('tr');
var tables=document.getElementsByTagName('table');
	for(var j=0;j<tables.length;j++){
		if(tables[j].className != 'calendarTableStyle'){
			if(!W3CDOM){
				for(var i = 0; i < trs.length; i++){
					trs[i]['onmouseover']=new Function('effecthover(this);return false;');
				}
			}
		}
	}
}
function effecthover(elto){
	elto.style.backgroundColor="#eee";
	if (elto.className=="odd"){
	elto['onmouseout']= new Function('this.style.backgroundColor="#f9f9f9";return false;');
	}
	else{
	elto['onmouseout']= new Function('this.style.backgroundColor="#fff";return false;');
	}
}


function pop(url,width,height){
	var thenav = document.getElementById('nav');
	var navlinks = thenav.getElementsByTagName('a');
	for(var i=0;i<navlinks.length;i++){
		if(navlinks[i].className == 'popMenu'){
		navlinks[i].href="#";	
		}
	}
	if (width == "" && height == "") {
		window.open(url);
	} else {
		window.open(url, 'popup', 'width=' + width + ',height=' + height);
	}
}

function makeBackButton(text,link)
{
	var b_Top=document.getElementById("bTop");
	var b_Bottom=document.getElementById("bBottom");
	volverBoton1=backButton(text,link);
	volverBoton2=backButton(text,link);	
	b_Top.appendChild(volverBoton2);		
	b_Bottom.appendChild(volverBoton1);
}

function backButton(textLink,titleLink)
{
	boton=document.createElement("a");
	boton.href="javaScript:history.back()";
	boton.innerHTML=textLink;
	boton.title=titleLink;
	return boton;
}


