function showCenteredLayer(lyrName) 
{
	var lyrWidth = document.getElementById(lyrName).clientWidth;
	var lyrHeight = document.getElementById(lyrName).clientHeight;
	
	var left = getViewPortWidth() / 2 - lyrWidth / 2; // document.body.offsetWidth
	var top = getViewPortHeight() / 2 - lyrHeight / 2 + getScrollTop();

	document.getElementById(lyrName).style.left = left;
	document.getElementById(lyrName).style.top = top;
}

function hideCenteredLayer(lyrName)
{
	document.getElementById(lyrName).style.left = -3000;
}

function getViewPortWidth() 
{
	var viewportwidth;
 
	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 
	if(typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerWidth;
 	}
 
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

	else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth !=
		'undefined' && document.documentElement.clientWidth != 0) {
		viewportwidth = document.documentElement.clientWidth;
 	}
 
 	// older versions of IE
 
 	else {
     	viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
 	}
	
	return viewportwidth;
}

function getViewPortHeight() 
{
	var viewportheight;
 
	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 
	if(typeof window.innerWidth != 'undefined') {
      	viewportheight = window.innerHeight;
 	}
 
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

	else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth !=
		'undefined' && document.documentElement.clientWidth != 0) {
       	viewportheight = document.documentElement.clientHeight;
 	}
 
 	// older versions of IE
 
 	else {
       	viewportheight = document.getElementsByTagName('body')[0].clientHeight;
 	}
	
	return viewportheight;
}

function getScrollTop() 
{
	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 validateName(name) 
{
	var isValid = true;
	
	//	Check to an empty name
	var trimmedName = name.replace(/^\s+|\s+$/g,"");
	if(trimmedName == "" || trimmedName == "Your Name") {
		isValid = false;	
	}
	
	return isValid;
}

function validateEmail(email) 
{
	var isValid = true;
	
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if(reg.test(email) == false) {
		isValid = false;
	}
	
	return isValid;
}                   
					
function playAudio(title, file)
{
	var winWidth = 400;
	var winHeight = 125;
	
	var screenWidth = window.screen.width;
	var screenHeight = window.screen.height;
	
	var left = (screenWidth - winWidth) / 2;
	var top = (screenHeight - winHeight) / 2;
	
	window.open("media/?title=" + title + "&file=" + file, "audio", 
		"left=" + left + ",top=" + top + ",width=" + winWidth + ",height=" + winHeight);	
}
