function externalLinks() { 
	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") == "external") anchor.target = "_blank"; 
	} 
} 
window.onload = externalLinks;

function getLeftPos(e) {
	pos = e.offsetLeft;
	while (e = e.offsetParent) pos += e.offsetLeft;
	return pos;
}

function getTopPos(e) {
	pos = e.offsetTop;
	while (e = e.offsetParent) pos += e.offsetTop;
	return pos;
}

function checkAll(e, checked) {
	if (!e.getElementsByTagName) return;
	var inputs = e.getElementsByTagName("input"); 
	for (var i=0; i<inputs.length; i++) { 
		var input = inputs[i]; 
		if (input.getAttribute("type") == "checkbox" && (! input.disabled)) input.checked = checked;
	} 
}
function getChildByName(form,childName) {
	var child;
	for( var i=0; i < form.elements.length; i++) {
		if (form.elements[i].name == childName) {
			child = form.elements[i];
		}
	}
	return child;
}
var vpoUpdList = {};
window.onbeforeunload = function() {
	var i = 0;
	for (var n in vpoUpdList) if (vpoUpdList[n]) i++;
	if (i) return 'There is some unsaved data in input forms!';
}

String.prototype.add = function (what) {
	if (this.match(new RegExp('\\b' + what + '\\b', 'g'))) return this;
	else return this + ' ' + what;
}
String.prototype.remove = function (what) {
	return this.replace(new RegExp('\\s*\\b' + what + '\\b\\s*', 'g'), ' ').replace(/\s*$/, '');
}
