function initAdUnit() {
    // debug info:
    // alert('initAdUnit executing');
    so2 = new SWFObject("/assets/scet/game/swf/ad_unit.swf?" + Math.floor(Math.random()*10000), "ad_unit", "512", "288", "9", "#dddddd");
    so2.addVariable("outletConfigXML", nbcu.app.scet.game.getParam("baseUri") + "/videoxml");
    so2.addVariable("adBridgeId", adUnitBridge);
    
    so2.addParam("allowScriptAccess","always");
    so2.addParam("allowFullScreen", "true");
    
    // debug info: restoring the following line to debug IE:
	if (navigator.appName.indexOf('Microsoft')!=-1) {
        if (jqN.browser.msie && jqN.browser.version.substr(0,1) < 7) {
            so2.write("videoAd");
        }
    }

	jqN('input#snf_email, input#sn_password').click(function() {
	    jqN('input#snf_email, input#sn_password').css("color","#333333")
	    jqN(this).val('');
	    jqN(this).blur(function() {
	        if(jqN(this).val() == ''){
		        jqN(this).val(emailTxtLabel)
	        }
	    })
		// jqN("#companionAd").css("visibility","visible");
	})
	jqN('#flashcontent').css('overflow','hidden');
    // debug info:
	if (navigator.appName.indexOf('Microsoft')==-1) {
        jqN('#harness-ads').css('display', 'none');
        jqN('#videoAdOuter').css('display','none');
        jqN("#videoAd").css('display', 'none');
    } else {
        if (jqN.browser.msie && jqN.browser.version.substr(0,1) < 7) {
	        jqN("#videoAd").css({'visibility':'visible', 'position':'absolute','bottom':'-2000px','z-index':'100', 'background':'transparent'});
        } else {
	        jqN("#videoAd").css({'visibility':'visible', 'position':'absolute','z-index':'1', 'background':'transparent'});
            so2.write("videoAd");
            jqN("#videoAd").css({"visibility":"visible", 'z-index':'9999','bottom':'60px'});
	        jqN("#videoAd").css({'visibility':'hidden'});

            /*
            jqN('#harness-ads').css({'visibility':'hidden', 'background':'transparent'});
            */

            jqN('#harness-ads').css('display', 'none');
            jqN('#videoAdOuter').css('display','none');
            jqN("#videoAd").css('display', 'none');
            
        }
    }


    jqN('#harness-ads').css({'z-index':'9999'});
    jqN('#companionAd').css('z-index','9999');
    // debug info: restore following line and place in if/else block to check for IE7 or greater
	if (navigator.appName.indexOf('Microsoft')==-1 || (jqN.browser.msie && jqN.browser.version.substr(0,1) < 7)) {
        jqN("#videoAd").css({"visibility":"visible", 'z-index':'9999','bottom':'60px'});
    }
    jqN("#companionAd").css("visibility","visible");
    jqN("#companionAd").css("display","block");

	jqN(function() {
		// jqN('body.nbcuni_gameSCET').append('<div id="blackout_game" style="z-index:9990"></div>');
		jqN('label[for="snf_email"], label[for="sn_password"]').hide();
		var emailTxtLabel = jqN('label[for="snf_email"]').text().split(":")[0];
		jqN('input#snf_email').val(emailTxtLabel)
		jqN('input#sn_password').val(jqN('label[for="sn_password"]').text())		
	})

    jqN(document).ready(function() {
        // debug info:
        // alert('page loaded');
	    if (navigator.appName.indexOf('Microsoft')==-1 || (jqN.browser.msie && jqN.browser.version.substr(0,1) < 7)) {
            jqN('#harness-ads').css('display', '');
            jqN('#videoAdOuter').css('display','');
            jqN('#videoAd').css('display', '');
	        jqN("#videoAd").css({'visibility':'hidden', 'position':'absolute','z-index':'100', 'background':'transparent'});
        }
    
	    // if (navigator.appName.indexOf('Microsoft')==-1 || (jqN.browser.msie && jqN.browser.version.substr(0,1) >= 7)) {
	    if (navigator.appName.indexOf('Microsoft')==-1 ) { //  || (jqN.browser.msie && jqN.browser.version.substr(0,1) >= 7) {
            so2.write("videoAd");
            jqN('#companionAd').css('display', 'none');

        }
    }); 

    // debug info:
    // alert('initAdUnit finished executing');
        
}

function playAd() {
    // debug info:
    // alert('playAd executing');

    // BEGIN new CSS
    jqN('#harness-ads').css('display', '');
    jqN('#videoAdOuter').css('display','');
    jqN('#videoAd').css('display', '');
    jqN('#companionAd').css('display', '');
    // jqN("#companionAd").css("display","block");
    /*
	jqN("#harness-ads").css('visibility','visible');
    jqN('#harness-ads').css({'z-index':'9999'});
    jqN('#companionAd').css('z-index','9999')
    jqN("#videoAd").css({"visibility":"visible", 'z-index':'9999','bottom':'60px'});
    jqN("#companionAd").css("visibility","visible");
    jqN("#companionAd").css("display","block");
    */
    // END new CSS

	var adUnitBridge;
	if(navigator.appName.indexOf('Microsoft')!=-1)
	{
		adUnitBridge = window.ad_unit;
	} else {
		adUnitBridge = window.document.ad_unit;
	}
	
	adUnitBridge.playAd();
}

function setVideoId(myVideoId) {
    // debug info:
    // alert('setVideoId executing');

        var adUnitBridge;
        if(navigator.appName.indexOf('Microsoft')!=-1)
        {
                adUnitBridge = window.ad_unit;
        } else {
                adUnitBridge = window.document.ad_unit;
        }

        adUnitBridge.setVideoId(myVideoId);
}

// JavaScript Document
function adBegin() {
    // debug info:
    // alert('adBegin executing');
        // BEGIN new CSS
        jqN('#harness-ads').css('display', '');
        jqN('#videoAdOuter').css('display','');
        jqN('#videoAd').css('display', '');
        jqN('#companionAd').css('display', '');
        // END new CSS

		jqN("#flashcontent").css({"visibility":"visible","height":"500px"});
		
		jqN("embed#game_harness").css({"height":"0px"})
		jqN("#harness-ads").css('visibility','visible');
		jqN('#harness-ads').css({'z-index':'9999'});
		jqN('#companionAd').css('z-index','9999')
		jqN("#videoAd").css({"visibility":"visible", 'z-index':'9999','bottom':'60px'});
		jqN("#companionAd").css("visibility","visible");
              	jqN("#companionAd").css("display","block");
		
		var gameHarnessSwf;
		if(navigator.appName.indexOf('Microsoft')!=-1)
		{
			gameHarnessSwf = window.game_harness;
		} else {
			gameHarnessSwf = window.document.game_harness;
		}

		gameHarnessSwf.adUnitOnAdBegin();
}

function adComplete() {
    // debug info:
    // alert('adComplete executing');

		jqN("embed#game_harness").css({"height":"500px"})

        // BEGIN new JS:
        /*
        jqN('#harness-ads').css('display', 'none');
        jqN('#videoAd').css('display', 'none');
        jqN('#companionAd').css('display', 'none');
        */
        // END new JS

		jqN("#harness-ads").css('visibility','hidden');
		// jqN("#videoAd").css({"visibility":"visible", "bottom":"-2000px", "z-index":"100"});
		jqN("#videoAd").css({"visibility":"hidden", "z-index":"100"});
		jqN("#companionAd").css("visibility","hidden");
        
		
		var gameHarnessSwf;
		if(navigator.appName.indexOf('Microsoft')!=-1)
		{
			gameHarnessSwf = window.game_harness;
		} else {
			gameHarnessSwf = window.document.game_harness;
		}

		gameHarnessSwf.adUnitOnAdComplete();
}

function adUnitInitComplete() {
    // debug info:
    // alert('adUnitInitComplete executing');

	var gameHarnessSwf;

	if(navigator.appName.indexOf('Microsoft')!=-1)
	{	
		gameHarnessSwf = window.game_harness;
	} else {
	
		gameHarnessSwf = document.game_harness;
	}
	
    gameHarnessSwf.adUnitOnPlayerReady();
}

/* Moved to template
function kingDotComFeed() {
	var myString = encodeURI('<midasplayer><game id="158" shortname="amazing_adventures" name="Amazing Adventures" description="Travel around the world and find all the objects in the picture!" description_long="You need to know what you are looking for in this Seek & Find game. Every location hides a number of objects, and it is up to you to find them! Find them all, and you will qualify for the bonus mini-game!" practice="true" money="true" subscription="true" new="false" multiplayer="false" link="http://www5.king.com/servlet/SelectServlet?partner=nbc&lang=en_US&country=US&target=%2Fgame%2Fstrategy-games%2Famazing-adventures%2F%3Flanguage%3Den_US"><image format="150x75" width="150" height="75" url="http://images.midasplayer.com/images/games/amazing_adventures_150x75.gif"/><image format="150x88" width="150" height="88" url="http://images.midasplayer.com/images/games/amazing_adventures_150x88.gif"/><image format="147x89" width="147" height="89" url="http://images.midasplayer.com/images/games/amazing_adventures_147x89.gif"/><image format="80x49" width="80" height="49" url="http://images.midasplayer.com/images/games/amazing_adventures_80x49.gif"/><instruction>Read what items you need at the bottom of the screen, and click them in any order.</instruction><instruction>You get a score penalty every time you click on items that are not listed, and a speed bonus if you find several quickly.</instruction><instruction>Click "Hint" if you cannot find an object, but this will cost you valuable points.</instruction><jackpot>$134.40</jackpot></game><game id="83" shortname="bejeweled2" name="Bejeweled 2" description="A sequel to the classic gem-switching game." description_long="This is the sequel to Bejeweled, the game that set off the casual gaming explosion when it was released! Switch the gems and create rows of three to score points. Rows of four and five generate fantastic powerups that will make your score go through the roof!" practice="true" money="true" subscription="true" new="false" multiplayer="false" link="http://www5.king.com/servlet/SelectServlet?partner=nbc&lang=en_US&country=US&target=%2Fgame%2Fpuzzle-games%2Fbejeweled-2%2F%3Flanguage%3Den_US"><image format="150x75" width="150" height="75" url="http://images.midasplayer.com/images/games/bejeweled2_150x75.gif"/><image format="150x88" width="150" height="88" url="http://images.midasplayer.com/images/games/bejeweled2_150x88.gif"/><image format="147x89" width="147" height="89" url="http://images.midasplayer.com/images/games/bejeweled2_147x89.gif"/><image format="80x49" width="80" height="49" url="http://images.midasplayer.com/images/games/bejeweled2_80x49.gif"/><instruction>Clear the gems by switching their places. First click one gem, and then move your mouse pointer over another gem that is adjacent to the first. You can only move if you create a row of at least three gems of the same colour.</instruction><instruction>If you create a row of four gems, you will be awarded a power gem. To blow up a power gem, include it in a row of at least two gems of the same colour.</instruction><instruction>Create a row of five or more gems to create a hyper cube. To activate the hyper cube, move it to one of the gems adjacent to it. The hyper cube will remove all gems of that colour from the board.</instruction><jackpot>$2187.15</jackpot></game><game id="175" shortname="scrabble_zing" name="SCRABBLEô ZING" description="SCRABBLEô ZING is a skill version of the classic board game" description_long="SCRABBLEô ZING is a skill version of the classic board game. It is a single-player game where you create words on the board to score the most points. Bonus points are awarded if you use all 7 tiles in a single round or a single word!" practice="true" money="true" subscription="true" new="true" multiplayer="false" link="http://www5.king.com/servlet/SelectServlet?partner=nbc&lang=en_US&country=US&target=%2Fgame%2Fword-games%2Fscrabble-zing%2F%3Flanguage%3Den_US"><image format="150x75" width="150" height="75" url="http://images.midasplayer.com/images/games/scrabble_zing_150x75.gif"/><image format="150x88" width="150" height="88" url="http://images.midasplayer.com/images/games/scrabble_zing_150x88.gif"/><image format="147x89" width="147" height="89" url="http://images.midasplayer.com/images/games/scrabble_zing_147x89.gif"/><image format="80x49" width="80" height="49" url="http://images.midasplayer.com/images/games/scrabble_zing_80x49.gif"/><instruction>Form words by placing tiles on the board. The first word must be placed on the star in the middle.</instruction><instruction>If you place all tiles in one round, you will get bonus points. If they all form a single word, your bonus will be even higher.</instruction><instruction>The game consists of 5 rounds. When you have played 5 rounds or run out of time, the game is over.</instruction></game><game id="122" shortname="catcorner" name="Cat Corner" description="Corner the Cats in this Jazzy game!" description_long="The Cats are all scrambled and need to be brought back to order. Create Rectangles where all four corners are of the same colour, and bring in the herring to maximize your score and keep the cats happy!" practice="true" money="true" subscription="true" new="false" multiplayer="false" link="http://www5.king.com/servlet/SelectServlet?partner=nbc&lang=en_US&country=US&target=%2Fgame%2Fstrategy-games%2Fcat-corner%2F%3Flanguage%3Den_US"><image format="150x75" width="150" height="75" url="http://images.midasplayer.com/images/games/catcorner_150x75.gif"/><image format="150x88" width="150" height="88" url="http://images.midasplayer.com/images/games/catcorner_150x88.gif"/><image format="147x89" width="147" height="89" url="http://images.midasplayer.com/images/games/catcorner_147x89.gif"/><image format="80x49" width="80" height="49" url="http://images.midasplayer.com/images/games/catcorner_80x49.gif"/><instruction>Click and hold your left mouse button to create a rectangle. You need to create rectangles where all four corners have the same colour.</instruction><instruction>Larger rectangles give more points, and later levels have more cats, making it possible to reach the really high scores.</instruction><instruction>The powerups need to be in one of the four corners to count. The clock increases your time, the herring increases your score, and the Cool Cat flips all cats of the same colour.</instruction><jackpot>$700.00</jackpot></game><game id="98" shortname="chuzzle" name="Chuzzle" description="Create big groups of cute Chuzzles!" description_long="Match the Chuzzles by colour and watch out for the Chuzzle Locks! Super Chuzzles and Giant Chuzzles add diversity to the skill version of this popular game!" practice="true" money="true" subscription="true" new="false" multiplayer="false" link="http://www5.king.com/servlet/SelectServlet?partner=nbc&lang=en_US&country=US&target=%2Fgame%2Fpuzzle-games%2Fchuzzle%2F%3Flanguage%3Den_US"><image format="150x75" width="150" height="75" url="http://images.midasplayer.com/images/games/chuzzle_150x75.gif"/><image format="150x88" width="150" height="88" url="http://images.midasplayer.com/images/games/chuzzle_150x88.gif"/><image format="147x89" width="147" height="89" url="http://images.midasplayer.com/images/games/chuzzle_147x89.gif"/><image format="80x49" width="80" height="49" url="http://images.midasplayer.com/images/games/chuzzle_80x49.gif"/><instruction>Grab a Chuzzle to move the line its part of, either horizontally or vertically.</instruction><instruction>When you have created a group of 3 or more Chuzzles, release your mouse button, and they will disappear.</instruction><instruction>Chuzzle locks and Giant Chuzzles can hinder your movement, but there is always at least one move to make!</instruction><jackpot>$466.19</jackpot></game><game id="162" shortname="monkey_quest" name="Monkey Quest" description="Help the Monkey burst the bubbles and survive the mine!" description_long="The Monkey needs to burst the bubbles in order to find the golden statue. Three different types of mini-games are located underground, and he has to release the stars to get there!" practice="true" money="true" subscription="true" new="false" multiplayer="false" link="http://www5.king.com/servlet/SelectServlet?partner=nbc&lang=en_US&country=US&target=%2Fgame%2Fpuzzle-games%2Fmonkey-quest%2F%3Flanguage%3Den_US"><image format="150x75" width="150" height="75" url="http://images.midasplayer.com/images/games/monkey_quest_150x75.gif"/><image format="150x88" width="150" height="88" url="http://images.midasplayer.com/images/games/monkey_quest_150x88.gif"/><image format="147x89" width="147" height="89" url="http://images.midasplayer.com/images/games/monkey_quest_147x89.gif"/><image format="80x49" width="80" height="49" url="http://images.midasplayer.com/images/games/monkey_quest_80x49.gif"/><instruction>Shoot the bubbles to create groups of 3 or more of the same colour. Release the star bubbles to enter a mini-game.</instruction><instruction>There are three mini-games, all discinctly different: Survival, Mining and Marksman.</instruction><instruction>The key to a good score is to make few shots and perform well in the mini-games, creating a golden statue in the end!</instruction><jackpot>$753.89</jackpot></game><game id="198" shortname="seashell" name="Seashell Squeeze" description="Switch the Seashells, blast columns and find the mermaid!" description_long="In the depths of the sea, the seashells stack up. Switch them and match them by colour to make the sea floor less crowded. As you remove seashells, the playing area will contract and make it harder and harder to find matches..." practice="true" money="true" subscription="true" new="true" multiplayer="false" link="http://www5.king.com/servlet/SelectServlet?partner=nbc&lang=en_US&country=US&target=%2Fgame%2Fpuzzle-games%2Fseashell-squeeze%2F%3Flanguage%3Den_US"><image format="150x75" width="150" height="75" url="http://images.midasplayer.com/images/games/seashell_150x75.gif"/><image format="150x88" width="150" height="88" url="http://images.midasplayer.com/images/games/seashell_150x88.gif"/><image format="147x89" width="147" height="89" url="http://images.midasplayer.com/images/games/seashell_147x89.gif"/><image format="80x49" width="80" height="49" url="http://images.midasplayer.com/images/games/seashell_80x49.gif"/><instruction>Click two seashells to make them switch places. Create lines of three or more of the same colour to remove them</instruction><instruction>When a column is empty, the play area will contract, making it harder to create matches.</instruction><instruction>There are three powerups: Bombs, column blasts and colour blasts. Use them wisely!</instruction><jackpot>$560.00</jackpot></game></midasplayer>');

	return myString;
}
*/

function activateDim() {
	// // jqN("#flashcontent").css({'visibility':'visible','z-index':'9990'});
	// jqN('#nbc2SCET_FLASH').css({'z-index':'9996'})
	// 
	// jqN('#blackout_game').css({'display':'block','background-color' : 'black', 'opacity':'0.7', 'position':'absolute', 'left':'0','top':'0','width':'100%','height':'2000px'});
	// // jqN('#nbc2SCET_FLASH').css({'z-index':'9998'});
	// jqN('#nbc-728').css({'z-index':'9999','opacity':'.6'});
	// jqN('.nbc-navigation').hide();
	// jqN('#blackout_game').click(function() {
	// 	deactivateDim();
	// })
}

function deactivateDim() {
	// jqN('#blackout_game').hide();
	// jqN('#nbc2SCET_FLASH').css({'z-index':'9996'})
		jqN('.nbc-navigation').show();
}

function refreshAd() {
    // debug info:
    // alert('refreshAd executing');

	nbcu.app.scet.game.refreshMetrics();
}

function onPageClose() {
    // debug info:
    // alert('onPageClose executing');

	var gameHarnessSwf;
	if(navigator.appName.indexOf('Microsoft')!=-1)
	{
		gameHarnessSwf = window.game_harness;
	} else {
		gameHarnessSwf = window.document.game_harness;
	}
	
	gameHarnessSwf.closeGame();
}

function onGameComplete() {
    // debug info:
    // alert('onGameComplete executing');

	if (nbcu.sn.session.getExternalPlatformUserId() || nbcu.sn.session.isLoggedIn()) {
		setTimeout("nbcu.app.scet.game.showProfileData();", 750);
	}
}

