//maked all added functions work onload. at the end of each function you want to work onload add addLoadEvent(function); to the end of the function.
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

// The following two functions make it possible to have web standard popups
window.onload = function() {
  if (!document.getElementsByTagName) return false;
  var lnks = document.getElementsByTagName("a");
  for (var i=0; i<lnks.length; i++) {
    if (lnks[i].className == "popup") {
      lnks[i].onclick = function() {
        popUp(this.getAttribute("href"));
        return false;
      }
    }
  }
}

function popUp(winURL) {
  window.open(winURL,"popup");
}

//-- Create a :Hover psuedo attribute for IE for header -- //
hdrHover = function() {
	if (document.getElementById('headerNav') != null) {
		if((document.all)&&(document.getElementById)) {
			var hdrCat = document.getElementById("headerNav").getElementsByTagName("li");
			for (var i=0; i<hdrCat.length; i++) {
				hdrCat[i].onmouseover=function() {
					this.className+=" hdrhover";
				}
				hdrCat[i].onmouseout=function() {
					this.className=this.className.replace(new RegExp(" hdrhover\\b"), "");
				}
			}
		}	
	}
}

//-- Create a :Hover psuedo attribute for IE for sidebar -- //
sdbrHover = function() {
	if (document.getElementById('sidebarNav') != null) {
		if((document.all)&&(document.getElementById)) {
			var sdbrCat = document.getElementById("sidebarNav").getElementsByTagName("li");
			for (var i=0; i<sdbrCat.length; i++) {
				sdbrCat[i].onmouseover=function() {
					this.className+=" sdbrhover";
				}
				sdbrCat[i].onmouseout=function() {
					this.className=this.className.replace(new RegExp(" sdbrhover\\b"), "");
				}
			}
		}	
	}
}

//**************************************************Add swfobject flash call**************************************************//
function initializeFlash() {
	if (!document.getElementById) return false;
	if (!document.getElementById('flashcontent')) return false;
	var so = new SWFObject("swf/home-billboard01.swf", "flash", "710", "249", "8", "#fff");
	so.addParam("wmode", "transparent");
	so.write("flashcontent");
}

//**************************************************Replace align attribute with class**************************************************//
function replaceAlign() {
  if (!document.getElementsByTagName) return false;
  if (!document.getElementsByTagName('img')) return false;
  var imgList = document.getElementsByTagName('img');
  for (var i=0; i<imgList.length; i++) {
    var align = imgList[i].getAttribute('align');
		if (align) {
			if (align == 'left') {
				imgList[i].className += ' left';
			}
			if (align == 'right') {
				imgList[i].className += ' right';
			}
			if (align == 'middle') {
				imgList[i].className += ' middle';
			}
    	imgList[i].removeAttribute('align')
    }
  }
}

//**************************************************Load all functions**************************************************//
addLoadEvent(hdrHover);
addLoadEvent(sdbrHover);
addLoadEvent(initializeFlash);
addLoadEvent(replaceAlign);