var isPlayOnStart = false;
var microSiteToHome = false;

// traces Flash messages to the UI, used for debugging
function trace(msg)
{
    var traceElem = document.getElementById('trace');
    if (traceElem)
	    traceElem.innerHTML = traceElem.innerHTML + msg + "<BR>" ;
}
/************************************************************************
                       SECTION DEBUGGING ENDS
************************************************************************/

/************************************************************************
                       SECTION WEBTRENDS BEGINS
************************************************************************/
var dcs_id = "dcse3xflyghjg5e6ym5wj21gv_2r7g"; // (sub-)site-specific identifier
   
// dcs values generated by SSO
var dcs_user_params = {
	'partner'	: '<%=Profile.Partner%>',
	'region'	: '<%=Profile.Region %>',
	'product'	: '<%=Profile.Connection%>',
	'VZID'		: '<%=Profile.Vzid%>',
	'zipcode'	: '<%=Profile.ZipCode%>',
	'account_type'	: '<%=Profile.CustomerType%>',
	'WT_cg':'VzSurround'
};
// this list may be populated by the page data
var dcs_request_params = {};	

//debugger
// used to track web trends clicks
function flashWebTrends(channel, section, module, actionitem)
{
    //DCS.dcssip = 'surround.verizon.net';
    WT.ti = "";
    DCS.dcsuri = "";
    WT.cg_n = "Global";
    WT.cg_s = "";
  
    if ((channel != 'null') && (channel != null))
    {
        DCS.dcsuri += channel+'/';
        WT.ti += channel;
        WT.cg_s = channel;
    }
    if ((section != 'null') && (section != null))
    {
        DCS.dcsuri += section+'/';
        WT.ti += " " + section;
    }
    if ((module != 'null') && (module != null))
    {
        if(module.indexOf(":vzCampaign") != -1)
	    {
            module = module.replace(":vzCampaign", "");
            WT.mc = module;
        }
          
        DCS.dcsuri += module+'/';
        WT.ti += " " + module;
    }
    if ((actionitem != 'null') && (actionitem != null))
    {
        DCS.dcsuri += actionitem;
    }
    
    DCS.dcsuri = DCS.dcsuri.replace(' ', '_'); 
    trace('webtrends:' + DCS.dcsuri);
	//alert("FWT: dcsUri: "+ DCS.dcsuri + "\nWT.ti: " + WT.ti + "\nWT.cg_n:" + WT.cg_n +"\nWT.cg_s:" + WT.cg_s   );
    dcsHit(WT.ti);
}


function trackPageView(channel, section, module, subgroup, campaign)
{
   // SurroundShell.refreshAds(channel, section, url);
	WT.ti = "Verizon Surround - ";
    DCS.dcsuri = "";
    WT.cg_n ="";
    WT.cg_s ="";

    if ((channel != 'null') && (channel != null))
    {
        DCS.dcsuri += channel+'/';
        WT.ti += channel;
        WT.cg_n = channel;
    }
    
    if ((subgroup != 'null') && (subgroup != null))
    {
          WT.cg_s = subgroup;
          DCS.dcsuri += subgroup+'/';
          WT.ti+= " - " + subgroup;
	}
	else 
    {
        if ((section != 'null') && (section != null))
        {
        	DCS.dcsuri += section+'/';
			WT.ti += " - " + section;
		}
		
    }

    if ((module != 'null') && (module != null))
	{
         DCS.dcsuri += module+'/';
         WT.ti+= " - " + module;
	} 
   
    if ((campaign != 'null') && (campaign != null))
    {
        WT.ti+= " - " + campaign;
        WT.mc_id = campaign;
    }
    
    DCS.dcsuri = DCS.dcsuri.replace(' ', '_');
	DCS.dcsuri = DCS.dcsuri.replace('%20', '');
    trace('webtrends:' + DCS.dcsuri);
    //alert("dcsUri: "+ DCS.dcsuri + "\nWT.ti: " + WT.ti + "\nWT.cg_n:" + WT.cg_n +"\nWT.cg_s:" + WT.cg_s   );
    //alert("WT.ti: " + WT.ti);
    dcsHit(WT.ti);
}


function trackEvent(itemName, eventType)
{
	WT.ti+=" - "+itemName
	//mtEvent(‘movies’,’hbo - rambo 6’,’play’);
	//alert("WT.ti: "+ WT.ti);
	//alert("subgroup: "+WT.cg_s);
	mtEvent(WT.cg_n, WT.ti,eventType);
}

function trackExternalUrl(url)
{
	if ( (typeof windowOptions == 'undefined') || (windowOptions=='') || (windowOptions==null))
	{
	   	dcsExit(url,"","","","","","");
	}
	else
	{
       //alert("test");
		dcsExit(url,"Verizon",windowOptions,"","","","");
    }
	//http://wapp.verizon.net/bookmarks/bmredir.asp?region=all&bw=dsl&cd=TBD&bm=webt_vzcentral", "VerizonCentral", "target=_blank","","","",""

}


/************************************************************************
                       SECTION WEBTRENDS ENDS
************************************************************************/

/************************************************************************
                       SECTION MY STUFF BEGINS
************************************************************************/
// updates the personalization tabbed menu (Recently Viewed, My Picks, Most Watched)
function updatePersonalization(channel, section, module, feedsId, feedId, itemId, videoUrl, imageUrl)
{
    trace('updatePersonalization called - channel:'+channel+', section:'+section+', module:'+module+', videoUrl:'+videoUrl+', imageUrl:'+imageUrl);
    if (section == "watchIt" && itemId>0)
    {
        //create the 2-D array for the recently watched items
        var retrievedArray = new Array(15);
        var watched = new Array(15);
        
        for (i=0; i <15; i++)
        {
            watched[i]=new Array(6);
        }
            
        //add new value to beginning of watched array
        watched[0][0] = channel;
        watched[0][1] = module;
        watched[0][2] = section;
        watched[0][3] = feedsId;
        watched[0][4] = feedId;
        watched[0][5] = itemId + "+++";

        //get any extant cookie and append the first 14 values to the new value (losing the 15th, if there is one)
        if (readCookie("ckieRecentlyWatched"))
        {
            retrievedArray = readCookie("ckieRecentlyWatched").split("+++");//gets the 'flattened' 2D array from the cookie and split into a single array
           
            ArrayLengthMax=14;
            
            if(retrievedArray.length<14)
                {ArrayLengthMax = retrievedArray.length;}
                
            //turn the 1-D array into a 2-D array    
            for(i=0; i<ArrayLengthMax-1;i++)
            { 
                temp = retrievedArray[i].split(","); 
                index=0;
                
                if (temp.length - 6 >= 0)
                {
                   index = temp.length - 6;
                }
                
                watched[i+1][0] = temp[index+0]; 
                watched[i+1][1] = temp[index+1];
                watched[i+1][2] = temp[index+2];
                watched[i+1][3] = temp[index+3];
                watched[i+1][4] = temp[index+4];
                watched[i+1][5] = temp[index+5] + "+++";
            }
        }
        
        //set the 2D watched array to the cookie
        setCookie("ckieRecentlyWatched", watched, 999);
    }
}

// called by Flash, used to the the Recently Watched list in the personalization section
function getWatchedListArray()
{
    var recentlyWatchedArray = new Object();

    if (readCookie("ckieRecentlyWatched"))
    {
        //gets the 'flattened' 2D array from the cookie and split into a single array
		retrievedArray = readCookie("ckieRecentlyWatched").split("+++");
	   
		ArrayLengthMax=14;
		subArray = Array();

		if (retrievedArray.length<14)
		{
			ArrayLengthMax = retrievedArray.length;
		}
			
		//turn the 1-D array into a 2-D array    
		for(i=0; i<(ArrayLengthMax-1);i++)
		{ 
			subArray = [];
			recentlyWatchedArray[i] = Array();
		    temp = retrievedArray[i].split(","); 
			index=0;
			
			if (temp.length - 6 >= 0)
			{
			   index = temp.length - 6;
			}
			
			subArray.push(temp[index+0]);
			subArray.push(temp[index+1]);
			subArray.push(temp[index+2]);
			subArray.push(temp[index+3]);
			subArray.push(temp[index+4]);
			subArray.push(temp[index+5]);

			recentlyWatchedArray[i] = subArray;
		}
    }

    return(recentlyWatchedArray);
}

/************************************************************************
                         SECTION MY STUFF ENDS
************************************************************************/

/************************************************************************
                            NAVIGATION EVENTS
************************************************************************/
// main surround class TODO: more main functionality should probably
// be wrapped up in this class and put in its own file

	
var SurroundShell = 
{
	initialize: function()
	{
	    
	    // Modified by LF
        /*
        SurroundShell.hidePlayer();
        */
        // End Modified by LF
	    
	    
        //Initialize the toolbar.
        window.setTimeout("RefreshNewsItems()", 500);
        window.setInterval("RefreshNewsItems()", 60000);
        itemTimerId = window.setInterval("ChangeNewsItem('Next', false)", 60000);
        if (isPlayOnStart)
        {
            // kind of a hack, wait, it is completely a hack
		    // flash is calling reset several times when the page loads, so
		    // in order for playOnStart to work, we wait for flash to do its thing
		    // then call playOnStart function
		    window.setTimeout("playOnStart()", 5000);
        }
        
        // part of firefox fix
        
        
        // Modified by LF
        /*
        $('#playerFrame').bind("mouseover", function(event){
            event.stopPropagation();
            $('#playerFrame').blur();
        });
        */
        // End Modified by LF
        
        
        $('#readItFrame').bind("mousemove", function(event){
            event.stopPropagation();
            $('#readItFrame').blur();
        });
        // end part of firefox fix
	},
	
	// handles callbacks from the Flash Nav and branches 
	// out to the animation methods below
	// this will need to get fleshed out to support
	// different behaviors by section
	navigate: function(channel, section, module, url)
	{	
		// master reset switch for DOM layers
		if (section == "reset")
		{	
			SurroundShell.reset(); 
		}
		if (section == "watchIt" && url != 'null')
		{	
			SurroundShell.animateWatchIt(channel, section, module, url); 
		}
		else if (section == "readIt" && url != 'null')
		{
			SurroundShell.animateReadIt(channel, url);				
		}
		else if ((section == "partners" || section == "playIt") && url != 'null')
		{
			SurroundShell.animatePartners(url);
		}
        SurroundShell.refreshAds(channel, section, url);
	},
	
	refreshAds: function(channel, section, url)
	{
        trace('refreshAds called - channel:' + channel + ', section:' + section + ', url:' + url);
        
		//alert("channel:" +channel + "Url:"+url);

        var adCampaignUrl = ""; 
        var adVirtualUrl = "";
        
        if (channel == "") channel = 'homepage';
        if (url.indexOf("NFL") >0) adCampaignUrl="football/1";
        
        adVirtualUrl= "vzsurround2.net/" + channel+ "/" + adCampaignUrl;
        
	    if (section == "readIt" && url != 'null')
	    {
	        RefreshAdTop1("Top1", adVirtualUrl);
	    }

        if (channel == "kids")
        {
            RefreshAdTop("Middle", adVirtualUrl);
        }
        else
        {
            RefreshAdTop("Top", adVirtualUrl);
        }
	},
	
	// a full reset to reformat the
	// DOM nodes back to the initial load state
	reset: function()
	{
	    // Modified by LF
	    /*
	    $('#playerContainer').show();
		$('#playerFrame').css("left", 1000);
		*/
		
		$('#readItFrame').hide();
		SurroundShell.hideESPN();
        SurroundShell.hideMoviePoll();
        SurroundShell.hideMusicPoll();
        SurroundShell.hideTVPoll();
        SurroundShell.hideFamilyPoll();
//        SurroundShell.hideSportsPoll();
	},
	//debugger
	gatedContentCheck: function(channel, section, module, url)
	{
	    Trace('SurroundShell.gatedContentCheck()');


        // gated content check
        var userConnection = getConnection().userConnection;
        var gated = false;	    
        if ((url.match(/ABC/) != null) && (url.match(/ssocheck/) == null))
        {
            gated = true;
        }
            
        if (isLoggedIn().IsLoggedIn == "false")
        {        
            
            if (gated)
            {
                // we use this for the second time back
                url += "&ssocheck=true";
                
                // build url to Verizon SSO with additional ActualTarget params
                gatedUrl = "https://sso.verizon.net/ssowebapp/VOLPortalLogin?login_type=basic&hc=1E0000&bdc=000000&ml=0&mt=0&mr=0&mb=0&ActualTarget="+escape('http://surround.verizon.net/gatedRedirect.aspx?')+"&keepThis=true&TB_iframe=true&height=179&width=319";  
                TB_show("Verizon Surround", gatedUrl);

            }
        }
        else
        {
            if (gated)
            {
                if (userConnection == "Vasonly")
               {
                    vasonlyUrl = "http://surround.verizon.net/NoVOLBroadBandRedirect.aspx?keepThis=true&TB_iframe=true&height=179&width=319";  
                    TB_show("Verizon Surround", vasonlyUrl);
  
               } 
            }
        }
        if (isLoggedIn().IsLoggedIn == "true")
        {              
            // play video from flash
           thisMovie("flashMain").showGatedContent();
           //RooGatedRedirect();
        }
    }, 
	
	animateWatchIt: function(channel, section, module, url)
	{
	    Trace('SurroundShell.animateWatchIt()');
	 
	    // Modified by LF
	    // ver de donde se llama y cambiar la llamada por la nueva forma
	    return;
	    // End Modified by LF
	    
        ////////////////////////////////////////////////////////////////////	
	
	
	    // hide roo player if flv file
	    if (url.match(/flv/) != null)
	    {
	        $('#playerFrame').hide();
	        $('#playerContainer').hide();       
	        return;
	    }
	    
        // show player 
        $('#playerContainer').show();
        $('#playerFrame').css("left", 0);
        $('#playerFrame').show();
        document.getElementById('playerFrameIframe').src = "default_player.html";
        $('#readItFrame').hide();
        $('#readItFrame').css("left", 1493);        

        // gated content check
        var userConnection = getConnection().userConnection;
        var gated = false;	    
        if ((url.match(/ABC/) != null) && (url.match(/ssocheck/) == null))
        {
            gated = true;
        }
            
        if (isLoggedIn().IsLoggedIn == "false")
        {        
            
            if (gated)
            {
                // we use this for the second time back
                url += "&ssocheck=true";
                
                // build url to Verizon SSO with additional ActualTarget params
                gatedUrl = "https://sso.verizon.net/ssowebapp/VOLPortalLogin?login_type=basic&hc=1E0000&bdc=000000&ml=0&mt=0&mr=0&mb=0&ActualTarget="+escape('http://surround.verizon.net/gatedRedirect.aspx')+"&keepThis=true&TB_iframe=true&height=179&width=319";  
                TB_show("Verizon Surround", gatedUrl);
                return;   
            }
        }
        else
        {
            if (gated)
            {
                if (userConnection == "Vasonly" || userConnection == "Dial" || userConnection=="Unknown")
               {
                    vasonlyUrl = "http://surround.verizon.net/NoVOLBroadBandRedirect.aspx?keepThis=true&TB_iframe=true&height=179&width=319";  
                    TB_show("Verizon Surround", vasonlyUrl);
                    return;   
               } 
            }
        }
        
        // play video
      
        document.getElementById('playerFrameIframe').src = url;
	}, 
	
	animateReadIt: function(channel, url)
	{
	    //$('#playerFrame').hide();
	    //$('#playerContainer').hide();	    
	    //$('#playerFrame').css("left", 1000);
	    $('#readItFrame').css("visibility", "visible");
	    $('#readItFrame').css("left", 493);
		
	    if(is_ie) {
	        $('#readItFrame').css("width", 607);
	        $('#readItFrame').css("height", 384);
	    }
        $('#readItFrame').css("z-index", 1000);
	    $('#readItFrame').show();
	    document.getElementById('readItFrame').scrollTop = 0;
		
	    var articleId = url.substring(url.indexOf('=') + 1, url.length);
	    ReadIt.refresh(articleId);

	},
	
	animatePartners: function(url)
	{
        popUpWindow (750, 520, '', url, 1, 1, true);
	},

	animateSearch: function(url)
	{
	    // Modified by LF
	    /*
	    $('#playerFrame').hide();
	    $('#playerContainer').hide();	    
	    $('#playerFrame').css("left", 1000);
	    */
        // End Modified by LF
	    
	    $('#readItFrame').hide();
	    $('#readItFrame').css("left", 1493);
	},
	
    showVCAST: function()
	{
	    Trace('SurroundShell.showVCAST()');
	    
	    // Modified by LF
	    /*
        $('#playerFrame').hide();
	    $('#playerContainer').hide();	    
	    $('#playerFrame').css("left", 1000);
	    */
        // End Modified by LF
    },
    
	hidePlayer: function()
	{
	    Trace('SurroundShell.hidePlayer()');
	
	    // Modified by LF
	    /*
		$('#playerFrame').hide();
	    $('#playerContainer').hide();
	    document.getElementById('playerFrameIframe').src = "default_player.html";
	    */
	    // End Modified by LF
	},
	
	showPlayer: function()
	{
	    Trace('SurroundShell.showPlayer()');
	
	    // Modified by LF
	    /*
    	$('#playerFrame').show();
        $('#playerFrame').css("left", 0);
	    $('#playerContainer').show();
	    document.getElementById('playerFrameIframe').src = "default_player.html";
	    */
	    // End Modified by LF
    },
	
    playPlayer: function(url)
    {
        Trace('SurroundShell.playPlayer()');
    
        // Modified by LF
        /*
        $('#playerFrame').show();
        $('#playerFrame').css("left", 0);
	    $('#playerContainer').show();
        document.getElementById('playerFrameIframe').src = url;
        */
        // End Modified by LF
    },
    
    stopPlayer: function()
    {
        Trace('SurroundShell.stopPlayer()');
    
        // Modified by LF
        /*
        document.getElementById('playerFrameIframe').src = "default_player.html";
        */
        // End Modified by LF
    },
    
	hideArticleView: function()
	{
	    $('#readItFrame').hide();
	    $('#readItFrame').css("left", 1493);	    
	},
	
	hideESPNPoll: function()
	{
	    $('#ESPNPoll').hide();
	    $('#ESPNPoll').css("left", 1500); /* fix firefox bug */
	},
	
	hideMoviePoll: function()
	{
	    $('#MoviePoll').hide();
	    $('#MoviePoll').css("left", 1500); /* fix firefox bug */
	},
	
	hideMusicPoll: function()
	{
	    $('#MusicPoll').hide();
	    $('#MusicPoll').css("left", 1500); /* fix firefox bug */
	},
	
	hideTVPoll: function()
	{
	    $('#TVPoll').hide();
	    $('#TVPoll').css("left", 1500); /* fix firefox bug */
	},
	
	hideFamilyPoll: function()
	{
	    $('#FamilyPoll').hide();
	    $('#FamilyPoll').css("left", 1500); /* fix firefox bug */
	},
	
//	hideSportsPoll: function()
//	{
//	    $('#SportsPoll').hide();
//	    $('#SportsPoll').css("left", 1500); /* fix firefox bug */
//	},
	
	showESPNPoll: function()
	{
	    document.getElementById('frmESPNPoll').src = "http://sports.espn.go.com/espn/broadband/poll";
	    $('#ESPNPoll').show();
	    $('#ESPNPoll').css("visibility", "visible");
	    $('#ESPNPoll').css("left", 50);
	},
	
	showMoviePoll: function(pollType)
	{
	    document.getElementById('frmMoviePoll').src = "/polls/moviepoll.htm";
	    $('#MoviePoll').show();
	    $('#MoviePoll').css("visibility", "visible");
	    if (pollType.match(/Expanded/) != null)
	    {
	        $('#MoviePoll').css("left", 435);
	        $('#MoviePoll').css("top", 198);
	    }
	    else
	    {
	        $('#MoviePoll').css("left", 60);
	        $('#MoviePoll').css("top", 183);
	    }
	},
	
	showMusicPoll: function(pollType)
	{
	    document.getElementById('frmMusicPoll').src = "/polls/musicpoll.htm";
	    $('#MusicPoll').show();
	    $('#MusicPoll').css("visibility", "visible");
	    if (pollType.match(/Expanded/) != null)
	    {
	        $('#MusicPoll').css("left", 435);
	        $('#MusicPoll').css("top", 198);
	    }
	    else
	    {
	        $('#MusicPoll').css("left", 60);
	        $('#MusicPoll').css("top", 183);
	    }
	},
	
	showTVPoll: function(pollType)
	{
	    document.getElementById('frmTVPoll').src = "/polls/tvpoll.htm";
	    $('#TVPoll').show();
	    $('#TVPoll').css("visibility", "visible");
	    if (pollType.match(/Expanded/) != null)
	    {
	        $('#TVPoll').css("left", 435);
	        $('#TVPoll').css("top", 216);
	    }
	    else
	    {
	        $('#TVPoll').css("left", 60);
	        $('#TVPoll').css("top", 193);
	    }
	},
	
	showFamilyPoll: function(pollType)
	{
	    document.getElementById('frmFamilyPoll').src = "/polls/familypoll.htm";
	    $('#FamilyPoll').show();
	    $('#FamilyPoll').css("visibility", "visible");
	    if (pollType.match(/Expanded/) != null)
	    {
	        $('#FamilyPoll').css("left", 435);
	        $('#FamilyPoll').css("top", 216);
	    }
	    else
	    {
	        $('#FamilyPoll').css("left", 60);
	        $('#FamilyPoll').css("top", 193);
	    }
	}
	
//	showSportsPoll: function(pollType)
//	{
//	    document.getElementById('frmSportsPoll').src = "/polls/sportspoll.htm";
//	    $('#SportsPoll').show();
//	    $('#SportsPoll').css("visibility", "visible");
//	    if (pollType.match(/Expanded/) != null)
//	    {
//	        $('#SportsPoll').css("left", 435);
//	        $('#SportsPoll').css("top", 190);
//	    }
//	    else
//	    {
//	        $('#SportsPoll').css("left", 60);
//	        $('#SportsPoll').css("top", 180);
//	    }
//	}
};

// wrapper for the flash call
// eg. channel = movies, 
//     section = watchit, 
//     module = hotvideos, 
//     webtrendsid = movies_watchit_hotvideos, 
//     url = http://g6publish.videodome.com/verizon/portal/?clipId=88461&channel=Movie+Trailers&bitrate=300&format=wmp&SiteId=surround
//debugger
//       navEvent(channel, section, module, url, actionitem, subgroup, campaign, type, title)
function navEvent(channel, section, module, url, webtrendsid) 
{
    
    //alert('navEvent called - channel:'+channel+', section:'+section+', module:'+module+', url:'+url+', webtrendsid:'+webtrendsid);
	trace('navEvent called - channel:'+channel+', section:'+section+', module:'+module+', url:'+url+', webtrendsid:'+webtrendsid);
    if (webtrendsid == 'null')
        webtrendsid = '';
	
	if (webtrendsid == "SearchButtonClick")
	{
	    SurroundShell.hideESPNPoll();
	    SurroundShell.animateSearch(url);
	    //flashWebTrends(channel, section, module, webtrendsid);
	    //trackPageView(channel, section, module, "","");
	}	 
    else if (webtrendsid == "HidePlayer")
	{
	    SurroundShell.hidePlayer();
    }	
    else if (webtrendsid == "showPlayer")
	{
	    SurroundShell.showPlayer();
    }
    else if (webtrendsid == "playPlayer")
	{
	    SurroundShell.playPlayer(url);
    }
    else if (webtrendsid == "HideArticle")
	{
		SurroundShell.hideArticleView();
    }    
    else if (webtrendsid == "HidePoll")
    {
        SurroundShell.hideESPNPoll();
        SurroundShell.hideMoviePoll();
        SurroundShell.hideMusicPoll();
        SurroundShell.hideTVPoll();
        SurroundShell.hideFamilyPoll();
//        SurroundShell.hideSportsPoll();
    }
    else if (webtrendsid == "ShowESPNPoll")
    {
        window.setTimeout('SurroundShell.showESPNPoll()', 2000);
    }
    else if ((webtrendsid == "ShowmoviesCondensedPoll") || (webtrendsid == "ShowmoviesExpandedPoll"))
    {
        window.setTimeout('SurroundShell.showMoviePoll("'+webtrendsid+'")', 1000);
    }
    else if ((webtrendsid == "ShowmusicCondensedPoll") || (webtrendsid == "ShowmusicExpandedPoll"))
    {
        window.setTimeout('SurroundShell.showMusicPoll("'+webtrendsid+'")', 1000);
    }
    else if ((webtrendsid == "ShowtvCondensedPoll") || (webtrendsid == "ShowtvExpandedPoll"))
    {
        window.setTimeout('SurroundShell.showTVPoll("'+webtrendsid+'")', 1000);
    }
    else if ((webtrendsid == "ShowfamilyCondensedPoll") || (webtrendsid == "ShowfamilyExpandedPoll"))
    {
        window.setTimeout('SurroundShell.showFamilyPoll("'+webtrendsid+'")', 1000);
    }
    else if ((webtrendsid == "ShowsportsCondensedPoll") || (webtrendsid == "ShowsportsExpandedPoll"))
    {
//        window.setTimeout('SurroundShell.showSportsPoll("'+webtrendsid+'")', 1000);
    }
    else
    {
	    //flashWebTrends(channel, section, module, webtrendsid);
	   // trackPageView(channel, section, module, "","");
	    //debugger
	    SurroundShell.navigate(channel, section, module, url);
	}
}

// renders the article text, pulled from the readit.ashx web service, to the screen
function renderArticle(channel, section, url) 
{
    //Modified by LF
    /*SurroundShell.stopPlayer();*/
    //End modified by LF
        
    //thisMovie("flashMain").closeExpandedView();
    thisMovie("flashMain").displayArticle();
    SurroundShell.animateReadIt(channel, url);
    RefreshAdTop1("Top1", channel);
}

// this function is called by the gated content from Roo
// After a successful login, the gatedRedirect.aspx page calls this function
function gatedRedirect(redirectUrl)
{
    if (_from != ""){
        if (_from == "Review"){
           Verizon.Surround.Web.Default.AddReview(_itemId, _itemTitle, _body)
        }else{
           Verizon.Surround.Web.Default.AddRating(_itemId, _starsRated)
        }
        _from = "";
        _itemId = "";
        _itemTitle = "";
        _starsRated = 0;
        _body = "";
    }
    
    /*
    var queryString = redirectUrl.match(/\?(.+)/)[1];
    var params = TB_parseQuery( queryString );
    
    var channel = params['vzchannel'];
    var section = params['vzsection'];
    var module = params['vzmodule'];
    var url = params['gatedRedirectUrl'];
    */

    /*Modified by LF
    navEvent(channel, section, module, url, '');
    */
    TB_remove();

    var userName = getUserName().userName;

    if (userName != '')
    {

        document.getElementById('SignInDiv').innerHTML = "<div class='header'>Hello " +userName +" | <a class='header' onclick='flashWebTrends(null, null, null, \HeaderSignOut\)' href='http://www.verizon.net/ssowebapp/logout/logout.jsp?target=http%3a%2f%2fsurround.verizon.net%2fdefault.aspx'>Sign Out</a></div>";

        document.getElementById('toolbar_div_section1').innerHTML = "<div id=\"ucToolBar_pnlLoggedIn\"><span id=\"ucToolBar_lblLoggedInUsername\" class=\"toolbar_textwhitearialbold\" style=\"margin-left:5px\">"+userName+"</span><span class=\"toolbar_textwhitearial\">- SIGNED IN | </span><a href=\"http://www.verizon.net/ssowebapp/logout/logout.jsp?target=http%3a%2f%2fsurround.verizon.net%2fdefault.aspx\" class=\"toolbar_title\" style=\"font-size: 9px; color:#f9dba9\">SIGN OUT</a><br /><img src=\"/images/toolbar_signedIn.png\" alt=\"Sign In\" border=\"0\" width=\"89\" height=\"20\" /></div>";

    }

    // play video from flash
     if (_from == ""){
        thisMovie("flashMain").showGatedContent();
     }
}

function gatedRedirect1(redirectUrl)
{
     //TB_remove();
     //thisMovie("flashMain").showGatedContent();
    window.parent.location.href ="http://surround.verizon.net/default.aspx?channel=tv&section=watchIt&openAccordion=Entertainment Reports";
        //document.getElementById('playerFrameIframe').src = url;
}
//For Fergie Send to a friend functionality. Called from flash.
function sendToFriend(fromName, fromEmail, toEmail, cityId, videoId) 
{
    Verizon.Surround.Web.Default.SendToFriend(fromName, fromEmail, toEmail, cityId, videoId, sendToFriendConfirmation);
    return true;
}
 
function sendToFriendConfirmation(results)
{
    if (results.value != null)
    {
        if (results.value == "Success")
            return true;
        else
            return false;
    }
}


function Trace(msg)
{
   return;
   //alert(msg);

}
//for NFL

function isVOLBroadband()
{
    var userConnection = getConnection().userConnection;
    
	
    if (isLoggedIn().IsLoggedIn == "true")
    {        
       if (userConnection == "Vasonly" || userConnection == "Dial" || userConnection=="Unknown")
          {
             // Logged in. Not a Broadband Customer.
		    return "-1"; 
          }
          else
          {
            //Broadband Customer. 
		return "1";
          }
    }
    else
    {
        return "0";
    }   
}
function vasOnlyAlertBox()
{
    microSiteToHome = true;
    vasonlyUrl = "http://surround.verizon.net/NoVOLBroadBandRedirect.aspx?keepThis=true&TB_iframe=true&height=170&width=280";  
    TB_show("Verizon Surround", vasonlyUrl);
}

function NoBroadBandTvAlertBox()
{
    microSiteToHome = true;
    vasonlyUrl = "http://surround.verizon.net/NoVOLBroadBandRedirect.aspx?Feature=NFL&keepThis=true&TB_iframe=true&height=170&width=280";  
    TB_show("Verizon Surround", vasonlyUrl);
}

function showEzinePopUp()
{

var url = "http://surround.verizon.net/Presents/Ezine/EzineSignUp.aspx?keepThis=true&TB_iframe=true&height=284&width=273";  

 TB_show('Surround Yourself E-Zine Sign Up',url,"");
}

function hboGatedRedirect()
{  
	var userConnection = getConnection().userConnection;
    if (isLoggedIn().IsLoggedIn == "false")
    {
            //url += "&ssocheck=true";
                
            // build url to Verizon SSO with additional ActualTarget params
            gatedUrl = "https://sso.verizon.net/ssowebapp/VOLPortalLogin?login_type=basic&hc=1E0000&bdc=000000&ml=0&mt=0&mr=0&mb=0&ActualTarget="+escape('http://surround.verizon.net/tv/hbo/gatedredirect.aspx?')+"&keepThis=true&TB_iframe=true&height=179&width=319";  
            TB_show("Verizon Surround", gatedUrl); 
            return;  
    }
    else
    {
        if (userConnection == "Vasonly")
        {
           vasonlyUrl = "http://surround.verizon.net/NoVOLBroadBandRedirect.aspx?keepThis=true&TB_iframe=true&height=179&width=318";  
		   TB_show("Verizon Surround", vasonlyUrl); 
        }
		else
		{
			return "1";
		}
    }
}
function RooGatedRedirect()
{  
		var userConnection = getConnection().userConnection;
    if (isLoggedIn().IsLoggedIn == "false")
    {
            //url += "&ssocheck=true";
                
            // build url to Verizon SSO with additional ActualTarget params
            gatedUrl = "https://sso.verizon.net/ssowebapp/VOLPortalLogin?login_type=basic&hc=1E0000&bdc=000000&ml=0&mt=0&mr=0&mb=0&ActualTarget="+escape('http://surround.verizon.net/gatedredirect.aspx?')+"&keepThis=true&TB_iframe=true&height=179&width=319";  
            TB_show("Verizon Surround", gatedUrl); 
            return;  
    }
    else
    {
        if (userConnection == "Vasonly")
        {
           vasonlyUrl = "http://surround.verizon.net/NoVOLBroadBandRedirect.aspx?keepThis=true&TB_iframe=true&height=179&width=318";  
		   TB_show("Verizon Surround", vasonlyUrl); 
        }
		else
		{
			TB_remove();
			return "1";
		}
    }
}

