/* [INCLUDE FILE] global */
// homepage animation stuff
var anim_current = 1;
var anim_info = new Array( 3 );
var anim_data = new Array( 3 );
var anim_link = new Array( 3 );
var anim_file = new Array( 3 );
var anim_path = new Array( 3 );

function $(idToGet) {
	return document.getElementById(idToGet);
}

// initialize animation data
function anim_init() {

	// only do this if the animation is available
	if ($( 'animList' ) == null ) { return false; }
	var animations	= $( 'animList' ).getElementsByTagName( 'li' );
	for(var y = 0; y < animations.length; y++ ) { anim_info[ y + 1 ] = animations[ y ]; }

	if ($( 'animData' ) == null ) { return false; }
	animations	= $( 'animData' ).getElementsByTagName( 'li' );	
	for (var y = 0; y < animations.length; y++ ) { anim_data[ y + 1 ] = animations[ y ]; }

	animations	= $( 'animData' ).getElementsByTagName( 'a' );	
	for (var y = 0; y < animations.length; y++ ) { anim_path[ y + 1 ] = animations[ y ].href; }

	if ($( 'animNumber' ) == null ) { return false; }	
	animations	= $( 'animNumber' ).getElementsByTagName( 'a' );
	for (var y = 0; y < animations.length; y++ ) {
		anim_link[ y + 1 ] = animations[ y ];
		filename = animations[ y ].href.split( "#" );
		anim_file[ y + 1 ] = filename[ 1 ];
		animations[ y ].href = "#";
	}

}

function anim_start() {
	anim_set( 1 );
}

// switch to next animation
function anim_next() {

	// make sure the animation can jump forward
	if ( $( 'animList' ) == null ) { return; }
	
	anim_current ++;

	if ( anim_current > 3 ) { anim_current = 1;	}

	anim_set();
	
}
	
// switch to previous animation
function anim_prev() {
	anim_current --;
		
	if ( anim_current < 1 ) { anim_current = 3; }
	anim_set();
}
	
function anim_set( anim_new ) {
	
	// if anim_new is set then change current anim
	if ( anim_new != null ) { anim_current = anim_new; }
	
	// check animation has loaded ok
	if( anim_info[ anim_current ] == null ) { return; }
	
	// loop through icon holders and set selected value 
	for( var y = 1; y <= 3; y++ ) {
		// if selected set class name else remove
		if ( y == anim_current ) {
			anim_info[ y ].className = "selected";
			anim_data[ y ].className = "selected";
			anim_link[ y ].className = "selected";
		} else {
			anim_info[ y ].className = "";
			anim_data[ y ].className = "";
			anim_link[ y ].className = "";
		}
	}
	
	if( $( "animHolder" ) != null ) {
	
		$( "animHolder" ).innerHTML = AC_FL_GetContent(
			'id', 'animation',
			'name', 'animation',
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0',
			'width', '290',
			'height', '200',
			'quality', 'high',
			'bgcolor', '#ffffff',
			'menu', 'false',
			'allowscriptaccess', 'sameDomain',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'movie', 'http://e.miniclip.com/swfcontent/animations/' + anim_file[ anim_current ] + '?url=' + anim_path[ anim_current ],
			'wmode', 'transparent'
		);
		
		// loop through icon holders and set selected value 
		for( var y = 1; y <= 3; y++ ) {
			// if selected set class name else remove
			if ( y == anim_current ) {
				//parent.anim_info[ y ].className = "selected";
				anim_info[ y ].className = "selected";
				anim_data[ y ].className = "selected";
				anim_link[ y ].className = "selected";
			} else {
				anim_info[ y ].className = "";
				anim_data[ y ].className = "";
				anim_link[ y ].className = "";
			}
		}
		
		
	} else {
	
		// loop through icon holders and set selected value 
		for( var y = 1; y <= 3; y++ ) {
			// if selected set class name else remove
			if ( y == anim_current ) {
				anim_info[ y ].className = "selected";
				anim_data[ y ].className = "selected";
				anim_link[ y ].className = "selected";
			} else {
				anim_info[ y ].className = "";
				anim_data[ y ].className = "";
				anim_link[ y ].className = "";
			}
		}
		
		frames['animHolderFrame'].location.href = "animdata.php?anim=" + anim_current;
		
	}
	
	return false;

}

// player homepage animation
var player_current = 1;
var playersAnim_time = 0;
var player_info = new Array( 3 );
var player_link = new Array( 3 );
var player_file = new Array( 3 );

// initialize animation data
function player_init() {

	// only do this if the animation is available
	// player tab info
	if ( $( 'playerList' ) == null ) { return false; }
	var animations	= $( 'playerList' ).getElementsByTagName( 'li' );
	for( var y = 0; y < animations.length; y++ ) { player_info[ y + 1 ] = animations[ y ];	}
	
	// player id
	if ( $( 'playerNumber' ) == null ) { return false; }
	animations	= $( 'playerNumber' ).getElementsByTagName( 'a' );
	for( var y = 0; y < animations.length; y++ ) {
		player_link[ y + 1 ] 	= animations[ y ];
		filename 				= animations[ y ].href.split( "#" );
		player_file[ y + 1 ]	= filename[ 1 ]; 
		animations[ y ].href 	= "#";

		$( "playerHolder" ).innerHTML = $( "playerHolder" ).innerHTML + AC_FL_GetContent(
			'id', 'animation',
			'name', 'animation',
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0',
			'width', '290',
			'height', '260',
			'quality', 'high',
			'bgcolor', '#ffffff',
			'menu', 'false',
			'allowscriptaccess', 'sameDomain',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'movie', '/players/swf/components/featuredplayer?uid=' + player_file[ y + 1 ],
			'wmode', 'transparent'
		);		
	}

}

function player_start() {

	player_set( 1 );
	
}

// switch to next animation
function player_next() {
	
	player_current ++;

	if ( player_current > 3 ) { player_current = 1;	}

	player_set();
	
}
	
// switch to previous animation
function player_prev() {

	player_current --;
		
	if ( player_current < 1 ) { player_current = 3; }
	
	player_set();
	
}
	
function player_set( player_new ) {
	
	// if anim_new is set then change current anim
	if ( player_new != null ) { player_current = player_new; }
	
	// check animation has loaded ok
	if( player_info[ player_current ] == null ) { return; }
	
	// loop through icon holders and set selected value 
	for( var y = 1; y <= 3; y++ ) {
		// if selected set class name else remove
		if ( y == player_current ) {
			player_info[ y ].className = "selected";
			player_link[ y ].className = "selected";
		} else {
			player_info[ y ].className = "";
			player_link[ y ].className = "";
		}
	}
	
	if( $( "playerHolder" ) != null ) {
		scrollPos = (player_current - 1) * 260;
		$( 'playerHolder' ).scrollTop = scrollPos;
	}
	
	clearTimeout( playersAnim_time );
	playersAnim_time = setTimeout( "player_next();", 10 * 1000 );	
	
	return false;

}

function confirmSubmit( message ) {

	var agree = confirm( message );

	if ( agree ) {
		return true;
	} else {
		return false;
	}
	
}
/* LIST ALL GAMES */

//var req = getXMLHttpRequest();
function list_init(languageCountrycode, category) { //category = games, ecards, toons
	xml_loadXMLDoc('/' + category + '/' + languageCountrycode + '/full_' + category + '_list.php', xml_onReadyStateChange_list);
//	list_ready();
}

function list_ready() {

	if($('gameList') == null) {
		return;
	}
	
	if(document.forms['jumpList'] == null) {
		return;
	}
	
	// list all games menu
	var games	= $('gameList').getElementsByTagName('a');

	document.forms['jumpList'].jumpSelect.options[0] = new Option(language[9], "");

	var oCount = 1;
	for( var y = 0; y < games.length; y++ ) {
	
		jlText = "";
		jlText = games[ y ].innerHTML;
		jlText = jlText.replace( /&amp;/, "&" );
		jlText = jlText.replace( "<img src=\"/images/challenge_game.gif\" style=\"margin: 0pt 0pt 0pt 4px; vertical-align: middle;\">", "" );
		jlText = jlText.replace( "<IMG style=\"MARGIN: 0px 0px 0px 4px; VERTICAL-ALIGN: middle\" src=\"http://cms.miniclip.com/images/challenge_game.gif\">", "" );
		jlText = jlText.replace( "<IMG style=\"MARGIN: 0px 0px 0px 4px; VERTICAL-ALIGN: middle\" src=\"http://www.miniclip.com/images/challenge_game.gif\">", "" );
		jlText = jlText.replace(/^\s+|\s+$/g, ''); // trim
		
		if( jlText != "" ) {
			document.forms[ 'jumpList' ].jumpSelect.options[ oCount ] = new Option( jlText, games[ y ].href );
			oCount ++;
		}
		
	}
	
	document.forms[ 'jumpList' ].jumpSelect.onchange = function() {
		list_jump();
	}
		
	// grab cookies
	var list_display = cookie_read( 'list_display' );
		
	// no cookie so set default
	if ( list_display == null ) {
		
		cookie_create( "list_display", "1", 150 );
		list_display = 1;
			
	// hidden so hide stuff
	} else if( list_display == "0" ) {
	
		$( 'WrapperComplete' ).className = "hidden";
		$( 'listToggle' ).innerHTML = language[ 7 ];
	}
}

// show/ hide the list
function list_toggle() {

	// grab cookies
	var list_display = cookie_read( 'list_display' );
	
	// currently hidden so show
	if( list_display == "0" ) {
			
		$( 'WrapperComplete' ).className = "shown";
		$( 'listToggle' ).innerHTML = language[ 8 ];
		cookie_create( "list_display", "1", 150 );
		
	// else hide	
	} else {

		$( 'WrapperComplete' ).className = "hidden";
		$( 'listToggle' ).innerHTML = language[ 7 ];		
		cookie_create( "list_display", "0", 150 );
		
	}
		
}

function list_jump( list ) {

	if( list == null ) { list = "jumpList"; }

	var newIndex = document.forms[ list ].jumpSelect.selectedIndex;
	
	if ( newIndex != 0 ) { 

		url = document.forms[ list ].jumpSelect.options[ newIndex ].value;
		top.location = url; 

	} 

}

/* MORE MENU */

var more_displayed = false;

function more_display() {

	if ( more_displayed == true ) {
		$( 'moreNav' ).className = "hidden";
		more_displayed = false;
	} else {
		$( 'moreNav' ).className = "shown";
		more_displayed = true;	
	}
	
}

/* clear current page links */
function clearCurrentLink() {
    var a = document.getElementsByTagName("A");
    
    for(var i = 0; i < a.length; i++) {
        if(a[i].href == window.location.href.split("#")[0] || a[i].href == window.location.href.split("?")[0]) {
		    a[i].className = a[i].className + " current";
		}
    }
}

/* RECENTLY PLAYED */
function recent_save() {
	// load existing recent games
	var recentgame = t_gameId;
	var recentlist = recent_load();
	var savedgames = 0;
	
	if( recentlist != null ) {
		var recentArray = recentlist.split( "|" );
		
		// loop through array
		for( i = 0; i < recentArray.length; i++ ) {
		
			// remove duplicates and crop list to recent 6
			if ( recentArray[ i ] != t_gameId && savedgames < 5 ) {
				recentgame = recentgame + "|" + recentArray[ i ];
				savedgames ++;			
			}
		}	
	}
	
	// save new list
	cookie_create( "recent_games", recentgame, 28 );
}

function recent_load() {

	// load recent games into array
	recentlist = cookie_read( "recent_games" );
	
	return recentlist;
	
}

function recent_write() {

	var mg_latest = $( "mg_latest" );
	
	if( mg_latest == null ) { return; }

	var recentlist = recent_load();
	var outputHTML = "<ul>";
	
	if( recentlist != null ) {
	
		var recentArray = recentlist.split( "|" );
		
		// loop through array
		for( i = 0; i <= recentArray.length; i++ ) {
		
			var gamelist = $( "tid_" + recentArray[ i ] );
			
			if ( recentArray[ i ] != 0 && gamelist != null ) {
			
				gamename = gamelist.innerHTML;
				gameurl = gamelist.href;

				outputHTML = outputHTML + "<li><a href=\"" + gameurl + "\">" + gamename + "</a></li>\n";
				
			}
					
		}
		
		outputHTML = outputHTML + "</ul>";
		
	} else {
		
		outputHTML = language[ 4 ];
		
	}
	
	mg_latest.innerHTML = outputHTML;
	
}

/* set homepage for IE */
function SetHomepage() {
	
	return;
	
	var monkey = new Array();
		monkey['img'] = 'ieHomepage_monkey.png';
		monkey['url']  = 'javascript:history.go(0);';
		monkey['onclick'] = 'onClick="SetHomepageAction(this)"';
		monkey['alt'] = 'Set Miniclip.com as your homepage';
	
//	var petOne = new Array();
//		petOne['img'] = 'homepagePetsPush01.jpg';
//		petOne['url']  = '/players/en/create-your-yome.php';
//		petOne['onclick'] = '';
//		petOne['alt'] = 'Adopt a pet now!';
		
//	var petTwo = new Array();
//		petTwo['img'] = 'homepagePetsPush02.jpg';
//		petTwo['url']  = '/players/en/create-your-yome.php';
//		petTwo['onclick'] = '';
//		petTwo['alt'] = 'Adopt a pet now!';

	var sketchstarPush = new Array();
		sketchstarPush['img'] = 'homepage-banner-topright_play.png';
		sketchstarPush['url']  = '/sketch-star/';
		sketchstarPush['onclick'] = '';
		sketchstarPush['alt'] = 'Create Free Animations! Play Sketch Star &raquo;';
		
	var randArray = new Array();
//		randArray[0] = petOne;
//		randArray[1] = petTwo;
		randArray[0] = sketchstarPush;
	if(document.all && cookie_read('homepageSet') != 'cookieset') {
		randArray[2] = monkey;
	}
	
	var randResult = Math.floor(Math.random() * randArray.length);
	var randShow = randArray[randResult];
														
	document.write('<a href="' + randShow['url'] + '" ' + randShow['onclick'] + '><img src="/images/' + randShow['img'] + '" alt="' + randShow['alt'] + '" /></a>');
}

function SetHomepageAction(object) {
	document.body.style.behavior="url(#default#homepage)";
	document.body.setHomePage("http://www.miniclip.com/");
	cookie_create("homepageSet", "cookieset", 365);
	clickTracker._trackPageview("/click/setHomepage")
}

/* COOKIES */
function cookie_create(name, value, days) {

	if(days) {
		var date = new Date();
		date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
		var expires = "; expires=" + date.toGMTString();
	} else {
		var expires = "";
	}
	
	document.cookie = name + "=" + value + expires + "; path=/";
}
	
function cookie_read(name) {

	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
		
	for(var i = 0; i < ca.length; i++) {
		var c = ca[i];
		while (c.charAt(0) == ' ') c = c.substring(1, c.length);
		if (c.indexOf(nameEQ) == 0 ) return c.substring(nameEQ.length, c.length);
	}
	
	return "";
	
}
	
function cookie_erase(name) {
	createCookie(name, "", -1);
}

/* CLIPBOARD (IE only - need to add mozilla version) */
function cb_init() {

	// check we're not in MSIE
	if ( navigator.appName != "Microsoft Internet Explorer" ) {
	
		// grab all the divs
		var divs = document.getElementsByTagName( "div" );
	
		// if a copy div replace content
	  	for( var i = 0; i < divs.length; i++ ) {
			var div = divs[ i ];
			// hide unusable buttons
			if ( div.className == "copyButton" ) {
				div.innerHTML = language[ 6 ];	
			}
		}	
	}

}

function cb_copy(item) {
	copied = item.createTextRange();
	item.focus();
	item.select();
	copied.execCommand("Copy");
}

/* GENERIC STUFF */
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

function writeEmail(name, display_name) {
 
	address = name + "&#64" + "miniclip.com";
	if (display_name == null) {
		document.write("<a href='mailto:" + address + "'>" + address + "</a>");
	} else {
		document.write("<a href='mailto:" + address + "'>" + display_name + "</a>");
	}
  
}

function prerollCreateGame(pr_gamename, pr_gamewidth, pr_gameheight) {

	// --------------------------------------------------------------------
	// create the code for a flash game, simple function that can be reused
	// --------------------------------------------------------------------
	str_return = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"" + pr_gamewidth + "\" height=\"" + pr_gameheight + "\">";
	str_return = str_return + "<param name=\"movie\" value=\"" + pr_gamename + "\">";
	str_return = str_return + "<param name=\"quality\" value=\"high\">";
	str_return = str_return + "<param name=\"menu\" value=\"false\">";
	str_return = str_return + "<embed src=\"" + pr_gamename + "\" quality=\"high\" menu=\"false\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"" + pr_gamewidth + "\" height=\"" + pr_gameheight + "\"></embed>";
	str_return = str_return + "</object>";

	$("video_ad").innerHTML = str_return;

}

var BrowserDetect = {
	init: function () {
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			this.navigator = data[i].string;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

function removeSidebarBoxAd() {
	
	outputHtml = "";
	outputHtml = outputHtml + "<style type='text/css'>";
	outputHtml = outputHtml + "#sidebarBoxBackground {display:none;}";
	outputHtml = outputHtml + "#sidebarBoxForeground {display:none;}";
	outputHtml = outputHtml + "#sideBar {margin-top:-5px;}";
	outputHtml = outputHtml + "</style>";
	document.write(outputHtml);
	addLoadEvent(removeSidebarBoxAdComplete);
	
}

function removeSidebarBoxAdComplete() {
	if($("sidebarBoxBackground") != null) {
		$("sidebarBoxBackground").innerHTML = "";
	}
	if($("sidebarBoxForeground") != null) {
		$("sidebarBoxForeground").innerHTML = "";
	}		
}

function insertHomepageVideo( htmlCode ) {
	$("homepageVideoInsert").innerHTML = htmlCode;
	$("homepageVideoInsert").style.display = "block";
}

function removeHomepageVideo() {
	$("homepageVideoInsert").innerHTML = "";
	$("homepageVideoInsert").style.display = "none";
}

function resizeFrame( f ) {
	$( f ).style.height = "50px";
	url = $( f ).contentWindow.location.href;
	if(url.indexOf("miniclip.com") > 0) {
		$( f ).style.height = $( f ).contentWindow.document.body.scrollHeight + "px";
	} else {
		$( f ).style.height = "500px";
	}
}

var shockwaveInstalled = null;
var shockwaveFirstTime = true;
var shockwaveTimeout = null;

function shockwaveIsInstalled() {

	var tVersionString = "0";

	if (navigator.mimeTypes && navigator.mimeTypes["application/x-director"] && navigator.mimeTypes["application/x-director"].enabledPlugin) {
		if (navigator.plugins && navigator.plugins["Shockwave for Director"] && (tVersionIndex = navigator.plugins["Shockwave for Director"].description.indexOf(".")) != - 1) {	
			tVersionString = navigator.plugins["Shockwave for Director"].description.substring(tVersionIndex-2, tVersionIndex+2);
		}
	} else if(navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0) {

		try {
			var obj = new ActiveXObject("SWCtl.SWCtl");
			if(obj != null) {
				tVersionString = obj.ShockwaveVersion("");
			}
		} catch(e) {
		
		}
		
		if(obj != null) {
			delete obj;
		}

	}
		
	if(parseInt(tVersionString) >= 11) {
		shockwaveInstalled = true;
	} else {
		shockwaveInstalled = false;
	}
	
	return shockwaveInstalled;

}

function shockwaveInstall() {
	
	var showGoldBar = true;

	if(shockwaveIsInstalled()) {

		// track new installs
		if(shockwaveFirstTime == false || cookie_read("sw") == 1) {
			//clickTracker._trackPageview("/sw/newInstall");
			pageTracker._trackPageview("/sw/newInstall");
			cookie_erase("sw");
		}
		
		// track total users with install
		//clickTracker._trackPageview("/sw/installed");
		pageTracker._trackPageview("/sw/installed");
		
		// hide installation messaging
		$("shockwaveGameContainer").style.display = "block";
		$("shockwaveInstallWrapper").style.display = "none";
		$("shockwaveInstallBar").style.display = "none";
		$("blackOverlay").style.display = "none";
		$("shockwaveInstallBar").innerHTML = "";
		
	} else {

		// track not installed
		if(shockwaveFirstTime == true) {
			//clickTracker._trackPageview("/sw/notInstalled");
			pageTracker._trackPageview("/sw/notInstalled");
			cookie_create("sw", "1", 10);
		}
		
		var goldbarMessage = "<div id='shockwaveDescription'><p><strong>Adobe Shockwave Required</strong></p><p>Installing is easy. When you see the yellow bar above, follow these steps &raquo;</p></div>";
		
		// if firefox or similar
		if(navigator.appName == "Netscape") {
			// if version 3
			if(navigator.userAgent.indexOf("Firefox/3") >= 0) {
				goldbarMessage = goldbarMessage + "<div id='shockwaveInstructions'><p>Click <strong>Install Missing Plugins</strong></p><p>Follow the instructions</p><p>Restart Firefox to finish</p></div>";
			// other versions
			} else {
				showGoldBar = false;
			}
		} else {
			goldbarMessage = goldbarMessage + "<div id='shockwaveInstructions'><p><strong>Click the Yellow bar</strong> above</p><p>Choose <strong>Install ActiveX Control</strong></p><p><strong>Click Install</strong> when prompted</p></div>";
		}
		
		goldbarMessage = goldbarMessage + "<div class='arrow'></div>";
		
		if(showGoldBar == true) {
			$("shockwaveGameContainer").style.display = "none";
			$("shockwaveInstallWrapper").style.display = "block";
			$("shockwaveInstallBar").style.display = "block";
			$("blackOverlay").style.display = "block";
			$("shockwaveInstallBar").innerHTML = goldbarMessage;
		}
		
		shockwaveTimeout = setTimeout("shockwaveInstall()", 4 * 1000);
	}

	shockwaveFirstTime = false;

}

function LoginBoxNotification(action){
	
	switch(action){
		case 'user_logged_in':
		case 'user_logged_out':
			window.location.reload();
	}
}

function statTracker(path) {

	clickTracker._trackPageview(path);
	//pageTracker._trackPageview("/sw/newInstall");
	
}

function jsDebug(data) {
	outputHtml = ""; 
	outputHtml = outputHtml + "<div style=\"background:#F5F5FF; margin-bottom:1px; padding:5px;\">";
	outputHtml = outputHtml + data;
	outputHtml = outputHtml + "</div>";
	$("jsDebugDataBox").innerHTML = $("jsDebugDataBox").innerHTML + outputHtml;
}





var hpto = new Object;
var toolbarHomepageTakeover = false;

function runTakeover(hpto) {
	
	// ---------
	// banner ad
	// ---------
	
	if (hpto.MpuURL != undefined) {
		hpto_MPU_URL = hpto.MpuURL;
		if (hpto.ClickURL != undefined) {
			hpto_MPU_URL = hpto_MPU_URL + '?clickTag=' + encodeURIComponent(hpto.ClickURL.replace('[timestamp]', ord));
		}
		takeoverEmbed = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" id="Ad_that_changes_background_AS1" width="300" height="250" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="' + hpto_MPU_URL + '" /><param name="quality" value="high" /><embed src="' + hpto_MPU_URL + '" quality="high" width="300" height="250" swLiveConnect=true id="Ad_that_changes_background_AS1" name="Ad_that_changes_background_AS1" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
		if ($('takeoverMPU') != null) {
			$('takeoverMPU').innerHTML = takeoverEmbed;
		} else {
			document.write(takeoverEmbed);
		}
	}
	
	// ----
	// skin
	// ----
	
	if (hpto.ImageURL_1 == undefined) {
		hpto_ImageURL_1 = hpto.ImageURL;
	} else {
		hpto_ImageURL_1 = hpto.ImageURL_1;
	}
	
	// Set defaults and fallbacks
	if ( hpto_ImageURL_1 != "" ) {
		hpto_Image_1 = 'url(' + hpto_ImageURL_1 + ') no-repeat center top !important';
	} else {
		hpto_Image_1 = '';
	}
	
	if (hpto.Colour == '') {
		hpto.Colour = '#333333';
	}

	// Define header options
	switch(hpto.Header) {	
	case 1:
		headerHeight = 55;
		break;
	case 2:
		headerHeight = 85;
		break;
	case 3:
		headerHeight = 125;
		break;s
	default:
		headerHeight = 0;
	}
	
	// Set wrapper/logo visibility
	if (hpto.Wrapper == true) {
	
		$('wrapper').style.marginTop = headerHeight + 'px';
	
		hpto.hpto_Logo = 'h1 a, h1 a:hover, h1 { background:url( /images/bg_h1.png ) no-repeat 12px 10px; }';
	
	} else {
	
		$('wrapper').style.background = 'none';
		$('wrapper').style.padding = headerHeight + 'px 0 0 0';
		
		if ( hpto.hpto_Logo == false ) {
			hpto.hpto_Logo = 'h1 a, h1 a:hover, h1 { background: none; }'; 
		} else {
			hpto.hpto_Logo = 'h1 a, h1 a:hover, h1 { background: url( /images/takeovers/takeoverLogo.png ) no-repeat 12px 10px; }';
		}

		// adjust tabs
		if ($('tabNav') != null) {
			$('tabNav').style.top = String(headerHeight).concat('px');
		}
	}
	
	if ($("toolbarPush")) {
		$("toolbarPush").innerHTML = '';
	}
	toolbarHomepageTakeover = true;
	document.body.style.marginRight = '';
	
	// Build the Takeover
	document.body.style.backgroundColor     = hpto.Colour;
	document.body.style.backgroundImage     = 'url(' + hpto_ImageURL_1 + ')';
	document.body.style.backgroundRepeat    = 'no-repeat';
	document.body.style.backgroundPosition  = 'top center';
	
	if($('beta') != null) {
		$('beta').style.display            = 'none';
	}
	hideMonkey();
	
	document.write('<style type="text/css">');
		document.write('.flagsHeader { display: none; }\n');
		document.write(hpto.hpto_Logo + '\n');
		document.write('.corner_bl.g, .corner_br.g { background-image: none; }\n');
		document.write('.ad_728_90 { margin-top: 25px; }\n');
	document.write('</style>');


	// ------
	// footer
	// ------
	if (hpto.FootURL != undefined) {
		if (hpto.FootURL.length > 0) {
			var hpto_FootImg = new Image();
			hpto_FootImg.src = hpto.FootURL;
			$('footerTakeover').innerHTML = '<img src="' + hpto.FootURL + '" />';
		}
	}

	// -----
	// stats
	// -----
	
	// Get statistics variables from array
	hpto_Agency = hpto.Agency;
	hpto_Client = hpto.Client;
	hpto_Campaign = hpto.Campaign;
	
	// If blank, set unknown.
	if(hpto_Agency == undefined) {
		hpto_Agency = "unknown";
	}
	if(hpto_Client == undefined) {
		hpto_Client = "unknown";
	}
	if(hpto_Campaign == undefined) {
		hpto_Campaign = "unknown";
	}
	
	// tracking
	if (hpto.TrackURL != undefined) {
		hpto.TrackURL = hpto.TrackURL.replace('[timestamp]', ord);
		tracker = new Image();
		tracker.src = hpto.TrackURL;
	}
	
	// Log takeover view to Google Analytics
	trackHPTO();
	
}

function trackHPTO(args) {

	// Get statistics variables from array
	hpto_Agency = hpto.Agency;
	hpto_Client = hpto.Client;
	hpto_Campaign = hpto.Campaign;
	
	// If blank, set unknown.
	if(hpto_Agency == undefined) {
		hpto_Agency = "unknown";
	}
	if(hpto_Client == undefined) {
		hpto_Client = "unknown";
	}
	if(hpto_Campaign == undefined) {
		hpto_Campaign = "unknown";
	}
	if (args == undefined) {
		args = '';
	}
	
	var path = '/takeovers/' + encodeURI(hpto_Agency.replace(' ', '-')) + '/' + encodeURI(hpto_Client.replace(' ', '-')) + '/' + encodeURI(hpto_Campaign.replace(' ', '-')) + args;
	statTracker(path);	

}

var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

// Handle all the FSCommand messages in a Flash movie.
function Ad_that_changes_background_AS1_DoFSCommand(command, args) {

	var Ad_that_changes_background_AS1Obj = isInternetExplorer ? document.all.Ad_that_changes_background_AS1 : document.Ad_that_changes_background_AS1;
	
	imagePath = hpto['ImageURL_' + args];
	if (imagePath == undefined) {
		imagePath = hpto.ImageURL;
	}
	
	document.body.style.backgroundImage = 'url(' + imagePath + ')';
	
	trackHPTO('/swapBackground/' + args);
}

// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub Ad_that_changes_background_AS1_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call Ad_that_changes_background_AS1_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}





function attachTracking() {

	var banner_ids = ['banner_leaderboard', 'banner_boxad', 'banner_pushad_small', 'banner_pushad_big', 'ss_pushad_big', 'ss_pushad_small'];
	var banner_anchor = null;
	
	for (var i = 0; i < banner_ids.length; i++) {
		banner_anchor = $(banner_ids[i]);
	
		if (banner_anchor && banner_anchor.href) {
			banner_anchor.onclick = function(e) {
				// stop browser from following the link
				if (!e) var e = window.event;
				e.cancelBubble = true;
				if (e.stopPropagation) e.stopPropagation();

				var image = this.getElementsByTagName('img');
				var path_list = image[0].src.split("/");
				var image_file = path_list[path_list.length - 1].split(".");
				
				var analytics_path = new Array();
				
				analytics_path[0] = 'adserver/click';
				analytics_path[1] = adServerProperties;
				analytics_path[2] = this.id;
				analytics_path[3] = image_file[0];
				
				statTracker(analytics_path.join('/'));
				// go to target url
				window.location.href = this.href;
				
				return false;
				
			}

			var image = banner_anchor.getElementsByTagName('img');
			var path_list = image[0].src.split("/");
			var image_file = path_list[path_list.length - 1].split(".");
			
			var analytics_path = new Array();
			
			analytics_path[0] = 'adserver/view';
			analytics_path[1] = adServerProperties;
			analytics_path[2] = banner_anchor.id;
			analytics_path[3] = image_file[0];
			
			statTracker(analytics_path.join('/'));
			
		}
		
	}
	
}

function setBodyMargin() {
	if(document.body.offsetWidth % 2 == 1) {
		document.body.style.marginRight = "1px";
	} else {
		document.body.style.marginRight = "0";
	}
}

var userAge = 0;

// Newsletter Signup (Added by Ben H - 23/04/09)
function coppaAge(coppa_age, form_id, email) {

	// Set Minimum Age Limit
	var ageLimit = 13;
	
	var userAge = $(coppa_age).value;
	
	var reg = /^([a-zA-Z0-9_\-\.]+)@((([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4})(\]?)$/;
	var address = document.forms[form_id].elements[email].value;
   
	if (userAge < ageLimit) {
		$("newsletterForm").innerHTML = '<h3>Sorry!</h3><p class="error">The Miniclip Newsletter is only available to players aged 13 years or over.</p>';
		cookie_create("coppaAge", theYear, 3); // Set a cookie to stop them from trying again
	} else {
		if ((reg.test(address) == false) || (userAge <= ageLimit)) {
			alert('Invalid Email Address');
			return false;
		} else {
			statTracker('/newsletter/signup/');
			return true;
		}
	}
   
}

function coppaCheck () {
	var age = cookie_read("coppaAge");
	if (age.length > 0 && age < 13) {
		document.getElementById("newsletterForm").innerHTML = '<h3>Sorry!</h3><p class="error">The Miniclip Newsletter is only available to players aged 13 years or over.</p>';
	}
}

/* Toolbar Push Strip */
function toolbarPush() {

	// make sure the game is running on a game page (t_gameId is only available on game pages)
	if (typeof(t_gameId) == 'undefined') {
		return;
	}
	
	// make sure there is space for the toolbar
	if (toolbarHomepageTakeover == true) {
		return;
	}
	
	
	if ($("toolbarPush")) {
		// make sure we're on www
		if(document.domain == "www.miniclip.com") {
			// see if the toolbar can be shown (variable "hidetoolbar" set in some templates)
			if (window['hideToolbar'] == undefined) {
				// see if the toolbar is installed with the toolbar cookie
				var toolbarId = cookie_read("minicliptb_id");
			
				if (toolbarId.length < 1) {
					// insert toolbar
					outputHtml = '<div class="toolbarContain">';
					outputHtml += '<a href="/games/en/toolbar/">Get the all new Miniclip toolbar for your browser!</a>';
					outputHtml += '<div class="toolbarBody">';
					outputHtml += '<a href="/games/en/toolbar/">Get the all new Miniclip toolbar for your browser!</a>';
					outputHtml += '</div>';
					outputHtml += '</div>';
					
					$("toolbarPush").innerHTML = outputHtml;
				}
				
			}
		}
	}
}

function reloadAvatar() {
	setTimeout('reloadAvatarReal()', 1500);
}

function reloadAvatarReal() {
	newSrc = $('loginbox_avatar').src + "&dc=" + (Math.random() * 10000000000000000);
	$('loginbox_avatar').src = newSrc;
}

/* TOOLBAR */

var cookName = "minicliptoolbar_id";
var cookieGame = "minicliptoolbarsession";
var msg_noplace = "There is no space to add more Miniclips, use the \"Edit My Miniclips...\" function to make space for new games.";

var gameurl = new Array();
var gametit = new Array();

var Maxgame = ( gametit.length - 1 );

// Function to extract game information from cookie
function toolbar_list() {

	var mg = $( 'mg_miniclips' );
	
	if( mg == null ) { return; }
	
	var thecook = cookie_read( cookieGame );
	var output = "";
	
	if( thecook == null || thecook == "" ) {
	
		output = language[ 0 ];	
	
	} else {
	
		thecook.toString();
		
		var cookArray = thecook.split( "~" );

		for( var ig = 1; ig < 12; ig = ig + 2 ) {
			
			if ( ig < cookArray.length ) {
				var num = cookArray[ ig ].split( "^" );
				
				tidVal = $( 'tid_' + num[ 1 ] );
				
				if( tidVal != null ) {
					detail1 = tidVal.href;
					detail2 = tidVal.innerHTML;
		
					output = output + "<li><a href='javascript:toolbar_delete( " + num[ 1 ] + " );' class='toolbar_delete'><img src='http://images-vip.napmia.miniclip.com/images/button_delete.gif' alt='delete this miniclip' /></a><a href='" + detail1 + "'>" + detail2 +"</a></li>";
				}
			}
		}

	}

	mg.innerHTML = output;

}

function toolbar_add( thegameid, refresh_list ) {

	var thecook = cookie_read( cookieGame );
	thecook.toString();
	
	gameName = $( "tid_" + thegameid ).innerHTML;

	// if game already exists...
	if ( thecook.indexOf( "^" + thegameid + "~" ) >= 0 ){
		alert(language[ 3 ] + " " + gameName + " " + language[ 2 ]);
		return;
	}
	
	var theline = "";
	
	if ( thecook.length < 5 ) {
		theline += "gm1^" + gameName + "~";
		theline += "ur1^" + thegameid + "~";
	} else {
		theline += "gm1^" + gameName + "~";
		theline += "ur1^" + thegameid + "~";
		theline += thecook;
	}
	
	countTheCook = thecook.split( "~" );
	toolbarcook = cookie_read( cookName );

	cookie_create( cookieGame, theline, 20000 );
	toolbar_refresh( 0, "add", gameName );

	if( refresh_list == true ) {
		toolbar_list();
	}
	
}

function toolbar_delete( gameID ) {
	var thecook = cookie_read( cookieGame );
	var theline = "";
	
	gameName = $( "tid_" + gameID ).innerHTML;
	
	thegames = thecook.split( "~" );

	for( i = 0; i < thegames.length - 2; i = i + 2 ) {

		// with the old code gameID could be 1 (3-foot-ninja) and it would delete any game with
		// a 1 in it. so i removed indexOf.. /andreas
		number = thegames[ i + 1 ].split( "^" );
		number = number[1];

		if (number == gameID) {
//		if( thegames[ i + 1 ].indexOf( gameID ) > -1 ) {
		
		} else {
			theline += thegames[ i ] + "~" + thegames[ i + 1 ] + "~";
		}
	
	}
	cookie_create( cookieGame, theline, 20000 );
	toolbar_refresh( 0, "remove", gameName );
	toolbar_list();

}

function toolbar_refresh( full, addOrRemove, gameName ){

	var thecook = cookie_read( cookieGame );
	thecook = thecook.toString();
	
	if (thecook.length > 5) {
	
		if (full == 1) {
			alert(msg_noplace);
		} else if( addOrRemove == "add" ){
			//alert( gameName + " has been added to My Miniclips. Click \"My Miniclips\" in the toolbar to use it!" );
		} else if (addOrRemove == "remove") {
			//alert (gameName + " " + language[1]);
		}
	}
}

function hideMonkey() {
	if ($('homepageMonkey') != null) {
		$('homepageMonkey').innerHTML = '';
	}
}

function detectUnityWebPlayer () {
	var tInstalled = false;
	if (navigator.appVersion.indexOf("MSIE") != -1 && navigator.appVersion.toLowerCase().indexOf("win") != -1) {
		tInstalled = detectUnityWebPlayerActiveX();
	} else if (navigator.mimeTypes && navigator.mimeTypes["application/vnd.unity"]) {
		if (navigator.mimeTypes["application/vnd.unity"].enabledPlugin && navigator.plugins && navigator.plugins["Unity Player"]) {
			tInstalled = true;	
		}
	}	
	return tInstalled;	
}/* [INCLUDE FILE] AC_RunActiveContent */
//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated.  All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '';
  if (isIE && isWin && !isOpera)
  {
    str += '<object ';
    for (var i in objAttrs)
    {
      str += i + '="' + objAttrs[i] + '" ';
    }
    str += '>';
    for (var i in params)
    {
      str += '<param name="' + i + '" value="' + params[i] + '" /> ';
    }
    str += '</object>';
  }
  else
  {
    str += '<embed ';
    for (var i in embedAttrs)
    {
      str += i + '="' + embedAttrs[i] + '" ';
    }
    str += '> </embed>';
  }

  return str;
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  document.write(AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs));
}

function AC_FL_GetContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  return AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  document.write(AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs));
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblclick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "menu":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
	  case "type":
	  case "swContextMenu":
	    ret.objAttrs[args[i]] = args[i+1];
	    ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
	    break;		
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}
/* [INCLUDE FILE] AC_ActiveX */
//v1.1
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AX_RunContent(){
  var ret = AC_AX_GetArgs(arguments);
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_AX_GetArgs(args){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "pluginspage":
      case "type":
      case "src":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "data":
      case "codebase":
      case "classid":
      case "id":
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  return ret;
}


function AC_JA_GetArgs(args){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
	  case "archive":
	  case "code":
      case "pluginspage":
      case "type":
      case "src":
      case "data":
      case "codebase":
      case "classid":
      case "id":
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  return ret;
}

function AC_GenerateApplet(objAttrs, params, embedAttrs) 
{ 
	
  var str = '<applet ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '</applet>';
//	alert(str);
  document.write(str);
}

function AC_JA_RunContent(){
  var ret = 
    AC_JA_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_GenerateApplet(ret.objAttrs, ret.params, ret.embedAttrs);
}
/* [INCLUDE FILE] tooltips */
//Edit the information between the quotes below with the path to your image.
var imagePath = "images/tooltiparrow.gif";

function addwarning(){
var thealinks = document.getElementsByTagName("a");
if (!thealinks) { return; }

for(var x=0;x!=thealinks.length;x++){

if(thealinks[x].className == "addToolTip"){
thealinks[x].setAttribute("tooltiptext",thealinks[x].title);
thealinks[x].removeAttribute("title");
thealinks[x].onmouseover=function gomouseover(){ddrivetip(this.getAttribute("tooltiptext"))};
thealinks[x].onmouseout=function gomouseout(){hideddrivetip();};
}
}
}

var offsetfromcursorX=15; //Customize x offset of tooltip
var offsetfromcursorY=15; //Customize y offset of tooltip

var offsetdivfrompointerX=0; //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=0; //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

document.write('<div id="theToolTip"></div>'); //write out tooltip DIV
document.write('<img id="ToolTipPointer" src="/images/x.gif" style="display:none;"/>'); //write out pointer image

var ie=document.all;
var ns6=document.getElementById && !document.all;
var enabletip=false;
if (ie||ns6) {
	var tipobj=document.all? document.all["theToolTip"] : document.getElementById? document.getElementById("theToolTip") : "";
}

var pointerobj=document.all? document.all["ToolTipPointer"] : document.getElementById? document.getElementById("ToolTipPointer") : "";

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function ddrivetip(thetext, thewidth, thecolor){
if (ns6||ie){
if (typeof thewidth!=="undefined") {tipobj.style.width=thewidth+"px";}
if (typeof thecolor!=="undefined" && thecolor!=="") {tipobj.style.backgroundColor=thecolor;}
tipobj.innerHTML=thetext;
enabletip=true;
return false;
}
}

function positiontip(e){
if (enabletip){
var nondefaultpos=false;
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20;
var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20;

var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX;
var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY;

var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000;

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth){
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=curX-tipobj.offsetWidth+"px";
nondefaultpos=true;
}
else if (curX<leftedge)
{tipobj.style.left="5px";}
else{
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px";
pointerobj.style.left=curX+offsetfromcursorX+"px";
}

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight){
tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px";
nondefaultpos=true;
}
else{
tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px";
pointerobj.style.top=curY+offsetfromcursorY+"px";
}
tipobj.style.visibility="visible";
if (!nondefaultpos) {pointerobj.style.visibility="visible";}
else{
pointerobj.style.visibility="hidden";}
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false;
tipobj.style.visibility="hidden";
pointerobj.style.visibility="hidden";
tipobj.style.left="-1000px";
tipobj.style.backgroundColor='';
tipobj.style.width='';
}
}

document.onmousemove=positiontip;
addwarning();