var oAjax = new ajaxObject();
var divName, currentProcess, curCusID;
var inProcess=false;

oAjax.OnSuccess = function() {
	
	var div = document.getElementById(divName);
	div.innerHTML = oAjax.GetResponseText();

	//Dau di cac layer Loading
	//document.getElementById('loading').style.display = "none";

    switch (currentProcess){		       
		case "uploadFile":
			document.getElementById('iframeUpload').style.display = "block";
			document.getElementById('iframePlayAlbum').style.height="50px";
			currentProcess = "";
			break;
	}  	
}
/*
oAjax.OnLoading = function() {
    getPageScroll();
    document.getElementById('loading').style.display='block';
}

*/

oAjax.OnLoading = function() {
	var div = document.getElementById(divName);
	div.innerHTML = "";
	div.innerHTML = "<table align=\"center\"><tr><td class=\"loading\"><img src=\"images/loading.gif\" align=\"left\"><b>Please wait... </b><br>Page is downloaded.</td></tr></table>";
}



oAjax.OnFailure = function() {
	var div = document.getElementById(divName);
	div.innerHTML = "Failed!";
}

function showHome(){
    divName ="divMain";
    oAjax.InitXmlHttpRequest('GET', 'index.php?act=home');
    oAjax.Commit(null);
}

function showHealth(){	
    divName ="divMain";
    oAjax.InitXmlHttpRequest('GET', 'index.php?act=Health');
    oAjax.Commit(null);
}
function showTravel(){
    divName ="divMain";
    oAjax.InitXmlHttpRequest('GET', 'index.php?act=Travel');
    oAjax.Commit(null);
}
function showTax(){
    divName ="divMain";
    oAjax.InitXmlHttpRequest('GET', 'index.php?act=Tax');
    oAjax.Commit(null);
}
function showWorker(){
    divName ="divMain";
    oAjax.InitXmlHttpRequest('GET', 'index.php?act=Worker');
    oAjax.Commit(null);
}

function showContact(){
    divName ="divMain";
    oAjax.InitXmlHttpRequest('GET', 'index.php?act=contact');
    oAjax.Commit(null);
}

function showAcounting(){
    divName ="divMain";
    oAjax.InitXmlHttpRequest('GET', 'index.php?act=Acounting');
    oAjax.Commit(null);
}

function showReal(){
    divName ="divMain";
    oAjax.InitXmlHttpRequest('GET', 'index.php?act=Real');
    oAjax.Commit(null);
}

function doContact(){
	divName ="divMain";
 	var $getVariable = buildPOST('frmContact');
    oAjax.InitXmlHttpRequest('GET', 'index.php?act=contact&' + $getVariable);
    oAjax.Commit(null);
}

// ******************************************************************
//Chuyen tat ca cac gia tri trong form thanh chuoi GET
// ******************************************************************
function buildPOST(theFormName) {
    theForm = document.forms[theFormName];
    var qs = ''
    for (e=0;e<theForm.elements.length;e++) {
        if (theForm.elements[e].name!='') {
            if((theForm.elements[e].type == "radio") && (!theForm.elements[e].checked)) {
            	continue;
            }
            var name = theForm.elements[e].name;
            qs+=(qs=='')?'':'&'
            qs+= name+'='+escape(theForm.elements[e].value);
        }
    }
    qs+="\n";
    return qs
}

function showWCI(){
	document.getElementById('divWCI').style.display ="block";
}

function showHTML(txtUrl,wWidth,hHeight){
	newWindow=window.open(txtUrl,'JohnPham','toolbar=no,width='+wWidth+',height='+hHeight+',resizable=yes,scrollbars=yes');	//newWindow.document.write('<html><head><\/head><body topmargin="0" leftmargin="0">\/body><\/html>');
	newWindow.focus();
}

	
	if (window.addEventListener) //DOM method for binding an event
		window.addEventListener("load", showHome, false)
	else if (window.attachEvent) //IE exclusive method for binding an event
		window.attachEvent("onload", showHome)
	else if (document.getElementById) //support older modern browsers
		window.onload=showHome
