// Prototype Ajax get - receives html
function getHTML(url, params, element)
{
	var myAjax = new Ajax.Updater(
					{success: element},
					url,
					{
						method: 'post',		
						parameters: params,
						asynchronous: false,
						onFailure: reportError,
						onLoading: function(loading) {
	  							//document.getElementById("mainScr3").innerHTML="Loading...";
							},
						evalScripts: true
					});

}

// submit html form
function submitForm(formObj, url, element)
{
	var params = Form.serialize(formObj);
	getHTML(url, params, element);
}

function reportError(request)
{
	alert('Sorry. There was an error.');
}

function startPopEvent(PopEvent)
{
    var desktop=window.open(PopEvent,"_blank","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,width=650,height=650,resizable");
}

function loadScreen(str, params)
{
	getHTML(str, params, 'bodyDiv');
}
function loadScreen2(str, params)
{
	getHTML('page2.php', params , 'mainDiv');
	getHTML('menu.php', 'mtype=SECOND', 'menuDiv');
	getHTML('topmenu.php', 'mtype=SECOND', 'topmenuDiv');
	getHTML('topbar.php', '', 'topBarDiv');	
	getHTML('spotlight.php', '', 'spotlight');
	getHTML('articles.php', 'categoryId='+shoots, 'shootsDiv');
	getHTML(str, params, 'bodyDiv');	
}
// Removes leading whitespaces
function LTrim( value )
{
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}

// Removes ending whitespaces
function RTrim( value )
{
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}

// Removes leading and ending whitespaces
function trim( value )
{
	return LTrim(RTrim(value));
}

// checks if a number is an integer
function isInt (str)
{
	var i = parseInt (str);

	if (isNaN (i))
		return false;

	i = i . toString ();
	if (i != str)
		return false;

	return true;
}
