(function($){
	
	$(document).ready(function(){
						
		$('#wrapper').children().css({opacity:0});
		
		$('#footer').css({width:$(window).width()});
		
		$('#wrapper').css({opacity:0,marginTop:$(window).height()/2,display:'block'}).delay(300).animate({
			width:800,
			height:400,
			opacity:0.9,
			marginTop:115,
			marginBottom:60
		},700,function(){
			$('#wrapper').children().animate({opacity:1},500,function(){
				switch(location.hash){
					case '#blog':
						$('#menu li.blog').click();
					break;
					case '#events':
						$('#menu li.events').click();
					break;
					case '#bio':
						$('#menu li.biography').click();
					break;
				}
			});
		});
		
		$('#overlay').css({height:$(window).height(),width:$(window).width()});
		
		var overloop = function(){
			$('#overlay_inner').css({marginLeft:1000}).animate({marginLeft:0-(4000)},30000,'linear',function(){overloop()});
		}
		overloop();
		
		$('#sign_up input').not('#faux_sub').bind('focus',function(){
			if($(this).val() == 'email address'){
				$(this).val('');
				$(this).css({color:'#000'});
			}
		}).bind('blur',function(){
			if($(this).val() == ''){
				$(this).val('email address');
				$(this).css({color:'#999'});
			}
		});
		
		$('#submit').click(function(){
			$('#faux_sub').click();
		});
		
		function validate(){
			if($('#sign_up input').val() != 'email address' && $('#sign_up input').val() != ''){
				return true;
			}
			return false;
		}
		
		$('#menu li').not('.highlight').mouseover(function(){
			$(this).prev().css('display','block').stop().animate({width:175},200);
		}).mouseout(function(){
			$(this).prev().stop().animate({width:1},200,function(){
				$(this).css('display','none');
			});
		});
		
		$('#menu li').not('.highlight').each(function(i){
			$(this).click(function(){
				var a=Math.round(Number($('#content_ul').css('marginLeft').split('px')[0])/565);
				a=a<0?0-a:a;a=a>i?(a-i)*400:(i-a)*400;
				$('#content_ul').stop().animate({'margin-left':0-(i*565)},a,'swing');
			});
		});
		
		$('.beat_port').click(function(){
			$('#players ul').stop().animate({marginLeft:0},400,'swing');
		});
		$('.soundcloud').click(function(){
			$('#players ul').stop().animate({marginLeft:-565},400,'swing');
		});
		
		$('.scroll .down').bind('mousedown',function(){
			var a = Number($('#bio').css('margin-top').split('px')[0]);
			a = a < 0 ? 0 - a : a;
			b = $('#bio').outerHeight();
			a = Math.round((a/b)*100)/100;
			a = 8000-(8000*a);
			$('#bio').animate({marginTop:200-($('#bio').outerHeight())},a,'linear');
		}).bind('mouseup',function(){
			$('#bio').stop()
		});
			
		$('.scroll .up').bind('mousedown',function(){
			var a = Number($('#bio').css('margin-top').split('px')[0]);
			a = a < 0 ? 0 - a : a;
			b = $('#bio').outerHeight();
			a = Math.round((a/b)*100)/100;
			a = 8000*a;
			$('#bio').animate({marginTop:0},a,'linear');
		}).bind('mouseup',function(){
			$('#bio').stop()
		});
		
		$('.scroll .up,.scroll .down').mouseout(function(){$('#bio').stop();});
		
		$.getJSON("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D%22http%3A%2F%2Ffeeds.artistdata.com%2Fxml.shows%2Fartist%2FAR-O62666H500860CY4%2Fxml%2Ffuture%22&format=json", function(data){
			var venue, date, vUrl, time, a = data.query.results.shows.show, b = a.length;
			a.reverse();
			while(b--){
				venue = a[b].venueName;
				date = a[b].date;
				vUrl = a[b].venueURI;
				time = Number(a[b].timeSet.split(':')[0]) > 12 ? Number(a[b].timeSet.split(':')[0])-12 : a[b].timeSet.split(':')[0] ;
				time = time == '00' ? 'Midnight' : time+'pm';
				$('#event_list').append('<li><a href="'+vUrl+'" target="_blank">'+venue+'</a><p>'+date+' @ '+time+'</p></li>');
			}
		});
		
		$('#buzz_link').click(function(){
			window.open('http://blog.kidcedek.com/buzzatsutra','_blank','');
		});
					
	});
	
}(jQuery))
