var xmlHttp

function GetXmlHttpObject() {
    var xmlHttp=null;

    try{ // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
    }
    catch (e){ // Internet Explorer
        try{
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e){
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}

function setClass(str){
    document.frmPaidRegister.txtPaidClass.value = str;
}

function checkEmailAvail(str){
    if (str.length==0){
        document.getElementById("email_return").innerHTML=""
        return
    }
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null){
        alert ("Browser does not support HTTP Request")
        return
    }
    var url="checkUserEmail.php"
    url=url+"?keys="+str
    //url=url+"&sid="+Math.random()
    xmlHttp.onreadystatechange=stateChanged
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)
}

function checkUserNameAvail(str){
    if (str.length==0){
        document.getElementById("txtResult").innerHTML=""
        return
    }
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null){
        alert ("Browser does not support HTTP Request")
        return
    }
    var url="checkUserName.php"
    url=url+"?keys="+str
    //url=url+"&sid="+Math.random()
    xmlHttp.onreadystatechange=stateChangedUserName
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)
}

function stateChangedUserName(){
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
        document.getElementById("txtResult").innerHTML=xmlHttp.responseText
    }
}

function disable_enable(formName,formField){
    if (document.all || document.getElementByid){
        document.formName.formField.disabled=!document.formName.formField.disabled
    }
}

function disable_enable_register(){
    if(document.all || document.getElementById){
        document.frmUserRegistration.submitRegistration.disabled=!document.frmUserRegistration.submitRegistration.disabled
    }
}

function check_if_empty(){
    if (document.frmUserRegister.txtEmail.value=='' || document.frmUserRegister.txtUserName.value=='' || document.frmUserRegister.passPw1.value=='' ||
        document.frmUserRegister.passPw2.value=='' || document.frmUserRegister.txtFirst.value=='' || document.frmUserRegister.txtLast.value=='' ||
        document.frmUserRegister.selSex.value=='' || document.frmUserRegister.txtAddress.value=='' || document.frmUserRegister.txtCity.value=='' ||
        document.frmUserRegister.selUserState.value=='' || document.frmUserRegister.txtZip.value=='' || document.frmUserRegister.chkAgree.value==''){
        document.frmUserRegister.submitUserRegister.disabled=true
    }else{
        document.frmUserRegister.submitUserRegister.disabled=false
    }
}

// AJAX Helper Functions
// Copyright (c) 2007-2009; Benjamin Samuel Eskew; http://www.kilermedia.com
function ajaxGetData(dataSource, divID){
    // Note: You must create an instance of the XMLHttpRequestObject
    // before using this function.
    //
    if(XMLHttpRequestObject){
        var obj = document.getElementById(divID);
        XMLHttpRequestObject.open("GET", dataSource);
        XMLHttpRequestObject.onreadystatechange = function(){
            if(XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200){
                obj.innerHTML = XMLHttpRequestObject.responseText;
            }
        }
        XMLHttpRequestObject.send(null);
        window.setTimeout("ajaxTimeout();", 5000);
        doWaiting();
    }
}

function ajaxPostData(dataSource, divID){
    // Note: You must create an instance of the XMLHttpRequestObject
    // before using this function.
    //
    if(XMLHttpRequestObject){
        var obj = document.getElementById(divID);
        XMLHttpRequestObject.open("POST", dataSource);
        XMLHttpRequestObject.onreadystatechange = function(){
            if(XMLHttpRequestObject.readyState == 4){
                obj.innerHTML = XMLHttpRequestObject.responseText;
            }
        }
        XMLHttpRequestObject.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        XMLHttpRequestObject.send(null);
        window.setTimeout("ajaxTimeout();", 5000);
        doWaiting();
    }
}

function ajaxTimeout(){
    if(XMLHttpRequestObject){
        if(XMLHttpRequestObject.readyState != 4 && XMLHttpRequestObject.readyState != 0){
            XMLHttpRequestObject.onreadystatechange = function(){};
            XMLHttpRequestObject.abort();
            window.alert("XMLHttpRequest aborted!");
        }
    }else{
        window.alert("XMLHttpRequest does not exist.");
    }
}

function doWaiting(){
    /*
     * Usage:
     *       <span id="loading" style="position: absolute;visibility: hidden; background-color: red;
             width: 75px;">Loading ...</span>
     */
    with(document.getElementById("loading")){
        style.visibility = "visible";
        if(navigator.appName == "Microsoft Internet Explorer"){
            style.posLeft = document.body.clientWidth - 75;
            style.posTop = 0;
        }else{
            style.left = (window.innerWidth - 75) + "px";
            style.top = "0px";
        }
    }
}

/* Below is copyright by some guy.
    (Found online, forgot where.)
*/
function makeHttpRequest(url, callback_function, return_xml){
    // Copyright (c) some guy or other.
   var http_request = false;

   if (window.XMLHttpRequest) { // Mozilla, Safari,...
       http_request = new XMLHttpRequest();
       if (http_request.overrideMimeType) {
           http_request.overrideMimeType('text/xml');
       }

   } else if (window.ActiveXObject) { // IE
       try {
           http_request = new ActiveXObject("Msxml2.XMLHTTP");
       } catch (e) {
           try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
           } catch (e) {}
       }
   }

   if (!http_request) {
       alert('Unfortunatelly your browser doesn\'t support this feature.');
       return false;
   }
   http_request.onreadystatechange = function() {
       if (http_request.readyState == 4) {
           if (http_request.status == 200) {
               if (return_xml) {
                   eval(callback_function + '(http_request.responseXML)');
               } else {
                   eval(callback_function + '(http_request.responseText)');
               }
           } else {
               alert('There was a problem with the request. (Code: ' + http_request.status + ')');
           }
       }
   }
   http_request.open('GET', url, true);
   http_request.send(null);
}

function loadBanner(xml){
    var html_content = xml.getElementsByTagName('content').item(0).firstChild.nodeValue;
    var reload_after = xml.getElementsByTagName('reload').item(0).firstChild.nodeValue;
    document.getElementById('ajax-banner').innerHTML = html_content;
    try {
        clearTimeout(to);
    } catch (e) {}
    to = setTimeout("nextAd()", parseInt(reload_after));
}

function nextAd(){
    var now = new Date();
    var url = 'ajax-banner.php?ts=' + now.getTime();
    makeHttpRequest(url, 'loadBanner', true);
}

function confirmation() {
	var answer = confirm("WARNING - do not close this message - please read - You have what many people call dangerous spyware known as ZANGO installed on your system. We are not here to sell you anything, you can remove it for free with Ad-Aware SE. Would you like to use Ad-Aware SE to remove ZANGO? If you click Ok you will be taken to its download page.")
	if (answer){
		window.location = "http://www.download.com/Ad-Aware-SE-Personal-Edition/3000-8022_4-10399602.html?tag=lst-0-1";
	}
	else{
		alert("I strongly advise you to remove Zango from your computer. Zango is bundled with free applications (games, tools and utilities) and once infected with Zango your internet surfing habits are monitored and advertisements are poped up every few minutes. Remove Zango before you infect others with it.")
	}
}