// JavaScript Document/////////////////////////////////////////////////////////////////////////////////////////\
// BROWSER DETECTION

var a = navigator.userAgent.toLowerCase();
var isSF = (a.indexOf("safari") > 0) ? true : false;
var xmlhttp = null;
//var isReady = false;




/////////////////////////////////////////////////////////////////////////////////////////
// DHTML MENU SWAP FIX
// This script solves the no-psuedo classes for IE problem with the dhtml menu

// Detect IE
var isIE = (navigator.userAgent.toLowerCase().indexOf("msie") > 0) ? true : false;

initNavBar = function() {
	// first we need to shorten the hgt of the bar itself
	var navContainer = document.getElementById('mainnav');
	if (navContainer) navContainer.style.height = "16px";
	
	// then we need to move items up to eliminate gaps
	var hasMenu = document.getElementById('mainnav');
	var menuBlocks = (hasMenu) ? document.getElementById('mainnav').getElementsByTagName('ul') : null;
	if (menuBlocks) {
		for (var i = 0; i < menuBlocks.length; i++) {
			var targElem = menuBlocks[i];
			var par = targElem.parentNode;
				var parpar = par.parentNode;
				var parparpar = parpar.parentNode;
			if (parparpar.id == 'mainnav') {
				targElem.style.top = "13px";
			}
		}
	}
}			
if (isSF) window.addEventListener("load", initNavBar, true);


sfHover = function() {
	var hasMenu = document.getElementById('mainnav');
	var liElems = (hasMenu) ? document.getElementById('mainnav').getElementsByTagName('li') : null;
	if (liElems) {
		for (var i = 0; i < liElems.length; i++) {
			if (liElems[i]) {
				liElems[i].onmouseover = function() {
					this.className += " sfhover";
					var ulElem = this.getElementsByTagName('ul');
					for (var j = 0; j < ulElem.length; j++) {
						var targUlElem = ulElem[j];
						var nextTag = targUlElem.firstChild;
						if (nextTag.nodeName != 'IFRAME') {
							var ulMat = document.createElement('iframe');
							ulMat.style.width = targUlElem.offsetWidth + "px";
							ulMat.style.height = targUlElem.offsetHeight + "px";
							targUlElem.insertBefore(ulMat, targUlElem.firstChild);
							targUlElem.style.zIndex = "99";
						}
						else {
							nextTag.style.width = targUlElem.offsetWidth + "px";
							nextTag.style.height = targUlElem.offsetHeight + "px";
						}
					}
				}
			}
			liElems[i].onmouseout = function() {
				this.className = this.className.replace(' sfhover', '');
			}
		}
	}
}
if (window.attachEvent) window.attachEvent('onload', sfHover);

////////////////////////////////////////////////////////////////////
//  getElementsByClass(name of class)
//  Retrieves all classes on the page and extracts the desired class

function getElementsByClass(maClass) {
   	var tabRetour = new Array();
     	var tabTmp = new Array();
     	tabTmp = document.getElementsByTagName("*");
     	j=0;
      	for (i=0; i<tabTmp.length; i++) {
       	if (tabTmp[i].className==maClass) {
           	tabRetour[j]=tabTmp[i];
        		j++;						
        	} 
       }
      	return tabRetour;
}

////////////////////////////////////////////////////////////////////