﻿$(document).ready(function() {

    // main search form effects
    $('#topSearch input.input').focus(function () {
        $(this).addClass('focus');
        if (this.value == this.defaultValue) {
            this.value = '';
        }
        if (this.value != this.defaultValue) {
            this.select();
        }
    });
    $('#topSearch input.input').blur(function () {
        $(this).removeClass('focus');
        if ($.trim(this.value == '')) {
            this.value = (this.defaultValue ? this.defaultValue : '');
        }
    });

    // Text scroller
    $('.artistList li').mouseover(function() {
        $('.text').stop().animate({ marginLeft: 0 }, 0);
        var boxWidth = $(this).width();
        var textWidth = $('.text a', $(this)).width();
        if (textWidth > boxWidth) {
            var animSpeed = textWidth - boxWidth;
            $('.text', $(this)).animate({ marginLeft: -animSpeed }, 1000);
        }

    }).mouseout(function() {
        $('.text').stop().animate({ marginLeft: 0 }, 1000);
    })

    //Artist List Hover
    //$('.artistList li a').hover(function () {
        //$(this).find('img').show();
    //}, function () {
       // $(this).find('img').hide();
    //});

    //Format tooltips
    $('ul.filter li a').hover(function() {
        $(this).find('span').show();
    }, function() {
        $(this).find('span').fadeOut('slow');
    });


}); 


// content slider
(function($) {
  $.sliderMain = function() {
  
    var curItem = 1;
	var maxPage = 0;
	var timeoutVar;
	//var width = 10000;
  
	function loadNewBanner() {
      clearTimeout(timeoutVar);
	  doTimeout();
	  var oldPage = curItem;
      if (curItem < 1) {
        curItem = 1;
      } else if (curItem > maxPage) {
        curItem = maxPage;
      }
	  $(".slideHold").animate({
        top: -((curItem - 1) * 325)
      }, 500);
	  
	  $('.sliderPaging ul li').removeClass('on');
	  $('.sliderPaging ul li[id="' + curItem + '"]').addClass('on');
	  Cufon.replace('.sliderPaging ul li h2');
	}
	
	function runNext() {
      curItem++;
      if (curItem > maxPage) {
        curItem = 1;
      }
      loadNewBanner();
    }

    maxPage = $('.slideHold div.slideItem').size();
	$(".slideHold").css({ 'height': (maxPage * 325) });
	
	$(".sliderPaging ul").show();
	$(".sliderPaging ul li:first").addClass("on");
	Cufon.replace('.sliderPaging ul li h2');
	
	$(".sliderPaging ul li").hover(function() {
	  $(this).addClass('hov');
	}, function() {
	    $(this).removeClass('hov');
    });
	
	$(".sliderPaging ul li").click(function() {
	  curItem = $(this).attr('id');
	  loadNewBanner();
      return false;
    });

    $(".slideHold div.slideItem").hover(function() {
	  clearTimeout(timeoutVar);
    }, function() {
      doTimeout();
    });
	
	doTimeout();
	
	function doTimeout() {
	  timeoutVar = setTimeout(function() {
        runNext();
      }, 5000);
	}
	
	return this;
  }
})(jQuery);

$( function() {
	$.sliderMain();
});



