// JavaScript Document

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_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 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 pageLoading() {
	if (document.getElementById('fadeScreen')) {
		fullHeight=f_clientHeight();
		if (document.body) fullHeight=document.body.scrollHeight;
		document.getElementById('fadeScreen').style.height=fullHeight+'px';
		document.getElementById('fadeScreen').style.visibility='visible';
		document.getElementById('pageLoading').style.left=Math.round((f_clientWidth()-146)/2)+'px';
		document.getElementById('pageLoading').style.top=Math.round((f_clientHeight()-42)/2+f_scrollTop())+'px';
		document.getElementById('pageLoading').style.visibility='visible';
	}	
}

function pageNotLoading() {
	if (document.getElementById('fadeScreen')) {
		document.getElementById('fadeScreen').style.visibility='hidden';
		document.getElementById('pageLoading').style.visibility='hidden';
	}
}

function validEmail(s) {
	good=true;
	if (s.indexOf('"')!=-1 || s.indexOf("'")!=-1) good=false;
	else {
		parts=s.split('@');
		if (parts.length!=2) good=false;
		else {
			uname=parts[0].split('.');
			for (i=0;i<uname.length;i++) {
				if (uname[i].length==0) good=false;
			}
			if (good) { 
				domain=parts[1].split('.');
				if (domain.length>1) {
					for (i=0;i<domain.length;i++) {
						if (i==domain.length-1) {
							if (domain[i].length<2 || domain[i].length>3) good=false;
						} else {
							if (domain[i].length==0) good=false;
						}
					}
				} else good=false;
			}
		}
	}
	return good;
}
