/****************************************/
/* @project: 	Klicked                 */
/* @author:		(c) 2010 by Simon Nagel */
/* @filename:	functions.js		    */
/****************************************/

function createRequestObject (){
    httpRQ = false;
    try{ httpRQ=new XMLHttpRequest(); }
    catch(e){
        try{ httpRQ=new ActiveXObject("Msxml2.XMLHTTP"); }
        catch(e){ httpRQ=new ActiveXObject("Microsoft.XMLHTTP"); }
    }
    return httpRQ;
}

function loadData(user){
    var httpRQUD = createRequestObject();
    if(httpRQUD) {
        httpRQUD.open('GET', 'get.userbar.php?user='+user, true);
        httpRQUD.onreadystatechange = function () {
            if(httpRQUD.readyState == 4) {
                setTimeout("loadData("+user+")",60000);
                document.getElementById("userbar").innerHTML = httpRQUD.responseText;          
         	}
     	};
     	httpRQUD.send(null);
    }
}

function klickRally(user){
    var httpRQKR = createRequestObject();
    if(httpRQKR) {
        httpRQKR.open('GET', 'get.klickrallybar.php?user='+user, true);
        httpRQKR.onreadystatechange = function () {
            if(httpRQKR.readyState == 4) {
                setTimeout("klickRally("+user+")",60000);
                document.getElementById("rallybar").innerHTML = httpRQKR.responseText;
         	}
     	};
        httpRQKR.send(null);
    }
}

function refRally(user){
    var httpRQKR = createRequestObject();
    if(httpRQKR) {
        httpRQKR.open('GET', 'get.refrallybar.php?user='+user, true);
        httpRQKR.onreadystatechange = function () {
            if(httpRQKR.readyState == 4) {
                document.getElementById("refrallybar").innerHTML = httpRQKR.responseText;
         	}
     	};
        httpRQKR.send(null);
    }
}

function bannerData(){
    var httpRQBD = createRequestObject();
    if(httpRQBD) {
        httpRQBD.open('GET', 'get.banner.php', true);
        httpRQBD.onreadystatechange = function () {
            if(httpRQBD.readyState == 4) {
                document.getElementById("mainContainer").innerHTML = httpRQBD.responseText;          
         	}
     	};
     	httpRQBD.send(null);
    }
}

function getaddress(emr2array) {
	var enc_adr = ''
	for (var i=0; i < emr2array.length; i++){
		enc_adr += String.fromCharCode(((Number(emr2array[i])-emr2array.length)/3))
	}
	document.write('<a href="mailto:' +enc_adr+ '">'+enc_adr+'</a>')
}

