﻿
//----------------------------------------------------------------------------
// Code to load functions on certain page events.
//----------------------------------------------------------------------------

function addLoadEvent(func) {
	if (window.addEventListener) {
		window.addEventListener("load", func, false);
	} 
	else if (window.attachEvent) {
		window.attachEvent("onload", func);
	}
	else if (document.getElementById) {
		window.onload=func; 
	}
	else {
		document.location = '/unsupported.asp?e=eventsJS'; 
	}
	return false;
}

function addResizeEvent(func) {
	if (window.addEventListener) {
		window.addEventListener("resize", func, false);
	} 
	else if (window.attachEvent) {
		window.attachEvent("onresize", func);
	}
	else if (document.getElementById) {
		window.onresize=func; 
	}
	else {
		document.location = '/unsupported.asp?e=eventsJS'; 
	}
	return false;
}

function addFocusEvent(func) {
	if (window.addEventListener) {
		window.addEventListener("focus", func, false);
	} 
	else if (window.attachEvent) {
		window.attachEvent("onfocus", func);
	}
	else if (document.getElementById) {
		window.onfocus=func; 
	}
	else {
		document.location = '/unsupported.asp?e=eventsJS'; 
	}
	return false;
}

function addBlurEvent(func) {
	if (window.addEventListener) {
		window.addEventListener("blur", func, false);
	} 
	else if (window.attachEvent) {
		window.attachEvent("onblur", func);
	}
	else if (document.getElementById) {
		window.onblur=func; 
	}
	else {
		document.location = '/unsupported.asp?e=eventsJS'; 
	}
	return false;
}

function addBeforeUnloadEvent(func) {
	if (window.addEventListener) {
		window.addEventListener("beforeunload", func, false);
	} 
	else if (window.attachEvent) {
		window.attachEvent("onbeforeunload", func);
	}
	else if (document.getElementById) {
		window.onbeforeunload=func; 
	}
	return false;
}

function addUnloadEvent(func) {
	if (window.addEventListener) {
		window.addEventListener("unload", func, false);
	} 
	else if (window.attachEvent) {
		window.attachEvent("onunload", func);
	}
	else if (document.getElementById) {
		window.onunload=func; 
	}
	return false;
}
