/*!
 * Zoey Van Goey JS
 * by Iain Phillips
 */
 $(document).ready(function() {

    $('a[href*=#]').click(function() {
    
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
        && location.hostname == this.hostname) {
        
            var $target = $(this.hash);
            
            $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
			
			if ((navigator.userAgent.indexOf('iPad') != -1 || navigator.userAgent.indexOf('iPhone') != -1)) {
				var targetPosition = $target.position();
				$('#top').css('top', targetPosition.top + 'px');
				var off = targetPosition.top;
				var add = off/6 + 55;
    			$('#cross').css('left', add + 'px');
				if ( add > 835) {
					$('#cross').css('left', 835 + 'px');
				}
				var sizer = $(window).height();
				$('#gigs').css('height', sizer + 'px');
				if ( sizer < 780) {
					$('#gigs').css('height', 780 + 'px');
				}
			}
            
            if ($target.length) {
            
                var targetOffset = $target.offset().top;
                
                $('html,body').animate({scrollTop: targetOffset}, 1000);
                    
                return false;
                
            }
            
        }
    
	});
	
	if ((navigator.userAgent.indexOf('iPad') != -1)) {
		$('#top').css('position', 'absolute');
	}
	
	$(window).scroll(function() {
		var off = $(window).scrollTop();
		var add = off/6 + 55;
    	$('#cross').css('left', add + 'px');
		if ( add > 835) {
			$('#cross').css('left', 835 + 'px');
		}
		var sizer = $(window).height();
		$('#gigs').css('height', sizer + 'px');
		if ( sizer < 780) {
			$('#gigs').css('height', 780 + 'px');
		}
		
		if ((navigator.userAgent.indexOf('iPad') != -1 || navigator.userAgent.indexOf('iPhone') != -1)) {
			$('#top').css('top', off + 'px');
		}
		
    });
	
	$(".video-content").hide();
	$(".video-content:first").show();
	$("ul#video-menu li").click(function() {
		$(".video-content").hide();
		var activeTab = $(this).find("a").attr("href");
		$(activeTab).fadeIn();
		return false;
	});
	
	$("ul#video-menu li").click(function(){
		var v = $("ul#video-menu li").index(this);
		var vp =  v * 100 + 20;
  		$("#video-indicator").animate({top: vp}, "slow");
	});
	
	$(".music-content").hide();
	$(".music-content:first").show();
	$("ul#music-menu li").click(function() {
		$(".music-content").hide();
		var musicTab = $(this).find("a").attr("href");
		$(musicTab).fadeIn();
		return false;
	});
	
	$("ul#music-menu li").click(function(){
		var m = $("ul#music-menu li").index(this);
		var mp =  m * 215 + 25;
  		$("#music-indicator").animate({left: mp}, "slow");
	});
	
	$(".about-content").hide();
	$(".about-content:first").show();
	$("ul#about-menu li").click(function() {
		$(".about-content").hide();
		var aboutTab = $(this).find("a").attr("href");
		$(aboutTab).fadeIn();
		return false;
	});
	
	$("ul#about-menu li").click(function(){
		var a = $("ul#about-menu li").index(this);
		var ap =  a * 174 + 20;
  		$("#about-indicator").animate({left: ap}, "slow");
	});
	
	$(".iframelays").hide();
	$("ul#home-menu li").click(function() {
		$(".click-off").show();
		$("#selected-button").attr("id", "button");
		$(".iframelays").hide();
		this.id = 'selected-button';
		var homeTab = $(this).find("a").attr("href");
		$(homeTab).fadeIn();
		return false;
	});
	
	$(".click-off").hide();
	$(".click-off").click(function() {
		$(".iframelays").hide();
		$(".click-off").hide();
		$("#selected-button").attr("id", "button");
	});
	
});
