function ID(id)
{
	return document.getElementById(id);
}

function getMyXY(o)
{
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) //Non-IE
	{
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) //IE 6+ in 'standards compliant mode'
	{
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	}
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) //IE 4 compatible
	{
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	else
	{
		myHeight = document.getElementById('mesure').offsetHeight;
		myWidth = document.getElementById('mesure').offsetWidth;
	}

	var w = o.offsetWidth;
	var h = o.offsetHeight;

	var x = Math.round((myWidth/2)-(w/2));
	var y = Math.round((myHeight/2)-(h/2));
	y += document.body.scrollTop;

	o.style.left = x+'px';
	o.style.top = y+'px';
}

function load()
{
	getMyXY(ID('pre_loader'));
}

function closePopup()
{
	var options = {};

	if($("#system_message_popup").dialog('isOpen'))
	{
		$.closePopupLayer('myStaticPopup');
		$("#system_message_popup").dialog('destroy');
	}
}

function setSystemMessage(html)
{
	ID('system_message').innerHTML = html;
	checkSystemMessage();
}

function checkSystemMessage()
{
	if(ID('system_message').innerHTML != '')
	{
		openStaticPopup();
		openPopup();
	}

	if(ID('system_task_message'))
	{
		if(ID('system_task_message').innerHTML != '')
		{
			ID('system_message').innerHTML = ID('system_task_message').innerHTML;
			openStaticPopup();
			openPopup();
		}

	}
}

function openPopup()
{
	$.ui.dialog.defaults.bgiframe = true;
	$(function()
	{
		var resizable = $("#system_message_popup").dialog('option', 'resizable');
		$("#system_message_popup").dialog({ resizable: true});
		$("#system_message_popup").bind('dialogclose', function(event, ui)
		{
			closePopup();
		});
	});
}

function openStaticPopup() 
{
	$.openPopupLayer({
		name: "myStaticPopup",
		width: 550,
		target: "system_message_hidden",
		beforeClose: function(){closePopup();}
	});
}

function siteSearch()
{
	if(document.getElementById('site_search').value == '')
		alert('Please enter some search criteria.');
	else
		document.getElementById('site_search_form').submit();
}

function getInternetExplorerVersion()
{
	var msg = '';
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
	{ //test for MSIE x.x;
	 var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
	if (ieversion>=8)
	  msg='';
	 else if (ieversion>=7)
	  msg='';
	 else if (ieversion>=6)
	  msg='';
	 else if (ieversion>=5)
	  msg='Please upgrade your version of Internet Explorer.';
	}
	
	if(msg != '')
		alert(msg);
}


