$(document).ready(function(){
    $(".header_left_item").click(function(){
        if(!$(this).hasClass("header_left_item_selected")){
            $(".header_left_item").removeClass("header_left_item_selected");
            $(this).addClass("header_left_item_selected");

            $(".header_img_box").hide();
            $("#big_"+$(this).attr("id")).show();

            $("#header_box_img img").attr("src",$("#big_"+$(this).attr("id")).children(".header_img_item").children("img").first().attr("src"));
            $("#big_banner_link").attr("href",$("#big_"+$(this).attr("id")).children(".header_img_item").children(".header_img_item_href").html());
            $("#header_box_text_bg .header_box_text_yellow").html("<strong>"+$("#big_"+$(this).attr("id")).children(".header_img_item").children(".header_img_item_artist").html()+"</strong>");
            $("#header_box_text_bg .header_box_text").html("<strong>"+$("#big_"+$(this).attr("id")).children(".header_img_item").children(".header_img_item_title").html()+"</strong>");
        }
    });

    $(".header_img_item").click(function(){
        $("#header_box_img img").attr("src",$(this).children("img").attr("src"));
        $("#big_banner_link").attr("href",$(this).children(".header_img_item_href").html());
        $("#header_box_text_bg .header_box_text_yellow").html("<strong>"+$(this).children(".header_img_item_artist").html()+"</strong>");
        $("#header_box_text_bg .header_box_text").html("<strong>"+$(this).children(".header_img_item_title").html()+"</strong>");
    });
    
    $(".sub_menu_item").mouseover(function(){
        if($(this).attr("id")!="sub_item_selected"){
            $(this).addClass("sub_item_selected");
        }
    });

    $(".sub_menu_item").mouseout(function(){
        if($(this).attr("id")!="sub_item_selected"){
            $(this).removeClass("sub_item_selected");
        }
    });

    $("a#bookmark").click(function(e){
    	e.preventDefault(); // this will prevent the anchor tag from going the user off to the link
    	var bookmarkUrl = window.location;
    	var bookmarkTitle = $("title").html();

    	if (window.sidebar) { // For Mozilla Firefox Bookmark
    		window.sidebar.addPanel(bookmarkTitle, bookmarkUrl,"");
    	} else if( window.external || document.all) { // For IE Favorite
    		window.external.AddFavorite( bookmarkUrl, bookmarkTitle);
    	} else if(window.opera) { // For Opera Browsers
    		$("a#bookmark").attr("href",bookmarkUrl);
    		$("a#bookmark").attr("title",bookmarkTitle);
    		$("a#bookmark").attr("rel","sidebar");
    	} else { // for other browsers which does not support
    		 alert('Your browser does not support this bookmark action');
    		 return false;
    	}
    });

    setTimeout("change_top_5()",4000);
});

function change_top_5(){
    $(".top_5_items").each(function(index) {
        if(!$(this).is(":hidden")){
            $(this).fadeOut(1000,function(){
                if($(this).next().html()){
                    $("#top_5_title").html($(this).next().attr("title"));
                    $(this).next().fadeIn(1000,function(){
                        setTimeout("change_top_5()",4000);
                    });
                }else{
                    $("#top_5_title").html($(".top_5_items").first().attr("title"));
                    $(".top_5_items").first().fadeIn(1000,function(){
                        setTimeout("change_top_5()",4000);
                    });
                }

            });
        }
    });
}
