// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults


/*
	Standards Compliant Rollover Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/

function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_o'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

/* opens a new window */

function opn(page,name,w,h,options) {
 var ops = '';
 if (w) { ops += ("WIDTH=" + w) };

 if (h) { 
  if (w) { ops += ","  };
  ops += ("HEIGHT=" + h);
 };

 if (options) {
  if (w || h) {
   ops += ",";
  };

  ops += options;
 }

 open(page,name,ops);
 
 return false; // so you can return this as onclick
};

/* centers a window */
function center(w,h) {
 window.moveTo((screen.width - w)/2,(screen.height - h)/2);
};

/***************************************************************/

function hover(state,obj) {
  if (state == 1) {
    obj.className = "highlightTD";
  } else {
    obj.className = "";
  }
}

function initPage() {
	initRollovers();
}	
window.onload = initPage;

/* son of suckerfish IE fix */
sfHover = function() {
	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"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
