IFILM.AdObj = function(targ, scriptSrc, confObj, disableRefresh, showCallout) {
	this.targ = targ;
	this.scriptSrc = scriptSrc;
	this.disableRefresh = disableRefresh || false;
	this.showCallout = showCallout || false;
	this.config = confObj || {
		width: '300',
		height: '251',
		FRAMEBORDER: "0",
		border: "0",
		marginwidth: "0",
		marginheight: "0",
		hspace: "0",
		vspace: "0",
		scrolling: "no", 
		style: "border: none",
		src: "/iframe/vciframesrc.jsp?advurl=" + encodeURIComponent(scriptSrc),
		allowtransparency: 'true'
	}
	IFILM.adManager.addAd(this);
	safelog("Ad Object created with scriptSrc:" + scriptSrc, "info", "IFILM.AdObj");	
}

IFILM.AdObj.prototype = {
	previouslyHidden: false,
	display: function() {
		var displayAt = jq('#' + this.targ).get(0);
		if(displayAt && displayAt.tagName) {
			var iframe;
			if(displayAt.tagName.toLowerCase() != "iframe") {
				var na = new NodeAssembly(displayAt);
				if(this.showCallout)
					na.createEl('p', {'class':'ad_callout'}, 'ADVERTISEMENT');
				var iframe = na.createElWithReturn("iframe", this.config);
				na.insertIn();
			} else {
				var iframe = displayAt;
			}
			
			safelog(this.scriptSrc);
			
			this.targetFrame = iframe;
			this.addHeightAdjustTrigger();
			
			var scriptTag= this.createAdString();
			this.dispatchAd(scriptTag);
		}
	},
	
	adjustHeight: function(targetFrame) {
		var cw = targetFrame.contentDocument || targetFrame.contentWindow.document;
		try {
			if(cw) {
				var atHTML = cw.getElementsByTagName("html")[0];
				if(atHTML) {
					var docSize = cw.body.scrollHeight || atHTML.offsetHeight;
					var rawSize = targetFrame.height;
					
					if(Math.abs(docSize - rawSize) > 20 && docSize < 700)
						targetFrame.height = docSize;
				}
				
				if(jq("img[src='http://m1.2mdn.net/viewad/817-grey.gif']", cw).get(0))
					jq(targetFrame).parent().hide();
			}
		} catch(e) {
			safelog("Error auto-resizing ad " + e, "Error", "IFILM.AdObj.adjustHeight");
		}
	},
	
	addHeightAdjustTrigger: function() {
		var adjustHeight = this.adjustHeight;
		if(this.targ != 'globalTextAdUnit') {
			jq(this.targetFrame).load(function(e) {
				adjustHeight(this);
			});
		}
	},
	
	createAdString: function() {
		var scriptTag = "/iframe/vciframesrc.jsp?advurl=" + encodeURIComponent(this.scriptSrc);
		scriptTag +=  "&ifilmrnd=" + Math.round(Math.random() * 1000000) + '-' + Math.round(Math.random() * 1000000);
		return scriptTag;
	
	},
	dispatchAd: function(adString) {
		if(this.targetFrame ) {
			var dispatcher = this.targetFrame.contentDocument || this.targetFrame.contentWindow.document; 
			var adLoc = adString || this.createAdString();
			this.adDisplayed = true;
		}
		
	},
	targetFrame: null,
	adDisplayed: false,
	refresh: function() {
		jq('#' + this.targ).empty();
		this.display();
	},
	styleref: [
		'<style type="text/css">',
		'body {margin:0; padding: 0; border: none; }',
		'</style><style type="text/css">',
		'a img { border: none; }',
		'</style>'
	]

}

IFILM.adManager = {
	ads: [],
	banner: null,
	ad_refresh_rate: null,
	timer: 10,
	textAd: function(msg) {
		if(StringUtils.trim(jq("#globaltxtad").html()) != '')
			jq("#globaltxtad").fadeOut("normal", function() { jq("#globaltxtad").html(msg); });
		else
			jq("#globaltxtad").html(msg);
			
		jq('#globaltxtad a').html(StringUtils.truncate(jq("#globaltxtad a").html(),60));
		jq('#globaltxtad').fadeIn("normal");
		
		//if(document.location.toString().indexOf('show') != -1)
			//jq('body').css('background-position', 'center 14px');
	},
	hideChannelPlayer: function() {
		jq('#SUPPLEMENT embed,#SUPPLEMENT object').css('display', 'none');
	},
	revealAds: function() {
		var adLim = IFILM.adManager.ads.length;
		for(i = 0; i < adLim; i++) {
			if(!IFILM.adManager.ads[i].previouslyHidden)
				jq('#' + IFILM.adManager.ads[i].targ + ' *').css('visibility', 'visible');
		}

		jq('body>iframe').not('#dsHistoryFrame').css('visibility','visible');
	},
	obscureAds: function() {
		var adLim = IFILM.adManager.ads.length;
		for(i = 0; i < adLim; i++) {
			if(jq('#' + IFILM.adManager.ads[i].targ).css('visibility') == 'hidden' || jq('#' + IFILM.adManager.ads[i].targ).css('display') == 'none')
				IFILM.adManager.ads[i].previouslyHidden = true;
				
			jq('#' + IFILM.adManager.ads[i].targ + ' *').css('visibility', 'hidden');
		}
		
		
		jq('body>iframe').not('dsFrame').css('visibility','hidden');
	},
	displayAds: function() {
		var adlim = this.ads.length;
		for(var x=0; x<adlim; x++)  {
			try {
				if(this.ads[x]) { this.ads[x].display(); }
			} catch(e) { safelog(e, "ERROR", "IFILM.adManager.displayAds"); }
			//this.ads[x] = null;
		}
	},
	refreshAds: function() {
		
		var adlim = this.ads.length;
		for(var x=0; x<adlim; x++) {
			if(this.ads[x].targ == 'HEADERAD') { 
				//jq('#HEADER').removeClass('ad-fullheader').css('background-image', 'url(http://dyn.ifilm.com/website/ver2/header_bg.png)') ;
				jq("#IFILM iframe").remove();
				jq('#HEADER .click_through').remove();
			}
			
			//jq('body iframe:last').remove();
			
			if(this.ads[x] && !this.ads[x].disableRefresh) { 
				this.ads[x].refresh(); 
			} else {
				safelog("reloading ad disabled for " + (x+1) + " of " + adlim, "info", "IFILM.adManager");
			}
		}
	},
	addAd: function(adObj) {
		if(adObj.display) {
			this.ads.push(adObj);
		}
	},
	displayAdsGeneric: function() {
		IFILM.adManager.displayAds();
	},
	displaySkin: function(frame) {
	},
	attachSkin: function(style_src) {
		var stylesheets = document.getElementsByTagName('link');
		var has_stylesheet = false;
		stylesheetLim = stylesheets.length;
		
		for(i = 0; i < stylesheetLim; i++) {
			if(style_src == stylesheets[i].href) {
				has_stylesheet = true;
			}
		}
		
		if(!has_stylesheet) {
			var parent_head = document.getElementsByTagName('head')[0];
			var e = document.createElement('link');
			e.type = 'text/css';
			e.href = style_src;
			e.rel = 'stylesheet';
			e.media = 'screen';
			parent_head.appendChild(e);
		}
	},
	hideAds: function(hideEl) {
		if(hideEl) { 
			hideEl.style.display = "none";
			if(hideEl.parentNode) {
				hideEl.parentNode.style.display="none";
				jq('#' + hideEl.parentNode.id + '_top, #' + hideEl.parentNode.id + '_bottom').css('display','none');
			}
		}
	},
	makeFullheader: function(url, clickThrough) {
		
		
		//if(jq.browser.msie && jq.browser.version < 7) {
		//	url = url.replace(/\.png/,'.jpg');
		//}
		
		//jq('#HEADER').css({'background-image': 'url('+url+')', 'background-repeat': 'no-repeat', 'background-position': 'top left'}).addClass('ad-fullheader').end();
		jq("#HEADERAD").css({'visibility': 'hidden', 'border':'0'});
		
		if(clickThrough)
			jq('#HEADER').prepend('<a href="' + clickThrough + '" target="_blank" class="click_through clearfix">&nbsp;</a>');
	
		if(jq.browser.msie && jq.browser.version < 7)
			jq('#HEADER a.click_through').css('z-index', '2000');
			
		jq('#LOGO a').css({position: 'relative', 'z-index': '2000'});
		
		jq('#HEADER .click_through').css({ 'top': '94px', 'left': jq('#BODYCONTENT').offset().left + 'px'});
		
			
			
	}, 
	createInterstitial: function(width) {
		if(!width) width = 600;
		try {
			tbGenerateOverlay();		
			jq('#INTERSTITIAL').before('<div id="timer">SPIKE.com will appear in <span id="timercount">:0' + IFILM.adManager.timer + '</span> seconds</div>');
			jq("#INTERSTITIAL").before('<div id="closead"><a href="#" id="closeadlink">Continue to SPIKE.com</a>');
			
			jq('#TB_window').remove();
			jq("#TB_overlay,#closeadlink").click(IFILM.adManager.removeInterstitial);
		} catch(e) { safelog(e); }
		
		jq(document).keyup(function(e) {
			if (e == null) // ie
				keycode = event.keyCode;
			else // mozilla
				keycode = e.which;
				
			if(keycode == 27) // close
				IFILM.adManager.removeInterstitial();
		});
		
		if(ie)
			 jq('html').css('overflow', 'hidden');
		
		if(width == 300) {
			jq('#INTERSTITIAL iframe,#INTERSTITIAL').css({ "width":"300px", "height":"250px"});
			jq('#timer').css('margin-top','75px');
		}
		
				 
		jq('#INTERSTITIAL').css({'margin-left':'-' + width/2 + 'px', 'margin-top':'-200px'}).show();
		
		jq("body>iframe,body>embed,body>object,#BODYCONTENT iframe, #BODYCONTENT embed, #BODYCONTENT object").css('visibility', 'hidden');
		IFILM.adManager.obscureAds();
		setTimeout(IFILM.adManager.incrementTimer, '1000');	
		IFILM.cookieManager.setSessionCookie('prestitial', true);
		
		if ( !(jQuery.browser.msie && jQuery.browser.version < 7) ) // take away IE6
			jq("#INTERSTITAL").css({marginTop: '-' + parseInt((200 / 2),10) + 'px'});
		
	},
	removeInterstitial: function(e) {
		if(e) { preventDefault(e); }
		
		jq("#TB_overlay").fadeOut("fast",function(){jq('#closead,#gt_link,#timer,#INTERSTITIAL,#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();});
		jq(document).unbind("keyup");
		jq("#closeadlink").unbind()
		
		jq("body>iframe,body>embed,body>object,#BODYCONTENT iframe,#BODYCONTENT embed,#BODYCONTENT object").css('visibility', 'visible');
		IFILM.adManager.revealAds();
				
		if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
			jq("body","html").css({height: "auto", width: "auto"});
			jq("html").css("overflow","");
		}
	},
	incrementTimer: function() {
		IFILM.adManager.timer--;
		
		jq('#timercount').html(':0' + IFILM.adManager.timer);
		if(IFILM.adManager.timer != 0)
			setTimeout(IFILM.adManager.incrementTimer,'1000');
		else
			IFILM.adManager.removeInterstitial();
	},
	reskinningUnit: function(imageUrl, bgColor) {
		IFILM.adManager.reskinPage(imageUrl, bgColor);
		jq("#BODYCONTENT").css('background-color', 'transparent');
		jq('#ad1div iframe').css({'position': 'relative', 'width':'330px', 'height': '270px', 'background': 'transparent none'});
		jq('#ad1div').css({'background': 'transparent none', 'border': 0, 'padding': 0, 'margin-bottom': '20px'});
		jq("#ad1div_top, #ad1div_bottom").remove();
		
		setTimeout(IFILM.adManager.removeTopBottom, 250)
	},
	reskinPage: function(imageUrl, bgColor) {
		jq('body').css('background', bgColor + ' url(' + imageUrl + ') no-repeat top center');
	},
	removeTopBottom: function() {
		if(jq('#ad1div_top').get(0))
			jq("#ad1div_top,#ad1div_bottom").remove();
		else
			setTimeout(IFILM.adManager.removeTopBottom, 250)
	}
}

function textAd(msg) {
	IFILM.adManager.textAd(msg);
}

/* GLOBAL AD STUFF FROM FRAME 0 */

var adid = "";
var query = window.location.search.substring(1);
var queryparams = query.split("&");
/*  Global Adv Vars for Dart */
ord=Math.random()*10000000000000000;
var dartRef, hbxRef, refsiteSession, reftypeSession;
/* Global Analytics Vars and Refsite Session Cookie for HBX */
refsiteid = "";
referralType = "";

pageLoadFuncs.push(function() {	
	//ad refresh rate and displaying the ads, handled as the last function of global functions
	window.setTimeout(IFILM.adManager.displayAdsGeneric, 1000);
	try {
		var min = 10000;
		
		if(!IFILM.adManager.ad_refresh_rate || IFILM.adManager.ad_refresh_rate == '') 
			return;		
			
		ad_refresh_rate = IFILM.adManager.ad_refresh_rate;			
		var valInSeconds = parseInt(ad_refresh_rate)*1000;
		
		if(isNaN(valInSeconds) || valInSeconds < min) {
			valInSeconds = min;
		}
		safelog("reload interval: " + valInSeconds, "INFO", "ad refresh interval");
		
		var z = window.setInterval('IFILM.adManager.refreshAds()', valInSeconds);
	} catch(e) {
		safelog("problem reloading " + e.message, "ERROR", "ad refresh interval");
	}
});

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Javascript function for Flash tagging
function resolveLink(args){

//alert(args);
  var string=document.location.href; 
 

  if  ( string.indexOf("http://surveys.relevantview.com/sbox/asandboxdev.sbt/")  != -1)
  {
	  var getrev= new Array();
	  var getrev=string.split("http://surveys.relevantview.com/sbox/asandboxdev.sbt/");
	  var result=getrev[1];
	  var filename=result.split("/"); 
	   
	  var filenamefinal=filename[0];
	  var filenamefinal=result.split(",");
	  var respondentid = filenamefinal[0];
	  var surveyid = filenamefinal[1];
	  var questionid = filenamefinal[2];
	  var url1 = filename[1];
	  var url2 = filename[2]; 
	
	
		//alert("http://surveys.relevantview.com/sbox/asandboxdev.sbt/" + respondentid + "," + surveyid  + "," + questionid+",1,0/http/www.tvland.com/" + args);
	
		if (args.indexOf("http://") != -1)
	
			{
	
				args = args.replace(new RegExp(/^http:\/\//i),"http/");
	  
	  			document.location.href = "http://surveys.relevantview.com/sbox/asandboxdev.sbt/" + respondentid + "," + surveyid  + "," + questionid  +",1,0/" + args;
			}
	
		else
		{
	
			document.location.href = "http://surveys.relevantview.com/sbox/asandboxdev.sbt/" + respondentid + "," + surveyid  + "," + questionid  +",1,0/" + url1 + "/" + url2  + args;
		}
  }
  else
  {
	  document.location.href =  args;
  } 
}

 
 
// Javascript function for Flash tagging
function getLocation() { 

	var string=document.location.href; 
	if  ( string.indexOf("http://surveys.relevantview.com/sbox/asandboxdev.sbt/")  != -1)
	{
		var getrev= new Array(); 
		var getrev=string.split("http://surveys.relevantview.com/sbox/asandboxdev.sbt/"); 
		var result=getrev[1]; 
		var filename=result.split("/"); 
		     
		var filenamefinal=filename[0];
		var filenamefinal=result.split(","); 
		var respondentid = filenamefinal[0];
		var surveyid = filenamefinal[1];
		var questionid = filenamefinal[2];
		var url1 = filename[1];
		var url2 = filename[2];
		var url;
		if (args.indexOf("http://") != -1)

		{
			args = args.replace(new RegExp(/^http:\/\//i),"http/");
  
  			url = "http://surveys.relevantview.com/sbox/asandboxdev.sbt/" + respondentid + "," + surveyid  + "," + questionid  +",1,0/" + args;
		}

		else
		{
			url = "http://surveys.relevantview.com/sbox/asandboxdev.sbt/" + respondentid + "," + surveyid  + "," + questionid  +",1,0/" + url1 + "/" + url2  + args;
		}
		
	}  
	else
	{  
		var url = document.domain;
	}
	 return url;
}





// Relevant View Java Script - END!!!!!!
NetworkScheduleManager = {
	today: new Date(),
	curDate: new Date(),
	maxDate: new Date(),
	convertShowTimeToDateTime: function(show_date, show_time) {
		var time_matches = show_time.match(/([0-9]{2})([0-9]{2})/);
		var date_matches = show_date.match(/([0-9]{4})([0-9]{2})([0-9]{2})/);
		var date = new Date();
		date.setHours(time_matches[1]);
		date.setMinutes(time_matches[2]);
		date.setSeconds(0);
		date.setMilliseconds(0);
		date.setYear(date_matches[1]);
		date.setMonth(date_matches[2]-1);	
		date.setDate(date_matches[3]);
		
		if(date.getHours() >= 0 && date.getHours() <=4)
			date.setDate(date.getDate()+1);
			
		return date;
	},
	success: function(o) {
		// must manually write HTML out here instead of
		// using the prefered node assembly because IE
		// for some reason won't render the HTML generated
		// by NodeAssembly
		
		var xml = o;
		var this_date = new Date();
		var today = new Date();
		var shows = o.getElementsByTagName('show');
		
		var table = jq('#schedule_table');
		table.empty();
		
		
		var table_code = '<table cellspacing="0" cellpadding="0" width="750">';
		
		
		var showLim = shows.length;
		
		
		table_code += '<tr>';
		table_code += '<td width="50" class="first-child">';
		try {
			table_code += '<ul>';
			for(i = 0; i < 7; i++) {
				this_date.setDate(today.getDate()+i);
				
				table_code += '<li class="' + (this_date.getDate() == NetworkScheduleManager.curDate.getDate()?' active':'') + '">';
				table_code += '<a href="#schedule_' + this_date.getFullYear() + '_' + this_date.getMonth() + '_' + this_date.getDate() + '">' + ((jq.browser.version != 6 && i == 0)?'Tonight':dateFormat(this_date, 'ddd')) + '</a>';	
				table_code += '</li>';
			}
			table_code += '</ul>';
		} catch(e) { safelog(e); }
		table_code += '</td>';	
		for(i = 0; i < showLim; i++) {
			show_date_time = NetworkScheduleManager.convertShowTimeToDateTime(shows[i].attributes.getNamedItem("showDate").value, shows[i].attributes.getNamedItem("showTime").value);
						
			
			
			time_hours =  show_date_time.getHours();
			time_min =  show_date_time.getMinutes();
			if(time_min < 10)
				time_min = "0" + time_min;
			var AM_PM = "AM";	
			if(time_hours > 12) {
				time_hours = time_hours - 12;
				AM_PM = "PM";				
			} else if (time_hours == 0) {
				time_hours = 12;
			}
			
			var showUrl = StringUtils.trim(getTag(shows[i], "showUrl"));
			var showTitle = getTag(shows[i], "showTitle");
			var episodeTitle = getTag(shows[i], "episodeTitle");
			var description = getTag(shows[i], "episodeDescription");
			showTitle = StringUtils.truncate(showTitle, 20);
			
			table_code += '<td width="140" valign="top">';
			table_code += '<strong class="time">' + time_hours + "<span>:" + time_min + " " + AM_PM + '</span></strong>';
			if(showUrl == '') {
				table_code += '<span class="show_title">' + showTitle + '</span>';
			} else {
				table_code += '<a href="' + showUrl +'" class="show_title">' + showTitle + '</a>';
			}
			if(StringUtils.trim(episodeTitle) != '')
				table_code += '<strong class="episode_title">' + episodeTitle + '</strong>';
			
			if(description.length == 0)
				table_code += '<p class="description"><em>No Description Available</em></p>';
			else
				table_code += '<p class="description">' + StringUtils.truncate(description, 100) + '</p>';
			table_code += '</td>';
			
		}
		table_code += "</tr>";
		table.html(table_code);
		
		NetworkScheduleManager.addTriggers();
		
	},
	failure: function(o) {
		safelog(o);
	},
	addTriggers: function() {
		jq('#network_schedule .nav_schedule').click(NetworkScheduleManager.trigger);
	},
	trigger: function(e) {
		if(e) {
			 preventDefault(e);
			 
			 var id = this.id;
			 multiplier = -1;
			 if(id.split('_')[1] == 'next')
			 	multiplier = 1;
			 
			 NetworkScheduleManager.curDate.setDate(NetworkScheduleManager.curDate.getDate()+(1*multiplier));
			 
			 if(NetworkScheduleManager.curDate.valueOf() < NetworkScheduleManager.today.valueOf())
			 	 NetworkScheduleManager.curDate.setDate(NetworkScheduleManager.curDate.getDate()+1)
			 else if(NetworkScheduleManager.curDate.valueOf() > NetworkScheduleManager.maxDate.valueOf())
			 	 NetworkScheduleManager.curDate.setDate(NetworkScheduleManager.curDate.getDate()-1);
		}
		
		
			 
		year =  NetworkScheduleManager.curDate.getFullYear();
		month = NetworkScheduleManager.curDate.getMonth()+1;
		the_date = NetworkScheduleManager.curDate.getDate();
		
		if(the_date < 10)
			the_date = "0" + the_date;
			
		if(month < 10)
			month = "0" + month;
			
		var start_date = year.toString() + month.toString() + the_date.toString();
		
		fetchFromAjax('/spikeTVScheduleAfter?startTime=' + start_date + ':2100', NetworkScheduleManager, null, 'GET');
	},
	init: function() {
		this.trigger();
		
		NetworkScheduleManager.maxDate.setDate(NetworkScheduleManager.today.getDate()+7);
		
		NetworkScheduleManager.maxDate.setHours(0);
		NetworkScheduleManager.maxDate.setMinutes(0);
		NetworkScheduleManager.maxDate.setSeconds(0);
		NetworkScheduleManager.maxDate.setMilliseconds(0);
		
		NetworkScheduleManager.today.setHours(0);
		NetworkScheduleManager.today.setMinutes(0);
		NetworkScheduleManager.today.setSeconds(0);
		NetworkScheduleManager.today.setMilliseconds(0);
	
		NetworkScheduleManager.curDate.setHours(0);
		NetworkScheduleManager.curDate.setMinutes(0);
		NetworkScheduleManager.curDate.setSeconds(0);
		NetworkScheduleManager.curDate.setMilliseconds(0);
		
	}
};

pageLoadFuncs.push(function() {
	NetworkScheduleManager.init();
	
	jq('.section_nav a.showlist').click(function(e) {
		if(e) preventDefault(e);
		
		var id_parts = jq(this).attr('id').split("_");
		
		if(!jq("#" + id_parts[1] + "showlist").is(':visible')) {
			jq('.showlisting').hide();
			jq("#" + id_parts[1] + "showlist").show().css({'left': (jq(this).offset().left-((jq(this).width()/2))) + 'px', 'top': (jq(this).offset().top+20) + 'px'} );
		} else {
			jq("#" + id_parts[1] + "showlist").hide();
		}
	});
	setTimeout("addScheduleTrigger()", 1000);
	
	jq("a.tn_frame").hover(function(e) {
		var el = jq('span', this).get(0);
		jq(el).show().css({ 'opacity': .7, 'left': (jq(this).width()/2)-(jq(el).width()/2) + 'px', 'top': (jq(this).height()/2)-(jq(el).height()/2) + 'px' } );
	}, function(e) {
		jq('span', this).hide();
	});
	
	jq('a.tn_frame span').click(function(e) {
		document.location = jq(this).parent().attr('href');
	});
	
	jq('#video_carousel_items a').click(NetworkPlayerManager.playNext);
	
});

function addScheduleTrigger() {
	
	jq('#schedule_table .first-child a').click(function(e) {
		if(e) preventDefault(e);
		
		var anchor_id = jq(this).attr('href');
		
		url_parts = anchor_id.split("#");
		
		date_parts = url_parts[1].split("_");

		year =  NetworkScheduleManager.curDate.setFullYear(date_parts[1]);
		month = NetworkScheduleManager.curDate.setMonth(date_parts[2]);
		the_date = NetworkScheduleManager.curDate.setDate(date_parts[3]);
		
		jq("#schedule_table .first-child a").removeClass('active');
		jq(this).addClass('active');
		
		NetworkScheduleManager.trigger();
		setTimeout("addScheduleTrigger()", 1000);
	});
}

NetworkPlayerManager = {
	playNext: function(e) {
		var metadata = player.getMetadata();
		
		if(metadata.isAd) {
			setTimeout(switchMetaData, 2500);
			return false;
		}
		
		if(e) {
			preventDefault(e);
			
		 	var id_parts = jq(this).attr('id').split("_");
		 	if(jq(this).parent().get(0).tagName == 'H5')
		 		el = jq(this).parent().parent();
		 	else
		 		el = jq(this).parent();
		} else {	
			var el = jq('#video_carousel_items li.active').next('li');
			if(!el.get(0)) return false;
			id_parts = el.attr('id').split('_');
		}
		
		jq('#vid_player').empty();
		
		config_url = config_url.replace(/ifilmId=([0-9]*)/, 'ifilmId=' + id_parts[1]); 
		var dartRef = dartRef || "";
		var cmpnidsession = cmpnidsession || "";
		var ord = ord || Math.random()*10000000000000000;
		
		            
		var so = new SWFObject("http://media.mtvnservices.com/player/loader/?v=1.0.6", "PRODUCT_OBJECT", "390", "247", "8", "#ffffff", true);            
		so.addParam("quality", "high");
		so.addParam("allowScriptAccess", "always");
		so.addParam("allowFullScreen", "true");
		so.addParam("wmode", "opaque");
		so.addParam("allownetworking", "all");			                        
		so.addParam("swfliveconnect", "true");
		so.addParam("seamlesstabbing", "true");                                                
		so.addVariable("CONFIG_URL", config_url);
		so.write('vid_player');
		
		jq('#video_carousel_items li').removeClass('active');
		el.addClass('active');
				
		setTimeout(switchMetaData, 2500);
	}
};

function switchMetaData() {
	var metadata = player.getMetadata();
	jq('#video_player p').html('<strong>' + metadata.title + '</strong> - ' + StringUtils.truncate(metadata.description, 75));
};