$(document).ready(function() {

    // Toggle the style switcher
    $('#switcher #switchPanel').show();
        $('#switcher #switchPanel').animate({marginTop:'-200px'},{queue:false,duration:0});
        $('#switcher .trigger').toggle(function(){
	    $('#switcher #switchPanel').animate({marginTop:'0px'},{queue:false,duration:500});
        }, function(){
	        $('#switcher #switchPanel').animate({marginTop:'-200px'},{queue:false,duration:500});
    });
    
    // Dropdown nav
    $("ul.dropdown li").hover(function() {
            $(this).css('z-index', '7')
            $('ul:first', this).stop(false,true).slideDown('fast');
        }, function() {
            $(this).stop();
            $(this).css('z-index', '6')
            $('ul:first', this).stop(false,true).slideUp('fast');
    });
    
    // Gig buy buttons
	$('.gigList li a.gigBuy').hover(function(){
		$('img', this).stop().animate({left:'-22px'},{queue:false,duration:150});
	}, function() {
		$('img', this).stop().animate({left:'0px'},{queue:false,duration:150});
	});
	
	// Footer social buttons
	$('#social ul li a').hover(function(){
		$('img', this).stop().animate({top:'-30px'},{queue:false,duration:200});
	}, function() {
		$('img', this).stop().animate({top:'0px'},{queue:false,duration:150});
	});
	
	//Toggle elements
	$("h2.trigger").toggle(function(){
		$(this).addClass("triggerOpen");
		}, function () {
		$(this).removeClass("triggerOpen");
	});
	$("h2.trigger").click(function(){
		$(this).next(".toggleContainer").slideToggle("slow");
	});	
	
	// Custom Tooltips
	$('.isleTip').hover(
		function() {
		this.tip = this.title;
		$(this).append(
			'<span class="isleTipHold">'
			+this.tip
			+'</span>'
		);
		this.title = "";
		$('.isleTipHold').hide();
		$(this).find('.isleTipHold').fadeIn(300);
	},
	function() {
		$('.isleTipHold').fadeOut(500);
			this.title = this.tip;
		}
	);
	
	//Discography rollovers
    $('.discogWrap ul li .overlay').css('opacity', 0.7);
    $('.discogWrap ul li').find('p').animate({bottom:'-100px'},{queue:false,duration:0});
    $('.discogWrap ul li').find('.overlay').animate({bottom:'-100px'},{queue:false,duration:0});
    $('.discogWrap ul li').hover(function(){
    $(this).find('.overlay').animate({bottom:'0px'},{queue:true,duration:300});
    $(this).find('p').animate({bottom:'0px'},{queue:true,duration:300});
    }, function(){
        $(this).find('.overlay').animate({bottom:'-100px'},{queue:true,duration:500});
        $(this).find('p').animate({bottom:'-100px'},{queue:false,duration:500});
    });

	
});

$(function () {      
    $('.photoList li')
        .append('<span class="hover" />').each(function () {
                var $span = $('> span.hover', this).css('opacity', 0);
                $(this).hover(function () {
                    $(this).addClass('over');
                    $span.stop().fadeTo(500, 1);
                }, function () {
                    $(this).removeClass('over');
                    $span.stop().fadeTo(500, 0);
                });
            });
            
});

//jScrollPane Plugin
$(function()
{
	$('.customScroll').jScrollPane();
});


// Style Switching
$(function() {
    $("ul.switches li a").click(function() {
        var styleType = $(this).attr('class');

        $("#progress div").animate({ width: "100%" }, 2700);
        $("#progress div").animate({ width: "0%" }, 0);

        setTimeout(function() {
            $("#dial").removeClass().addClass(styleType);
            $("body").removeClass().addClass(styleType);
        }, 2700);
        eraseCookie("styleType");
        createCookie("styleType", styleType, 9999);
        return false;
    });

    $("a.erase").click(function() {
        $("#progress div").animate({ width: "100%" }, 2700);
        $("#progress div").animate({ width: "0%" }, 0);
        setTimeout(function() {
            eraseCookie("styleType");
            $("body").removeClass().addClass("style1");
            $("#dial").removeClass().addClass("style1");
            $("a.erase").addClass("active");
        }, 2700);
        return false;
    });
});

function createCookie(name,value,days) {
if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}
function eraseCookie(name) {
    createCookie(name,"",-1);
}


(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;
      }
	  $(".contentBanHold").animate({
        left: -((curItem - 1) * 924)
      }, 500);
	  
	  $('.sliderPaging a').removeClass('on');
	  $('.sliderPaging a[rel="'+curItem+'"]').addClass('on');
	}
	
	function runNext() {
      curItem++;
      if (curItem > maxPage) {
        curItem = 1;
      }
      loadNewBanner();
    }

    maxPage = $('.contentBanHold div.slideItem').size();
	$(".contentBanHold").css({ 'width': (maxPage * 924) });
	
	$(".sliderPaging").show();
	$(".sliderPaging a:first").addClass("on");
	
	$(".sliderPaging a").click(function() {
	  curItem = $(this).attr('rel');
	  loadNewBanner();
      return false;
    });

    $(".contentBanHold div.slideItem").hover(function() {
	  clearTimeout(timeoutVar);
    }, function() {
      doTimeout();
    });
	
	doTimeout();
	
	function doTimeout() {
	  timeoutVar = setTimeout(function() {
        runNext();
      }, 7000);
	}
	
	return this;
  }
})(jQuery);

$( function() {
	$.sliderMain();
});



// Main content banner slider

/*$(document).ready(function() {
  var timeoutVar;
  $(".sliderPaging").show();
  $(".sliderPaging a:first").addClass("on");

  var bannerWidth = $(".contentBanSlider").width();
  var bannerSum = $(".contentBanHold div").size();
  var bannerReelWidth = bannerWidth * bannerSum;
  $(".contentBanHold").css({ 'width': bannerReelWidth });

  rotate = function() {
    //$(".contentBanHold").stop();
    var triggerID = $active.attr("rel") - 1;
    var bannerPosition = triggerID * bannerWidth;

    $(".sliderPaging a").removeClass('on');
    $active.addClass('on');

    $(".contentBanHold").animate({
      left: -bannerPosition
    }, 500, rotateSwitch);

  };

  rotateSwitch = function() {
  
    timeoutVar = setTimeout( function() {
	  $active = $('.sliderPaging a.on').next();
      if ($active.length === 0) {
        $active = $('.sliderPaging a:first');
      }
      rotate();
	}, 3000);
    //play = setInterval(function() {
    //  $active = $('.sliderPaging a.on').next();
    //  if ($active.length === 0) {
    //    $active = $('.sliderPaging a:first');
    //  }
    //  rotate();
    //}, 3000);
  };

  rotateSwitch();

  $(".contentBanHold div").hover(function() {
	clearTimeout(timeoutVar);
    //clearInterval(play);
  }, function() {
    rotateSwitch();
  });

  $(".sliderPaging a").click(function() {
    $active = $(this);
	clearTimeout(timeoutVar);
    //clearInterval(play);
    rotate();
    rotateSwitch();
    return false;
  });
});*/



$(document).ready(function() {

   $('.hoverText').mousemove(function(e) {
      var mouseX = e.pageX;
      var mouseY = e.pageY;
      var thisWidth = $('.popoverHover').width();
      var thisHeight = $('.popoverHover').height();
      $('.popoverHover').css({ 'left': (mouseX - Math.floor(thisWidth / 2) - 10) + 'px', 'top': (mouseY - 20 - thisHeight) + 'px' });
   });

   $('.hoverText').mouseover(function() {
      $('.popoverHover').html($(this).attr('title'));
      $('.popoverHover').show();
   });

   $('.hoverText').mouseout(function() {
      $('.popoverHover').html('');
      $('.popoverHover').hide();
   });

});