function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}

function newWindowLinks() {
	if (!document.getElementsByTagName) return;
	
	var anchors = document.getElementsByTagName("a");
	
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if(anchor.getAttribute("href") && anchor.getAttribute("rel") == "newWindow")
			anchor.target = "_blank";
	}
}

function getAlphaNumRegex(ignoreWhiteSpace){
	return "^([a-zA-Z0-9'()/\\\\,\\-" + (ignoreWhiteSpace == true ? "\\s": "") + "]+)$";
}

function getAlphaRegex(ignoreWhiteSpace){
	return "^[a-zA-Z'\\-" + (ignoreWhiteSpace == true ? "\\s": "") + "]+$";
}

function getNumRegex(ignoreWhiteSpace){
	return "^([0-9" + (ignoreWhiteSpace == true ? "\\s": "") + "]+)$";
}

function getEmailAddressRegex(){
	return "^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
}

function getPostcodeRegex(){
	return "^(GIR 0AA|[A-PR-UWYZ]([0-9]{1,2}|([A-HK-Y][0-9]|[A-HK-Y][0-9]([0-9]|[ABEHMNPRV-Y]))|[0-9][A-HJKS-UW])[\\s]*[0-9][ABD-HJLNP-UW-Z]{2})$";
}

addLoadEvent(newWindowLinks);