<?xml version="1.0" encoding="UTF-8"?>
<Module> 
  <ModulePrefs title="WHO HAS THE BIGGEST BRAIN?" height="220" thumbnail="http://static.playfish.com/game/brain/igoogle/brain_icon.jpg" description="__MSG_brain_desc__" author="Playfish" author_email="info@playfish.com" screenshot="http://static.playfish.com/game/brain/igoogle/brain_screenshot.jpg" author_location="London" author_affiliation="NA" title_url="http://forum.playfish.com/" author_aboutme="N/A" author_link="http://www.playfish.com" author_quote="N/A">
	<icon>http://static.playfish.com/game/brain/igoogle/brain_icon.jpg</icon>
	<Require feature="opensocial-0.8"/>
	<Require feature="views"/>
	<Require feature="flash"/> 
	<Require feature="dynamic-height"/>
	<Optional feature="content-rewrite">
		<Param name="include-urls"/>

		<Param name="exclude-urls">.*</Param>

		<Param name="include-tags"/>
	</Optional>
	 <Locale lang="en" messages="http://static.playfish.com/game/brain/igoogle/ALL_ALL.xml"/>
	 <Locale lang="es" messages="http://static.playfish.com/game/brain/igoogle/es_ALL.xml"/>
	 <Locale lang="it" messages="http://static.playfish.com/game/brain/igoogle/it_ALL.xml"/>
	 <Locale lang="fr" messages="http://static.playfish.com/game/brain/igoogle/fr_ALL.xml"/>
	 <Locale lang="de" messages="http://static.playfish.com/game/brain/igoogle/de_ALL.xml"/>
	 <Locale lang="tr" messages="http://static.playfish.com/game/brain/igoogle/tr_ALL.xml"/>
	 <Locale lang="no" messages="http://static.playfish.com/game/brain/igoogle/no_ALL.xml"/>
	 <Locale lang="da" messages="http://static.playfish.com/game/brain/igoogle/da_ALL.xml"/>
	 <Locale lang="nl" messages="http://static.playfish.com/game/brain/igoogle/nl_ALL.xml"/>
	 <Locale lang="el" messages="http://static.playfish.com/game/brain/igoogle/el_ALL.xml"/>
  </ModulePrefs>
	
  <Content type="html" view="canvas"><![CDATA[
	<script type="text/javascript">
		var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
		document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
	</script>
	<script type="text/javascript">
		try {
		var pageTracker = _gat._getTracker("UA-2883265-13");
		pageTracker._trackPageview();
		} catch(err) {}
	</script>
	<style type="text/css">
		div#canvas_wrapper { width:770px; float:left; margin:0; padding:0; } 
		div#content_left { float:left; height:700px; width:115px; background-image:url(http://static.playfish.com/game/brain/sidebar/bg.jpg); }
		div#content_center { float:left; width:640px; height:700px; margin-left:5px; }
		div#content_links { float:left; width:760px; clear:both; height:60px; text-align:center; }
		#content_links p { font-family:tahoma,verdana,arial,sans-serif; font-size:11px; }
		a { color:#3e5ea0; text-decoration:none; font-weight:bold;}
		a:hover { text-decoration:underline; } 
		div#buttons { margin:50px 0 0 0; border:0; }

		div#profile_wrapper { width:770px; float:left; margin:0; padding:0; } 

	</style>

	<script type="text/javascript">
		function showGame() {
			document.getElementById("profile_wrapper").style.display = "none";
			document.getElementById("canvas_wrapper").style.display = "block";
		}
		function callbackInvite(resp) {
			
		};

		function shareApp() {
			var invites = new Array(1);
			var message = opensocial.newMessage("Join the fun in this highly addictive brain training game!");
			opensocial.requestShareApp(invites, message, callbackInvite);
		};
	</script>

	<div id="canvas_wrapper">
		<div id="content_left">
    			<div id="buttons">
			<a target="_blank" href="http://www.playfish.com/support"><img src="http://static.playfish.com/game/brain/sidebar/menu_faq.png" onmouseover="javascript:this.src='http://static.playfish.com/game/brain/sidebar/menu_faq_hover.png';" onmouseout="javascript:this.src='http://static.playfish.com/game/brain/sidebar/menu_faq.png';" border="0" /></a><br />
			<a target="_blank" href="http://forum.playfish.com/"><img src="http://static.playfish.com/game/brain/sidebar/menu_forum.png" onmouseover="javascript:this.src='http://static.playfish.com/game/brain/sidebar/menu_forum_hover.png';" onmouseout="javascript:this.src='http://static.playfish.com/game/brain/sidebar/menu_forum.png';" border="0" /></a><br />
			<a href="javascript:shareApp()"><img src="http://static.playfish.com/game/brain/sidebar/menu_invite.png" onmouseover="javascript:this.src='http://static.playfish.com/game/brain/sidebar/menu_invite_hover.png';" onmouseout="javascript:this.src='http://static.playfish.com/game/brain/sidebar/menu_invite.png';" border="0" /></a><br /> 
			<br />
			</div>
		</div>
		<div id="content_center">
		</div>
		<div id="content_links">
    			<p>
			<a target="_blank" href="http://forum.playfish.com/">Discuss Game</a>  |  <a href="javascript:shareApp()">Invite Friends</a>  |  <a target="_blank" href="http://www.playfish.com/support">FAQ</a>  |  <a href="http://www.playfish.com/?page=advertisers">Advertise</a>  |  <a href="http://static.playfish.com/legal/terms.html">Terms of service</a>
			<br />If the game doesn't load or you experience problems, please <a href="http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash&Lang=English">update your version of Flash </a>
			</p>
		</div>
	</div>
	<div id="profile_wrapper">

	</div>
	

	<script type="text/javascript">

		var profile_loaded = false;
		              
 		function invite() {
			shareApp();
		};

		function callbackProfile(response){
			var data = response.text;
			var open_t = data.indexOf("<style>");
			var close_t = data.indexOf("</style>");
			var content = data.substr(0, open_t);
			content += data.substr(close_t + 8);
			var style = document.createElement("style");
			var text = data.substring(open_t + 7, close_t);
			style.setAttribute("type", "text/css");
			if (style.styleSheet) {
				style.styleSheet.cssText = text;
		       }
			else {
				style.appendChild(document.createTextNode(text));
			}
			if (!profile_loaded) {
				document.getElementsByTagName("head")[0].appendChild(style);
				profile_loaded = true;
			}

			document.getElementById("profile_wrapper").innerHTML = content;
			document.getElementById("canvas_wrapper").style.display = "none";
			document.getElementById("profile_wrapper").style.display = "block";
		};


  		function profile(id) {
			var url = "http://75.101.203.126/g/ig/brain/tab?pf_uid="+id + "&" + Math.floor(Math.random()*1000000);
			var params = {};
			params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.TEXT;
			params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.GET;
			params[gadgets.io.RequestParameters.AUTHORIZATION] = gadgets.io.AuthorizationType.SIGNED;
			gadgets.io.makeRequest(url, callbackProfile, params);	
		}

		function JSCallBack() {
			
		};

		function callbackCanvas(response){
			var params = JSON.parse(response.text);
			var url = params['loaderUrl'];
			
			//url = "http://static.playfish.com/game/brain/swf/brain_gameloader_2_5_2.swf";
			//var flashvars = params['flashvars'];
			//flashvars  = flashvars.replace(/brain_game_2_4_9.swf/gi, 'brain_game_2_5_2.swf');
		        //params['flashvars'] = flashvars;
						
			gadgets.flash.embedFlash(url, content_center, 7, params);
		};

       		function makeCachedRequest(url, callback, params, refreshInterval) {
  			var ts = new Date().getTime();
  			var sep = "?";
  			if (refreshInterval && refreshInterval > 0) {
    				ts = Math.floor(ts / (refreshInterval * 1000));
  			}
  			if (url.indexOf("?") > -1) {
    			sep = "&";
  			}
  			url = [ url, sep, "nocache=", ts ].join("");
  			gadgets.io.makeRequest(url, callback, params);
		}
		
		function ownerResponse(data) {
			var owner = data.get('owner');
			if (owner.hadError()) {
				if (owner.getErrorCode() == 'forbidden' ||
					owner.getErrorCode() == '403') {
					doACLMessage();
				} else {
					doGenericError();
				}
			} else if (owner.getData().getId() == -1) {
					doLoginMessage();
			} else {
					load();
			}
		}

		function doACLMessage() {
			document.getElementById('content_center').innerHTML = '<img src="http://static.playfish.com/game/brain/igoogle/acl_canvas.jpg">';
		}

	       function doLoginMessage() {
			document.getElementById('content_center').innerHTML = '<img src="http://static.playfish.com/game/brain/igoogle/login.jpg">';
		}

		function doNonSocialMessage() {
			document.getElementById('content_center').innerHTML = '<img src="http://static.playfish.com/game/brain/igoogle/nonsocial_canvas.jpg">';
		}

		function doGenericError() {
			document.getElementById('content_center').innerHTML = '<img src="http://static.playfish.com/game/brain/igoogle/genericerror_canvas.jpg">';
		}

		function getOwner() {
			var u = gadgets.util;
			if (u.hasFeature('opensocial-0.8')) {
				var req = opensocial.newDataRequest();
				req.add(req.newFetchPersonRequest(opensocial.IdSpec.PersonId.OWNER), 'owner');
				req.send(ownerResponse);
			} else {
				doNonSocialMessage();
			}
		}


		function load() {
			  var urlParams = gadgets.util.getUrlParameters();
			  var st = urlParams.st;
			  var prefs = new gadgets.Prefs();
			  var url = "http://75.101.203.126/g/ig/brain/iframe?lang=" + prefs.getLang() + "&rand=" + Math.floor(Math.random()*1000000);
			  var params = {};
			  params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.TEXT;
			  params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.GET;
			  params[gadgets.io.RequestParameters.AUTHORIZATION] = gadgets.io.AuthorizationType.SIGNED;
			  //gadgets.io.makeRequest(url, callbackCanvas, params);
			  makeCachedRequest(url, callbackCanvas, params, 1);
			
		};
		gadgets.util.registerOnLoadHandler(function() { getOwner(); });

	</script>
	
    ]]>  
  </Content>

<Content type="html" view="home">
    <![CDATA[
       <script type="text/javascript">

    function goToView(dest) {
      var supported_views = gadgets.views.getSupportedViews();
      gadgets.views.requestNavigateTo(supported_views[dest]);
    };
</script>

<!-- preload images for mouseover -->
<script type="text/jscript">
	var image = new Image();
	image.src = "http://static.playfish.com/game/brain/igoogle/button_mouseover.gif";
	
	image = new Image();
	image.src = "http://static.playfish.com/game/brain/igoogle/button.gif";

</script>

       <script type="text/javascript">
		function showContent(data) {
			var open_t = data.indexOf("<style>");
			var close_t = data.indexOf("</style>");
			var content = data.substr(0, open_t);
			content += data.substr(close_t + 8);
			var style = document.createElement("style");
			var text = data.substring(open_t + 7, close_t);
			style.setAttribute("type", "text/css");
			if (style.styleSheet) {
				style.styleSheet.cssText = text;
		       }
			else {
				style.appendChild(document.createTextNode(text));
			}
			document.getElementsByTagName("head")[0].appendChild(style);

			var handle = document.getElementById("dom_handle");
			var content_div = document.createElement("div");
			content_div.innerHTML = content;
			handle.appendChild(content_div);

		}


		function callbackHome(response){
			showContent(response.text);
		};

		function loadHome() {
			  var url = "http://75.101.203.126/g/ig/brain/profile?" + Math.floor(345);
			  var params = {};
			  params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.TEXT;
			  params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.POST;
			  params[gadgets.io.RequestParameters.AUTHORIZATION] = gadgets.io.AuthorizationType.SIGNED;

			  gadgets.io.makeRequest(url, callbackHome, params);

			  
		};
		
		function viewerResponse(data) {
			var viewer = data.get('viewer');
			if (viewer .hadError()) {
				if (viewer .getErrorCode() == 'forbidden' ||
					viewer .getErrorCode() == '403') {
					doACLMessage();
				} else {
					doGenericError();
				}
			} else if (viewer .getData().getId() == -1) {
					doLoginMessage();
			} else {
					loadHome();
			}
		}

		function doACLMessage() {
			document.getElementById('dom_handle').innerHTML = '<center><img style="border:1px solid #78d4ae;" src="http://static.playfish.com/game/brain/igoogle/acl_home.jpg"></center>';
		}

	       function doLoginMessage() {
			document.getElementById('dom_handle').innerHTML = '<center><img style="border:1px solid #78d4ae;"src="http://static.playfish.com/game/brain/igoogle/login_home.jpg"></center>';
		}

		function doNonSocialMessage() {
			document.getElementById('dom_handle').innerHTML = '<center><img style="border:1px solid #78d4ae;"style="border:1px solid #78d4ae;" src="http://static.playfish.com/game/brain/igoogle/nonsocial_home.jpg"></center>';
		}

		function doGenericError() {
			document.getElementById('dom_handle').innerHTML = '<center><img style="border:1px solid #78d4ae;"src="http://static.playfish.com/game/brain/igoogle/genericerror_home.jpg"></center>';
		}


		function getViewer() {
			var u = gadgets.util;
			if (u.hasFeature('opensocial-0.8')) {
				var req = opensocial.newDataRequest();
				req.add(req.newFetchPersonRequest(opensocial.IdSpec.PersonId.VIEWER), 'viewer');
				req.send(viewerResponse);
			} else {
				loadHome();
			}
		}
		gadgets.util.registerOnLoadHandler(function() { getViewer(); });

	</script>
	<div id="dom_handle"></div>
 ]]> 
</Content>

</Module>