//SW moved content to MasterJS.js

function AppendToWindowOnloadEvent(objFunctionToCall)
{
	if(window.addEventListener) {
		window.addEventListener('load', objFunctionToCall, false);
	} else if(window.attachEvent) {
		window.attachEvent('onload', objFunctionToCall);
	}
}

function AppendEventHandler(strElementSourceID, strEvent, objHandlerFunction) {
	var objElement = document.getElementById(strElementSourceID)
	if (!objElement) {
		return false;
	}

	if(window.addEventListener) {
		//FireFox events do not use the "on" prefix; remove the prefix if present
		if (strEvent.indexOf("on") != -1) {
			strEvent = strEvent.replace("on", "");
		}
		objElement.addEventListener(strEvent, objHandlerFunction, false);
	} else if(window.attachEvent) {
		//IE events use the "on" prefix; add the prefix if mising
		if (strEvent.indexOf("on") == -1) {
			strEvent = "on" + strEvent;
		}
		objElement.attachEvent(strEvent, objHandlerFunction);
	}	
}

function AppendEventHandlerByElement(objElement, strEvent, objHandlerFunction) {
	if (!objElement) {
		return false;
	}

	if(window.addEventListener) {
		//FireFox events do not use the "on" prefix; remove the prefix if present
		if (strEvent.indexOf("on") != -1) {
			strEvent = strEvent.replace("on", "");
		}
		objElement.addEventListener(strEvent, objHandlerFunction, false);
	} else if(window.attachEvent) {
		//IE events use the "on" prefix; add the prefix if mising
		if (strEvent.indexOf("on") == -1) {
			strEvent = "on" + strEvent;
		}
		objElement.attachEvent(strEvent, objHandlerFunction);
	}	
}

function RemoveEventHandlerByElement(objElement, strEvent, objHandlerFunction) {
	if (!objElement) {
		return false;
	}

	if(window.removeEventListener) {
		//FireFox events do not use the "on" prefix; remove the prefix if present
		if (strEvent.indexOf("on") != -1) {
			strEvent = strEvent.replace("on", "");
		}
		objElement.removeEventListener(strEvent, objHandlerFunction, false);
	} else if(window.detachEvent) {
		//IE events use the "on" prefix; add the prefix if mising
		if (strEvent.indexOf("on") == -1) {
			strEvent = "on" + strEvent;
		}
		objElement.detachEvent(strEvent, objHandlerFunction);
	}	
}

