//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 function make it possible to have web standard popups**************************************************//
function strictNewWindow() {
  if (!document.getElementsByTagName) return false;
  var aList = document.getElementsByTagName('a');
  for (var i=0; i<aList.length; i++) {
    if (aList[i].className == 'popup') {
      aList[i].onclick = function() {
        window.open(this.getAttribute('href'),'popup');
        return false;
      }
    }
    if (aList[i].className == 'popupTest') {
      aList[i].onclick = function() {
        window.open(this.getAttribute('href'),'popupTest','width=600,height=525');
        return false;
      }
    }
  }
}

//**************************************************The following function make it possible to have web standard popups**************************************************//
function googleNewWindow() {
	if (!document.getElementById) return false;
	if (!document.getElementById('frmGoogleMap')) return false;
	var mapForm = document.getElementById("frmGoogleMap");
	if(mapForm.getAttribute("action").substring(0, 4) == "http") {
		mapForm.target = "_blank";
	}
}

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

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

//**************************************************Load all functions**************************************************//
addLoadEvent(strictNewWindow);
addLoadEvent(googleNewWindow);
addLoadEvent(hdrHover);
addLoadEvent(initializeFlash);