ajax={};
ajax.x=function() {
	try{//FF
		return new XMLHttpRequest();
	}catch(e){//IE
		try{
			return new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			return new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
}
ajax.send=function(u,f,m,lder,a) {
	var x=ajax.x();
	x.open(m,u,true);
	x.onreadystatechange=function() {
		if(x.readyState==4){
			if(x.status==200){
				jx.lderstart(lder,true);
				result='';
				result=x.responseText;
				result=escape(result);
				if(result=='SESSIONERROR') {
					jx.error('session');
					return;
				} else if(result=='RUNTIMEERROR') {
					jx.error('runtime');
					return;
				} else if(result=='SQLERROR') {
					jx.error('sql');
					return;
				}
				runfunc=f+'(\''+result+'\')';
				eval(runfunc);
			}
		}else{
			jx.lderstart(lder,null);
		}
	}
	if(m=='POST'){
		x.setRequestHeader('Content-type','application/x-www-form-urlencoded');
		x.setRequestHeader('Content-length',a.length);
	}else{
		x.setRequestHeader('Content-type','text/plain');
	}
    x.setRequestHeader('Connection','close');
	x.send(a);
}
ajax.get=function(url,func,lder){
	ajax.send(url,func,'GET',lder);
}
ajax.post=function(url,func,lder,args){
	ajax.send(url,func,'POST',lder,args);
}


jx={
	sid:function(){return new Date().getTime()},
	error:function(type){
		ertxt=[];
		ertxt['session'] = '<center><h2>Your account is beeing used somewhere else</h2><br><h3>Please check:</h3>Is someone else using the same account?<br>Are you loged in to <b>unitedprofile</b> and <b>macma</b> at the same time?<br><br><input type="button" value="Restart" class="mainbut" onclick="blklvenf=1;top.location.href=\'http://'+hostver+'\'"></center>';
		ertxt['runtime'] = '<center><big>The site has encountered an runtime error and must restart.</big><br><br><input type="button" value="Restart" class="mainbut" onclick="blklvenf=1;top.location.href=\'http://'+hostver+'\'"></center>';
		ertxt['sql'] = '<center><big>The site has encountered an data base error and must restart.</big><br><br><input type="button" value="Restart" class="mainbut" onclick="blklvenf=1;top.location.href=\'http://'+hostver+'\'"></center>';
		//de.popup(500,escape(ertxt[type]));
		noexitmessage=true;
		top.location.href='http://'+host+'/login.php?e=1';
		return;
	},
	dataArray:function(data){
		newa=new Array();
		newa=data.split("[;]");
		return newa;
	},
	lderstart:function(lder_,stop){
		loadset='<img src="_gfx/load_1.gif" align="texttop"> Laddar...';
		if(stop==true){
			loadset='';
			jx.lderstarted=null;
		}
		if((lder_!='undefined'&&jx.lderstarted==null)||(lder_!='undefined'&&stop==true)){
			multilder=[];
			funclder=[];
			multilder=lder_.split(";");
			funclder=lder_.split("|");
			try{
				if(multilder[1]!=null) {
					for(m=0;m<=multilder.length-1;m++)$(multilder[m]).innerHTML=loadset;
				} else if(funclder[1]!=null) {
					eval(funclder[1]+'(stop)');
				} else {
					try{
						$(lder_).innerHTML=loadset;
					}catch(e){}
				}
			}catch(e){}
			if(stop==null){
				jx.lderstarted=true;
			}
		}
	},
	return_call:function(url,func,lder,met){
		if(!met)met='GET';
		if(!lder)lder='undefined';
		if(met=='POST'){
			splitUrl=url.split('.php?');
			param=splitUrl[1];
			posturl=splitUrl[0]+'.php';
			ajax.post(posturl,func,lder,param);
		}else{
			ajax.get(url,func,lder);
		}
	}
};