var xmlHttp;
function createXMLHttpRequest() {
    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } 
    else if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();                
    }
}
function GoDelectMessages(messageids){
	createXMLHttpRequest();
    var url = "ajax/deletemessage.php?messageid=" + messageids;
   	xmlHttp.open("GET", url, true);
    xmlHttp.onreadystatechange = goCallback;
    xmlHttp.send(null);
}
function GoDelectMessages2(messageids){
	createXMLHttpRequest();
    var url = "../ajax/deletemessage.php?messageid=" + messageids;
   	xmlHttp.open("GET", url, true);
    xmlHttp.onreadystatechange = goCallback2;
    xmlHttp.send(null);
}

function GoUpdateHBVBalance(balance,username){
    createXMLHttpRequest();
    var url = "ajax/updateBalance.php?username=" + username +"&balance="+balance;
   	xmlHttp.open("GET", url, true);
    xmlHttp.onreadystatechange = goCallback;
    xmlHttp.send(null);
}

function GoAddHostViewdNum(hostname,username){
    createXMLHttpRequest();
    var url = "ajax/addviewdnum.php?hostname=" + hostname+"&username="+username;
   	xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
}
function GoAddHostFreeViewdNum(hostname){
    createXMLHttpRequest();
    var url = "ajax/addfreeviewdnum.php?hostname=" + hostname;
   	xmlHttp.open("GET", url, true);
    xmlHttp.send(null);
}

function createRssFeed(){
    if( confirm('Are you sure to create the new rss feed?') ){
        createXMLHttpRequest();
        var url = "../ajax/createrssfeed.php";
   	    xmlHttp.open("GET", url, true);
        xmlHttp.onreadystatechange = goCallbackTest;
        xmlHttp.send(null);
    }else{
        return;
    }
}

function GoUpdateNeedSMS(usrid){
    createXMLHttpRequest();
    var url = "../ajax/updateNeedSMS.php?userid=" + usrid;
  
   	xmlHttp.open("GET", url, true);
    xmlHttp.onreadystatechange = goCallbackNeedSMS;
    xmlHttp.send(null);
}



function goCallbackNeedSMS(){
    if (xmlHttp.readyState == 4) {
        if (xmlHttp.status == 200) {
       
			    window.location.reload(); 
        }
    }
}

function goCallback() {
    if (xmlHttp.readyState == 4) {
        if (xmlHttp.status == 200) {
			window.location.reload(); 
        }
    }
}
function goCallback2() {
    if (xmlHttp.readyState == 4) {
        if (xmlHttp.status == 200) {
			location.href= "messageboard.php";

        }
    }
}

function goCallbackUpdateBalance(){
    if (xmlHttp.readyState == 4) {
        if (xmlHttp.status == 200) {
            location.href= window.location.href;
        }
    }
   
}
function goCallbackTest(){
     if (xmlHttp.readyState == 4) {
        if (xmlHttp.status == 200) {
           alert(xmlHttp.responseText);
        }
    }
}

//-------------------------------------------------------------------------------------------
//scrollback
//--------------------------------------------------------------------------------------------

function Trim(strValue)
{
	return strValue.replace(/^\s*|\s*$/g,"");
}
function SetCookie2(sName, sValue)
{
	document.cookie = sName + "=" + escape(sValue);
}

function GetCookie(sName)
{
	var aCookie = document.cookie.split(";");
	for (var i=0; i < aCookie.length; i++)
	{
		var aCrumb = aCookie[i].split("=");
		if (sName == Trim(aCrumb[0])) 
		{
			return unescape(aCrumb[1]);
		}
	}

	return null;
}
function scrollback()
{
	
	if (GetCookie("scroll")!=null){document.documentElement.scrollTop=GetCookie("scroll")}
}




