 function addEvent( obj, type, fn ) {
  if ( obj.attachEvent ) {
   obj['e'+type+fn] = fn;
   obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
   obj.attachEvent( 'on'+type, obj[type+fn] );
   } else
  obj.addEventListener( type, fn, false );
 }

function rolloverMain(div) {
 if(!document.getElementById(div)) { return; }
 var rImg = document.getElementById(div).getElementsByTagName('img');
 for(i=0;i<rImg.length;i++) {
  rImg[i].onmouseover = function() {
    if(this.id == "active") { return; }
	 this.src = this.src.replace(".gif","_o.gif");
	}
	rImg[i].onmouseout = function() {
     if(this.id == "active") { return; }    
	 this.src = this.src.replace("_o.gif",".gif");
	}
 }
}

function rolloverSub(div) {
 if(!document.getElementById(div)) { return; }
 var rItems = document.getElementById(div).getElementsByTagName('li');
 for(i=0;i<rItems.length;i++) {
  rItems[i].onmouseover = function() {
	 this.style.backgroundImage = "url(http://www.aquacollege.de/_globalimages/subnavigationItembackground.gif)";
	}
	rItems[i].onmouseout = function() {
	 this.style.backgroundImage = "";
	}
 }
}

function popup() {
 if(!document.getElementById('outerwrapper')) { return; }
 var container = document.getElementById('outerwrapper');
 var hrefs = container.getElementsByTagName('a');
 for(i=0;i<hrefs.length;i++) {
  if(hrefs[i].className == "pop") {
	 hrefs[i].onclick = function() {
	  window.open(this.href,this.id,"scrollbars=1,menubar=1,toolbar=1,resizable=1,width=1050,height=650");		
		return false; 
	 }
	} 
 }
}

function setWrapperSize() {
 var x,y;
 if (self.innerHeight) // all except Explorer
 {	y = self.innerHeight; }
 else if (document.documentElement && document.documentElement.clientHeight)
	// Explorer 6 Strict Mode
 {	y = document.documentElement.clientHeight; }
 else if (document.body) // other Explorers
 { y = document.body.clientHeight; }
 document.getElementById('wrapper').style.height = (y-220) + "px";
}

function fixFirstEntry() {
 if(!document.getElementById('wrapper')) { return; }
 var ar = document.getElementById('wrapper').getElementsByTagName('div');
 for(i=0;i<ar.length;i++) {
  if(ar[i].className == "entry") {
	 ar[i].style.backgroundImage = "none";
	 break;
	}
 }
}

/* this will go when the site is live */
function disableLinks(div) {
 if(!document.getElementById(div)) { return; }
 var rHref = document.getElementById(div).getElementsByTagName('a');
 for(i=0;i<rHref.length;i++) {
  rHref[i].onclick = function() {
	 return false;
	}
 }
}


addEvent( window, 'load', function() { rolloverMain('mainnavi'); } );
addEvent( window, 'load', function() { rolloverSub('subnavigation'); } );
addEvent( window, 'load', function() { fixFirstEntry(); } );
addEvent( window, 'load', function() { popup(); } );


addEvent( window, 'load', function() { setWrapperSize(); } );
addEvent( window , 'resize', function() { setWrapperSize(); } );
