					function trackAvatar (tClick){
						omniCall.setRepProps("pageName=" + tClick);
						sendReportingCall({setOverrides:{s_pageName:(omniCall.pathToString('p')+omniCall.pageName),s_hier2:(omniCall.pathToString('h'))}});
					}
		
					var MyArray;
					var MyArtArray;
					var MyChapterArray;
					var MyHighScoreArray;
					var sexe;
					var race;
					var skipToGame;
					
					function makeTest(perso){
						window.alert(perso)
					}
					
					function DeleteCookie(number,path,domain) {
						name = "avatar"+number;
						if (readCookie(name)) {
							document.cookie = name + "=" +
							"; expires=Thu, 01-Jan-70 00:00:01 GMT";
						}
						name = "avatarart"+number;
						if (readCookie(name)) {
							document.cookie = name + "=" +
							"; expires=Thu, 01-Jan-70 00:00:01 GMT";
						}
						//////////////////////////////
						name = "avatarchapter"+number;
						if (readCookie(name)) {
							document.cookie = name + "=" +
							"; expires=Thu, 01-Jan-70 00:00:01 GMT";
						}
						//////////////////////////////
					}
					function ResetChapterCookie(perso){
						name = "avatarchapter"+perso;
						if (readCookie(name)) {
							document.cookie = name + "=" +
							"; expires=Thu, 01-Jan-70 00:00:01 GMT";
						}
					}
					function readCookie(name){
						var cookieValue = "";
						var search = name + "=";
						if(document.cookie.length > 0){ 
							offset = document.cookie.indexOf(search);
							if (offset != -1){ 
								offset += search.length;
								end = document.cookie.indexOf(";", offset);
							if (end == -1) end = document.cookie.length;
								cookieValue = unescape(document.cookie.substring(offset, end))
							}
						}
						return cookieValue;
					}
					function parsePersoInfo(perso){
						//window.alert(perso)
						var tempArray = new Array();
						// name and sexe
						index = 0;
						index2 = 0;		
						index = perso.indexOf("[", 0);
						index2 = perso.indexOf("]", index);
						data = perso.substring(index+1, index2);
						index3 = data.indexOf("/", 0);
						name = data.substring(0, index3);
						sexe = data.substring(index3+1, data.length);
						tempArray[tempArray.length] = name;
						tempArray[tempArray.length] = sexe;
						//tempArray.push(name);
						//tempArray.push(sexe);
						// level
						index = perso.indexOf("[", index2);
						index2 = perso.indexOf("]", index);
						data = perso.substring(index, index2 + 1);
						index3 = data.indexOf("/", 0);
						level = data.substring(1, index3-1);
						tempArray[tempArray.length] = level;
						//tempArray.push(level);
						MyArray[MyArray.length] = tempArray;
						//MyArray.push(tempArray);
						// high score
						index = perso.indexOf("[", index2);
						index2 = perso.indexOf("]", index);
						index = perso.indexOf("[", index2);
						index2 = perso.indexOf("]", index);
						index = perso.indexOf("[", index2);
						index2 = perso.indexOf("]", index);
						data = perso.substring(index, index2 + 1);
						index3 = data.indexOf("/", 0);
						highScore = data.substring(1, index3);
						//window.alert(highScore)
						MyHighScoreArray[MyHighScoreArray.length] = highScore;
						//MyHighScoreArray.push(highScore)
					}
					//////////////////
					// Add by Simon //
					//////////////////
					function parsePersoArt(perso){
						var tempArtArray = new Array();
						index = 0;
						index2 = 0
						index = perso.indexOf("av", index);
						index = index+2
						tempArt = perso.substring(index, perso.length);
						art = parseInt(tempArt)
						tempArtArray[tempArtArray.length] = art;
						//tempArtArray.push(art);
						MyArtArray[MyArtArray.length] = tempArtArray;
						//MyArtArray.push(tempArtArray);
					}
					function parsePersoChapter(perso){
						var tempChapterArray = new Array();
						index = 0;
						index2 = 0
						index = perso.indexOf("av", index);
						index = index+2
						tempChapter = perso.charAt(index);
						chapter = parseInt(tempChapter)
						tempChapterArray[tempChapterArray.length] = chapter;
						//tempChapterArray.push(chapter);
						MyChapterArray[MyChapterArray.length] = tempChapterArray;
						//MyChapterArray.push(tempChapterArray);
					}
					function Querystring()
					{
					// get the query string, ignore the ? at the front.
						var querystring=location.search.substring(1,location.search.length);
					// parse out name/value pairs separated via &
						var args = querystring.split('&');
					
					// split out each name = value pair
						for (var i=0;i<args.length;i++)
						{
							var pair = args[i].split('=');
					
							// Fix broken unescaping
							temp = unescape(pair[0]).split('+');
							temp0 = temp.join(' ');
							
							temp = unescape(pair[1]).split('+');
							temp1 = temp.join(' ');
							
							this[temp0]=temp1;
						}
					
						this.get=Querystring_get;
					}
					function Querystring_get(strKey,strDefault)
					{
						var value=this[strKey];
						if (value==null){value=strDefault;}
						
						return value;
					}
					//////////////////
					function start(){
						var qs = new Querystring()
						skipToGame = 0;
						goToGame = qs.get("gtg", "false")
						if (goToGame == "true"){
							location.href="game.jhtml";
						}

						var qs2 = new Querystring()
							skipToGameQuit = 0;
							goToGameQuit = qs2.get("gquit", "false")
							if (goToGameQuit == "true"){
								skipToGameQuit = 1;
							}

						MyArray = new Array();
						//////////////////
						// Add by Simon //
						//////////////////
						MyArtArray = new Array();
						MyChapterArray = new Array();
						MyHighScoreArray = new Array();
						//////////////////
						perso1 = readCookie("avatar1");
						perso2 = readCookie("avatar2");
						perso3 = readCookie("avatar3");
						perso4 = readCookie("avatar4");
						for(var i=1;i<5;i++){
							if(eval('perso'+i) == ""){
								var tempArray = [0,0,0];
								MyArray[MyArray.length] = tempArray;
								//MyArray.push(tempArray);
							}else{
								parsePersoInfo(eval('perso'+i));
							}
						}
						//////////////////
						// Add by Simon //
						//////////////////
						persoArt1 = readCookie("avatarart1");
						persoArt2 = readCookie("avatarart2");
						persoArt3 = readCookie("avatarart3");
						persoArt4 = readCookie("avatarart4");
						for(var a=1;a<5;a++){
							if(eval('persoArt'+a) == ""){
								var tempArtArray = [0];
								MyArtArray[MyArtArray.length] = tempArtArray;
								//MyArtArray.push(tempArtArray);
							}else{
								parsePersoArt(eval('persoArt'+a));
							}
						}
						persoChapter1 = readCookie("avatarchapter1");
						persoChapter2 = readCookie("avatarchapter2");
						persoChapter3 = readCookie("avatarchapter3");
						persoChapter4 = readCookie("avatarchapter4");
						for(var e=1;e<5;e++){
							if(eval('persoChapter'+e) == ""){
								var tempChapterArray = [0];
								MyChapterArray[MyChapterArray.length] = tempChapterArray;
								//MyChapterArray.push(tempChapterArray);
							}else{
								parsePersoChapter(eval('persoChapter'+e));
							}
						}
						//////////////////
						//window.alert(MyArray);
						//window.alert(MyArtArray);
						//window.alert(MyChapterArray);
						//StartGame(0);
						document.writeln('<table cellpadding=0 cellspacing=0 align="left"><tr><td>');
						

	if (navigator.appName.indexOf("Microsoft Internet")!=-1)
	{
	document.writeln('<OBJECT ' + 
	'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '+
	'codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash_dir/swflash.cab#version=4,0,2,0" '+
	'width="760" '+
	'height="560" '+
	'id="avaMenu" ' +
	'><param  name="movie" value="index.swf">'+
	'><param  name="menu" value="false">'+
	'><param  name="wmode" value="transparent">'+
	'><param  name="saveInfo" value="' + MyArray + '">'+
	'><param  name="artInfo" value="' + MyArtArray + '">'+
	'><param  name="chapterInfo" value="' + MyChapterArray + '">'+
	'><param  name="highScoreInfo" value="' + MyHighScoreArray + '">'+
	'</OBJECT>');
	}
	else
	{
document.writeln('<EMBED ' + 
	'name="avaMenu" ' +
	'pluginspage="http://www.macromedia.com/shockwave/download/" ' +
	'type="application/x-shockwave-flash" ' + "\n" +
	'width="760" \n' +
	'height="560" \n' +
	'menu="false" \n' +
	'wmode="transparent" \n' +
	'src="index.swf" \n' +
	'flashvars="saveInfo='+MyArray+'&artInfo='+MyArtArray+'&chapterInfo='+MyChapterArray+'&highScoreInfo='+MyHighScoreArray+'"></EMBED>');
	}	

						document.writeln('</td></tr></table>');
					}
					function getFlashMovieObject()
					{
					   if (navigator.appName.indexOf("Microsoft Internet")!=-1)
					   {
					     return window.avaMenu;
					   }
					   else
					   {
					     return window.document.avaMenu; 
						}     
					}
					function SendDataToFlashMovie()
					{
						var flashMovie=getFlashMovieObject();
						flashMovie.SetVariable("/:saveInfo", MyArray);
						flashMovie.SetVariable("/:artInfo", MyArtArray);
						flashMovie.SetVariable("/:chapterInfo", MyChapterArray);
						flashMovie.SetVariable("/:highScoreInfo", MyHighScoreArray);
						flashMovie.SetVariable("/:goToGame", skipToGame);
						flashMovie.SetVariable("/:goToGameQuit", skipToGameQuit);
					}
					function setName(aname){
						//window.alert(aname);
					}
					function doPassVar(args){
					  // var sendText = args.value;
						window.document.avaMenu.SetVariable("myVar", "allo");
					}
					function callFunction(){
						window.document.avaMenu.TCallLabel("/", "functionOne");
					}
					function StartGame(persotype, personame, persolevel, cookienumber){
						//Xml = [race] [sexe] c [AiChapter]
					    /*final static int EARTH_BOY = 1;
					    final static int EARTH_GIRL = 2;
					    final static int WATER_BOY = 3;
					    final static int WATER_GIRL = 4;*/
						switch (persotype){
					    	case 1:
					    		race = "e";
					    		sexe = "b";
					    		break;
					    	case 2:
					    		race = "e";
					    		sexe = "g";
					    		break;
					    	case 3:
					    		race = "w";
					    		sexe = "b";
					    		break;
					    	case 4:
					    		race = "w";
					    		sexe = "g";
					    		break;
					    }
						var width	= 640,
							height	= 480,
							left	= screen.width / 2 - width / 2,
							top		= screen.height / 2 - height / 2;
						//alert("persotype="+persotype+"&game="+race+sexe+"c"+persolevel+"&saveId="+cookienumber);
						window.location = "launch.jhtml?heroName="+escape(personame)+"&game="+race+sexe+"c"+persolevel+"&saveId="+cookienumber, null, "left=" + left + ",top=" + top + ",width=" + width + ",height=" + height + ",toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=yes";
					}
					
					window.name = "avatar";
					start();

//  Function to delete a cookie. (Sets expiration date to start of epoch)
//    name -   String object containing the cookie name
//    path -   String object containing the path of the cookie to delete.  This MUST
//             be the same as the path used to create the cookie, or null/omitted if
//             no path was specified when creating the cookie.
//    domain - String object containing the domain of the cookie to delete.  This MUST
//             be the same as the domain used to create the cookie, or null/omitted if
//             no domain was specified when creating the cookie.
function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

/*  Examples
	var expdate = new Date ();
	FixCookieDate (expdate); // Correct for Mac date bug - call only once for given Date object!
	expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000) * 180 ); // 6 months from now
	
	var cookieValue = "Werd";
		
	SetCookie ("WTMapCookie", cookieValue , expdate);
	GetCookie ("WTMapCookie")
*/
/************************************************************************************
End of Sarbakan's Cookie Functions
************************************************************************************/


	var today = new Date();
	var expires = new Date(today.getTime() + 10000 * 24 * 60 * 60 * 1000);
	var settings = document.cookie;	

	function get_product_build_version()
	{
		return buildVersion;
	}

	function doalert(message){
		alert(message);
	}

	function loadSettings()
	{
		var ReturnString="";
		ReturnString = getGameCookie("BB2SAVESET");
		if(ReturnString == null)
			ReturnString="";

		return (ReturnString);
	}

	function saveSettings(settings)
	{
		setGameCookie("BB2SAVESET",settings);
	}

	function getUnlock(code)
	{
		var ReturnString="";
		ReturnString = getGameCookie(code);
		if(ReturnString == null)
			ReturnString="0";

		return (ReturnString);
	}

	function setUnlock(code, value)
	{
		setGameCookie(code,value);
	}

	function getGameCookie(name)
	{
		var index = settings.indexOf(name + "=");
		if (index == -1) return null;
		index = settings.indexOf("=", index) + 1;
		var endstr = settings.indexOf(";", index);
		if (endstr == -1) endstr = settings.length;
		return unescape(settings.substring(index, endstr));
	}


	function setGameCookie (name,value)
	{
		var path=null;
		var domain=null;
		secure=false;
		document.cookie = name + "=" + escape ( value ) +
			((expires) ? "; expires=" + expires.toGMTString() : "") +
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			((secure) ? "; secure" : "");
			settings = document.cookie;
	}
