/*
Script for IE6
this applies the 'sfhover' class to li elements in the 'nav' id,  ul element 
when they are 'moused over' and removes it, using a regular expression, when 
'moused out'
---------------------------------------------------------------------------------*/

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);

/*
---------------------------------------------------------------------------------*/


/* MOOTOOLS ACCORDION
---------------------------------------------------------------------------------*/
window.addEvent('domready', function() {
	// get the id value from url
	var hashes = parseInt(getURLParam("id"));
	// if id matches any of the ones below, submenu # will expand when loading the page
	var elementId = 0;
	if(hashes == 1) { var elementId = 0; }
	if(hashes == 2) { var elementId = 1; }
	if(hashes == 3) { var elementId = 2; }
	if(hashes == 4) { var elementId = 3; }

	//create our Accordion instance
	var myAccordion = new Accordion($('accordion'), 'h3.toggler', 'div.element', {
		alwaysHide: false,
		display: elementId,
		opacity: false,
		onActive: function(toggler, element){
			toggler.setStyle('color', '#FFF');
			toggler.setStyle('cursor', 'pointer');
		},
		onBackground: function(toggler, element){
			toggler.setStyle('color', '#FFF');
			toggler.setStyle('cursor', 'pointer');
		}
	});
	
	$$('h3.toggler').addEvent('mouseover',function(){
		this.setStyle('cursor', 'pointer');
	});
	
	/*(
	$$('h3.toggler').addEvent('mouseout',function(){
		this.setStyle('color', '#0D0D0D');
	}); */
	
	// FOR SIDE MENU 
	//create our Accordion instance
	var myAccordion = new Accordion($('accordion'), 'li.togg', 'ul.elem', {
		alwaysHide: false,
		display: elementId,
		opacity: false,
		onActive: function(toggler, element){
			toggler.setStyle('color', '#FFF');
			toggler.setStyle('cursor', 'pointer');
			toggler.setStyle('margin', '0');
			toggler.setStyle('padding', '0');
		},
		onBackground: function(toggler, element){
			toggler.setStyle('color', '#FFF');
			toggler.setStyle('cursor', 'pointer');
			toggler.setStyle('margin', '0');
			toggler.setStyle('padding', '0');
		}
	});
	//make it open on hover  
	$$('.togg').addEvent('mouseenter', function() { this.fireEvent('click'); });


});



// GET URL ID
//function that gets the page id from the URL
function getURLParam(strParamName){
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
  	var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if (aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return unescape(parseInt(strReturn));
}

/* ---------------------------------------------------------------------------------*/