   var http_request = false;
   function makePOSTRequest(url, parameters,divid) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
     
      http_request.onreadystatechange = function alertContents(){		  
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(divid+"--"+http_request.responseText);
            result = http_request.responseText;
			if(divid!="nodivid"){
				document.getElementById(divid).innerHTML = result;            
			}
         } else {
            alert('There was a problem with the request.');
         }
      }else{
		if(divid!="nodivid"){
			document.getElementById(divid).innerHTML = "<img src='images/loading.gif'/>"; 
		 }
	  }
   }
	
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
	  
   };
 
	


	var http_request2 = false;
   function makePOSTRequest2(url, parameters,divid) {
      http_request2 = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request2 = new XMLHttpRequest();
         if (http_request2.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request2.overrideMimeType('text/xml');
            http_request2.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request2 = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request2 = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request2) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
     
      http_request2.onreadystatechange = function alertContents(){
      if (http_request2.readyState == 4) {
         if (http_request2.status == 200) {
            //alert(divid+"--"+http_request2.responseText);
            result = http_request2.responseText;
			if(divid!="nodivid"){
				document.getElementById(divid).innerHTML = result;            
			}
         } else {
            alert('There was a problem with the request...');
         }
      }else{
		if(divid!="nodivid"){
			document.getElementById(divid).innerHTML = "<img src='images/loading.gif'/>"; 
		 }
	  }
   }
	
      http_request2.open('POST', url, true);
      http_request2.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request2.setRequestHeader("Content-length", parameters.length);
      http_request2.setRequestHeader("Connection", "close");
      http_request2.send(parameters);
	  
   };


   var http_request3 = false;
   function makePOSTRequest3(url, parameters,divid) {
      http_request3 = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request3 = new XMLHttpRequest();
         if (http_request3.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request3.overrideMimeType('text/xml');
            http_request3.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request3 = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request3 = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request3) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
     
      http_request3.onreadystatechange = function alertContents(){
      if (http_request3.readyState == 4) {
         if (http_request3.status == 200) {
            //alert(divid+"--"+http_request3.responseText);
            result = http_request3.responseText;
			if(divid!="nodivid"){
				document.getElementById(divid).innerHTML = result;            
			}
         } else {
            alert('There was a problem with the request...');
         }
      }else{
		if(divid!="nodivid"){
			document.getElementById(divid).innerHTML = "<img src='images/loading.gif'/>"; 
		 }
	  }
   }
	
      http_request3.open('POST', url, true);
      http_request3.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request3.setRequestHeader("Content-length", parameters.length);
      http_request3.setRequestHeader("Connection", "close");
      http_request3.send(parameters);
	  
   };
   

 

/** below is the functions use to submit ratings */
	function submitRatingVotes(game_id, vote)	{
		var poststr = "gmid=" + encodeURI( game_id ) + 
							"&vote=" + encodeURI( vote ) ;
		makePOSTRequest('submit_rating_votes.php', poststr, 'rateing_vote');
	};

	/*function getRatingVotes(game_id)	{
		var poststr = "gameid=" + encodeURI( game_id ) ;
		makePOSTRequest('get_rating_votes.php', poststr, 'get_rateing_vote');
	};*/

/** above is the functions use to submit ratings */



/** below is the functions use to submit Email id subscription */
	function submitEmailSubscription(obj)	{
		var poststr = "email=" + encodeURI( obj ) ;
		if(validate_email(obj)==true){
			makePOSTRequest('submit_email_id_subscription.php', poststr, 'emailsubscribe');
		}
	};
/** above is the functions use to submit Email id subscription */




/** below is the functions use to submit Poll */
	function submitPollVote(option,obj)	{
		var poststr = "pollid=" + encodeURI( obj ) +
					 "&option=" + encodeURI( option ) ;
			makePOSTRequest('submit_poll_vote.php', poststr, 'poll_vote');
	};
/** above is the functions use to submit Poll */
/** below is the functions use to show Poll result*/
	function getPollVoteResult(obj){
		var poststr = "pollid=" + encodeURI( obj );
			makePOSTRequest('get_poll_vote_result.php', poststr, 'poll_vote');
	}
/** above is the functions use to show Poll result*/




/** below is the functions use to add Free Games Play count*/
	function addFGPlays(fgid)	{
		var poststr = "fgid=" + encodeURI( fgid ) ;
		makePOSTRequest('submit_free_game_plays.php', poststr, 'nodivid');
	};
/** above is the functions use to add Free Games Play count */


/** below is the functions use to add Game in My Games section */
	function addToMyGames(obj)	{
		var poststr = "gmid=" + encodeURI( obj ) ;
		makePOSTRequest('add_to_my_games.php', poststr, 'addtomygames');
	};
/** above is the functions use to add Game in My Games section */

/** below is the functions use to get game for My Games section */
	function getMyGames(obj)	{
		var poststr = "uid=" + encodeURI( obj ) ;
		makePOSTRequest('get_my_games.php', poststr, 'gettomygames');
	};
/** above is the functions use to get Game for My Games section */


	function specialcharcheck(obj,alerttxt){
		var iChars = "!@#$%^&*()+=-[]\\\'/{}|\":<>?";

		  for (var i = 0; i < obj.length; i++) {
			if (iChars.indexOf(obj.charAt(i)) != -1) {
			alert ("Your "+alerttxt+" has special characters. \nThese are not allowed.\n Please remove them and try again.");
			return false;
			}
		  }
	};
   
   function submit_comment(gameid) {
   var userid = document.getElementById("userid").value;
   var comment = document.getElementById("txtcomment").value;
    if(comment==""){
		alert("Please enter your comment");
	}else if(comment.length > 150){
		alert("Please enter your comment less than 150 characters");
	}else if(specialcharcheck(comment, "Comment")==false){
	}else{

	  var poststr = "gmid=" + encodeURI( gameid ) +
						"&userid=" + encodeURI( userid ) +
						"&txtcomment=" + encodeURI( document.getElementById("txtcomment").value );
      makePOSTRequest('submit_comment.php', poststr,'writeCommentresult');
	
	//return true;
	}//end of else

   };

   function submit_comment_on_user(from_uid) {
   var userid = document.getElementById("uid").value;
   var comment = document.getElementById("txtcomment").value;
    if(comment==""){
		alert("Please enter your comment");
	}else if(comment.length > 150){
		alert("Please enter your comment less than 150 characters");
	}else if(specialcharcheck(comment, "Comment")==false){
	}else{

	  var poststr = "from_uid=" + encodeURI( from_uid ) +
					"&uid=" + encodeURI( userid ) +
					"&txtcomment=" + encodeURI( document.getElementById("txtcomment").value );
      makePOSTRequest('submit_comment_on_user.php', poststr,'writeCommentresult');
	
	//return true;
	}//end of else

   };


/** below are the functions use to fetch Comments */
    function getComments(obj) {
		if(obj==0){
			document.getElementById('get_comments').innerHTML = "";
		}else{
			var poststr = "gmid=" + encodeURI( obj ) ;
			makePOSTRequest('getComments.php', poststr,'get_comments');
		}
	};

	function getComments_next(obj,limit) {
		if(obj==0){
			document.getElementById('get_comments').innerHTML = "";
		}else{
			var poststr = "gmid=" + encodeURI( obj ) +
								"&limit=" + encodeURI( limit ) ;
			makePOSTRequest('getComments.php', poststr,'get_comments');
			}		
	};

	function showCommentPannel(obj){
		if(obj=="reviews"){
			document.getElementById('reviews').style.display="block";
			document.getElementById('postcomment').style.display="none";
			//document.getElementById('txtcomment').value="";
			getComments(document.getElementById('hidden_gmid').value);
		}else{
			document.getElementById('reviews').style.display="none";
			document.getElementById('postcomment').style.display="block";
		}
	};
/** above are the functions use to fetch Comments */



/** below are the functions use to fetch Comments On User */
    function getCommentsOnUser(obj, action) {
		if(obj==0){
			document.getElementById('get_comments_on_user').innerHTML = "";
		}else{
			var poststr = "uid=" + encodeURI( obj ) +
						  "&action=" + encodeURI( action );
			makePOSTRequest('getCommentsOnUser.php', poststr,'get_comments_on_user');
		}
	};

	function getCommentsOnUser_next(obj,limit, action) {
		if(obj==0){
			document.getElementById('get_comments_on_user').innerHTML = "";
		}else{
			var poststr = "uid=" + encodeURI( obj ) +
						  "&limit=" + encodeURI( limit ) +
						  "&action=" + encodeURI( action );
			makePOSTRequest('getCommentsOnUser.php', poststr,'get_comments_on_user');
		}		
	};






	function addFriend(fid) {

			var poststr = "fid=" + encodeURI( fid ) ;
			makePOSTRequest('add_friends.php', poststr,'addfrienddiv');
	};

	function getFriend(obj) {
		if(obj==0){
			document.getElementById('dispfrindslistidiv').innerHTML = "";
		}else{
			var poststr = "uid=" + encodeURI( obj ) ;
			makePOSTRequest3('my_friend_list_include.php', poststr,'dispfrindslistidiv');
		}
	};

	function getFriend_next(obj,limit) {
		if(obj==0){
			document.getElementById('dispfrindslistidiv').innerHTML = "";
		}else{
			var poststr = "uid=" + encodeURI( obj ) +
				"&limit=" + encodeURI( limit ) ;
			makePOSTRequest('my_friend_list_include.php', poststr,'dispfrindslistidiv');
		}
					
	};


	function showCommentPannel_on_user(obj){
		if(obj=="reviews"){
			document.getElementById('reviews').style.display="block";
			document.getElementById('postcomment').style.display="none";
			//document.getElementById('txtcomment').value="";
			getCommentsOnUser(document.getElementById('hidden_uid').value);
		}else{
			document.getElementById('reviews').style.display="none";
			document.getElementById('postcomment').style.display="block";
		}
	};
/** above are the functions use to fetch Comments On User */




/** below are the functions use to fetch User Game plays detail i.e points detail*/
    function getPointsDetail(obj) {
		if(obj==0){
			document.getElementById('get_points_detail').innerHTML = "";
		}else{
			var poststr = "uid=" + encodeURI( obj ) ;
			makePOSTRequest2('getPointDetails.php', poststr,'get_points_detail');
		}
	};

	function getPointsDetail_next(obj,limit) {
		if(obj==0){
			document.getElementById('get_points_detail').innerHTML = "";
		}else{
			var poststr = "uid=" + encodeURI( obj ) +
								"&limit=" + encodeURI( limit ) ;
			makePOSTRequest2('getPointDetails.php', poststr,'get_points_detail');
			}		
	};
/** above are the functions use to fetch User Game plays detail i.e points detail*/



function findQuickLink(id){
	window.location.href="games.php?gmid="+document.getElementById(id).value;
}

function findQuickLinkCat(id){
	window.location.href="category.php?catid="+document.getElementById(id).value;
}



function validate_email(email) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = email;
   if(reg.test(address) == false) {
      alert('Invalid Email Address');
      return false;
   }else{
	   return true;
   }
}

//*** below is the code to BookMark the URL
function addToBookmark(title, url) {

        if (window.sidebar) { // Mozilla Firefox Bookmark
                window.sidebar.addPanel(title, url,"");
                return false;
        } 
        else if( window.external ) { // IE Favorite
                window.external.AddFavorite( url, title); 
                return false;
        }
        else if(window.opera && window.print) { // Opera Hotlist
                var elem = document.createElement('a');
                elem.setAttribute('href',url);
                elem.setAttribute('title',title);
                elem.setAttribute('rel','sidebar');
                elem.click();
                return false;
        }
 }



/** below is the functions use to add Time Spend on each game in secounds*/
	function addTimeSpendCount(gid, ts)	{
		var poststr = "gid=" + encodeURI( gid ) +
					  "&ts=" + encodeURI( ts ) ;
		makePOSTRequest('submit_time_spend_count.php', poststr, 'nodivid');
	};
/** above is the functions use to add Time Spend on each game in secounds*/


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
