var CookieJar = {};
var Utilities = {};

var Browse = {};
var BrowseButtons = {};
var diLib = {};
var PageControls = {};
var PageControlsSetup = {};
var Rollover = {};
var Scenes = {};
var SectionNav = {};
var Slideshow = {};
var Thumbnails = {};
var Util = {};
var Validate = {};
var VideoButtons = {};

var AuthError = {};
var HQ = {};
var TVEUtil = {
	init : function() {
		//alert('init')
	}
};

Utilities = {
	getAuthFailStatement: function() {
/*
		if($('#logoutContainer').attr('style') == undefined) {
			Browse.strAuthFailStatement = 'You must sign in before accessing full length episodes. Click the Login button to sign in.';
		} else {
			Browse.strAuthFailStatement = 'You are not authorized to view this content. Please contact your TV provider for further assistance.';
		}
		return Browse.strAuthFailStatement;
*/
	},
	getCookieNames : function() {
		return CookieJar;
	},
	cookieMonster : function(strCookies) {

		switch (strCookies) {
		case null:
		case undefined:
		case '':
			var CookieJar = Utilities.getCookieNames();
			break;
		default:
			var strDelimiter = strCookies.match(/[\|:\.,#-]/);
			var CookieJar = strCookies.split(strDelimiter);
			break;
		}

		var cookie = '';
		var cookie_action = null;
		for ( var c in CookieJar) {
			cookie = CookieJar[c].replace(/ /g, '');
			switch (cookie) {
			case 'TVEpage':

				$.cookie(cookie, 1, options)
				break;
			case 'TVEcollection':
				$.cookie(cookie, nAllEpisodesCollectionId, options)
				break;
			default:
				$.cookie(cookie, null, options)
				break;
			}
		}
	},
	log : function(str) {
		try {
			console.log(str)
		} catch (e) {
		}
	},
	debug : function(str) {
		try {
			console.debug(str)
		} catch (e) {
		}
	},
	trace : function(str) {
		try {
			console.trace(str)
		} catch (e) {
		}
	},
	info : function(str) {
		try {
			console.info(str)
		} catch (e) {
		}
	},
	warn : function(str) {
		try {
			console.warn(str)
		} catch (e) {
		}
	},
	error : function(str) {
		try {
			console.error(str)
		} catch (e) {
		}
	}
};

CookieJar = {
	cookie_name : 'TVEnp',
	cookie_name_id : 'TVEid',
	cookie_name_collection : 'TVEcollection',
	cookie_name_collectionUrl : 'CollectionUrl',
	cookie_name_page : 'TVEpage',
	cookie_name_showName : 'TVEshowName'
};
var authTypeCall = null;
// TVEUtil.authVideoId = false;
var bHasRun = false;
var bHaltClick = true;
var bInitPlay = true;
var currentFriendsMap = {};
var currentPlaylistMap = {};
var currentSceneId = "";
var currentScenesArray = [];
var currentSectionMap = {};
var currentTeaserMap = {};
var currentTodaysTopMap = {};
var currentVideoId = "";
var currentVideoObj = {};
var cvpReady = false;
var deepLinkedCategory = deepLinkedCategory || "";
var deepLinkedVideo = deepLinkedVideo || "";
var driver = driver || "";
var grouperTeaserMap = {};
var handleAddPlaylistItem = handleAddPlaylistItem || function() {
};
var lastQueued = "";
var lastTrackedVideo = {};
var logAdobe = false;
var navXml = "";
var player = {};
var queueVideoId = "";
var relatedTeaserMap = {};
// TVEUtil.setState = false;
var tveModeCall = null;
var waitingVideo = "";
var nAllEpisodesCollectionId = 49050;

var options = {
	path : '/'
};

var accessToken = accessToken || "";

// var _strDomain = location.hostname; // == 'www.adultswim.com' && ?
// 'http://pre-prod.adultswim.com' : '';
// if(){

// }
// alert('accessToken ' + accessToken)

var COOKIE_VAL_collection = $.cookie(CookieJar.cookie_name_collection) == null ? nAllEpisodesCollectionId
		: $.cookie(CookieJar.cookie_name_collection);
var COOKIE_VAL_collectionUrl = $.cookie(CookieJar.cookie_name_collectionUrl) == null ? '/astv/mvpd/services/getAllEpisodes.do'
		: $.cookie(CookieJar.cookie_name_collectionUrl);
var COOKIE_VAL_page = $.cookie(CookieJar.cookie_name_page) == null ? 1 : $
		.cookie(CookieJar.cookie_name_page);

Utilities.log('|-o-| COOKIE_VALs ' + COOKIE_VAL_collection + ' : '
		+ COOKIE_VAL_collectionUrl + ' : ' + COOKIE_VAL_page);

function setShowName(sn) {
	Utilities.log('|-o-| |-o-| setShowName ' + sn)
	$.cookie("TVEshowName", sn, {
		path : '/'
	});
}
