// Replace rel="external" to target="_blank"
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";
	}
}
// Check that display isn't too small to display the main div
function centerMain() {
	// Width of the div
	var BodyWidth		= null;
	var mb				= document.getElementById('main-big');
	var w				= 920;
	var mw				= w / 2 * -1;
	if(window.innerWidth) {
		BodyWidth = window.innerWidth;
	} else {
		BodyWidth = document.body.clientWidth;
	}
	if (BodyWidth < w) {
		mb.style.left 			= '5px';
		mb.style.marginLeft 	= '0px';
	} else {
		mb.style.left 			= '50%';
		mb.style.marginLeft 	= mw+'px';
	}
	// Heigh of the div
	var BodyHeight		= null;
	var mb				= document.getElementById('main-big');
	var h				= 800;
	if(window.innerHeight) {
		BodyHeight = window.innerHeight;
	} else {
		BodyHeight	= document.documentElement.clientHeight;
		if (BodyHeight == 0) {
			BodyHeight = document.body.clientHeight;
		}
	}
	if (BodyHeight < h) {
		mb.style.height 		= h+'px';
	} else {
		mb.style.height			= '100%';
	}
}
// Width Size of the body
function wSize() {
	var w = 0;
	if(window.innerWidth) {
		w = window.innerWidth;
	} else {
		w = document.body.clientWidth;
	}
	w = w - 80;
	if (w < 960) {
		w = 960;
	}
	return w;
}
// Height Size of the body
function hSize() {
	var h = 0;
	if(window.innerHeight) {
		h = window.innerHeight;
	} else {
		h	= document.documentElement.clientHeight;
		if (h == 0) {
			h = document.body.clientHeight;
		}
	}
	h = h - 80;
	if (h < 560) {
		h = 560;
	}
	return h;
}
// Open Security and Privacy Popup
function OpenSecurityPrivacy() {
	GB_showCenter('Security and Privacy', '../../popup_security_privacy.php', 670, 635);
}
// Open Legal Popup
function OpenLegal() {
	GB_showCenter('Legal Information', '../../popup_legal.php', 670, 635);
}
// Contact Us Popup
function Contact_Us() {
	GB_showCenter("Contact Us", "../../popup_contact.php", 670, 635);
}
// Flow Chart Popup
function FlowChart() {
	GB_showCenter("Flowchart", "../../popup_flowchart.php", 670, 850);
}

// OnLoad
window.onload = function() {
	externalLinks();
	centerMain();
}
// OnResize
window.onresize = function() {
	centerMain();
}
