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

/* ONLOAD EVENTS */
$(document).ready(function() {
	/* RIGHT SIDE HEIGHT */
	//if (($("#content") && $("#side")) && ($("#content").outerHeight(true) > $("#side").outerHeight(true))) $("#side").height($("#content").outerHeight(true));
	/* EXTERNAL LINKS */
	$("a[rel='external']").attr({ target: '_blank' });
	/* SET AS HOMEPAGE LINK */
	$('#setashomepage').click(function() {
		$.setHomepage(base_href);
	});
});

/* 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)) + '');
}

/* MAXLENGHT */
function maxlength(object, length) {
	return (object.value.length <= length);
}

/* WINDOW SIZE */
window.size = function() {
	var w = 0;
	var h = 0;
	if (!window.innerWidth) {
		if (!(document.documentElement.clientWidth == 0)) {
			w = document.documentElement.clientWidth;
			h = document.documentElement.clientHeight;
		}
		else {
			w = document.body.clientWidth;
			h = document.body.clientHeight;
		}
	}
	else {
		w = window.innerWidth;
		h = window.innerHeight;
	}
	return { width: w, height: h };
}

/* WINDOW CENTER */
window.center = function() {
	var hWnd = (arguments[0] != null) ? arguments[0] : {width: 0, height: 0 };
	var _x = 0;
	var _y = 0;
	var offsetX = 0;
	var offsetY = 0;
	if (!window.pageYOffset) {
		if (!(document.documentElement.scrollTop == 0)) {
			offsetY = document.documentElement.scrollTop;
			offsetX = document.documentElement.scrollLeft;
		}
		else {
			offsetY = document.body.scrollTop;
			offsetX = document.body.scrollLeft;
		}
	}
	else {
		offsetX = window.pageXOffset;
		offsetY = window.pageYOffset;
	}
	_x = ((this.size().width - hWnd.width) / 2) + offsetX;
	_y = ((this.size().height - hWnd.height) / 2) + offsetY;
	return { x: _x, y: _y };
}

/* SHOW / HIDE DIV */
displayDiv = function(id) {
	var oDiv = document.getElementById(id);
	if (!oDiv) return false;
	var oWindowCenter = window.center({width: 425, height: 315});
	oDiv.style.top = oWindowCenter.y + "px";
	oDiv.style.left = oWindowCenter.x + "px";
	oDiv.style.visibility = 'visible';
        oDiv.style.display = 'block';
}
function hideDiv(id) {
	var oDiv = document.getElementById(id);
	if (!oDiv) return false;
	oDiv.style.visibility = 'hidden';
        oDiv.style.display = 'none';
}

