// Rollover  v2.0.1
// documentation: http://www.dithered.com/javascript/rollover/index.html
// license: http://creativecommons.org/licenses/by/1.0/
// code by Chris Nott (chris[at]dithered[dot]com)
/*document.getElementById('layerDhtml').style.visibility='hidden';*/
function isDefined(property) {
  return (typeof property != 'undefined');
}
var rolloverInitialized = false;
function rolloverInit() {
   if (!rolloverInitialized && isDefined(document.images)) {
      // get all images (including all <input type="image">s)
	  // bbe 20050607 - hover effect dont work for form-input images ..
      // use getElementsByTagName() if supported
      var images = new Array();
      if (isDefined(document.getElementsByTagName)) {
         images = document.getElementsByTagName('img');
         var inputs = document.getElementsByTagName('input');
         for (var i = 0; i < inputs.length; i++) {
            if (inputs[i].type == 'image') {
               images[images.length] = inputs[i];
            }
         }
      }
      // otherwise, use document.images and document.forms collections
      // remove if not supporting IE4, Opera 4-5
      else {
         images = document.images;
         inputs = new Array();
         for (var formIndex = 0; formIndex < document.forms.length; formIndex++) {
            for (var elementIndex = 0; elementIndex < document.forms.elements.length; elementIndex++) {
               if (isDefined(document.forms.elements[i].src)) {
                  inputs[inputs.length] = document.forms.elements[i];
               }
            }
         }
      }
      // get all images with '_off.' in src value
      for (var i = 0; i < images.length; i++) {
         if (images[i].src.indexOf('_off.') != -1) {
            var image = images[i];
            // store the off state filename in a property of the image object
            image.offImage = new Image();
            image.offImage.src = image.src;
            // store the on state filename in a property of the image object
            // (also preloads the on state image)
            image.onImage = new Image();
            image.onImage.imageElement = image;
            // add onmouseover and onmouseout event handlers once the on state image has loaded
            // Safari's onload is screwed up for off-screen images; temporary fix
            if (navigator.userAgent.toLowerCase().indexOf('safari') != - 1) {
               image.onmouseover = function() {
                  this.src = this.onImage.src;
               };
               image.onmouseout = function() {
                  this.src = this.offImage.src;
               };
            }
            else {
               image.onImage.onload = function() {
                  this.imageElement.onmouseover = function() {
                     this.src = this.onImage.src;
                  };
                  this.imageElement.onmouseout = function() {
                     this.src = this.offImage.src;
                  };
               };
            }
            // set src of on state image after defining onload event handler
            // so cached images (that load instantly in IE) will trigger onload
            image.onImage.src = image.src.replace(/_off\./, '_on.');
         }
      }
   }
   rolloverInitialized = true;
}

function manual_rollover(id){
	if (id.src.indexOf('_off.') != -1){
		id.src = id.src.replace(/_off\./, '_on.');
	}else{
		id.src = id.src.replace(/_on\./, '_off.');
	}
}

// call rolloverInit when document finishes loading
if (isDefined(window.addEventListener)) {
   window.addEventListener('load', rolloverInit, false);
}
else if (isDefined(window.attachEvent)) {
   window.attachEvent('onload', rolloverInit);
}

function setContStretcherHeight(){
	if ( document.documentElement.clientHeight ){
		document.getElementById('stretcher').style.height = (document.documentElement.clientHeight - 140)+"px";
	}
	if ( window.innerHeight ){
		document.getElementById('stretcher').style.height = (window.innerHeight  - 140)+"px";
	}
	return true;
}

function jscss(a,o,c1,c2)
{
	switch (a){
		case 'swap':
			o.className=!jscss('check',o,c1)?o.className.replace(c2,c1):o.className.replace(c1,c2);
		break;
		case 'add':
			if(!jscss('check',o,c1)){o.className+=o.className?' '+c1:c1;}
		break;
		case 'remove':
			var rep=o.className.match(' '+c1)?' '+c1:c1;
			o.className=o.className.replace(rep,'');
		break;
		case 'check':
			return new RegExp('\\b'+c1+'\\b').test(o.className)
		break;
	}
}

//GO1.1

///////////////////////////////////////
//
//  Generic onload by Brothercake
//  http://www.brothercake.com/
//
///////////////////////////////////////

//onload function


//setup onload function
if(typeof window.addEventListener != 'undefined'){
	//.. gecko, safari, konqueror and standard
	window.addEventListener('load', generic_onload, false);
}else if(typeof document.addEventListener != 'undefined'){
	//.. opera 7
	document.addEventListener('load', generic_onload, false);
} else if(typeof window.attachEvent != 'undefined'){
	//.. win/ie
	window.attachEvent('onload', generic_onload);
}//** remove this condition to degrade older browsers
else{
	//.. mac/ie5 and anything else that gets this far
	//if there's an existing onload function
	if(typeof window.onload == 'function'){
		//store it
		var existing = onload;
		//add new onload handler
		window.onload = function(){
			//call existing onload function
			existing();
			//call generic onload function
			generic_onload();
		};
	}else{
		//setup onload function
		window.onload = generic_onload;
	}
}



// DR1.0 :: domReady 
// *****************************************************
// DOM scripting by brothercake -- http://www.brothercake.com/
// GNU Lesser General Public License -- http://www.gnu.org/licenses/lgpl.html
//******************************************************

//DOM-ready watcher
function domReady(){
	//start or increment the counter
	this.n = typeof this.n == 'undefined' ? 0 : this.n + 1;
	//if DOM methods are supported, and the body element exists
	//(using a double-check including document.body, for the benefit of older moz builds [eg ns7.1] 
	//in which getElementsByTagName('body')[0] is undefined, unless this script is in the body section)
	//>>> and any elements the script is going to manipulate exist
	if(
		typeof document.getElementsByTagName != 'undefined' 
		&& (document.getElementsByTagName('body')[0] != null || document.body != null)
		//>>> && document.getElementById('something') != null 
	){
	//>>>-- DOM SCRIPTING GOES HERE --<<<
		/*alert("The DOM is ready!");*/
		/*document.getElementById('layerDhtml').style.visibility='hidden';*/
	//>>>-----------------------------<<<
	}
	//otherwise if we haven't reached 60 (so timeout after 15 seconds)
	//in practise, I've never seen this take longer than 7 iterations [in kde 3.2.2 
	//in second place was IE6, which takes 2 or 3 iterations roughly 5% of the time]
	else if(this.n < 60){
		//restart the watcher
		//using the syntax ('domReady()', n) rather than (domReady, n)
		//because the latter doesn't work in Safari 1.0
		setTimeout('domReady()', 250);
	}
};
//start the watcher
domReady();

