		/**
		 * Ajax.Request.abort
		 * extend the prototype.js Ajax.Request object so that it supports an abort method
		 */
		Ajax.Request.prototype.abort = function() {
		    // prevent and state change callbacks from being issued
		    this.transport.onreadystatechange = Prototype.emptyFunction;
		    // abort the XHR
		    this.transport.abort();
		    // update the request counter
		    Ajax.activeRequestCount--;
		    if (Ajax.activeRequestCount < 0) {
		        Ajax.activeRequestCount = 0;
		    }
		};

		
		function doAjax2(method,url,params,id_msg,id_temp,tempmsg,next){
					
			return new Ajax.Request(url,
			{
				method: method,
				parameters: params,
				onCreate: function(transport){
					if(id_temp)
						id_temp.innerHTML=tempmsg;
				
				},
				onSuccess: function(transport){
					if(id_temp)
						id_temp.innerHTML="";
					if(id_msg){
						id_msg.innerHTML=transport.responseText;
					//	id_msg.scrollTop = id_msg.scrollHeight;
					}
					if(next)
					    eval(unescape(next));
				},
				onFailure: function(transport){
					if(showtemp)
						showtemp.innerHTML="<span style=\"color:red\">"+transport.responseText+"</span>";
					else
						id_msg.innerHTML="<span style=\"color:red\">"+transport.responseText+"</span>";
				}
			});
			
								
		}


		
		function doAjax(method,params,id_msg,id_data,showtemp){
			
			url='./index.php';
			new Ajax.Request(url,
			{
				method: method,
				parameters: params,
				onCreate: function(transport){
					if(showtemp)
						showtemp.innerHTML="loading...";
				
				},
				onSuccess: function(transport){
					if(showtemp)
						showtemp.innerHTML="";
					if(id_msg){
						id_msg.innerHTML=transport.responseText;
					//	id_msg.scrollTop = id_msg.scrollHeight;
					}
				},
				onFailure: function(transport){
					if(showtemp)
						showtemp.innerHTML="<span style=\"color:red\">"+transport.responseText+"</span>";
					else
						id_msg.innerHTML="<span style=\"color:red\">"+transport.responseText+"</span>";
				}
			});
			
								
		}
		
		function doContinuousAjax(method,params,t,showtemp){
			url='./index.php';
			//alert(1);
			new Ajax.PeriodicalUpdater(t,url,
			{
				method: method,
				parameters: params,
				onCreate: function(transport){
			
				},
				onSuccess: function(transport){
					t.innerHTML=transport.responseText;
				},
				onFailure: function(transport){
					t.innerHTML="<span style=\"color:red\">Failed</span>";
				}
			});
		}
				
		
		function myRequest(type,params,id_msg,id_data,showtemp){
			doAjax(type,params,id_msg,id_data,showtemp);
			return false;
		}
		
		

		function sendInvite(id){
			var str='';

			for (i=0; i<document.selectedUsers.length; i++){
			    if(document.selectedUsers.elements[i].name=="group")
			     	if(document.selectedUsers.elements[i].checked == true)
			     		str=str+document.selectedUsers.elements[i].value+';';
			}
			url='./index.php';
			

			new Ajax.Request(url,
			{
				method: 'post',
				parameters: 'd=list&_event_Email=Email&names='+str+"&msg="+encodeURIComponent(document.selectedUsers.playerlookup_msg.value),
				onCreate: function(transport){
					document.getElementById('msg').innerHTML="<img src=./images/mail.gif>";
				},
				onSuccess:  function(transport){
					document.getElementById('msg').style.color='Green';
					document.getElementById('msg').innerHTML='Invitations sent!';
				},
				onFailure:  function(transport){
					document.getElementById('msg').style.color='Red';
					document.getElementById('msg').innerHTML='Sending invitations failed!';
				}
			});

			//alert(str);
			
			return false;
		}


		function addChoice(val){
			if(val.length>0 && val!=null){
				d = document.getElementById("users");

				var newdiv=new Element('div',{name:'tempdiv'});
				var cb=new Element('input',{type:'checkbox',name:'group',checked:'true',value:val});

				myregexp = new RegExp(/^(\d{1,})_(.{0,})/);
				reg=myregexp.exec(val);
				if(reg){
					txtVal=reg[2];
					
				}
				else
					txtVal=val;

				var txt=document.createTextNode(txtVal);
				newdiv.appendChild(cb);
				newdiv.appendChild(txt);

				d.appendChild(newdiv);
			}
			hideMenu(document.getElementById("player_results"));
			
			return false;
		}

		function removeUsers(){
			var more=true;
			while(more){
				more=false;
		  		for (i=0; i<document.selectedUsers.length; i++){
				     if(document.selectedUsers.elements[i].name=="group")
				     	if(document.selectedUsers.elements[i].checked == true)
				     	{
				     		var parent=document.selectedUsers.elements[i].ancestors();
				     		document.getElementById("users").removeChild(parent[0]);
				     		more=true;
				     	}
				}
			}
			return false;
		}

		function changeAll(){
			if(document.selectedUsers.selAll.value==1)
				document.selectedUsers.selAll.value=0;
			else
				document.selectedUsers.selAll.value=1

			for (i=0; i<document.selectedUsers.length; i++){
			    if(document.selectedUsers.elements[i].name=="group"){
			    	if(document.selectedUsers.selAll.value==0)
			    		document.selectedUsers.elements[i].checked = false;
			    	else
			    		document.selectedUsers.elements[i].checked = true;
				}
			}
		}
		
		

		function hideMenu(id){
			id.style.left=-500;
			id.style.top=-500;
			//alert(id.style.left);

		}

		function showMenu(id){
			var src=document.getElementById('input');
			var offset=src.positionedOffset();
			id.style.top=0+parseInt(src.style.height)+offset[1];
			id.style.left=0+parseInt(src.style.height)+offset[0];

		}

		function MouseOver(id){
			id.style.backgroundColor="#AAF";
		}

		function MouseOut(id){
			id.style.backgroundColor="#FFF";
		}

		function MouseUp(id,val,name){
			addChoice(val+'_'+name);
		}
		

		function IsEmpty(aTextField) {
		   if ((aTextField.value.length==0) ||
		   (aTextField.value==null)) {
		      return true;
		   }
		   else { return false; }
		}
		

		function getTime(endtime) {
			now = new Date();
			endtime=endtime.match(/^(....).(.{1,2}).(.{1,2})/);
			y2k = new Date();
			y2k.setFullYear(eval(endtime[1]),eval(endtime[2])-1,eval(endtime[3]));
			days = (y2k - now) / 1000 / 60 / 60 / 24;
			daysRound = Math.floor(days);
			
			hours = (y2k - now) / 1000 / 60 / 60 - (24 * daysRound);
			hoursRound = Math.floor(hours);
			minutes = (y2k - now) / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound);
			minutesRound = Math.floor(minutes);
			seconds = (y2k - now) / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound);
			secondsRound = Math.round(seconds);
			sec = (secondsRound == 1) ? " second." : " seconds.";
			min = (minutesRound == 1) ? " minute" : " minutes, ";
			hr = (hoursRound == 1) ? " hour" : " hours, ";
			dy = (daysRound == 1) ? " day" : " days, "
			document.write(Math.floor(days/7));
		}

		function changeDate(endtime){
			endtime=endtime.replace(/^(....).(.{1,2}).(.{1,2})/,"$2/$3/$1")
			endtime=endtime.replace(/(\d\d:\d\d:\d\d)/,"");
			document.write(endtime);
		}

		function writeSubstring(str,len){
			document.write(str.substring(0,len));
		}
		
	
		
		function goToTrade(pid,cid){
			changeTab('TransactionsTab_body', 'TransactionsTab_tab');

			changeYourSel(pid,cid);
			getCelebs($('trade_form'),$('hiddenYourUserIdGame'),cid);
			return false;
		}

		function changeYourSel(pid,cid){
			var els=$('hiddenYourUserIdGame').descendants();
			els.each(function(item){
				if(item.value==pid)
					item.selected=true;
				else
					item.selected=false;
			});
		}
		function getCelebs(f,id,cid){
			s="hiddenUserGameId="+id.value+"&_event_trade_change=''&hiddenCelebId="+cid;
			return myRequest('post',s,$('selYourCelebs_wrapper'),'test','1');

		}
		
		
		

		function changeDate(endtime){
			endtime=endtime.replace(/^(....).(.{1,2}).(.{1,2})/,"$2/$3/$1")
			endtime=endtime.replace(/(\d\d:\d\d:\d\d)/,"");
			document.write(endtime);
		}
		function changeDateTime(endtime){
			endtime=endtime.replace(/^(....).(.{1,2}).(.{1,2})/,"$2/$3/$1")
			//endtime=endtime.replace(/(\d\d:\d\d:\d\d)/,"");
			document.write(endtime);
		}		
		
		function changeImage(id,val,name,current){

			if(name!=current){
			if(val==0)
					id.className=name+'2_img';
			else
					id.className=name+'_img';
			}
		}
		
		function getPlace(num){
			var suf;
			switch(num){
				case 1:
					suf='st';
					break;
				case 2:
					suf='nd';
					break;
				case 3:
					suf='rd';
					break;
				default:
					suf='th';
					break;
			}
			document.write(num+suf);
		}

		function titlebar(msg1,msg2)
		{
			//var msg  = "Your message here --- hscripts.com";
			//var speed = 500;

			//var msg1  = "    ****** "+msg+" ******";
			//var msg2  = "    ------- "+msg+" -------";

			if(msg_val == 0){
				masg = msg1;
				msg_val = 1;
			}
			else if(msg_val == 1){
				masg = msg2;
				msg_val = 0;
			}

			document.title = masg;
			//alert(0);
			
			//alert("titlebar("+pos+",'"+msg1+"','"+msg2+"'"+speed+")");
			//title_timer = window.setTimeout("titlebar("+pos+",'"+msg1+"','"+msg2+"',"+speed+")",speed);
		}
		
		
		var lastpubmsg='';
		var title_timer=null;
		var msg_val=0;
		
		function checkmsgupdate(){
			
			url='./index.php';
			param="_event_gameforum_checkNewMsg=''&gameId=-1";
		//	alert(url);
			new Ajax.PeriodicalUpdater(lastpubmsg,url,
			{
				method: 'POST',	
				parameters: param,
				onSuccess: function(transport){
				//	alert(transport.responseText);
					if(transport.responseText=='true'){
						
						clearInterval(title_timer);
						title_timer=setInterval("titlebar('Fanlebrity.com','***NEW MESSAGE**')",500);
					}
					else
						clearInterval(title_timer);
				}
			});

		}
		
		

		function DHTMLSound(el,surl) {
			el.innerHTML="<embed src='"+surl+"' hidden=true autostart=true loop=false>";
		}
		
	

