/* BASE HREF */
var base_href = 'http://' + window.location.host + '/';

/* ONLOAD EVENTS */
$(document).ready(function(){
	/* external links */
	$("a[rel='external']").attr({ target: '_blank' });
});

/* OPEN WINDOW */
function openWindow(url, width, height) {
	if (!width) width = 800;
	if (!height) height = 600;
  window.open('' + url + '', '_blank', 'location=1, menubar=1, resizable=1, scrollbars=1, status=1, titlebar=1, toolbar=1, width=' + width + ', height=' + height + ', left=' + parseInt((screen.width / 2) - (width / 2)) + ', top=' + parseInt((screen.height / 2) - (height / 2)) + '');
}

/* OPEN DIALOG */
function openDialog(url, width, height) {
	if (!width) width = 800;
	if (!height) height = 600;
  window.open('' + url + '', '_blank', 'location=0, menubar=0, resizable=0, scrollbars=1, status=0, titlebar=0, toolbar=0, width=' + width + ', height=' + height + ', left=' + parseInt((screen.width / 2) - (width / 2)) + ', top=' + parseInt((screen.height / 2) - (height / 2)) + '');
}

/* LOAD SCRIPT */
function loadScript(url, callback) {
	var f = arguments.callee;
	if (!("queue" in f)) f.queue = {};
	var queue = f.queue;
	if (url in queue) {
		if (callback) {
			if (queue[url]) queue[url].push(callback);
			else callback();
		}
		return;
	}
	queue[url] = callback ? [callback] : [];
	var script = document.createElement("script");
	script.type = "text/javascript";
	script.onload = script.onreadystatechange = function() {
		if (script.readyState && script.readyState != "loaded" && script.readyState != "complete") return;
		script.onreadystatechange = script.onload = null;
		while (queue[url].length) queue[url].shift()();
		queue[url] = null;
	};
	script.src = url;
	document.getElementsByTagName("head")[0].appendChild(script);
}

