window.NbcuPando = jQuery.extend(true, {}, window.Pando);
window.Pando.Install.actions.message = function() {
	window.NbcuPando.Install.actions.message();
	window.pmbStatusKnownFlag = true;
};


window.Pando.Install.actions.upgrade = function() {
	window.NbcuPando.Install.actions.upgrade();
	window.pmbStatusKnownFlag = true;
};
window.Pando.Install.actions.forceUpgrade = function() {
	window.NbcuPando.Install.actions.forceUpgrade();
	window.pmbStatusKnownFlag = true;
};
window.Pando.compatability = function() {
	// exact copy from original except the alert is not displayed and window.pmbStatusKnownFlag = false
	var operatingSystems = {
		windows: new Array(),
		mac: new Array()
	};
	
	operatingSystems.windows.push("Internet Explorer 7");
	operatingSystems.windows.push("Internet Explorer 6");
	operatingSystems.windows.push("Firefox 3");
	operatingSystems.windows.push("Firefox 2");
	operatingSystems.windows.push("Chrome");
	
	operatingSystems.mac.push("Firefox 3");
	operatingSystems.mac.push("Firefox 2");
	operatingSystems.mac.push("Safari");
	operatingSystems.mac.push("Chrome");  
	operatingSystems.mac.push("Camino");
	
	var dividerString = "= = = = = = = = = = = = = = = = = = = =";
	
	var compatible = false;
	if (Pando.windows) {
		if (jqN.browser.msie || jqN.browser.mozilla || /chrome/.test( navigator.userAgent.toLowerCase() )) {
			compatible = true;
		}					
	} else if (Pando.mac) {
		if (jqN.browser.mozilla || jqN.browser.safari || /chrome/.test( navigator.userAgent.toLowerCase() )) {
			compatible = true;
		}
	}
	if (!compatible) {
		if (typeof Pando.config.compatability.callback.func != "undefined" && !Pando.config.compatability.callback.func) {
			var alert_string = "";
			if (typeof Pando.config.compatability.alert_message != "undefined") {
				alert_string = Pando.config.compatability.alert_message; 
				alert_string += "\n";
				alert_string += "\n";
			}					
			alert_string += dividerString;
			alert_string += "\n";
			alert_string += "\n";
			alert_string += "Windows\n";
			for (var elm in operatingSystems.windows) {
				alert_string += operatingSystems.windows[elm];
				alert_string += "\n";
			}
			alert_string += "\n";
			alert_string += "Mac\n";		
			for (var elm in operatingSystems.mac) {
				alert_string += operatingSystems.mac[elm];
				alert_string += "\n";
			} 
			alert_string += "\n";
			alert_string += dividerString;
//			alert(alert_string);
		} else {
			var objectNamespace = Pando.config.compatability.callback.func;
			var objectArgs = false;
			if (typeof Pando.config.compatability.callback.args != "undefined") {
				objectArgs = Pando.config.compatability.callback.args;
			}
			if (objectArgs) {
				new objectNamespace(objectArgs);
			} else {
				new objectNamespace();
			}
		}
		
		window.pmbStatusKnownFlag = false;
//		window.pmbInstalledFlag = false;
	}	
//	return compatible;		
	return true;
};
window.Pando.Plugin.init = function() {
//	debug('calling plugin init');
	setTimeout("window.NbcuPando.Plugin.init();", 5000);
};


var isDirectReady = false;

jqN(document).ready(function() {
	if (Direct.OSDetection() == 'Mac') {
		jqN('.user-control-library').hide();
	}
	
	if (!isFullEpisode) {


		tooltip(
			jqN('.user-control-library').unbind().addClass('inactive').css('cursor', 'default'),
			'MY LIBRARY is currently only available when viewing a Full Episode.',
			{
				preShow: function(box) {
					jqN('#user-controls').after(jqN('.bt-wrapper').addClass('my-library-tooltip'));
				}
			}
		);
	
	} else if (!Direct.canRunDirect()) {

		tooltip(
			jqN('.user-control-library').unbind().addClass('inactive').css('cursor', 'default'),
			'My Library is available for the HD+ download service (PC only).  Click Preferences then select the "Best" viewing option in the General Preferences tab to access this feature.',
			{
				preShow: function(box) {
					jqN('#user-controls').after(jqN('.bt-wrapper').addClass('my-library-tooltip'));
				}
			}
		);
	}
	
	jqN('.user-control-preferences').click(function() {
		if (!isDirectReady || activeAd) {
			return false;
		}
		//dimScreen();

		jqN('.user-control-library').removeClass('userControlActive');
		jqN(this).addClass('userControlActive');
		showPreferences();
 
	});

	jqN('.user-control-faq').click(function() {
		hidePreferences();
		hideLibrary();
	});


	jqN('.user-control-whats-new').click(function() {
		hidePreferences();
		hideLibrary();
	});
});


function getSizeOptions(prop) {
	var sizes = {
		fullscreen: {id:"fullscreen", width:1280, height:720},
		large: {id:"large", width:896, height:529},
		normal: {id:"normal", width:640, height:385},
		popout: {id:"popout", width:512, height:325},
		full: {id:"full", width:971, height:571} //971x571
	};
	
	// default to large if the size is not found	
	return (sizes[prop] != undefined) ? sizes[prop]: sizes.large;
}

// called by flex when the user has requested to change the player size
function prepCanvas(size) {
	jqN('#video-player').removeClass();
	jqN('#nbc-right-content').removeClass();
	//var stageWidth = document.documentElement.clientWidth;
	//var stageHeight = jqN('#nbc-wrapper').height()+jqN('#nbc-footer').height();
	switch (size) {


		// controls are eventually going to be 25 pixels high. now they are 37 pixels high
		case "normal":
	if(isDimmed == true)
			{
			//var stageHeight = jqN('#nbc-wrapper').height()+jqN('#nbc-footer').height();


		//jqN('#trans-overlay').height(stageHeight); 
			}

			break;

		case "large":
			//alert(isDimmed);
			
			jqN('#video-player').addClass('large-canvas');
			jqN('#nbc-right-content').addClass('large-canvas'); 
			jqN('#scet_mainContent').addClass('large-canvas'); 	
		   if(isDimmed == true)
			{
			//var stageHeight = jqN('#nbc-wrapper').height()+jqN('#nbc-footer').height();


		//jqN('#trans-overlay').height(stageHeight); 
			}
			break;
			
		case "full":
			//jqN('#video-player').addClass('full-canvas');
			jqN('#nbc-right-content').addClass('full-canvas'); 
			jqN('#scet_mainContent').addClass('full-canvas'); 
			jqN('#video-player').addClass('full-canvas');
			//jqN('#nbc-right-content').addClass('large-canvas');  //just trying something here (ph)

			break;

		default:
	}
}

function goToVideo(videoId) {
	if (jqN('#comment-content').css('display') != 'none' && jqN('#comment-content .sn_comment_form_div').css('display') != 'none' && jqN('.sn_comment_form_div form.sn_comment_form').length > 0) {
		setTimeout("goToVideo(" + videoId + ")", 1000);
		return;
	}
	
	if (videoId) {
	    window.location = "http://www.nbc.com/app/video/redirect_by_video_id.php?videoId=" + videoId;
	}
}

function getDirectVersion(){
	return Direct.getExternal().Version;
}

function logToDirect(logLevel, logMessage){
	Direct.getExternal().log(logLevel, logMessage);
}

function getSProp10(){
	return s_prop10;
}

var firstVideoId = assetId;
var isInFullscreen = false;
var escapeFullscreenSize = '';
var initialSize = '';
var activeAd = false;
var interceptScreenEnabled = false;
var prevDimState = false;

function loadFlash()
{
	var value = null;
	var specialInitParams = "";
	QueryString_Parse();

	if (isFullEpisode) {
		interceptScreenEnabled = true;	
		initialSize = 'large';
	} else {
		initialSize = 'normal';
	}


	prepCanvas(initialSize);
	initialSize = getSizeOptions(initialSize);
	escapeFullscreenSize = initialSize.id;
	
	document.getElementById('scet-main-video').innerHTML = '<a target="_blank" href="http://get.adobe.com/flashplayer/"><img src="/assets/scet/video/images/flash-requirement.gif" border="0" alt="This content requires Flash. To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player. Download the free Flash Player now!"/></a>';
	var so = new SWFObject("/assets/video/4-0/swf/NBCVideoApp.swf", "rewindpl3_0", initialSize.width, initialSize.height, "10");
	so.addParam("allowScriptAccess", "always");
	so.addParam("allowFullScreen", "true");
	so.addParam("autoplay", "true");
	so.addParam("scale", "noborder");

	so.addParam("wmode", "transparent");
	so.addParam("salign", "TL");

    if (!isFullEpisode) {
        if (nbcu.config.getParam("nbcuEnvironment") == 'production') {
            if (document.domain.indexOf("themoreyouknow.com") >= 0) {
                so.addVariable("configId", 16010);
            } else {
                so.addVariable("configId", 16009);
            }
        } else {
            so.addVariable("configId", 16209);
        }
        // specify the size of the ads in the player
        so.addVariable("AdEngineExtension__adCanvasWidth", 640);
        so.addVariable("AdEngineExtension__adCanvasHeight", 360);    // restrict the sizes to fullscreen + normal
        specialInitParams = "?isShortForm=true%26videoId=" + firstVideoId;
    }

    if (parentCategoryId && parentCategoryId == 30488) {
        so.addVariable("configId", 17010);
        specialInitParams = "?videoId=" + firstVideoId;
    }

    if (showId) {
        if (showId == 352) {
            if (specialInitParams == '') {
                specialInitParams = '?siteId=352';
            } else {
                specialInitParams += '%26siteId=352';
            }
        }
    }

	so.addVariable("initURL", baseUri.replace('video2', 'video') + "/episodes/init.xml" + specialInitParams);
	so.addVariable("rewindConfigURL", "/assets/video/4-0/xml/outlet_config.xml");
	so.addVariable("directConfigURL", "/assets/video/4-0/xml/outlet_direct_config.xml");
	so.addVariable("offlineConfigURL", "/assets/video/4-0/xml/outlet_offline_config.xml");
	so.addVariable("directDownloadURL", "/video/direct/NBCDirectInstaller4-0.exe");
	so.addVariable("playbackQualityXML", "/assets/video/4-0/xml/PlaybackQualityOptions.php");
	so.addVariable("initialSize", initialSize.id);
	so.addVariable("interceptScreenEnabled", false);

	so.addVariable("OptionsExtension__showID", showId);
	so.addVariable("OptionsExtension__initXML", baseUri.replace('video2', 'video') + "/episodes/init.xml" + specialInitParams);
	so.addVariable("OptionsExtension__configXML", widgetConfigUri);
	so.addVariable("OptionsExtension__siteURL", nbcu.app.scet.video.getParam("pageUri"));	
	
	so.addVariable("versionCheck", "/assets/video/4-0/xml/versioncheck.xml");
	so.addVariable("forceRewind", "false");
	
	for (var i=0;i<QueryString.keys.length;i++)
	{
		so.addVariable(QueryString.keys[i],QueryString.values[i]);
	}
	so.write("scet-main-video");
}

/** API Begin **/

// Executed when My LIbrary and Preferences panels are closed.
function popupPanelClosed()
{
	jqN('.user-control-library').removeClass('userControlActive');
	jqN('.user-control-preferences').removeClass('userControlActive');
removeDim();
	changePlayerSize(escapeFullscreenSize);
}

function interceptOpened()
{
	if (isFullEpisode) {
		changePlayerSize('full');
	}
}

function interceptClosed()
{
	changePlayerSize(escapeFullscreenSize);
}

// called by flex when the user has requested to change the player size
function changePlayerSize(size)
{

	prepCanvas(size);
	switch (size)
	{
		// controls are eventually going to be 25 pixels high. now they are 37 pixels high
		case "normal":
			jqN('#scet-main-video').css('padding-top', '6px');
			thisMovie().width=640;
			thisMovie().height=385;
			notifyPlayerOfSizeChange(size);
			jqN('#video-player').removeClass('large-canvas');
	jqN('#video-player').removeClass('full-canvas');
jqN('#nbc-right-content').removeClass('large-canvas'); 
jqN('#scet_mainContent').removeClass('large-canvas'); 
jqN('#nbc-right-content').removeClass('full-canvas'); 
			jqN('#scet_mainContent').removeClass('full-canvas');

			break;

		case "large":
			jqN('#scet-main-video').css('padding-top', '6px');
			thisMovie().width=896;
			thisMovie().height=529;
		
			notifyPlayerOfSizeChange(size);
		
			break;
		case "full":
			jqN('#scet-main-video').css('padding-top', '0');
			thisMovie().width=971;
			thisMovie().height=571; // 546 branded canvas height + 25 pixels for the countdown timer
			break;
		case "popout":
			// size player to 512x288 and pop out
			thisMovie().width=512;
			thisMovie().height=325;
			notifyPlayerOfSizeChange(size)
			break;
		case "fullscreen":
			// size player to 1280x720
			thisMovie().width=1280;
			thisMovie().height=720;
			notifyPlayerOfSizeChange(size);	
			break;
		default:
			alert("Error, attempt to request invalid size from Flex Application")

	}
}



// Notifies the player that its size has changed.
function notifyPlayerOfSizeChange(size)
{
	// valid values are "fullscreen", "normal", "large", and "popout"
	if(size != "fullscreen") escapeFullscreenSize = size;
	thisMovie().playerSizeChanged(size);
}

// Event handler for fullscreen events from Flash
function onFullscreenEvent(isFullScreen)
{	

		isInFullscreen = isFullScreen; // isInFullscreen is a js variable to track the fullscreen status of the player
	if((!isFullScreen) && (activeAd==true)) {
		
//dimScreen();

		changePlayerSize("full");
		
	}
	else if (!isFullScreen) {
		changePlayerSize(escapeFullscreenSize);

	}
}

// Instructs the player to play a long or short form video
function instructPlayerToPlayVideo(videoID, timeIn, timeOut)
{
	thisMovie().playVideo(videoID, timeIn, timeOut);
}

function showPreferences()
{
	thisMovie().togglePreferences(true);
	changePlayerSize("full");
if(isDimmed == true)
			{
			//var stageHeight = jqN('#nbc-wrapper').height()+jqN('#nbc-footer').height();


		//jqN('#trans-overlay').height(stageHeight); 
			}
}

function hidePreferences()
{
	thisMovie().togglePreferences(false);
	popupPanelClosed();
}

function showLibrary()
{
	if(Direct.canRunDirect())
	{
		thisMovie().toggleLibrary(true);
		changePlayerSize("full");
	}
	else
	{
		alert("This functionality is available only for NBC Direct users.");
	}		
}

function hideLibrary()
{
	thisMovie().toggleLibrary(false);
	popupPanelClosed();
}

// Helper method to get the dom reference to the player.  This might be done elsewhere by the NBC JS team
function thisMovie() {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        var movie = window["rewindpl3_0"];
    } else {
    	var movie = document.getElementById("rewindpl3_0");
    }
    return movie;
}
/** API End **/
/*
var onPlayerModeUpdate = function(e) {
	if (e == 'direct' && isFullEpisode) {
		jqN('.user-control-library').unbind().click(function() {
			if (!isDirectReady || activeAd) {
				return false;
			}

			jqN('.user-control-preferences').removeClass('userControlActive');
			jqN(this).addClass('userControlActive');
			
			showLibrary();
		}).removeClass('inactive').css('cursor', 'pointer');
		return;
	}
	
	if (!isFullEpisode) {

		tooltip(
			jqN('.user-control-library').unbind().addClass('inactive').css('cursor', 'default'),
			'MY LIBRARY is currently only available when viewing a Full Episode.',
			{
				preShow: function(box) {
					jqN('#user-controls').after(jqN('.bt-wrapper').addClass('my-library-tooltip'));
				}
			}
		);		
	} else {



		tooltip(

			jqN('.user-control-library').unbind().addClass('inactive').css('cursor', 'default'),
			'My Library is available for the HD+ download service (PC only).  Click Preferences then select the "Best" viewing option in the General Preferences tab to access this feature.',
			{
				preShow: function(box) {
					jqN('#user-controls').after(jqN('.bt-wrapper').addClass('my-library-tooltip'));
				}
			}
		);

	}	
};
*/

var onPlayerModeUpdate = function(e) {
	if (e == 'direct' && isFullEpisode) {
		jqN('.user-control-library').unbind().click(function() {
			if (!isDirectReady || activeAd) {
				return false;
			}

			jqN('.user-control-preferences').removeClass('userControlActive');
			jqN(this).addClass('userControlActive');
			
			showLibrary();
		}).removeClass('inactive').css('cursor', 'pointer');
		return;
	}
	
	if (!isFullEpisode) {

		tooltip(
			jqN('.user-control-library').unbind().addClass('inactive').css('cursor', 'default'),
			'MY LIBRARY is currently only available when viewing a Full Episode.',
			{
				preShow: function(box) {
					jqN('#user-controls').after(jqN('.bt-wrapper').addClass('my-library-tooltip'));
				}
			}
		);		
	} else {




		tooltip(
			jqN('.user-control-library').unbind().addClass('inactive').css('cursor', 'default'),
			'My Library is available for the HD+ download service (PC only).  Click Preferences then select the "Best" viewing option in the General Preferences tab to access this feature.',
			{
				preShow: function(box) {
					jqN('#user-controls').after(jqN('.bt-wrapper').addClass('my-library-tooltip'));
				}
			}
		);

	}	
};

// IE compatible setup ad engine handler

var onAdBreakEnd = function(e)
{	
	activeAd = false;	
	if(!isInFullscreen)
	{
		//activeAd = false;
		if (!prevDimState) {
			removeDim();
		}
		jqN('#scet_mainContent').removeClass('full-canvas');
		changePlayerSize(escapeFullscreenSize);
	}
};

var onAdBreakComplete = function(e)
{		
	isDirectReady = true;
};

var onAdBegin = function(e)
{
	activeAd = true;

	if(!isInFullscreen)
	{
		activeAd = true;
		prevDimState = isUserDimmed;
		//dimScreen();
		/* if(isDimmed == true)
			{
			var stageHeight = jqN('#nbc-wrapper').height()+jqN('#nbc-footer').height();


		jqN('#trans-overlay').height(stageHeight); 
			}*/

		if (isFullEpisode) {
			changePlayerSize('full');
if(isDimmed == true)
			{
			var stageHeight = jqN('#nbc-wrapper').height()+jqN('#nbc-footer').height();


		//jqN('#trans-overlay').height(stageHeight); 
			}

		}
	}
$('.bt-wrapper').css('zIndex','99999997');

};

var onActiveLogoRequested = function(e)
{
	var output = document.getElementById("companionAdDiv");
	var src = e.data.url;
	var clickThru = e.data.clickThru;
	var lc = src.toLowerCase();
	if (lc.indexOf(".swf") > -1)
	{
//		alert("SWF 300x60 not supported.  File received: " + src);
	}
	else
	{
		if (typeof(src) != "undefined" && src) {
			output.innerHTML = '<a href="' + clickThru + '" class="ad300x60" target="_blank"><img src="' + src + '" id="img300x60"/></a>';
		}


	}
jqN(document).ready(function(){
jqN(document).pngFix();
});
	
};

var onAdEnd = function(e)
{
	if(e.data.ad.adType == "pause") onAdBreakEnd(e);
var output = document.getElementById("companionAdDiv");

jqN(document).ready(function(){
jqN(document).pngFix();
});
}

var onAdLoading = function(e)
{
	jqN("#companionAdDiv").html("");
}

var onPlayerStart = function(e)
{
	nbcu.app.scet.video.logEvent({ event: 'play' });
}

var onPlayerEnd = function(e)
{
	 nbcu.app.scet.video.logEvent({ event: 'completed' });
}

var adEngineExtension;
/*
var onOutletEvent = function(e)
{
	if(e.type == "outletInited")
	{
		adEngineExtension = Outlet.getOutletExtension("AdEngineExtension");

		if(!isFullEpisode)
		{
			jqN("#companionAdDiv").css("height", "250px");
			adEngineExtension.registerDiv("companionAdDiv");
		}
		else
		{
			adEngineExtension.addEventListener("AD_BREAK_EVENT_ON_END", onAdBreakEnd);
			adEngineExtension.addEventListener("AD_EVENT_ON_BEGIN", onAdBegin);
			adEngineExtension.addEventListener("AD_ACTIVE_LOGO_REQUESTED", onActiveLogoRequested);
			adEngineExtension.addEventListener("AD_EVENT_ON_END", onAdEnd); 	
		}
	}
};
*/

var pandoExtension; // a reference to the pando helper extension. required for pando installation
var cmDAO; // a reference to the content metadata extension

function onApplicationReadyEvent()
{
	// do whatever. play the first video, perhaps?
	if(firstVideoId) instructPlayerToPlayVideo(firstVideoId, timeIn, timeOut);
	
	// Player events
	var playerExtension = Outlet.getOutletExtension("VideoPlayerExtension");
	playerExtension.addEventListener("Player.start", onPlayerStart);
	playerExtension.addEventListener("Player.end", onPlayerEnd);
	
	adEngineExtension = Outlet.getOutletExtension("AdEngineExtension");

	if(!isFullEpisode)
	{
		jqN("#companionAdDiv").css("height", "250px");
		adEngineExtension.registerDiv("companionAdDiv");
		adEngineExtension.setOverride("random", randDARTNumber);
		adEngineExtension.addEventListener("AD_BREAK_EVENT_ON_COMPLETE", onAdBreakComplete);
	}
	else
	{
		adEngineExtension.addEventListener("AD_BREAK_EVENT_ON_COMPLETE", onAdBreakComplete);
		adEngineExtension.addEventListener("AD_BREAK_EVENT_ON_END", onAdBreakEnd);
		adEngineExtension.addEventListener("AD_EVENT_ON_BEGIN", onAdBegin);
		adEngineExtension.addEventListener("AD_ACTIVE_LOGO_REQUESTED", onActiveLogoRequested);
		adEngineExtension.addEventListener("AD_EVENT_ON_END", onAdEnd); 	
		adEngineExtension.addEventListener("AD_BREAK_EVENT_ON_LOADING", onAdLoading);
		
		pandoExtension = Outlet.getOutletExtension("PandoJsOutletExtension");
		pandoExtension.addEventListener("P2P_TRANSFER_STARTED", onPandoTransferStarted);
		
		cmDAO = Outlet.getOutletExtension("ContentMetadataDAO");
		cmDAO.addEventListener("CONTENT_METADATA.video_content_update", onVideoContentUpdate);
	}	
}

/**
event handler when video content updates
*/
function onVideoContentUpdate(evt)
{
	jqN('.video-meta-title').html(evt.data.metadata.metadata.title);
	jqN('#short-description-text').html(evt.data.metadata.metadata.description);
/*	
	document.getElementById('titleDiv').innerHTML = "<b>" + evt.data.metadata.metadata.title + "</b> (clip id " + evt.data.metadata.metadata.clipid + ")";
	document.getElementById('descriptionDiv').innerHTML = evt.data.metadata.metadata.description;
*/	
}


function sendInterceptTrackingPixels() {
	window.adInterceptTracking.location.href = '/assets/scet/video/frames/ads/intercept/';
}

var transfersArray = [];
/**
Event handler for pando transfer starts. Add the href of the asset to an array, so we can
pause the transfers when the page unloads
*/
function onPandoTransferStarted(evt)
{
	transfersArray.push(evt.href);
}

function pauseAllTransfers()
{
	for(var i = 0; i < transfersArray.length; i++)
	{
		Pando.Control.pause( { href:transfersArray[i], callback: { func:function(){ } } } );
	}
}

/**
PMB installation is complete. dynamically insert the version retrieved from a REST call,
and let the pando helper extension know that installation is complete (if available). 
* */
function onPandoInstallationComplete()
{
	window.pmbInstalledFlag = true;
	window.pmbStatusKnownFlag = true;
	
	if(pandoExtension) pandoExtension.onInstallationComplete();
}

var pandoConfig = {
	push: { 
		upgrade:"2.3.3.6" 
	},
	installer : {
		exe: "http://cdn.pandonetworks.com/pando/pmb/PMBInstNBC.exe",
		jar: "/assets/video/4-0/pmb/PDInstallerAppletNBC.jar",
		dmg: "http://cdn.pandonetworks.com/pando/pmb/PMBInstNBC.dmg"
	},
	js: {
		directory: 'http://com-services.pandonetworks.com/js/'
	},
	install: {
		callback: {
			func: function() {
//				debug('calling callback');
				onPandoInstallationComplete();
			}
		},
		only: true
	}
};

function isPMBStatusKnown()
{
	return window.pmbStatusKnownFlag;
}

function isPMBInstalled()
{
	return window.pmbInstalledFlag;
}

window.pmbStatusKnownFlag = false;
window.pmbInstalledFlag = false;

Pando.activate(pandoConfig);


window.onbeforeunload = pauseAllTransfers;
