$(document).ready(function(){

	$('.tab').click(function(){
		var _this = this;
		$(this).animate({
			height:'70px',
			opacity: 1
		});
		
		var allow_page = true;
		if(allow_music == false && $(this).attr('title')=='music'){
			allow_page = false;
		}
		if(allow_tumblr == false && $(this).attr('title')=='tumblr'){
			allow_page = false;
		}
		
		if(at_page != $(this).attr('title') && allow_page == true){
			$('.right-side').slideUp('fast', function(){
				$(this).html($(_this).attr('content'));
				if(at_page == 'about'){
					add_email();
				}
				$(this).slideDown('slow');
			});
			at_page = $(this).attr('title');
			$('head title').html(SITE_NAME+' &gt; '+at_page);

			_gaq.push(function() {
				var pageTracker = _gat._getTracker(ANALITICS_CODE);
				var link = $(this);
				link.href = pageTracker._getLinkerUrl('http://robin-orlic.com/?page='+at_page);
			});
		}
		
	});
	
	$('.tab a').click(function(){
		var _this = $(this).parent('.tab');
		$(_this).animate({
			height:'70px',
			opacity: 1
		});
		
		var allow_page = true;
		if(allow_music == false && $(_this).attr('title')=='music'){
			allow_page = false;
		}
		if(allow_tumblr == false && $(_this).attr('title')=='tumblr'){
			allow_page = false;
		}
		
		if(at_page != $(_this).attr('title') && allow_page == true){
			$('.right-side').slideUp('fast', function(){
				$(this).html($(_this).attr('content'));
				if(at_page == 'about'){
					add_email();
				}
				$(this).slideDown('slow');
			});
			at_page = $(_this).attr('title');
			$('head title').html(SITE_NAME+' &gt; '+at_page);

			_gaq.push(function() {
				var pageTracker = _gat._getTracker(ANALITICS_CODE);
				var link = $(_this);
				link.href = pageTracker._getLinkerUrl('http://robin-orlic.com/?page='+at_page);
			});
		}
		
	});

	
	
	$('.tab').mouseover(function(){
		var allow_page = true;
		if(allow_music == false && $(this).attr('title')=='music'){
			allow_page = false;
		}
		if(allow_tumblr == false && $(this).attr('title')=='tumblr'){
			allow_page = false;
		}
		if(allow_page == true){
			var _this = this;
			$(this).animate({
				height:'70px',
				opacity: 1
			});
		}
		/*if(at_page != $(this).attr('title')){
					$('.right-side').slideUp('fast', function(){
					$(this).html($(_this).attr('content'));
					if(at_page == 'about'){
						add_email();
					}
					$(this).slideDown('slow');
				});
		}
		at_page = $(this).attr('title');
		*/
	});
	$('.tab').mouseleave(function(){
		$(this).animate({
			height:'37px',
			opacity: 1
		});
	});
	
	$('.music-tabs').click(function(){
		
		alert($(this).attr('rel'));
			
		$('.music .music-content').each(function(){
			
				$(this).css({'display':'none'});
			
		});
		//non_display_each('music-content');
		
		$('.'+$(this).attr('rel')).css({'display':'block'});
		
		
		
	});
	
	
	//load_music_tabs();
	
	
	$('.right-side .folder_list li a').click(function(){
		return false;
	});
	$('.left-side a').click(function(){
		return false;
	});
	
	$('.loader').css('display','none');
	$('.loader-background').css('display','none');
 	$('.container').css('display','block');
 	
	if (at_page != 'music'){
		
		call_music(20);
	
	}else{
		allow_music = true;
		$('.music-tab').attr('content', $('.right-side').html());
		$('.music-loading').css({'display':'none'});
	}
	if (at_page != 'tumblr'){
		
		call_tumblr();
	
	}else{
		allow_tumblr = true;
		$('.tumblr-loading').css({'display':'none'});
 		$('.tumblr-tab').attr('content', $('.right-side').html());
 		
	}
	
	get_current_track();
	setInterval("get_current_track()",45000);
	
});
