$(function() {
    var faqQuestions = $("div.faqs_container div.title");
    faqQuestions.append("<span>See more</span>");
    faqQuestions.toggle(
		function(){
			$(this).next().slideToggle(350);
			$(this).find("span").text("Close");
			$(this).addClass("open");
		},
		function(){
			$(this).next().slideToggle(350);
			$(this).find("span").text("See more");
			$(this).removeClass("open");
		}
	);
});

// function to scroll to Guide Pod
$(function() {
$("div#anchor a").css("cursor","pointer");
$("div#anchor a").click(
	function() {
    guideInfo();
	});
});		

function guideInfo() {
    guideInfoPos = $("#faqs").position().top;
	$("html, body").animate({scrollTop:guideInfoPos}, 1300, "swing");
};

//play EPG movie
$(function() {
var flashvars = { flvName:"EPGPLayer", flvPath:"http://dl.groovygecko.net/anon.groovy/clients/akqa/bskyb/skyhd/EPG_Demo.flv"};

    $("div#EPGContainer #EPGPlayer img").css("cursor","pointer").click(function(){
    swfobject.embedSWF("/library/hd/flash/howDoesPlayer.swf", attributes.id, "616", "378", reqFlashVersion+".0.0", false, flashvars, params, attributes);
    });
});

/***********************************************
	function renderScroller()
	Takes an HTML list and converts it into a scrolling carousel. 
	--------------------------------------------
	The renderScroller function needs to be called once the page has fully loaded
	and the script has access to the DOM.
	Note: Requires the JQuery library.
***********************************************/
$(document).ready(function() {
    
    $('ul.highlights').each(function()
    {
        var totalListItems = $(this).find('li').size(); 
        
        if (totalListItems >= 5)        
        {   
            $(this).wrap('<div class="scroller hdChannelsScroller"><div class="scroll"></div></div>');        
            $(this).parent().before('<img src="/library/hd/christmas/images/scroller_left_arrow_purple.gif" alt="Scroll channels" width="34" height="34" class="scrollLeft" />');
            $(this).parent().after('<img src="/library/hd/christmas/images/scroller_right_arrow_purple.gif" alt="Scroll channels" width="34" height="34" class="scrollRight" />');
        }
   
    });    
    
    var $scrollers = $('div.scroll');
    
    $scrollers.each(function (i){
    var ulWidth = 0;
        var $list = $(this).find('ul');
        var $listItems = $list.find('li');                
    $listItems.each(function (i){
            ulWidth += parseInt($(this).css('width'));
    });
        $list.css({width:ulWidth});
    });
    
    $('img.scrollLeft').click(
        function(){
            var distance = $(this).parent().find('div.scroll ul li').css('width');
            $(this).parent().find('div.scroll').animate(
                {scrollLeft: '-=' + distance}
            );
        }
    );
    
    $('img.scrollRight').click(
        function(){
            var distance = $(this).parent().find('div.scroll ul li').css('width');
            $(this).parent().find('div.scroll').animate(
                {scrollLeft: "+=" + distance}
            );
        }
    );
});
