


	var sendReq = getXmlHttpRequestObject();
	var sendReqRanking = getXmlHttpRequestObject();
	var receiveReq = getXmlHttpRequestObject();
	var receiveReqUsers = getXmlHttpRequestObject();
	var lastMessage = 0;
	var lastUserUpdate = 1;
	var FlageSoundOn = -1;
	
	var mTimer;
	var usersTimer;
	
	var TimerNewMsg;
	var FlageMsg = 1;
	var FlageIsOnFocus = 1;
	var LoginType = -1;
	var GDivID_element
	var DivObj
	//Gets the browser specific XmlHttpRequest Object
	function getXmlHttpRequestObject() {
		if (window.XMLHttpRequest) {
			return new XMLHttpRequest();
		} else if(window.ActiveXObject) {
			return new ActiveXObject("Microsoft.XMLHTTP");
		} else {
			document.getElementById('p_status').innerHTML = 'Status: Cound not create XmlHttpRequest Object.  Consider upgrading your browser.';
		}
	}
		
	function getGameByID()
	{
			var err;
			try
			{
				getGameAdv();
			}
			catch(err) {}
				 
			getGameByIDAjax();
			
			try
			{
				mTimer = setTimeout('FuncCloseGameAdv();',15000);
			}
			catch(err) {}
				
	}
	
	function FuncCloseGameAdv()
	{
		
		var loc_div = document.getElementById('ShowGame');
		loc_div.style.display='';
		
		var loc_div = document.getElementById('ShowAdv');
		loc_div.style.display='none';
		
	}

    function getGameAdv()
    {
		var Banner1
		var loc_div = document.getElementById('ShowAdv');
		
		Banner1 = '<!-- BEGIN STANDARD TAG - 300 x 250 - ROS: 2all Placement 2 - DO NOT MODIFY --> ' 
		Banner1 = Banner1 + ' <IFRAME FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=NO WIDTH=468 HEIGHT=60 SRC="http://ad.z5x.net/st?ad_type=iframe&ad_size=468x60&section=767274"></IFRAME>'
		Banner1 = Banner1 + ' <!-- END TAG --> '
		//' loc_div.innerHTML = Banner1
    }
  
	function getGameByIDAjax() {
		var game_id
		
		game_id = document.getElementById('game_id').value 
		if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {
			// alert('readyState');
			// alert('getChat.asp?chat=1&last=' + lastMessage);
			
			// document.getElementById('DivLog').innerHTML = document.getElementById('DivLog').innerHTML + '<BR>' + 'getChat.asp?chat=' + chat_id + '&last=' + lastMessage
			
			receiveReq.open("GET", 'GameAjax.asp?ID=' + game_id + '', true);
			receiveReq.onreadystatechange = handleReceiveGame; 
			receiveReq.send(null);
		}			
	}

 
	//Function for handling the return of chat text
	function handleReceiveGame() {
 
		var getgamehtml;
		var loc_div;
		
		if (receiveReq.readyState == 4) {

			var loc_div = document.getElementById('ShowGame');
			var getgamehtml = receiveReq.responseText;
			loc_div.innerHTML = getgamehtml;
			// mTimer = setTimeout('getChatText();',2000); //Refresh our chat in 2 seconds
		}
	}
	
	
	//Add a message to the chat server.
	function funcCallURL(url) {
		
		if (sendReq.readyState == 4 || sendReq.readyState == 0) 
		
		{			
			var param
			//document.getElementById('DivLog').innerHTML = document.getElementById('DivLog').innerHTML + '<BR>' + 'getChat.asp?chat=' + chat_id + '&last=' + lastMessage
			//document.getElementById('DivLog').innerHTML = document.getElementById('DivLog').innerHTML + '<BR>' + param
			sendReq.open("POST", url, true);
			
			sendReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");   
//			sendReq.setRequestHeader("Content-length", param.length);   
			sendReq.setRequestHeader("Connection", "close"); 
			
			sendReq.onreadystatechange = handleCallURL; 
			
			sendReq.send();
		}
		
	}



	function handleCallURL() {
	
		// document.writeln(receiveReq.responseXML);
		// return 0;
		if (sendReq.readyState == 4 || sendReq.readyState == 0) 
		{   
			//document.getElementById('DivLog').innerHTML = sendReq.responsetext
		}	
		
		//Clear out the existing timer so we don't have 
		//multiple timer instances running.
 
		
	}

    function funcAjaxCall(url,ObjID) 
    
	{
		//return  confirm('האם אתה בטוח שברצונך yyy חבר זה?')
		
		
		DivObj = document.getElementById(ObjID);

		if (sendReq.readyState == 4 || sendReq.readyState == 0) {
			// url = 'Ajax_Check_UserName.asp?Name=' + Name + '&chkuser=1'
			sendReq.open("GET",url , true);
			sendReq.onreadystatechange = handleReceiveTextstatus; 
			sendReq.send(null);
		}
	}
	
	function handleReceiveTextstatus() 
	{
		
		//var x	
		if (sendReq.readyState == 4) 
		{
			// var ActDiv = document.getElementById('chkusr');
			var xmldoc = sendReq.responseText;
			//alert(xmldoc)
			DivObj.innerHTML = xmldoc;
		}
	}



function FuncGameAddToFavorite(GameID)
{
	var s;
	s = 'GameAjaxAction.asp?Action=1&ID=' + GameID;
	funcCallURL(s);
	document.getElementById('GameAddToFavorite').style.display = 'none';
	document.getElementById('GameAddToFavoriteRemove').style.display = '';
}


function FuncGameAddToFavoriteRemove(GameID)
{
	var s;
	s = 'GameAjaxAction.asp?Action=2&ID=' + GameID;
	funcCallURL(s);
	document.getElementById('GameAddToFavorite').style.display = '';
	document.getElementById('GameAddToFavoriteRemove').style.display = 'none';	
}

function SelectThis(obj)
{
	var err1;
	var CopiedTxt;
	try
	{
		obj.focus();
		obj.select();
	}
	catch(err1)
	{ }
	try
	{
		CopiedTxt = document.selection.createRange();
		CopiedTxt.execCommand("Copy");
	}
	catch(err1){}
}



	//Add a message to the chat server.
	function Comnt_sendComment() {
		var EntityType
		var EntityID
		var ComentTitle
		var ComentDesc
		var username
		EntityType = document.getElementById('EntityType').value 
		EntityID = document.getElementById('EntityID').value 
		LocUserName = document.getElementById('LocUserName').value 
		ComentTitle = document.getElementById('ComentTitle').value 
		ComentDesc = document.getElementById('ComentDesc').value 
		
		document.getElementById('LocUserName').style.backgroundColor = "#ffffff"; 
		document.getElementById('ComentTitle').style.backgroundColor = "#ffffff"; 
		document.getElementById('ComentDesc').style.backgroundColor = "#ffffff"; 
		if (LocUserName=='')
		{
			document.getElementById('LocUserName').style.backgroundColor = "#ffdddd" ; 
			return(0);
		}
		if (ComentTitle=='')
		{
			document.getElementById('ComentTitle').style.backgroundColor = "#ffdddd" ; 
			return(0);
		}
		if (ComentDesc=='')
		{
			document.getElementById('ComentDesc').style.backgroundColor = "#ffdddd" ; 
			return(0);
		}				
 
		//if(document.getElementById('ComentTitle').value == '') {
			// alert("You have not entered a message");
		//	return;
		//}
		
		if (sendReq.readyState == 4 || sendReq.readyState == 0) 
		
		{
			
			var param = 'ComentTitle=' + encodeURIComponent(ComentTitle);
			param += '&ComentDesc=' + encodeURIComponent(ComentDesc);
			param += '&LocUserName=' + encodeURIComponent(LocUserName);
			param += '&EntityType=' + String(EntityType) ;
			param += '&EntityID=' + String(EntityID);
			
			
			//document.getElementById('DivLog').innerHTML = document.getElementById('DivLog').innerHTML + '<BR>' + 'getChat.asp?chat=' + chat_id + '&last=' + lastMessage
			//document.getElementById('DivLog').innerHTML = document.getElementById('DivLog').innerHTML + '<BR>' + param
			sendReq.open("POST",'GameAjaxAction.asp?Action=3', true);
			 
							
			sendReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");   
			sendReq.setRequestHeader("Content-length", param.length);   
			sendReq.setRequestHeader("Connection", "close"); 
			
			sendReq.onreadystatechange = Comnt_sendComment_Handle; 
			
			sendReq.send(param);
			document.getElementById('AddCommentsForm').innerHTML = 'Sending....';
			
			
		}
		
		//document.getElementById('txt_message').focus();
	}
	
	
	
	//When our message has been sent, update our page.
	function Comnt_sendComment_Handle() {
	
		// document.writeln(receiveReq.responseXML);
		// return 0;
		if (sendReq.readyState == 4 || sendReq.readyState == 0) 
		{   
			document.getElementById('AddCommentsForm').innerHTML = "תודה !!!";
			
			document.getElementById('cmnts_SubShowCommentsByEntity').innerHTML = sendReq.responseText;
			
		}	
		
		//Clear out the existing timer so we don't have 
		//multiple timer instances running.		
	}	
	
 
