$(document).ready(function() {
	
	$('.top-slider').scrollable({
		size:5,
		next: '#top-slider-next',
		prev: '#top-slider-prev'
	}).circular();
	
	$('#carousel .slides').easySlider({
		nextId: 'next-slide-2',
		prevId: 'prev-slide-2',
		totalId: 'total-2',
		speed: 500,
		vertical: true
	});
	
	$('#header #menu li').hover(function(){
		$(this).addClass('hover');
	},
	function() {
		$(this).removeClass('hover');
	})
	.click(function() {
		var active = $(this).hasClass('active');
		$('#header #menu li.active').removeClass('active');
		if ( !active ) {
			$(this).addClass('active');
		}
	});
	$('.menu .item').hover(function(){
		$(this).addClass('hover');
	},
	function() {
		$(this).removeClass('hover');
	});
	
	
	$('#slider .slide, #slider .slide *').click(function() {
		var slide = !$(this).hasClass('slide') ? $(this).parents('.slide') : $(this);
		window.location = $(slide).find('a').attr('href');
	});
	$('#slider .slide').hover(function(){
		$(this).addClass('hover');
	},
	function() {
		$(this).removeClass('hover');
	});
	
	
	var prevSQuery = '';
	
	
	$('#search input#query').focus(function() {
		prevSQuery = $(this).val();
		if ( prevSQuery == 'Find artist and music' ) {
			$(this).val('');
		}
	})
	.blur(function() {
		var curSQuery = $(this).val();
		if ( curSQuery == '' ) {
			if ( prevSQuery != '' ) {
				$(this).val(prevSQuery);
			} else {
				$(this).val('Find artist and music');
			}
		}
	})
	.keypress(function() {
		prevSQuery = '';
	});
	
	
	$('#home .block, #home .block *').click(function() {
		var block = !$(this).hasClass('block') ? $(this).parents('.block') : $(this);
		window.location = $(block).find('a').attr('href');
	});
	
	
	$(".albums .menu").tabs(".panes > div", {
		effect: 'fade',
		fadeOutSpeed: 0,
		fadeInSpeed: 400
	});
	
	
	$('.playlist .list').jScrollPane();
	$('#sidebar .list').jScrollPane();
	$('#chart-toggler').click(function() {
		if ( $('#chart').is(':hidden')) {
			$('#chart').show();
			$('#chart-white-block').animate({
				height: '280px'
			},
			600);
			$('#chart').animate({
				top: '90px'
			},
			600);
		} else {
			$('#chart-white-block').animate({
				height: '0px'
			},
			600);
			$('#chart').animate({
				top: '-175px'
			},
			600, function() {
			 	$('#chart').hide();
			});
		}
	});
});
