String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

function createXmlHttpObj()
{
	var xmlHttp;
	try
	{
		// IE7+, Firefox, Opera 8.0+, Safari, Chrome
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			// IE5, IE6
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e)
		{
			alert("Your browser does not support AJAX!");
			return false;
		}
	}
	return xmlHttp;
}

function ajaxFunction(strFileAndVars,strCompleteFunction,objArgs)
{
	var xmlHttp = createXmlHttpObj();
	var d = new Date();

	if (strFileAndVars.indexOf("?") == -1)
		strFileAndVars = strFileAndVars + "?nocachevar=" + d.getTime();
	else
		strFileAndVars = strFileAndVars + "&nocachevar=" + d.getTime();

	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			var strResponse = xmlHttp.responseText;
			if (! objArgs)
				window[strCompleteFunction](strResponse.trim());
			else
				window[strCompleteFunction](strResponse.trim(),objArgs);
		}
	}
	xmlHttp.open("GET",strFileAndVars,true);
	xmlHttp.send(null);
}

/* fix for iphone and ipad nav */
if ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1) || (navigator.userAgent.indexOf('iPad') != -1)) 
{
	window.onscroll = resetNavPosition;
	setTimeout(resetNavPosition,2000);  // force it once after the page loads
}

function resetNavPosition() 
{
	if (document.getElementById('navbar_container'))
	{
		document.getElementById('navbar_container').style.position = 'absolute';;
		document.getElementById('navbar_container').style.top = (window.innerHeight + window.pageYOffset - 96) + 'px';
		document.getElementById('navbar_container').style.left = (window.pageXOffset) + 'px';	
	}	
}



