function serverProcess(){
	/* (c)2007 by gld */
	this.serverArr = [["85.153.15.101","27015","ag1.playag.com",0],["85.153.15.102","27015","ag2.playag.com",0],["85.153.15.103","27015","ag3.playag.com",1]];
	this.xmlfn = null;
	this.dvLoading = null;
	this.dvPlayerInfoT = null;
	this.dvPSInfo = null;
	this.serverId = null;
	this.onProcess = false;
	this.playerinfoarr = [];
	this.serverinfoarr = [];
	this.firstRun = true;
	this.maxTNum = 3;
	
	this.prepare = function(){
		this.dvLoading = document.getElementById('si_loading');
		this.dvPlayerInfoT = document.getElementById('si_players_t');
		this.dvPSInfo = document.getElementById('sb_o_bilgi');
		this.dvPlayerInfoT.title = this.dvPSInfo.title = "(c)2007 by gld";
		
		this.getServerInfo(0,0);
	};
	this.getServerInfo = function(sid,typ){
		if(!this.onProcess){
			if(typ==1) this.firstRun = false;
			this.dvLoading.style.display = "";
			this.serverId = sid;
			this.onProcess = true;
			//
			var thisn = this;
			posturl = "serverAddr="+this.serverArr[this.serverId][0]+"&serverAddrPort="+this.serverArr[this.serverId][1]+"&serverType="+this.serverArr[this.serverId][3];
			this.xmlfn = new xmlfnc();
			this.xmlfn.sendloadReturnFunc = function(){ thisn.looksAndFeels(); }
			this.xmlfn.sendLoadData(1,posturl);
		}
	}
	this.looksAndFeels = function(){
		/*playerinfoarr
		0 : nick
		1 : frag
		2 : time
		3 : purenick
		4 : id
		5 : imgurl
		*/
		this.serverinfoarr = this.xmlfn.returnArray[0];
		this.playerinfoarr = this.xmlfn.returnArray[1];
		
		if(this.playerinfoarr.length>0){
			strwrite = '';
			for(i=0;i<(this.playerinfoarr.length>this.maxTNum?this.maxTNum:this.playerinfoarr.length);i++){
				id = this.playerinfoarr[i][4];
				imgurl = this.playerinfoarr[i][5];
				imgurl = imgurl.length<1?'/dl/msnaq0.gif':imgurl;
				imgurl = imgurl.indexOf('av-')>-1?('/forum/uploads/'+imgurl):imgurl;
				
				strwrite += '<div class="index_sunucu_player">';
				if(id>0) strwrite += '<a href=\"/forum/index.php?showuser='+id+'\">';
				strwrite += '<img src="'+imgurl+'" alt="" />';
				strwrite += '<div id="pl_nick"><span>Nick:</span> '+this.playerinfoarr[i][0]+'</div>';
				strwrite += '<div id="pl_time"><span>Time:</span> '+this.parseTime(this.playerinfoarr[i][2])+'</div>';
				strwrite += '<div id="pl_frag"><span>Frag:</span> '+this.playerinfoarr[i][1]+'</div>';
				if(id>0) strwrite += '</a>';
				strwrite += '</div>';
			}
			strwrite += '</table>';
			this.dvPlayerInfoT.innerHTML = strwrite;
		}else{
			this.dvPlayerInfoT.innerHTML = '<div id="mesaj">Mevcut oyuncu bulunamadı!</div>';
		}
		
		this.dvLoading.style.display = "none";
		this.onProcess = false;
		this.tabA(this.serverId);
		this.viewA(-1);
		
		if(this.firstRun && this.playerinfoarr.length<1){ this.firstRun=this.serverId==this.serverArr.length-2?false:this.firstRun; this.getServerInfo(this.serverId+1,0); return; }
	}
	this.tabA = function(indx){
		for(i=0;i<this.serverArr.length;i++){
			document.getElementById("sunucuItem"+i).className = "index_sunucu_item";
		}
		document.getElementById("sunucuItem"+indx).className = "index_sunucu_item_sel";
	}
	this.viewA = function(typ){
		tmpobj1 = document.getElementById('oyuncular');
		tmpobj1_s = document.getElementById('oyuncular_sel');
		tmpobj2 = document.getElementById('sunucu_bilgisi');
		tmpobj2_s = document.getElementById('sunucu_bilgisi_sel');
		switch(typ){
			case 0:
				if(tmpobj1_s!=null){
					tmpobj1_s.id = "oyuncular";
					this.dvPSInfo.style.display = "none";
					break;
				}else{
					tmpobj1.id = "oyuncular_sel";
					if(tmpobj2_s!=null) tmpobj2_s.id = "sunucu_bilgisi";
					this.dvPSInfo.style.display = "";
				}
				if(this.playerinfoarr.length>this.maxTNum){
					strwrite = '<b id="sb_o_name">Oyuncu</b><b id="sb_o_frag">Frag</b><b id="sb_o_time">Zaman</b>';
					for(i=this.maxTNum;i<this.playerinfoarr.length;i++){
						id = this.playerinfoarr[i][4];
						
						strwrite += '<div id="sb_o_name">';
						if(id>0) strwrite += '<a href=\"/forum/index.php?showuser='+id+'\">';
						strwrite += this.playerinfoarr[i][0];
						if(id>0) strwrite += '</a>';
						strwrite += '</div><div id="sb_o_frag">'+this.playerinfoarr[i][1]+'</div><div id="sb_o_time">'+this.parseTime(this.playerinfoarr[i][2])+'</div>';
					}
					this.dvPSInfo.innerHTML = strwrite;
				}else{
					this.dvPSInfo.innerHTML = '<div id="mesaj">Diğer oyuncular bulunamadı!</div>';
				}
			break;
			case 1:
				if(tmpobj2_s!=null){
					tmpobj2_s.id = "sunucu_bilgisi";
					this.dvPSInfo.style.display = "none";
					break;
				}else{
					tmpobj2.id = "sunucu_bilgisi_sel";
					if(tmpobj1_s!=null) tmpobj1_s.id = "oyuncular";
					this.dvPSInfo.style.display = "";
				}
			case -1:
				if(typ){
					if(tmpobj2) tmpobj2.id = "sunucu_bilgisi_sel";
					if(tmpobj1_s!=null) tmpobj1_s.id = "oyuncular";
					this.dvPSInfo.style.display = "";
				}
				if(this.serverinfoarr.length>0){
					/*serverinfoarr
					0 : sunucu adi
					1 : sunucu tipi
					2 : harita adi
					3 : oyuncu sayisi
					4 : max oyuncu
					*/
					strwrite = '<div id="sbilgi" style="padding-top:10px;">Ad: <span>'+this.serverinfoarr[0]+'</span></div>';
					strwrite += '<div id="sbilgi">Adres: <span>'+this.serverArr[this.serverId][2]+'</span></div>';
					strwrite += '<div id="sbilgi">Oyun tipi: <span>'+this.serverinfoarr[1]+'</span></div>';
					strwrite += '<div id="sbilgi">Oyuncu Sayısı: <span>'+this.serverinfoarr[3]+' / '+this.serverinfoarr[4]+'</span></div>';
					strwrite += '<div id="sbilgi">Harita: <span>'+this.serverinfoarr[2]+'</span></div>';
					//strwrite += '<div id="sbilgimap"><img src="/mapimgs/'+this.serverinfoarr[2]+'.jpg" style="this.style.display=\"none\";" alt="" /></div>';
					this.dvPSInfo.innerHTML = strwrite;
					
					tmpdiv = document.createElement('div');
					tmpdiv.id = "sbilgimap";
					
					tmpimg = document.createElement('img');
					tmpimg.src = '/mapimgs/'+this.serverinfoarr[2]+'.jpg';
					tmpimg.style.display = "none";
					tmpimg.onload = function(){ tmpimg.style.display=""; }
					
					tmpdiv.appendChild(tmpimg);
					this.dvPSInfo.appendChild(tmpdiv);
				}else{
					this.dvPSInfo.innerHTML = '<div id="mesaj">Sunucu ile iletişim kurulumadı!</div>';
				}
			break;
		}
	}
	this.parseTime = function(time){
		
		saindx = time.indexOf(" sa");
		dkindx = time.indexOf(" dk");
		snindx = time.indexOf(" sn");
		
		sa = Number(time.substr(0,saindx));
		dk = Number(time.substr(saindx==-1?1:saindx+4,dkindx-(saindx==-1?1:saindx+4)));
		sn = Number(time.substr(dkindx+4,snindx-(dkindx+4)));
		
		sa = saindx==-1?"00":(sa<10?"0"+sa:sa);
		dk = (dk<10?"0"+dk:dk);
		sn = (sn<10?"0"+sn:sn);
		
		return sa+":"+dk+":"+sn;
	}
}
