// JavaScript Document

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
			for (i=0; i<navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI") {
					for(k=0; k<node.childNodes.length; k++){
						var onodes = node.childNodes[k];
						if(onodes.nodeName == "UL"){
							var inodes = onodes.childNodes;
							for (j=0; j<inodes.length; j++){
								lnode = inodes[j];
								lnode.onmouseover=function(){this.className+=" over"; if(document.getElementById("flashItem")){flashRoot = document.getElementById("flashItem"); flashRoot.style.display = "none";}}
								lnode.onmouseout=function(){this.className=this.className.replace(" over", ""); if(document.getElementById("flashItem")){flashRoot = document.getElementById("flashItem"); flashRoot.style.display = "block";}}
							}
						}
					}
					node.onmouseover=function() {
						this.className+=" over";
						if(document.getElementById("flashItem")){
							flashRoot = document.getElementById("flashItem"); flashRoot.style.display = "none";
						}
					}
					node.onmouseout=function() {
						this.className=this.className.replace(" over", "");
						if(document.getElementById("flashItem")){
							flashRoot = document.getElementById("flashItem"); flashRoot.style.display = "block";
						}
					}
				}
			}
				sidenavRoot = document.getElementById("sidenav");
				if(sidenavRoot){
					for (i=0; i<sidenavRoot.childNodes.length; i++) {
						node = sidenavRoot.childNodes[i];
						if (node.nodeName=="LI") {
							node.onmouseover=function() {
								this.className="over " + this.className;
							}
							node.onmouseout=function() {
								this.className=this.className.replace("over ", "");
							}
						}
					}
				}
	}
}

startsolutions = function() {
	if (document.getElementById("subcontentInclude")) {	
		subInclude = document.getElementById("subcontentInclude");
				for (i=0; i<subInclude.childNodes.length; i++) {
					node = subInclude.childNodes[i];
					if (node.nodeName=="DIV") {
						var attrMax = node.attributes.length;
						for(var j=0; j< attrMax; j++){
							if ((node.attributes.item(j).nodeName == 'class') && (node.attributes.item(j).nodeValue == 'product')){
									node.onmouseover=function() {
									this.className="over " + this.className;
									}
									node.onmouseout=function() {
									this.className=this.className.replace("over ", "");
									}
							}
						}
						
					}
				}
	}
}

/*function flashNavFIX(flashName){
	if (document.getElementById(flashName)){
		var flashID = document.getElementById(flashName);
		node = flashID.childNodes[i];
			for(k=0; k<node.childNodes.length; k++){
				var flashID2 = node.childNodes[k];
				if (flashID2.style.display == "block"){
					flashID2.style.display = "none";	
				}
				else{
					flashID2.style.display = "block";	
				}
			}
	}
}*/

function flashNavFIX(flashName){
	if (document.getElementById(flashName)){
		var flashID = document.getElementById(flashName);
			if (flashID.style.display == "block"){
				flashID.style.display = "none";	
			}
			else{
				flashID.style.display = "block";	
			}
	}
}

function showErrorDiv(divName)
{    
	if (document.getElementById(divName))
    	{ 
		    var errorDiv = document.getElementById(divName); 
        	if (errorDiv.style.display == "none")
        	{ 
			errorDiv.style.display = ""; 
        	}
    	}
}

// REMOVE THIS BEFORE PUBLISHING!!!
var refreshinterval=15;  // in seconds
var displaycountdown="yes" ;
var starttime; 
var nowtime; 
var reloadseconds=0; 
var secondssinceloaded=0;

function starttime() { 
	starttime=new Date();
	starttime=starttime.getTime();
	countdown() ;
} 

function countdown() { 
	nowtime= new Date();
	nowtime=nowtime.getTime(); 
	secondssinceloaded=(nowtime-starttime)/1000 ;
	reloadseconds=Math.round(refreshinterval-secondssinceloaded);
	if (refreshinterval>=secondssinceloaded) { 
		var timer=setTimeout("countdown()",1000);
		if (displaycountdown=="yes") { 
			window.status="REMOVE THIS JAVASCRIPT BEFORE PUBLISHING!!!  Page refreshing in "+reloadseconds+ " seconds"; 
		} 
	} 
	else { 
		clearTimeout(timer);
		window.location.reload(true); 
	} 
} 

//window.addOnLoadListener(starttime);
// REMOVE THIS BEFORE PUBLISHING!!!


window.addOnLoadListener(startsolutions);
window.addOnLoadListener(startList);

 

	var SiteSearch_SearchFieldID = "searchBox";
	var SiteSearch_PathToResults = "/search.aspx?txtSearch=";


	function sitesearch_htmlEncode(s) {
		var str = new String(s);
		str = str.replace(/&/g, "&amp;");
		str = str.replace(/</g, "&lt;");
		str = str.replace(/>/g, "&gt;");
		str = str.replace(/"/g, "&quot;");
		str = str.replace(/ /g, "%20");
		return str;
	}



	function sitesearch_getElement(id){
		if(document.getElementById){
			return document.getElementById(id);
		}
		else if (document.all){
			return document.all[id];
		}
	} //sitesearch_GetElement

	function sitesearch_get()
	{
		var e = sitesearch_getElement(SiteSearch_SearchFieldID);

		if (e.value.replace(/ /g, '') == '')
		{
			alert("Please enter a search term");
			e.focus();
			return false;
		}
		
		window.location = SiteSearch_PathToResults + sitesearch_htmlEncode(e.value);
		// this is needed for IE 7 when you click on button (as opposed to pressing enter)
		return false;
	} //end sitesearch_get

	function sitesearch_onkeypress(e){
		// window.event IE
		if (!e) var e = window.event;
		
		// if == 13 == enter key pressed
		if( e.keyCode == 13 ){
			sitesearch_get();
			return false;
		}
	}

	

	function sitesearch_onfocus(oTxt){
		if( oTxt.value == " search" ){
			oTxt.value = "";
		}
	}

//}
