var winW = f_clientWidth();
var winH = f_clientHeight();

function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}

function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}

function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function loginOnClick() {
	document.getElementById('bodyDiv').style.display='none'; 
	document.getElementById('pocketlifeDiv').style.display='block';
	if (window.event) window.event.returnValue = false;
	return false;
}

function setSize(width,height) {
	if (window.outerWidth) {
		window.outerWidth = width;
		window.outerHeight = height;
	}
	else if (window.resizeTo) {
		window.resizeTo(width,height);
	}
}

function resize(){  
	var frame = document.getElementById("bodyDiv");  
	var pocketlifeFrame = document.getElementById("pocketlifeDiv");  
	var htmlheight = document.body.parentNode.scrollHeight;  
	var windowheight = window.innerHeight;  
	if ( htmlheight < windowheight ) { document.body.style.height = windowheight + "px"; frame.style.height = windowheight + "px"; }  
	else { document.body.style.height = htmlheight + "px"; frame.style.height = htmlheight + "px"; pocketlifeFrame.style.height = htmlheight + "px"; }  
} 

function goHome() {
	var hostnameParts = new Array();
	hostnameParts = location.hostname.split(".");
	var port = location.port;
	if (port == null)
		port = "";
	else
		port = ":" + port;  
	var pathname = location.pathname.substring(0, location.pathname.lastIndexOf("/"));
	if (hostnameParts.length > 2 && hostnameParts[0] != "www" && hostnameParts[0] != "test" && hostnameParts[0] != "dev")
		location.href = (location.protocol + "//" + location.hostname + port + pathname + "/" + hostnameParts[0] + ".html");
	else
		location.href = (location.protocol + "//" + location.hostname + port + pathname + "/index.html");
}
