var initialized	= false;
var theTime		= 0;

Event.observe(window, 'load', function() { init(); });
Event.observe(window, 'load', function() { refreshAd(); });

function init() {
	var flashvars = {
		configURL: swf_config,
		JSEventListener:"handleMosaicEvent",
		OMNITURE_ACCOUNT: omni_account,
		OMNITURE_MOVIEID: omni_movieid,
		OMNITURE_VISITORNAMESPACE: omni_vistornamespace,
		OMNITURE_TRACKINGSERVER: omni_trackingserver,
		OMNITURE_TRACKCLICKMAP: omni_trackclickmap,
		OMNITURE_TRACKLOCAL: omni_tracklocal,
		OMNITURE_TESTSUPPORT: omni_testsupport
	};
	var params = {
		bgcolor: "#ffffff",
		allowscriptaccess: "always",
		allowFullScreen:"true"
	};
	var attributes = {
		id:"mosaicModule",
		name:"mosaicModule"
	};

	swfobject.embedSWF(swf_player, "moduleDiv", "832", "468","9", "expressinstall.swf",  flashvars, params, attributes);
}

function selectStream(p_ID) {
	if (initialized) {	// only let calls go through after the module is initialized
		var module = (navigator.appName.indexOf("Microsoft") != -1) ? window["mosaicModule"] : document["mosaicModule"];

		module.selectStream(p_ID);
	}
}

function mute(p_v) {
	if (initialized) {	// only let calls go through after the module is initialized
		var module = (navigator.appName.indexOf("Microsoft") != -1) ? window["mosaicModule"] : document["mosaicModule"];

		module.mute(p_v);
	}
}

function handleMosaicEvent(p_evt) {
	switch (p_evt.type) {
		case "initialized":
			initialized = true;
			break;
		case "feedSelected":
			break;
		case "feedRequested":
			break;
		case "prerollAdRequested":
			// perform ad banner swap
			window.frames["bannerAd"].location.replace("http://www.dreamsocket.com");
			break;
	}
}

// Timer for ad refreshing
function refreshAd () {
    theTime = setInterval ( "cnnad_refreshAds()", ad_refresh_length );
}

function adtimer () {
//	var adURL = "http://ads.tnt.tv/html.ng/site=pga&pga_pagetype=live1&pga_pos=728x90_sync&pga_rollup=majors&pga_section=pga&pga_subsection=video&page.allowcompete=yes";
	var html = '<iframe hspace="0" vspace="0" marginHeight="0" marginWidth="0" src="' + ad_url + '" border="0" frameborder="0" width="728" height="90" scrolling="no"  id="banner_ad_frame"></iframe>';

	document.getElementById("ad_728").innerHTML = html;
}
