/* 
Derived from a script by Alejandro Gervasio. 
Modified to work in FireFox by Stefan Mischook for Killersites.com

How it works: just apply the CSS class of 'column' to your pages' main columns.
*/
/********************************************************
 * Copyright (C) 2002-2003, CodeHouse.com. All rights reserved.
 * CodeHouse(TM) is a registered trademark.
 *
 * THIS SOURCE CODE MAY BE USED FREELY PROVIDED THAT
 * IT IS NOT MODIFIED OR DISTRIBUTED, AND IT IS USED
 * ON A PUBLICLY ACCESSIBLE INTERNET WEB SITE.
 * 
 * CodeHouse.com JavaScript Library Module: Browser Sniffer Class
 *
 * You can obtain this script at http://www.codehouse.com
 ********************************************************/
function CJL_BrowserSniffer()
{
   var ua = navigator.userAgent;
//   alert(ua);
   this.isOpera = function()
   {
      return /Opera/.test(ua);
   }

   this.isSafari = function()
   {
      return /Safari/.test(ua);
   }

   this.isGecko = function()
   {
      return navigator.product == "Gecko" &&
	     ! ( this.isOpera() || this.isSafari() );
   }

   this.isIEWin = function()
   {
      return window.external && /Win/.test(ua);
   }

   this.isIEMac = function()
   {
      return window.external && /Mac/.test(ua);
   }

   this.getVersion = function()
   {
      if( this.isIEWin() || this.isIEMac() )
      {
         return Number(ua.match(/MSIE ([0-9.]+)/)[1]);
      }
      else if( this.isSafari() )
      {
         return Number(ua.match(/[0-9.]+$/));
      }
      else if( this.isGecko() )
      {
         var n = ua.match(/rv:([0-9.]+)/)[1];

         var ar = n.split(".");

         var s = ar[0] + ".";

         for(var i = 1; i < ar.length; ++i)
         {
            s += ("0" + ar[i]).match(/.{2}$/)[0];
         }

         return Number(s);
      }
      else if( this.isOpera() )
      {
         return Number(ua.match(/Opera.([0-9.]+)/)[1]);
      }
      else
      {
         return null;
      }
   }
}

var is = new CJL_BrowserSniffer();


var cssType = '<link rel="styleSheet" type="text/css"  href="';
var cssDef = '<link rel="styleSheet" type="text/css"  href="';

function browserSetup(dirPrefix,filename) {
	var canRun = false;
	var browserType;
	
	if (is) {
			canRun= true;
	}
	if (!canRun) {
		alert("It is highly recommended that you upgrade your browser to a more modern browser e.g. Firefox or IE6");
		cssType = null;
		return;
	}  else {
		if (is.isSafari() ) {
			    //alert("safari found");
				browserType="Safari";
				cssType +=  dirPrefix + 'safari.css">';
		
		} else if (is.isIEWin())  {
			   
			
				browerType="winIE";
				cssType += dirPrefix + 'ie.css">';
				//alert("ie found");
		} else if (is.isGecko()){
				cssType = null;
		}
		
     }
	
	//alert(cssType);
	
	if (cssType != null) 
	   document.write(cssType);
}


function show(id, level) {
var d = document.getElementById(id);
	if (level < 2) {
	    for (var i = 1; i<=10; i++) {
		    if (document.getElementById('smenu'+i)) {
				document.getElementById('smenu'+i).style.display='none';
				
			}
	    }
	}
if (d) {
	d.style.display='block';
    d.className='moveOver';
	}
}



var winHeight;
function getWindowHeight() {
var windowHeight=0;
if (typeof(window.innerHeight)=='number') {
windowHeight=window.innerHeight;
}
else {
if (document.documentElement&&
document.documentElement.clientHeight) {
windowHeight=
document.documentElement.clientHeight;
}
else {
if (document.body&&document.body.clientHeight) {
windowHeight=document.body.clientHeight;
}
}
}
//alert("windowHeight " + windowHeight);
return (windowHeight);
}

matchColumns=function(){ 

     var divs,contDivs,maxHeight,divHeight,d; 
	
     // get all <div> elements in the document 

     divs=document.getElementsByTagName('div'); 

     contDivs=[]; 

     // initialize maximum height value 

     maxHeight=0; 

     // iterate over all <div> elements in the document 
     winHeight = getWindowHeight() ;
     for(var i=0;i<divs.length;i++){ 

          // make collection with <div> elements with class attribute 'container' 

          if(/\bcolumn\b/.test(divs[i].className)){ 

                d=divs[i]; 

                contDivs[contDivs.length]=d; 

                // determine height for <div> element 

                if(d.offsetHeight){ 

                     divHeight=d.offsetHeight; 					

                } 

                else if(d.style.pixelHeight){ 

                     divHeight=d.style.pixelHeight;					 

                } 

                // calculate maximum height 

                maxHeight=Math.max(maxHeight,divHeight); 
				//alert(maxHeight);

          } 

     } 
	 //maxHeight = Math.max(maxHeight,winHeight);
	
     //alert(maxHeight);
     // assign maximum height value to all of container <div> elements 

     for(var i=0;i<contDivs.length;i++){ 
          
           contDivs[i].style.height=maxHeight + "px"; 
		  
		  //alert(contDivs[i].style.height);

     } 

} 

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"), "");
		}
	}
}




// Runs the script when page loads 
var dirPrefix = "";

browserSetup( " ","styles.css"); 
window.onload=function(){ 

     if(document.getElementsByTagName){ 

          //matchColumns();			 
		 
     } 
	
	
} 
if (window.attachEvent) window.attachEvent("onload", sfHover); 
