// JavaScript Document
utilities = {
	confirmSubmit : function() {
		var str = "This action is not reversible, are you sure you wish to continue?";
		if (arguments[1] != null) str += "\n" + arguments[1];
		var agree = window.confirm(str);
		if (agree) {
			if (arguments[0] !== null) {
				this.goUrl(arguments[0]);
			} else {
				return true;
			}
		} else {
			return false;
		}
	}
};

linkfunctions = {
	externallinks : function () {
		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";
				if (anchor.title == '') {
					anchor.title = "External link";
				} else {
					anchor.title = "External link - " + anchor.title;
				}
			}
		}
	},
	goUrl : function(url) {
		if (url == 'back') {
			history.go(-1);
		} else {
			document.location = url;
		}
	},
	popupPic : function (in_link) { 
		if (in_link.href != '' && in_link.href !='#') {
			window.open("/assets/images/openpic.asp?url=" + in_link.href, "", "resizable=no,scrollbars=no,height=200,width=200");
		} else {
			window.open("/assets/images/openpic.asp?url=" + in_link, "", "resizable=no,scrollbars=no,height=200,width=200");
		}
		return false;
	}
}

Forms = {
	highlightFields : function (in_fields) {
		Event.observe(window, 'load', function() { Forms._highlightFields(in_fields) }, false);
	},
	_highlightFields : function(in_fields) {
		var fldAr = in_fields.split(",");
		for (var i=0; i<fldAr.length; i++) {
			this.highlightField(fldAr[i]);
		}
	},
	highlightField : function(in_elem) {
		var fld = $(in_elem);
		var lbl = fld.parentNode;
		lbl = lbl.getElementsByTagName('label');
		if (lbl.length == 0) {
			lbl = fld.parentNode.parentNode;
			lbl = lbl.getElementsByTagName('label');
		}
		Element.addClassName(fld, 'errFld');
		Element.addClassName(lbl[0], 'errLbl');
	}
};

addEvent(window,'load', linkfunctions.externallinks);