function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

//======================== W3C compliant Popup script
function popupLauncher() {
	var links = document.getElementsByTagName('a');
	for(i=0;i<links.length;i++) {
		if (links[i].rel == "external") {
			links[i].onclick = function tmp() { window.open(this.href,'_blank'); return false; }
		}	
	}
}

//======================== IE6 antiflicker
try {
  document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}

//======================== Serve safari 3 a separate style sheet
var isSafari3 = false; 
//window.devicePixelRatio &&  window.getMatchedCSSRules is only implemented by Safari 3 now.
if(window.devicePixelRatio && window.getMatchedCSSRules && !window.Opera){
	//you need 	put html {list-style-image:none;} in yout Safari 3 only stylesheet first
	//we detect whether if it's Safari 3 by checking if it read some Safari 3 only styles 
	isSafari3 = !!window.getMatchedCSSRules(document.documentElement,'');
	document.write("<link rel='stylesheet' type='text/css' href='css/safari3.css'>");
}

//======================== Input button rollover effect for ie
function InputRollOver() {
if (document.all&&document.getElementById) {
	TheSubmit = document.getElementById("submit");
		if (TheSubmit){
			if (TheSubmit.nodeName=="INPUT") {
				TheSubmit.onmouseover=function() {
					this.className+=" over";
				}
				TheSubmit.onmouseout=function() {
				this.className=this.className.replace(" over", "");
		   	}
		}
	  }
  }
}
function hideOnload() {
	var el = document.getElementsByTagName('*');
	for(i=0;i<el.length;i++) {
		if (el[i].className.indexOf('hide') != -1) {
			el[i].style.display = 'none';
		}
	}	
}
function hide(target) {
	target.style.display = "none";
} 
function show(target) {
	target.style.display = "block";
}
function toggle(target) {
	if (target.style.display == "block" || target.style.display == "") {
		target.style.display = "none";
	} else {
		target.style.display = "";
	}
}

function $(el) {
	return document.getElementById(el);
}

addLoadEvent(hideOnload);
addLoadEvent(popupLauncher);
addLoadEvent(InputRollOver);
