String.prototype.trim = function(){
	return this.replace(/^\s+|\s+$/g,'');	
}

function ajax()
{
	this.prototype.get=get(param,updatepanel);
}

var xmlHttp;

function showpage(str)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser tidak support HTTP Request")
 return
 } 
var url="page.php"
url=url+"?page="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("content").innerHTML=xmlHttp.responseText 
 } 
}

function GetXmlHttpObject()
{
    var xmlHttp=null;
    if (window.XMLHttpRequest) // Firefox, Opera 8.0+, Safari
    {
        try
        {
            xmlHttp = new XMLHttpRequest();
        }
        catch (e)
        {
            xmlHttp = false;
        }
    }
	else if(window.ActiveXObject) //for IE
    {
        try
        {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e)
        {
            xmlHttp = false;
        }
    }
    
    if (!xmlHttp)
        alert("browser tidak support XMLHTTP.");
    else
        return xmlHttp;
}

function post(param)
{
	
}

function getsub(param,parent,updatepanel)
{
	showprogress(true);
		
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
	{
		param=param+Math.random();
		xmlHttp.open("GET", param, true);
		xmlHttp.onreadystatechange = function (){
			if (xmlHttp.readyState == 4)
			{
				if (xmlHttp.status == 200)
				{
					response = xmlHttp.responseText;
					res = document.getElementById(updatepanel);
					res.innerHTML = response;
					document.getElementById("content").style.display='none';
					document.getElementById("content2").style.display='none';
					document.getElementById(parent).style.display='';
					res.style.display='';
				}
				else
				{
				alert("There was a problem accessing the server: " + xmlHttp.statusText);
				}
				showprogress(false);
			}
		}
	xmlHttp.send(null);
	}
}

function showprogress(display)
{
	pgr=document.getElementById('progress');
	if(display==true)
		pgr.style.display='';
	else
		pgr.style.display='none'
}

window.addEventListener("pageshow", onEventProc, true);
function onEventProc(aEvent)
{
	  var win = aEvent.currentTarget;
	  var top_doc = win.frames[0].document;
	  var cur_doc = aEvent.target;
	  if (top_doc == cur_doc)
		alert("load complete");
}

