
$(document).ready(function() {
	


$('.views-field-field-playlist-hi-five-nid').jScrollPane();
$('.views-field-field-playlist-the-latest-nid').jScrollPane();
$('.view-id-whats_hot').jScrollPane();

	$(".view-dom-id-7").fadeOut("0");
	$(".view-dom-id-6").fadeOut("0");

$('#whats-hot-wrapper .most-played-button').click(function() {
	$(".top-rated-button").removeClass("active");
	$(".new-button").removeClass("active");
	$(".most-played-button").addClass("active");
	$(".view-dom-id-7").fadeOut("0");
	$(".view-dom-id-6").fadeOut("0");
	$(".view-dom-id-5").fadeIn("0");
});


$('#whats-hot-wrapper .top-rated-button').click(function() {
	$(".most-played-button").removeClass("active");
	$(".new-button").removeClass("active");
	$(".top-rated-button").addClass("active");
	$(".view-dom-id-5").fadeOut("0");
	$(".view-dom-id-7").fadeOut("0");
	$(".view-dom-id-6").fadeIn("0");
});


$('#whats-hot-wrapper .new-button').click(function() {
	$(".top-rated-button").removeClass("active");
	$(".most-played-button").removeClass("active");
	$(".new-button").addClass("active");
	$(".view-dom-id-5").fadeOut("0");
	$(".view-dom-id-6").fadeOut("0");
	$(".view-dom-id-7").fadeIn("0");
});

	// show hide the email terms and button

	$('#email-input').focus(function() {
	$("#confirm").fadeIn("0");
	$("#email-signup").fadeIn("0");
	});
	
	$('#email-input').blur(function() {
	$("#confirm").fadeOut("0");
	$("#email-signup").fadeOut("0");
	});
	
	// animate the service links bar
	
//	setTimeout(function() {$('#follow').animate({"top": "+=30px"}, "slow")} , 2500); // delays 1.5 sec since we cannot use jquery delay

	// setup the homepage tile carousel
	function tilecarousel_initCallback(carousel) {


    $('#tilecarousel-next').bind('click', function() {
        carousel.next();
        return false;
    });

    $('#tilecarousel-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
    
    
    // Pause autoscrolling if the user moves with the cursor over a tile
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
	};

    $("#tilecarousel").jcarousel({
        scroll: 1,
        auto:2,
        wrap: 'circular',
        initCallback: tilecarousel_initCallback,
    });



    // set the service links follow bar animation cookie

  
  if ($.cookie("follow")=="seen")
  {
  	 $('#follow').addClass('seen');
  	 
  }
  
  $.cookie('follow', 'seen', { path: '/' });



	// search form behavior at top of page

	$.fn.delay = function(time, callback){
		// Empty function:
		jQuery.fx.step.delay = function(){};
		// Return meaningless animation, (will be added to queue)
		return this.animate({delay:1}, time, callback);
	}


	var inputbox = $("#email-input");

	inputbox.val('enter your email');

	inputbox.bind('focus click', function() {
			$(this).css({color: '#000000'});

			if ( $(this).val() == 'enter your email') {
				$(this).val('');
			}
	});

	inputbox.bind('blur', function() {
		if ( $(this).val() == '' ) {
			$(this).animate({color:'#ffffff'}, 0, function() {
				$(this).val('enter your email');
				$(this).animate({ color: '#999999' }, 500);
			});
		}
	});


});
