var $j = jQuery.noConflict();
$j(document).ready(function() {

$j('.external li a').click(function()
{
     this.target='_blank';
});

/* blockquote */
/*
$j('.blockquote_end').css('background','none');
var inner=$j('.blockquote_end').html();
inner=inner+'<span class="last_quote"></span>';
$j('.blockquote_end').html(inner);
*/


$j('.top_drop_down ul li').hover(function(){
		$j(this).children('ul').css('display','block');
	}, function(){
		$j(this).children('ul').css('display','none');
	});

$j('#main_bar li').hover(function(){
		$j(this).addClass('over');
	}, function(){
		$j(this).removeClass('over');
	});

$j('#main_bar li:first a span').addClass('space');
$j('#main_bar li:first').next('#main_bar li').find('span').addClass('space');
	
$j('#search_box button').hover(function(){
		$j(this).addClass('over');
	}, function(){
		$j(this).removeClass('over');
	});
	
$j('#rolloverfooter').hover(function(){
        $j(this).attr("src", "http://www.digitaluk.co.uk/__data/assets/image/0006/14757/ban_last_hover.jpg");
    },  function(){
        $j(this).attr("src", "http://www.digitaluk.co.uk/__data/assets/image/0005/14756/ban_last.jpg");
    });
	
$j('.show_transcript').toggle(function(){
        $j('.show_transcript').html('Hide transcript');
        $j('.transcript').show('slow');
    }, function(){
        $j('.show_transcript').html('Show transcript');
        $j('.transcript').hide('slow');
    });	

/*
$j('.top_push_box_content ul li.last').mouseover(function(){
    if(!($j(this).hasClass('currentlast')))
    {
        $j(this).addClass('currentlast');
        $j(this).mouseout(function(){
            $j(this).removeClass('currentlast');
        });
    }
});
*/
	
/* start flowplayer */ 
            
$playlist = new Array();

$vUrls = $j("#video_list input.videoUrl");

$vUrls.each(function(){
    $playlist.push($j(this).val());
  });

if($playlist.length == 3)
{
flowplayer("player", 
           "http://www.digitaluk.co.uk/__data/assets/file/0003/48936/flowplayer-3.2.0.swf", 
           {
             clip:  
               {
	         autoPlay: true
	       },

             playlist: 
               [
                 $playlist[0]
               ],
             onLoad: function()
               {
                 if($j("#playChapter").length)
                   {
                     $chapterId = $j("#playChapter").val();
                     $f().setPlaylist([ $j("#videoId_" + $chapterId).val() ]);
                   }
               },
             plugins: 
               {
	         controls: 
                   {
		     url: 'http://www.digitaluk.co.uk/__data/assets/file/0004/48937/flowplayer.controls-3.2.0.swf',
		     tooltips: 
                       {
		         buttons: true,
		         fullscreen: 'Enter Fullscreen mode'
	               }
                   }
               }
    });
  }
else if($playlist.length == 2)
  {
    flowplayer("player", 
           "http://www.digitaluk.co.uk/__data/assets/file/0003/48936/flowplayer-3.2.0.swf", 
           {
             clip:  
               {
	         autoPlay: true
	       },
             playlist: 
               [
                 $playlist[0]
               ],
             onLoad: function()
               {
                 if($j("#playChapter").length)
                   {
                     $chapterId = $j("#playChapter").val();
                     $f().setPlaylist([ $j("#videoId_" + $chapterId).val() ]);
                   }
               },
             plugins: 
               {
	         controls: 
                   {
		     url: 'http://www.digitaluk.co.uk/__data/assets/file/0004/48937/flowplayer.controls-3.2.0.swf',
		     tooltips: 
                       {
		         buttons: true,
		         fullscreen: 'Enter Fullscreen mode'
	               }
                   }
               }
  });
  }
else if($playlist.length == 1)
  {
    flowplayer("player", 
           "http://www.digitaluk.co.uk/__data/assets/file/0003/48936/flowplayer-3.2.0.swf", 
           {
             clip:  
               {
                 bufferLength: 3,
	         autoPlay: true,
                 autoBuffering: true
	       },

             playlist: 
               [
                 $playlist[0]
               ],
             onLoad: function()
               {
                 if($j("#playChapter").length)
                   {
                     $chapterId = $j("#playChapter").val();
                     $f().setPlaylist([ $j("#videoId_" + $chapterId).val() ]);
                   }
               },
             plugins: 
               {
	         controls: 
                   {
		     url: 'http://www.digitaluk.co.uk/__data/assets/file/0004/48937/flowplayer.controls-3.2.0.swf'
                   }
               }
  });
  }

/* start playbutton */

$j('.video_box span').removeClass('txt').addClass('play_button').html('');
    
$j('.video_box a').mouseover(function()
    {
        $j('.video_box span').removeClass('play_button').addClass('play_button play_button_over'); 
    });
    
$j('.video_box a').mouseout(function()
    {
        $j('.video_box span').removeClass('play_button_over').addClass('play_button'); 
    }); 

/* start switchover menu */

if($j('#switchover_menu').length){
        $j('#tab_video').css('display','none');
        
$j('div#regional a#switchover_map_tab_menu').removeClass('regional_active');
        
        $j('#switchover_map_tab_menu').click(function(event){
                    event.preventDefault();
$j('#tab_switchover_map').fadeIn('slow',
function()
{
$j('#tab_video').css('display','none');
});
              $j('#switchover_map_tab_menu').addClass('active');

              $j('#tab_video').css('display','none');
              $j('#video_tab_menu').removeClass('active');
        });
        
        $j('#video_tab_menu').click(function(event){
                        
$j('#tab_video').fadeIn('slow',
function()
{
$j('#tab_switchover_map').css('display','none');
});

$j('#switchover_map_tab_menu').removeClass('regional_active');
              $j('#video_tab_menu').addClass('right active');
$j('#switchover_map_tab_menu a').removeClass('active');

              event.preventDefault();
              $j('#tab_switchover_map').css("display", "none");
        });
    };
	
	
});

$j(window).load(function() {
/*
 $j('div.double_push_box_content').each(function(){
            var max_height = 0;
                   
            $j(this).find('.push_box_content').each(function(){
                if ($j(this).height() > max_height) max_height = $j(this).height();
            });
                $j(this).find('.push_box_content').height(max_height);
        });
*/

/* video listing hover*/

var href_adres = window.location.href;

var business_search = href_adres.search(/chapter=49436/);
if ( business_search != -1)
{
var i=0;
    $j('#video_list li').each(function()
{
    if(i==1)
 $j(this).addClass('current');
    i++;
}
);
   
}

var tmp_current=0;

        $j(".top_push_box_content ul li").each(function(){
        if($j(this).is("[class^='current']"))
        {
tmp_current=1;
        }
        if($j(this).is("[class^='currentlast']"))
        {
tmp_current=1;
        }
        });

if(tmp_current==0)
{
        $j(".top_push_box_content ul li:first").addClass('current');
}

$j(".top_push_box_content ul li").mouseover(function(){

if(!$j(this).is("[class^='current']"))
{
    if($j(this).is("[class^='last']"))
    {
        $j(".top_push_box_content ul li").each(function(){
        if($j(this).is("[class^='current']"))
        {
              $j(this).removeClass('current').addClass('tabwhite');

        }
        if($j(this).is("[class^='currentlast']"))
        {
              $j(this).removeClass('currentlast').addClass('tabwhitelast').addClass('last');

        }

        });

        $j(this).addClass('currentlast');
        $j(this).mouseout(function(){
            $j(this).removeClass('currentlast');
$j(".top_push_box_content ul li").each(function(){
            if($j(this).is("[class^='tabwhite']"))
            {
              $j(this).removeClass('tabwhite').addClass('current');
            }
            if($j(this).is("[class^='tabwhitelast']"))
            {
              $j(this).removeClass('tabwhitelast').removeClass('last').addClass('currentlast');
            }
        });
            
        });
    }
    else
    {
        $j(".top_push_box_content ul li").each(function(){
        if($j(this).is("[class^='current']"))
        {
              $j(this).removeClass('current').addClass('tabwhite');

        }
        if($j(this).is("[class^='currentlast']"))
        {
              $j(this).removeClass('currentlast').addClass('tabwhitelast').addClass('last');

        }

        });

        $j(this).addClass('current');
        $j(this).mouseout(function(){
            $j(this).removeClass('current');
            $j(".top_push_box_content ul li").each(function(){
            if($j(this).is("[class^='tabwhite']"))
            {
              $j(this).removeClass('tabwhite').addClass('current');
            }

            if($j(this).is("[class^='tabwhitelast']"))
            {
              $j(this).removeClass('tabwhitelast').removeClass('last').addClass('currentlast');
            }

        });
    });
    }
}
});




/* video listing*/

if($j('#video_list').length)
{
var myclass = $j('#video_list').find('li:last').attr('class');
var mycurrent = myclass.search('current');

if(mycurrent != -1) {
$j('#video_list').find('li:last').removeClass();
$j('#video_list').find('li:last').addClass('currentlast');
} else {
$j('#video_list').find('li:last').addClass('last');
};
}

});


