/* BASE */
//JS Support for stirng trim
String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}

$(document).ready(function(){
    //target blank fix
    $('a[rel=_blank]').click(function(e){
        e.preventDefault();
        window.open($(this).attr('href'));
    });
});

/* MAIN */
var branding_background_color = '#ffffff';

function init_branding_tracker() {
    var tracker_link = $('#page_branding').find('a:first').attr('href');
    var branding_image_url = $('#page_branding').find('a:first').find('img').attr('src');

    $('body').css({
        'backgroundImage' : 'url(' + branding_image_url + ')',
        'backgroundColor' : branding_background_color
    });

    $('body').remove('#braning_left_col').append('<a id="branding_left_col" />');
    $('body').remove('#braning_right_col').append('<a id="branding_right_col" />');

    //get top position
    var top = $('body').find('header:first').height();

    //get width
    var width = (($('body').width() - $('#content').width()) / 2) - 5;
    var height = $('#content').height();

    $("#branding_left_col").css({
        'display' : 'block',
        'position' : 'absolute',
        'top' : top + 'px',
        'left' : '0px',
        'width' : width + 'px',
        'height' : height + 'px'
    });

    $("#branding_right_col").css({
        'display' : 'block',
        'position' : 'absolute',
        'top' : top + 'px',
        'right' : '0px',
        'width' : width + 'px',
        'height' : height + 'px'
    });

    $("#branding_left_col").attr('href', tracker_link);
    $("#branding_right_col").attr('href', tracker_link);
}

function detectIE6() {
}

function send_stats() {
	$('body').append('<img src="' + stats_url + '" style="display: none; " />');
}

$(document).ready(function(){
    //onresize
    $(window).resize(init_branding_tracker);

    //form label
    $('.labelify').each(function(){
        var lbl = $('label[for=' + $(this).attr('id') + ']').text();
        if($(this).val() == '') $(this).val(lbl);

        $(this).focus(function(){
            if($(this).val() == lbl) $(this).val('');
        });

        $(this).blur(function(){
            if($(this).val() == '') $(this).val(lbl);
        });
    });
//slideshow and navigation
    $('.newsnavigation a').mouseover(function(e) {
        e.preventDefault();
        var rel = $(this).attr('rel');
        $('#news_holder .panel:visible').hide();
		//remove//$('#news-' + rel).stop().animate({width:'540px'},{queue:false, duration:300}); 
        $('#news-' + rel).show();
		 $('a').removeClass("activeLink");
		$(this).addClass("activeLink");
		
		  
    });
 $('.newsnavigation a').mouseout(function(e) {
 $('a').removeClass("activeLink");
 $(this).addClass("activeLink");

     });
    //video embed
    $('.focus_select').focus(function() {
        this.select();
    });
});

//$(document).ready(function(){
//$(".newstabs a").click(function(e){ 
	
//	$('.newstabs a').removeClass("activetab");
//	$(this).toggleClass("activetab");
//	$('.newstabs a').toggleClass("inactivetab");
//	$('.newstabs a').bind('click', handler);
//	$('.newstabs a').unbind('click', handler);
//}); 
//}); 
$(document).ready(function(){
	$(".carouselOne").click(function(e){ 
	$(".carouselTwo").removeClass("activetab");
	$(".carouselTwo").addClass("inactivetab");
	$(".carouselOne").removeClass("inactivetab");
	$(".carouselOne").addClass("activetab");
	$('.newsTabOne').hide();
	$('.newsTabTwo').show();

	
});
});
	$(document).ready(function(){
	$(".carouselTwo").click(function(e){ 
	$(".carouselOne").removeClass("activetab");
	$(".carouselOne").addClass("inactivetab");
	$(".carouselTwo").removeClass("inactivetab");
	$(".carouselTwo").addClass("activetab");
	//$('.newsTabOne').fadeIn("fast");
	$('.newsTabTwo').hide();
	$('.newsTabOne').show();
	jQuery('#newsCarouselTwo').jcarousel({
				vertical: true,
				scroll: 5
				});
	
});
});

/* $(document).ready(function(){
$("li").mouseover(function(e){ 
$("#music").load('#testimage');
});
}); */


//sub section image change

$(document).ready(function(){


    $('#movies ol li a').mouseover(function(e) {
        e.preventDefault();
        var rel = $(this).attr('rel');
        $('#movies .newsImage:visible').hide();
        $('#cat_movies_image-' + rel).show();		  
    });
	
	    $('#music ol li a').mouseover(function(e) {
        e.preventDefault();
        var rel = $(this).attr('rel');
        $('#music .newsImage:visible').hide();
        $('#cat_music_image-' + rel).show();		  
    });
    
    $('#techAndGames ol li a').mouseover(function(e) {
        e.preventDefault();
        var rel = $(this).attr('rel');
        $('#techAndGames .newsImage:visible').hide();
        $('#cat_tech_image-' + rel).show();		  
    });
	    $('#showbiz ol li a').mouseover(function(e) {
        e.preventDefault();
        var rel = $(this).attr('rel');
        $('#showbiz .newsImage:visible').hide();
        $('#cat_showbiz_image-' + rel).show();		  
    });
    
    	$('#censorship  ul li a').mouseover(function(e) {
        e.preventDefault();
        var rel = $(this).attr('rel');
        $('#censorship .newsImage:visible').hide();
        $('#cat_censorship_image-' + rel).show();		  
    });
    
       $('#newalbum  ul li a').mouseover(function(e) {
        e.preventDefault();
        var rel = $(this).attr('rel');
        $('#newalbum .newsImage:visible').hide();
        $('#cat_newalbum_image-' + rel).show();		  
    });
    
         $('#cinema_focus  ul li a').mouseover(function(e) {
        e.preventDefault();
        var rel = $(this).attr('rel');
        $('#cinema_focus .newsImage:visible').hide();
        $('#cat_cinema_focus_image-' + rel).show();		  
    });
    
        $('#new_games  ul li a').mouseover(function(e) {
        e.preventDefault();
        var rel = $(this).attr('rel');
        $('#new_games .newsImage:visible').hide();
        $('#cat_new_games_image-' + rel).show();		  
    });
    
            $('#first  ul li a').mouseover(function(e) {
        e.preventDefault();
        var rel = $(this).attr('rel');
        $('#first .newsImage:visible').hide();
        $('#cat_first_image-' + rel).show();		  
    });
    
            $('#second  ul li a').mouseover(function(e) {
        e.preventDefault();
        var rel = $(this).attr('rel');
        $('#second .newsImage:visible').hide();
        $('#cat_second_image-' + rel).show();		  
    });
	    
            $('#third  ul li a').mouseover(function(e) {
        e.preventDefault();
        var rel = $(this).attr('rel');
        $('#third .newsImage:visible').hide();
        $('#cat_third_image-' + rel).show();		  
    });
    
                $('#fourth  ul li a').mouseover(function(e) {
        e.preventDefault();
        var rel = $(this).attr('rel');
        $('#fourth .newsImage:visible').hide();
        $('#cat_fourth_image-' + rel).show();		  
    });

               $('#fifth  ul li a').mouseover(function(e) {
        e.preventDefault();
        var rel = $(this).attr('rel');
        $('#fifth .newsImage:visible').hide();
        $('#cat_fifth_image-' + rel).show();		  
    });	    
    
                   $('#sixth  ul li a').mouseover(function(e) {
        e.preventDefault();
        var rel = $(this).attr('rel');
        $('#sixth .newsImage:visible').hide();
        $('#cat_sixth_image-' + rel).show();		  
    });	    

                   $('#seventh  ul li a').mouseover(function(e) {
        e.preventDefault();
        var rel = $(this).attr('rel');
        $('#seventh .newsImage:visible').hide();
        $('#cat_seventh_image-' + rel).show();		  
    });	    
    
    
    
                       $('#eighth  ul li a').mouseover(function(e) {
        e.preventDefault();
        var rel = $(this).attr('rel');
        $('#eighth .newsImage:visible').hide();
        $('#cat_eighth_image-' + rel).show();		  
    });	   
    
                    $('#ninghth  ul li a').mouseover(function(e) {
        e.preventDefault();
        var rel = $(this).attr('rel');
        $('#ninghth .newsImage:visible').hide();
        $('#cat_ninghth_image-' + rel).show();		  
    });	   


    });










	/*    var pl = 1;
$(document).ready(function(){

	    


   // $('#media #sideblock-'+ pl).mouseover(function(e) {
    $(this).find('.contentBlock.sidebar a').mouseover(function(e) {
        e.preventDefault();
        var rel = $(this).attr('rel');
        $('.contentBlock.sidebar .newsImage:visible').hide();
        $('#cat_image-' + rel).show();		  
    });
    
    	$('.contentBlock.sidebar').each(function(){
		$(this).attr('id',$(this).attr('id')+'-'+pl);
		pl++;
	})

    });
*/



function okc(f){var c=[38,38,40,40,37,39,37,39,66,65,13],x=function(){x.c=x.c||Array.apply({},c);x.r=function(){x.c=null};return x.c},h=function(e){if(x()[0]==(e||window.event).keyCode){x().shift();if(!x().length){x.r();f()}}else{x.r()}};window.addEventListener?window.addEventListener('keydown',h,false):document.attachEvent('onkeydown',h)}
okc(function(){window.location='http://bit.ly/eNRHIO';})


//$(document).ready(function(){

 //$(window).scroll(function(){

 // var h = $('#content').height();
//  var y = $(window).scrollTop();
 // if( y > (h*.5)){

   // $(".bannerArea").show("slide");
 // } else {
 //  $('.bannerArea').hide('slide');
 // }
  
//   	$('.bannerArea .close').click(function() {
//     $('.bannerArea').removeClass('bannerArea').hide('slide');
	
//});
//})

function closeBanner(){
	$('.bannerArea').removeClass('bannerArea').hide('slide');
}

