var allmenu = '';
var fb = '';
var ms = '';
var em = '';
var mail = '';
 
var allClipId = 0;
var fbClipId = 0;
var msClipId = 0;
var emClipId = 0;
var mailClipId = 0;
 
var globalClient = '';
var globalX = 0;
var globalY = 0;
 
init();

//Outlet code for 4.x player
var metadata={};
var player;
function metadataHandler() {
	metadata = player.getMetaData().properties;
	//long deswcription is usually null, use the description
	metadata.longdescription = metadata.description
}
function loadShareMenuEvents(){
	player = Outlet.getOutletExtension("embeddedPlayer");
	player.addEventListener("AD_BREAK_EVENT_ON_LOADING",metadataHandler);
}	

//end outlet code update
 
function init(client)
{
 
	if (typeof client == 'undefined' || client == '') {
		client = Widget_GetDomain();
	}
	
	client = client.toLowerCase();
	globalClient = client;
	if(client == '89.10'){
		globalClient='bravotv.com' 
	}
	
	if (globalClient == 'bravotv.com' || globalClient == 'clearspring.com') {
 
		
		var myX = 0;
		var myY = 0;
		// The following is taken from BravoTV's current page http://video.bravotv.com/player/?id=0
		if (typeof Position != 'undefined') {
			var posarr = Position.cumulativeOffset($('fpv_clipActWidget'));
			
			if (typeof posarr != 'undefined' && posarr != 0){
				myX = posarr[0] - 35;
				myY = posarr[1] + 25; ///$('fpv_clipActWidget').offsetHeight;
			}
		}
 
 
		globalX = myX;
		globalY = myY;
	}
 
	outputCSS();
	outputJS();
}
 
function setLaunchpadLocation(x, y){
	globalX = x;
	globalY = y;
}
 
function loopFunction(fnc)
{
	window.maxLoopCount = 10;
	if (!isLoadingShowing()) {
		showLoading();
	}
	if (window.originalObjectTimer == undefined || window.originalObjectTimer < 1) {
		window.currentLoopCount = 0;
	}
	if (window.currentLoopCount >= window.maxLoopCount) {
		return;
	}
	if (metadata != undefined){
		var cleanFnc = "";
		for(var i = 0; i < fnc.length ; i++) { 
			if (fnc.charAt(i) != '\\') {
				cleanFnc += fnc.charAt(i);
			}
		}
		eval(cleanFnc);
		return;
	}
	window.currentLoopCount++;
	clearTimeout(window.originalObjectTimer);
	window.originalObjectTimer = setTimeout('loopFunction(\''+fnc+'\');', 500);
}
 
function isLoadingShowing()
{
	var loadingDiv = document.getElementById('loading_launchpad');
	if (loadingDiv != undefined && loadingDiv.style.display != "none") {
		return true;
	} 
	return false;
}
 
function toggleLoading()
{
	var loadingDiv = document.getElementById('loading_launchpad');
	if (loadingDiv != undefined && loadingDiv.style.display == "none") {
		loadingDiv.style.display = "block";
	} else {
		loadingDiv.style.display = "none";
	}
}
 
function showLoading() 
{
	var loadingDiv = document.getElementById('loading_launchpad');
	if (loadingDiv != undefined && loadingDiv.style.display == "none") {
		loadingDiv.style.display = "block";
	}
}
 
function hideLoading() 
{
	var loadingDiv = document.getElementById('loading_launchpad');
	if (loadingDiv != undefined && loadingDiv.style.display != "none") {
		loadingDiv.style.display = "none";
	}
}
 
function updateAllLocations (x ,y) {
	
	var facebookTarget = document.getElementById('facebook_target');
	facebookTarget.style.left = x+"px";
	facebookTarget.style.top = y+"px";
	
	var myspaceTarget = document.getElementById('myspace_target');
	myspaceTarget.style.left = x+"px";
	myspaceTarget.style.top = y+"px";
	
	var embedTarget = document.getElementById('embed_target');
	embedTarget.style.left = x+"px";
	embedTarget.style.top = y+"px";
	
	var emailTarget = document.getElementById('email_target');
	emailTarget.style.left = x+"px";
	emailTarget.style.top = y+"px";
	
	var allTarget = document.getElementById('all_target');
	allTarget.style.left = x+"px";
	allTarget.style.top = y+"px";
	
	var loadingLaunchpad = document.getElementById('loading_launchpad');
	loadingLaunchpad.style.left = x+"px";
	loadingLaunchpad.style.top = y+"px";
	
	globalX = x;
	globalY = y;
	
}
 
function outputJS() {
	
	var jsTag = '';
	
	// For now I'm just making the default domain (clearspring.com) mimic bravotv
	if (globalClient == 'bravotv.com' || globalClient == 'clearspring.com') {
		jsTag = "<script type=\"text/javascript\" src=\"http://cdn.clearspring.com/launchpad/v2/standalone.js\"></script>";
		document.write(jsTag);
	}
 
}
 
function outputCSS() {
	
	var cssTag = '';
	
	// For now I'm just making the default domain (clearspring.com) mimic bravotv
	if (globalClient == 'bravotv.com' || globalClient == 'clearspring.com') {
		cssTag = "<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"http://widgets.nbcuni.com/player/css/widgets_bravo.css?v=3\" />";
		//cssTag = "<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"http://watercooler/viralapps/public/watercooler/fb/css/widgets_bravo.css?v=3\" />";
		document.write(cssTag);
	}
	
}
 
function outputHorizontalButtons(xOverride, yOverride, useImgs) {
 
	if (typeof useImgs == 'undefined') useImgs = false;
	
	if (typeof xOverride == 'undefined') xOverride = globalX;
	if (typeof yOverride == 'undefined') yOverride = globalY;
	
	// For now I'm just making the default domain (clearspring.com) mimic bravotv
	if (globalClient == 'bravotv.com' || globalClient == 'clearspring.com') {
		outputHorizontalButtonsForBravo(useImgs);
		createDiv(xOverride,yOverride, false, 'share_buttons');
	} else {
		alert('Unknown client: ' + globalClient);
	}
 
 
}
 
function outputHorizontalButtonsForBravo(useImgs)
{
	/*
		
		<div id="share_buttons">
			<ul class="grab_it_btns">
				<li class="share_it">SHARE:</li>
				<li class="facebook">
					<a title="FACEBOOK" onclick="loopFunction(&#39;showlaunchpad(\\&quot;facebook\\&quot;,Widget_GetWidgetID(),videoID,metadata.title,\\&quot;http://video.nbcuni.com/player/mezzanine/image.php?site=bravo&amp;appkey=a36d73f72e57a9c8bf&amp;path=\\&quot;+metadata.mezznimagepath,(metadata.longdescription!=\\&quot;null\\&quot;)?metadata.longdescription:metadata.description,\\&quot;http://www.bravotv.com\\&quot;+document.location.pathname)&#39;);" href="#self">facebook</a>
				</li>
				<li class="myspace">
					<a title="MYSPACE" onclick="loopFunction(&#39;showlaunchpad(\\&quot;myspace\\&quot;,Widget_GetWidgetID(),videoID,metadata.title,\\&quot;http://video.nbcuni.com/player/mezzanine/image.php?site=bravo&amp;appkey=a36d73f72e57a9c8bf&amp;path=\\&quot;+metadata.mezznimagepath,(metadata.longdescription!=\\&quot;null\\&quot;)?metadata.longdescription:metadata.description,\\&quot;http://www.bravotv.com\\&quot;+document.location.pathname)&#39;);" href="#self">myspace</a>
				</li>
				<li class="embed">
					<a title="EMBED" onclick="loopFunction(&#39;showlaunchpad(\\&quot;embed\\&quot;,Widget_GetWidgetID(),videoID,metadata.title,\\&quot;http://video.nbcuni.com/player/mezzanine/image.php?site=bravo&amp;appkey=a36d73f72e57a9c8bf&amp;path=\\&quot;+metadata.mezznimagepath,(metadata.longdescription!=\\&quot;null\\&quot;)?metadata.longdescription:metadata.description,\\&quot;http://www.bravotv.com\\&quot;+document.location.pathname)&#39;);" href="#self">embed</a>
				</li>
				<li class="send">
					<a title="SEND" onclick="loopFunction(&#39;showlaunchpad(\\&quot;email\\&quot;,Widget_GetWidgetID(),videoID,metadata.title,\\&quot;http://video.nbcuni.com/player/mezzanine/image.php?site=scifi&amp;appkey=c909074868ab86e8e6&amp;path=\\&quot;+metadata.mezznimagepath,(metadata.longdescription!=\\&quot;null\\&quot;)?metadata.longdescription:metadata.description,\\&quot;http://www.bravotv.com\\&quot;+document.location.pathname)&#39;);" href="#self">send</a>
					<a title="SEND TO FRIEND" onclick="eval('hidemenus();fpv_ShowSTFv2();');" href="#self">send</a>
				</li>
				<li class="more">
					<a title="MORE SHARE OPTIONS" onclick="loopFunction(&#39;showlaunchpad(\\&quot;all\\&quot;,Widget_GetWidgetID(),videoID,metadata.title,\\&quot;http://video.nbcuni.com/player/mezzanine/image.php?site=bravo&amp;appkey=a36d73f72e57a9c8bf&amp;path=\\&quot;+metadata.mezznimagepath,(metadata.longdescription!=\\&quot;null\\&quot;)?metadata.longdescription:metadata.description,\\&quot;http://www.bravotv.com\\&quot;+document.location.pathname)&#39;);" href="#self">more</a>
				</li>
			</ul>
		</div>
	*/
	
	
	// we'll be using this a few times throughout here, just declaring for convinence
	var closeDiv = "</div>";
 
	var containerDivOpen = "<div id=\"share_buttons\" style=\"position:relative\">";
	//var grabItButton = "<input type=\"button\" onclick=\"eval('Widget_Overlay(Widget_GetWidgetID(),videoID,metadata.title)');\" class=\"fpv_buttonFormat\" value=\"Grab It\" name=\"fpv_btnWidget\" id=\"fpv_btnWidget\" style=\"display: none;\"/>";
	var ulOpen = "<ul class=\"grab_it_btns\">";
	
	var shareMessage = "<li id=\"shareit_message\" class=\"share_it\">SHARE:</li>";
	
	var facebook = "<li class=\"facebook\">";
	facebook += "<a title=\"FACEBOOK\" onclick=\"loopFunction(&#39;showlaunchpad(\\&quot;facebook\\&quot;,Widget_GetWidgetID(),videoID,metadata.title,\\&quot;http://video.nbcuni.com/player/mezzanine/image.php?site=bravo&amp;appkey=a36d73f72e57a9c8bf&amp;path=\\&quot;+metadata.mezznimagepath,(metadata.longdescription!=\\&quot;null\\&quot;)?metadata.longdescription:metadata.description,\\&quot;http://www.bravotv.com\\&quot;+document.location.pathname)&#39;);\" href=\"#self\">";
	
	if (useImgs) { 
		facebook += "<img style=\"border: none\" src=\"facebook_norm.png\" width=\"25px\" height=\"25px\" />";
	}
 
	facebook += "</a>"
	facebook += "</li>";
	
	var myspace = "<li class=\"myspace\">";
	myspace += "<a title=\"MYSPACE\" onclick=\"loopFunction(&#39;showlaunchpad(\\&quot;myspace\\&quot;,Widget_GetWidgetID(),videoID,metadata.title,\\&quot;http://video.nbcuni.com/player/mezzanine/image.php?site=bravo&amp;appkey=a36d73f72e57a9c8bf&amp;path=\\&quot;+metadata.mezznimagepath,(metadata.longdescription!=\\&quot;null\\&quot;)?metadata.longdescription:metadata.description,\\&quot;http://www.bravotv.com\\&quot;+document.location.pathname)&#39;);\" href=\"#self\">";
	
	if (useImgs) { 
		myspace += "<img style=\"border: none\" src=\"myspace_norm.png\" width=\"25px\" height=\"25px\" />";
	}
	
	myspace += "</a>"
	myspace += "</li>";
	
	var embed = "<li class=\"embed\">";
	embed += "<a title=\"EMBED\" onclick=\"loopFunction(&#39;showlaunchpad(\\&quot;embed\\&quot;,Widget_GetWidgetID(),videoID,metadata.title,\\&quot;http://video.nbcuni.com/player/mezzanine/image.php?site=bravo&amp;appkey=a36d73f72e57a9c8bf&amp;path=\\&quot;+metadata.mezznimagepath,(metadata.longdescription!=\\&quot;null\\&quot;)?metadata.longdescription:metadata.description,\\&quot;http://www.bravotv.com\\&quot;+document.location.pathname)&#39;);\" href=\"#self\">";
	
	if (useImgs) { 
		embed += "<img style=\"border: none\" src=\"embed_norm.png\" width=\"25px\" height=\"25px\" />";
	}
	
	embed += "</a>"
	embed += "</li>";
	
	var send = "<li class=\"send\">";
	// This is commented out since they seem to want to use their existing send email logic
	//send += "<a title=\"SEND\" onclick=\"showlaunchpad('email',Widget_GetWidgetID(),videoID,metadata.title,metadata.longDescription?metadata.longDescription:metadata.shortDescription,'http://video-test.bravotv.com/player/?id='+videoID);\" href=\"#self\">";
	send += "<a title=\"SEND\" onclick=\"loopFunction(&#39;showlaunchpad(\\&quot;email\\&quot;,Widget_GetWidgetID(),videoID,metadata.title,\\&quot;http://video.nbcuni.com/player/mezzanine/image.php?site=scifi&amp;appkey=c909074868ab86e8e6&amp;path=\\&quot;+metadata.mezznimagepath,(metadata.longdescription!=\\&quot;null\\&quot;)?metadata.longdescription:metadata.description,\\&quot;http://www.bravotv.com\\&quot;+document.location.pathname)&#39;);\" href=\"#self\">";
	if (useImgs) { 
		send += "<img style=\"border: none\" src=\"email_norm.png\" width=\"25px\" height=\"25px\" />";
	}
	
	send += "</a>"
	send += "</li>";
	
	var more = "<li class=\"more\">";
	more += "<a title=\"MORE SHARE OPTIONS\" onclick=\"loopFunction(&#39;showlaunchpad(\\&quot;all\\&quot;,Widget_GetWidgetID(),videoID,metadata.title,\\&quot;http://video.nbcuni.com/player/mezzanine/image.php?site=bravo&amp;appkey=a36d73f72e57a9c8bf&amp;path=\\&quot;+metadata.mezznimagepath,(metadata.longdescription!=\\&quot;null\\&quot;)?metadata.longdescription:metadata.description,\\&quot;http://www.bravotv.com\\&quot;+document.location.pathname)&#39;);\" href=\"#self\">";
	
	if (useImgs) { 
		more += "<img style=\"border: none\" src=\"all_norm.png\" height=\"25px\" />";
	}
	
	more += "</a>"
	more += "</li>";
	
	var ulClose = "</ul>";
	
	document.write(containerDivOpen);
	//document.write(grabItButton);
	document.write(ulOpen);
	document.write(shareMessage);
	document.write(facebook);
	document.write(myspace);
	document.write(embed);
	document.write(send);
	document.write(more);
	document.write(ulClose);
	document.write(closeDiv);
}
 
function createDiv(x,y,zindex, parentId){
if (typeof zindex == 'undefined') zindex = false;
if (typeof parentId == 'undefined') parentId = false;
 
var appendToElement = null;
 
if (parentId != false) {
	appendToElement = document.getElementById(parentId);
} else {
	appendToElement = document.body;
	
}
 
newDiv2 = document.createElement("div");
newDiv2.id = "facebook_target";
newDiv2.style.left = x+"px";
newDiv2.style.top = y+"px";
newDiv2.style.position = "absolute";
newDiv2.style.overflowX="hidden";
 
 
appendToElement.appendChild(newDiv2);
 
newDiv3 = document.createElement("div");
newDiv3.id = "myspace_target";
newDiv3.style.left = x+"px";
newDiv3.style.top = y+"px";
newDiv3.style.position = "absolute";
newDiv3.style.overflowX="hidden";
appendToElement.appendChild(newDiv3);
 
newDiv4 = document.createElement("div");
newDiv4.id = "embed_target";
newDiv4.style.left = x+"px";
newDiv4.style.top = y+"px";
newDiv4.style.position = "absolute";
newDiv4.style.overflowX="hidden";
appendToElement.appendChild(newDiv4);
 
newDiv5 = document.createElement("div");
newDiv5.id = "email_target";
newDiv5.style.left = x+"px";
newDiv5.style.top = y+"px";
newDiv5.style.position = "absolute";
newDiv5.style.overflowX="hidden";
appendToElement.appendChild(newDiv5);
 
newDiv6 = document.createElement("div");
newDiv6.id = "all_target";
newDiv6.style.left = x+"px";
newDiv6.style.top = y+"px";
newDiv6.style.position = "absolute";
newDiv6.style.overflowX="hidden";
appendToElement.appendChild(newDiv6);
 
loadingDiv = document.createElement("div");
loadingDiv.id = "loading_launchpad";
loadingDiv.style.left = x+"px";
loadingDiv.style.top = y+"px";
loadingDiv.style.position = "absolute";
loadingDiv.style.overflow="hidden";
loadingDiv.style.width="298px";
loadingDiv.style.height="40px";
loadingDiv.style.display = "none";
loadingDiv.style.textAlign= "center";
loadingDiv.style.backgroundColor = "#FFFFFF";
loadingDiv.innerHTML = "<div style='padding-top: 10px;'><img src='http://widgets.nbcuni.com/player/javascript/ajax_busy.gif' /><span>&nbsp;Loading...</span></div>";
appendToElement.appendChild(loadingDiv);
 
if(zindex==true){
newDiv2.style.zIndex="9999";
newDiv3.style.zIndex="9999";
newDiv4.style.zIndex="9999";
newDiv5.style.zIndex="9999";
newDiv6.style.zIndex="9999";
loadingDiv.style.zIndex="9999";
}
 
}
 
function setGreyBackground()
{
	containerDiv = document.createElement("div");
	containerDiv.id = "grey_background";
	containerDiv.style.display = "block";
	containerDiv.style.visibility = "visible";
 
	document.body.appendChild(containerDiv);
 
 
	backgroundDiv = document.createElement("div");
	backgroundDiv.style.backgroundColor = "black";
	backgroundDiv.style.backgroundImage = "none";
	backgroundDiv.style.backgroundRepeat = "repeat";
	backgroundDiv.style.backgroundAttachment = "scroll";
	backgroundDiv.style.backgroundPosition = "0% 0%";
	backgroundDiv.style.overflow = "hidden";
	backgroundDiv.style.position = "absolute";
	backgroundDiv.style.left = "0px";
	backgroundDiv.style.top = "0px";
	backgroundDiv.style.width = "1440px";
	backgroundDiv.style.height = "19000px";
	backgroundDiv.style.opacity = "0.5";
 
	containerDiv.appendChild(backgroundDiv);
	
/*<div id="grayout" style="display: block; visibility: visible;">
<div style="background: black none repeat scroll 0% 0%; overflow: hidden; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; position: absolute; left: 0px; top: 0px; width: 1440px; height: 1900px; opacity: 0.5;"/>
</div>*/
}
 
function showlaunchpad(mType, widgetId, clipId, clipTitle, clipThumb, clipdes, clipUrl){
	
hidemenus();
	var vTitle=Widget_SiteName()
	if(clipTitle=="" || clipTitle==null || clipTitle=="undefined" || clipTitle==undefined){
	var cTitle=vTitle
 
	}else{
	var cTitle=vTitle +" - "+clipTitle
	}
	if (widgetId == '' || widgetId == null || widgetId == 0){
		widgetid = Widget_GetWidgetID()
	}
 
	var ws = $LaunchpadUtil.windowSize();
	
	//var targetId = document.getElementById('target_id');
	//targetId.style.left = (((978 / 2) + (ws.width - 978) / 2) - 100) + "px";
 
	// re-using the same element
	//targetId.innerHTML = '';
 
 
var menuType=mType
switch (menuType){
	case "all":
 
		if ( allmenu == '' || allClipId != clipId){
			allClipId = clipId;
			if (!isLoadingShowing()) {
				showLoading();
			}
			allmenu=$Launchpad.CreateMenu({menuConfig: {global: {template: "custom", skin: 1, border:0x639EC9, height:210, width:300},style:{menu:{chrome: 0x639EC9, alpha: 100, background: 16777215, foreground: 3355443, link: 26316, title: 3355443, hover: 6273502}}}, servicesInclude : ['myspace','facebook','google','wordpress','live','blogger','livejournal','hi5','spaces','friendster'], wid : widgetId, config : { "clipID" : clipId, "video_title": cTitle, "video_imgurl":clipThumb, "video_description":clipdes, "video_url":clipUrl} , targetElement : "all_target", menuHeight: "210", menuWidth: "300" });
		}
	if (isLoadingShowing()) {
		hideLoading();
	}
allmenu.show();
	break;
	case "embed":
	if ( em == '' || emClipId != clipId){	
			emClipId = clipId;
			if (!isLoadingShowing()) {
				showLoading();
			}
 
			em=$Launchpad.CreateMenu({menuConfig: {global: {template: "custom", skin: 1, border:0x639EC9, height:210, width:300},style:{menu:{chrome: 0x639EC9, alpha: 100, background: 16777215, foreground: 3355443, link: 26316, title: 3355443, hover: 6273502}}},servicesInclude : ['embed'], wid : widgetId, config : { "clipID" : clipId, "video_title": cTitle, "video_imgurl":clipThumb, "video_description":clipdes, "video_url":clipUrl}, targetElement : "embed_target", menuHeight: "210", menuWidth: "300" });
		}
	if (isLoadingShowing()) {
		hideLoading();
	}
em.show();
	break;
	case "email":
		if ( mail == '' || mailClipId != clipId){
			mailClipId = clipId;
			if (!isLoadingShowing()) {
				showLoading();
			}
 
			mail=$Launchpad.CreateMenu({menuConfig: {global: {template: "custom", skin: 1, border:0x639EC9, height:300, width:300},style:{menu:{chrome: 0x639EC9, alpha: 100, background: 16777215, foreground: 3355443, link: 26316, title: 3355443, hover: 6273502}}}, servicesInclude : ['email'], wid : widgetId, config : { "clipID" : clipId, "video_title": cTitle, "video_imgurl":clipThumb, "video_description":clipdes, "video_url":clipUrl}, targetElement : "email_target", menuHeight: "300", menuWidth: "300" });
	}
	if (isLoadingShowing()) {
		hideLoading();
	}
mail.show();
	break;
	case "myspace":
		if ( ms == '' || msClipId != clipId){
			msClipId = clipId;
			if (!isLoadingShowing()) {
				showLoading();
			}
 
 
			ms=$Launchpad.CreateMenu({menuConfig: {global: {template: "custom", skin: 1, border:0x639EC9, height:210, width:300},style:{menu:{chrome: 0x639EC9, alpha: 100, background: 16777215, foreground: 3355443, link: 26316, title: 3355443, hover: 6273502}}}, servicesInclude : ['myspace'], wid : widgetId, config : { "clipID" : clipId, "video_title": cTitle, "video_imgurl":clipThumb, "video_description":clipdes, "video_url":clipUrl}, targetElement : "myspace_target", menuHeight: "210", menuWidth: "300" });
		}
	if (isLoadingShowing()) {
		hideLoading();
	}
ms.show();
	break;
	case "facebook":
		if ( fb == '' || fbClipId != clipId){
			fbClipId = clipId;
			if (!isLoadingShowing()) {
				showLoading();
			}
 
			fb=$Launchpad.CreateMenu({menuConfig: {global: {template: "custom", skin: 1, border:0x639EC9, height:210, width:300},style:{menu:{chrome: 0x639EC9, alpha: 100, background: 16777215, foreground: 3355443, link: 26316, title: 3355443, hover: 6273502}}}, servicesInclude : ['facebook'], wid : widgetId, config : { "clipID" : clipId, "video_title": cTitle, "video_imgurl":clipThumb, "video_description":clipdes, "video_url":clipUrl}, targetElement : "facebook_target", menuHeight: "210", menuWidth: "300" });
		}
	if (isLoadingShowing()) {
		hideLoading();
	}
fb.show();
	break;
	}
 
 
	//document.getElementById(menuType).style.zIndex = -1;
	//document.getElementById(menuType).style.top = '250px';
}
 
function hidemenus(){
	if (allmenu != '')
		allmenu.hide();
	if (em != '')
		em.hide();
	if (mail != '')
		mail.hide();
	if (ms != '')
		ms.hide();
	if (fb != '')
		fb.hide();
 
}
 
 
function Widget_GetWidgetID() {
	var fullDomainArray = new Array();
	var domainArray = new Array();
	var widgetid = "";
	fullDomainArray = String( window.location ).split("/");
	domainArray = fullDomainArray[2].split(".");
	domainName = domainArray[domainArray.length-2]+"."+domainArray[domainArray.length-1];
	switch (domainName)
	{
		case "dotcomedy.com":
			widgetid = "465703d43bf8ed1d";
			break;
		case "ivillage.com":
			widgetid = Widget_getiVillageWidgetId(domainArray);
			break;
		case "accesshollywood.com":
			widgetid = "482a0d55893fbe3f";
			break;
		case "scifi.com":
			widgetid = "48e10f5e9dbb50aa";
			break;
		case "bravotv.com":
			widgetid = "4657041ec2a2cf53";
			break;
		case "89.10":
			widgetid = "4657041ec2a2cf53";
			break;
		case "nbc.com":
			widgetid = "465704e99b38fadc";
			break;
		case "nbcsports.com":
			widgetid = "46570546189e9e76";
			break;
		case "sionnbcsports.com":
			widgetid = "46570546189e9e76";
			break;
		case "usanetwork.com":
			widgetid = "4657059775fa3215";
			break;
		case "outzonetv.com":
			widgetid = "4692b44034eae007";
			break;
		case "reeltalktv.com":
			widgetid = "46d53a0a8ca871de";
			break;
		case "greenisuniversal.com":
			widgetid = "471ebd0654ae98f7";
			break;
			case "petside.com":
			widgetid = "47b61e8a785ed619";
			break;
		case "oxygen.com":
			widgetid = "486ba487be882f6f";
			break;
		case "hotchalk.com":					
			widgetid = "48a47d4b81a98ea2";
			break;
		case "ge.com":					
			widgetid = "482a0d55893fbe3f";
			break;
		case "nbcuni.com":					
			widgetid = "49ac102fc3b71c23";
			break;			
		default:
			widgetid = "4644bb88b5677b70";
	}
	return widgetid;
}
 
function Widget_SiteName() {
	var fullDomainArray = new Array();
	var domainArray = new Array();
	var sitename = "";
	fullDomainArray = String( window.location ).split("/");
	domainArray = fullDomainArray[2].split(".");
	domainName = domainArray[domainArray.length-2]+"."+domainArray[domainArray.length-1];
	switch (domainName)
	{
		case "dotcomedy.com":
			sitename = "Dot Comedy Video";
			break;
		case "ivillage.com":
			sitename = "iVillage Video";
			break;
		case "accesshollywood.com":
			sitename = "Access Hollywood Video";
			break;
		case "scifi.com":
			sitename = "SCI FI Video";
			break;
		case "bravotv.com":
			sitename = "Bravo TV Video";
			break;
		case "89.10":
			sitename = "Bravo TV Video";
			break;
		case "nbc.com":
			sitename = "NBC Video";
			break;
		case "nbcsports.com":
			sitename = "NBC Sports Video";
			break;
		case "sionnbcsports.com":
			sitename = "Video";
			break;
		case "usanetwork.com":
			sitename = "USA Network Video";
			break;
		case "outzonetv.com":
			sitename = "Outzone Video";
			break;
		case "reeltalktv.com":
			sitename = "Reel Talk Video";
			break;
		case "greenisuniversal.com":
			sitename = "Green Is Universal Video";
			break;
			case "petside.com":
			sitename = "Petside.com Video";
			break;
		case "oxygen.com":
			sitename = "Oxygen Video";
			break;
		case "hotchalk.com":					
			sitename = "Hotchalk Video";
			break;
		case "nbcuni.com":					
			widgetid = "Test Video";
			break;
		case "ge.com":					
			sitename = "GE Video";
			break;			
		default:
			sitename = "Video";
	}
	return sitename;
}
 
function Widget_getiVillageWidgetId(domainArray)
{
	var ivillagewidgetid = "4772a211f870b9a4";
	var intheloopwidgetId = "4657029c165aaaf4";
	domainName = domainArray[domainArray.length-3]+"."+ domainArray[domainArray.length-2]+"."+domainArray[domainArray.length-1];
	if(domainName == 'intheloop.ivillage.com')
	{
		return intheloopwidgetId;
	}else{
		return ivillagewidgetid;
	}
}
 
function Widget_GetDomain() {
	var fullDomainArray = new Array();
	var domainArray = new Array();
	fullDomainArray = String( window.location ).split("/");
	domainArray = fullDomainArray[2].split(".");
 	domainName = domainArray[domainArray.length-2]+"."+domainArray[domainArray.length-1];
		
 	switch (domainName) {
	
	case "dotcomedy.com": return domainName; break;
	case "ivillage.com": return domainName; break;
	case "accesshollywood.com": return domainName; break;
	case "scifi.com": return domainName; break;
	case "bravotv.com": return domainName; break;
	case "89.10": return domainName; break;
	case "nbc.com": return domainName; break;
	case "nbcsports.com": return domainName; break;
	case "sionnbcsports.com": return domainName; break;
	case "usanetwork.com": return domainName; break;
	case "reeltalktv.com": return domainName; break;
	case "petside.com": return 'nbc.com'; break;
	case "oxygen.com": return 'nbc.com'; break;
	case "teacher.hotchalk": return 'nbc.com'; break;
	case "ge.com": return 'nbc.com'; break;
	case "nbcuni.com": return 'nbcuni.com'; break;
	//case "greenisuniversal.com": return domainName; break;
	
	default: return 'clearspring.com'
 
	} 
	
}