$(document).ready(function() {        
	$('#ns_widget_mailchimp-email-3').val('E-post');
	
	var antall = $(".artist").size();
	storrelse = 100/antall;
	$(".artist").css({'width' : storrelse+'%'});
	
	antall = $("#pagenav li").size();
	antall = antall - $(".children li").size();
	
	storrelse = 800/antall;
	$("#pagenav li, .children li ").css({'width' : storrelse+'px'});
	var gjemt = 0;
	var gjemt2 = 1;
	


$('.goto').mouseenter(function() {
	var $that = $(this);

		$('.facebook-hidden', $that).stop(true, false).animate({
			top: 0
		}, 400, 'swing');
		
		$('.facebook-hidden h3', $that).stop(true, false).animate({
			top: 0
		}, 600, 'swing');
		
		$('#like', $that).stop(true, false).animate({
			top: 0
		}, 800, 'swing');

		
	});
	
	$('.goto').mouseleave(function() {
		var $that = $(this);
		
			$('.facebook-hidden', $that).animate({
				top: 125
			}, 400, 'swing');
			
			$('.facebook-hidden h3', $that).stop(true, false).animate({
			top: 200
			}, 600, 'swing');
			
			$('#like', $that).stop(true, false).animate({
			top: 300
			}, 800, 'swing');
			
			
	});
	
$('.band_wrapper').mouseenter(function() {

		$('.band_info').stop(true, false).animate({
					opacity: 1
				}, 600, 'swing');
				
		var div = $('.band_info');

			$({
				z: ~~div.css('zIndex')
				// ~~ to get an integer, even from non-numerical values like "auto"
			}).animate({
				z: 20
			}, {
				step: function() {
					div.css('zIndex', ~~this.z);
				},
				duration: 600
			});
	});
	
$('.band_wrapper').mouseleave(function() {
	$('.band_info').stop(true, false).animate({
			opacity: 0
		}, 600, 'swing');
		
	var div = $('.band_info');

		$({
			z: ~~div.css('zIndex')
			// ~~ to get an integer, even from non-numerical values like "auto"
		}).animate({
			z: -20
		}, {
			step: function() {
				div.css('zIndex', ~~this.z);
			},
			duration: 800
		});

		
	});
	
	$('.artist').hover(function(){	
	var $that = $(this);
	var idValue = $(this).attr("id");
	
		$('.band_navn', $(this)).stop(true, false).animate({
			 opacity:1
		}, 700, 'swing');
		
		$('.artist_slide', $that).stop(true, false).animate({
			top: -155
		}, 300, 'swing',function(){

			$('#band_'+idValue).stop(true, false).animate({
				opacity: 1
			}, 200, 'swing');
		});
		
	} , function() { //On hover out...
	var $that = $(this);
	var idValue = $(this).attr("id");
		$('.band_navn', $that).stop(true, false).animate({
			opacity:0.5
		}, 700, 'swing');
		
		$('.artist_slide', $that).stop(true, false).animate({
			top: 60
		}, 1400, 'swing');
	
		$('#band_'+idValue).stop(true, false).animate({
			opacity:0
		}, 400, 'swing');
	});
	

	
	$('.alle_band').click(function() {
		if(gjemt == 0){
			
			$('.band_wrapper').stop(true, false).animate({
				height: 0
			}, 700, 'swing',function(){
				$('.band_wrapper').css({'border-bottom-width': '0px'});
			});
			
			$('.alle_band_tekst').stop(true, false).removeClass("opp").addClass("ned");
			gjemt = 1;
			
		} else{
			
			$('.band_wrapper').stop(true, false).animate({
				height: 154
			}, 700, 'swing').css({'border-bottom-width': '1px'});
			$('.alle_band_tekst').stop(true, false).removeClass("ned").addClass("opp");
			
			gjemt = 0;
		}
			
			
	});
	
	$('.nyhetsarkiv').click(function() {
		if(gjemt2 == 0){
			
			$('.nyhetsarkiv_wrapper').stop(true, false).animate({
				height: 0
			}, 700, 'swing').css({'border-bottom-width': '0px'});
			$('.nyhetsarkiv_tekst').stop(true, false).removeClass("opp").addClass("ned");
			gjemt2 = 1;
			
		} else{
			
			$('.nyhetsarkiv_wrapper').stop(true, false).animate({
				height: 100
			}, 700, 'swing');
			$('.nyhetsarkiv_tekst').stop(true, false).removeClass("ned").addClass("opp");
			
			gjemt2 = 0;
			
		}	
	});
	
	$(".nyhetsarkiv_wrapper div").hover(function() {	//On hover...
		$(this).stop().animate({ 
			opacity: 1 //Find the span tag and move it up 40 pixels
		}, 250);
	} , function() { //On hover out...
		$(this).stop().animate({
			opacity: 0.5 //Move the span back to its original state (0px)
		}, 250);
	});
	
	$(".bandspiller").hover(function() {	//On hover...
		$(this).stop().animate({ 
			top:0 //Find the span tag and move it up 40 pixels
		}, 250);
	} , function() { //On hover out...
		$(this).stop().animate({
			top:-175 //Move the span back to its original state (0px)
		}, 250);
	});
	
	$.fn.wait = function(time, type) {
        time = time || 1000;
        type = type || "fx";
        return this.queue(type, function() {
            var self = this;
            setTimeout(function() {
                $(self).dequeue();
            }, time);
        });
    };
	

	$('.info').wait(1500).animate({opacity: 1}, 300).wait(3000).animate({opacity: 0}, 300);
	
	

	
});

