function update_game()
{
	if(window.XMLHttpRequest)
		xmlhttp=new XMLHttpRequest;
	else
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==4&&xmlhttp.status==200) {
			var response = xmlhttp.responseText;
			var game;
			if(response == "#new") {
				document.location = "http://www.gamestoenjoy.com/site/index.php?option=com_content&view=article&id=1257";
			}
			else if(response.indexOf("#found ") != -1) {
				game = response.substring(7, response.length-4);
				alert('The game ' + game + ' already exists in your favorite games');
			}
			else if(response.indexOf("#update ") != -1) {
				var game = response.substring(8, response.length-4);
				alert('The game ' + game + ' was added to your favorite games');
			}
		}
	};
	var url;
	if(document.location.toString().indexOf("www")>=0)
	url = "http://www.";
	else
	url ="http://";
	if(document.location.toString().indexOf("gamestoenjoy")>=0)
	url += "gamestoenjoy.com/site";
	else if(document.location.toString().indexOf("gametoenjoy")>=0)
	url += "gametoenjoy.com";
	var current_url = document.location.toString();
	var pos = current_url.indexOf("&id=");
	var game_id = current_url.substring(pos + 4);
	pos = game_id.indexOf("&");
	if(pos != -1)
	game_id = game_id.substring(0, pos);
	var new_url = url + "/user.php?d=" + (new Date).getTime() + "&u=" + game_id;
	xmlhttp.open("GET", new_url);
	xmlhttp.send();
}
function getAllChildren(a){return a.all?a.all:a.getElementsByTagName("*")}function squidoo_url(){var a="http://api.addthis.com/oexchange/0.8/forward/squidoo/offer?url=";gameUrl=escape(window.location.href);a+=gameUrl;a+="&title=";a+=document.title;return a}function techno_url(){var a="http://technorati.com/cosmos/search.html?url=";gameUrl=escape(window.location.href);a+=gameUrl;a+="&title=";a+=document.title;return a}function google_url(){var a="http://www.google.com/bookmarks/mark?op=edit&bkmk=";gameUrl=escape(window.location.href);a+=gameUrl;a+="&title=";a+=document.title;return a}function myspace_url(){var a="http://www.myspace.com/Modules/PostTo/Pages/?l=3&u=";gameUrl=escape(window.location.href);a+=gameUrl;a+="&t=";a+=document.title;a+="&c=Addicting game";return a}function reddit_url(){var a="http://reddit.com/submit?url=";gameUrl=escape(window.location.href);a+=gameUrl;a+="&title=";a+=document.title;return a}function del_url(){var a="http://del.icio.us/post?v=4&noui&jump=close&url=";gameUrl=escape(window.location.href);a+=gameUrl;a+="&title=";a+=document.title;return a}function digg_url(){var a="http://digg.com/submit?url=";gameUrl=escape(window.location.href);a+=gameUrl;a+="&title=";a+=document.title;a+="&media=news&topic=playable_web_games";return a}function facebook_url(){var a="http://www.facebook.com/sharer.php?u=";gameUrl=escape(window.location.href);a+=gameUrl;a+="&title=";a+=document.title;return a}function email_url(){var a="mailto:?subject=";a+=document.title;a+="&body=";gameUrl=escape(window.location.href);a+=gameUrl;return a}function twitter_url(){var a="http://twitter.com/home?status=";a+=document.title;a+=" ";gameUrl=escape(window.location.href);a+=gameUrl;return a}function random_games(){if(window.XMLHttpRequest)xmlhttp=new XMLHttpRequest;else xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4&&xmlhttp.status==200)document.getElementById("random_games").innerHTML=xmlhttp.responseText};var a;if(document.location.toString().indexOf("www")>=0)a="http://www.";else a="http://";if(document.location.toString().indexOf("gamestoenjoy")>=0)a+="gamestoenjoy.com/site";else if(document.location.toString().indexOf("gametoenjoy")>=0)a+="gametoenjoy.com";var b=a+"/random_games.php?dummy="+(new Date).getTime();xmlhttp.open("GET",b);xmlhttp.send()}function create_bookmarks(){document.write('<div style="width:160px; height: 50px; border: #E6E6E6 1px solid; background-color: #E5F0FA;">');if(navigator.appName=="Microsoft Internet Explorer")document.write('<table align="center"><tr><td height="12"></td></tr><tr><td><a title="Add Site to Favorites" href="javascript:;" onclick="window.external.AddFavorite(\'http://www.gamestoenjoy.com/site/\', \'Games to Enjoy\')"><img src="images/icon_share/add_site.png" width="16" height="16" border="0" alt="Add Site to Favorites" /></a></td><td width="20"></td><td><a title="Add Page to Favorites" href="javascript:;" onclick="window.external.addFavorite(top.location.href,document.title)"><img src="images/icon_share/add_page.png" width="16" height="16" border="0" alt="Add Page to Favorites" /></a></td><td width="20"></td><td><td><a title="Make Homepage" href="javascript:;" style="behavior:url(#default#homepage)" onclick="setHomePage(\'http://www.gamestoenjoy.com/site/\')"><img src="images/icon_share/make_homepage.png" width="16" height="16" border="0" alt="Make Homepage" /></a></td></tr></table>');else document.write('<table align="center"><tr><td height="12"></td></tr><tr><td><a title="Add Site to Bookmarks" href="javascript:;" onclick="window.sidebar.addPanel(\'Games to Enjoy\',\'http://www.gamestoenjoy.com/site/\',\'\')"><img src="images/icon_share/add_site.png" width="16" height="16" border="0" alt="Add Site to Bookmarks" /></a></td><td width="40"></td><td><a title="Add Page to Bookmarks" href="javascript:;" onclick="window.sidebar.addPanel(document.title,top.location.href,\'\')"><img src="images/icon_share/add_page.png" width="16" height="16" border="0" alt="Add Page to Bookmarks" /></a></td></tr></table>');document.write("</div>")}function more_games(){var a='<script src="http://www.gamestoenjoy.com/site/more_games.php"></script>';return a}function show_facebook_like(){url=escape(window.location.href);var a='<script src="http://www.gamestoenjoy.com/site/facebook_like.php?url='+url+'"></script>';return a}function show_rating(){var a=gup("id");var b='<script src="http://www.gamestoenjoy.com/site/voting/index.php?articleId='+a+'"></script>';return b}function gup(a){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var b="[\\?&]"+a+"=([^&#]*)";var c=new RegExp(b);var d=c.exec(window.location.href);if(d==null)return"";else return d[1]}function changeText(a,b){var c=document.all?1:0;var d=0;if(parseInt(navigator.appVersion)>=5){d=1}if(d){var e=document.getElementById(a);e.innerHTML=b}else if(c){document.all[a].innerHTML=b}}function handleResponse(){if(xmlhttp.readyState==4){if(xmlhttp.status==200){var a=xmlhttp.responseText;var b=new Array;if(a.indexOf("|")!=-1){b=a.split("|");changeText(b[0],b[1])}}}}function sndReq(a,b,c,d){var e=document.getElementById("unit_ul"+b);e.innerHTML='<div class="loading"></div>';xmlhttp.open("get","http://www.gamestoenjoy.com/site/voting/rpc.php?j="+a+"&q="+b+"&t="+c+"&c="+d);xmlhttp.onreadystatechange=handleResponse;xmlhttp.send(null)}function myXMLHttpRequest(){var a;try{a=new ActiveXObject("Msxml2.XMLHTTP")}catch(b){try{a=new ActiveXObject("Microsoft.XMLHTTP")}catch(c){a=false}}if(!a&&typeof XMLHttpRequest!="undefined"){try{var a=new XMLHttpRequest}catch(b){var a=false;alert("couldn't create xmlhttp object")}}return a}var xmlhttp;if(!xmlhttp&&typeof XMLHttpRequest!="undefined"){try{xmlhttp=new XMLHttpRequest}catch(e){xmlhttp=false}}var ratingAction={"a.rater":function(a){a.onclick=function(){var a=this.href.replace(/.*\?(.*)/,"$1");var b=a.split("&");var c=new Array;for(j=0;j<b.length;j++){var d=b[j].replace(/(.*)=.*/,"$1");var e=b[j].replace(/.*=(.*)/,"$1");c[d]=e}var f=c["q"];var g=c["j"];var h=c["t"];var i=c["c"];sndReq(g,f,h,i);return false}}};var Behaviour={list:new Array,register:function(a){Behaviour.list.push(a)},start:function(){Behaviour.addLoadEvent(function(){Behaviour.apply()})},apply:function(){for(h=0;sheet=Behaviour.list[h];h++){for(selector in sheet){list=document.getElementsBySelector(selector);if(!list){continue}for(i=0;element=list[i];i++){sheet[selector](element)}}}},addLoadEvent:function(a){var b=window.onload;if(typeof window.onload!="function"){window.onload=a}else{window.onload=function(){b();a()}}}};Behaviour.register(ratingAction);Behaviour.start();document.getElementsBySelector=function(a){if(!document.getElementsByTagName){return new Array}var b=a.split(" ");var c=new Array(document);for(var d=0;d<b.length;d++){token=b[d].replace(/^\s+/,"").replace(/\s+$/,"");if(token.indexOf("#")>-1){var e=token.split("#");var f=e[0];var g=e[1];var h=document.getElementById(g);if(f&&h.nodeName.toLowerCase()!=f){return new Array}c=new Array(h);continue}if(token.indexOf(".")>-1){var e=token.split(".");var f=e[0];var i=e[1];if(!f){f="*"}var j=new Array;var k=0;for(var l=0;l<c.length;l++){var m;if(f=="*"){m=getAllChildren(c[l])}else{m=c[l].getElementsByTagName(f)}for(var n=0;n<m.length;n++){j[k++]=m[n]}}c=new Array;var o=0;for(var p=0;p<j.length;p++){if(j[p].className&&j[p].className.match(new RegExp("\\b"+i+"\\b"))){c[o++]=j[p]}}continue}if(token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/)){var f=RegExp.$1;var q=RegExp.$2;var r=RegExp.$3;var s=RegExp.$4;if(!f){f="*"}var j=new Array;var k=0;for(var l=0;l<c.length;l++){var m;if(f=="*"){m=getAllChildren(c[l])}else{m=c[l].getElementsByTagName(f)}for(var n=0;n<m.length;n++){j[k++]=m[n]}}c=new Array;var o=0;var t;switch(r){case"=":t=function(a){return a.getAttribute(q)==s};break;case"~":t=function(a){return a.getAttribute(q).match(new RegExp("\\b"+s+"\\b"))};break;case"|":t=function(a){return a.getAttribute(q).match(new RegExp("^"+s+"-?"))};break;case"^":t=function(a){return a.getAttribute(q).indexOf(s)==0};break;case"$":t=function(a){return a.getAttribute(q).lastIndexOf(s)==a.getAttribute(q).length-s.length};break;case"*":t=function(a){return a.getAttribute(q).indexOf(s)>-1};break;default:t=function(a){return a.getAttribute(q)}}c=new Array;var o=0;for(var p=0;p<j.length;p++){if(t(j[p])){c[o++]=j[p]}}continue}if(!c[0]){return}f=token;var j=new Array;var k=0;for(var l=0;l<c.length;l++){var m=c[l].getElementsByTagName(f);for(var n=0;n<m.length;n++){j[k++]=m[n]}}c=j}return c}
