
$j(document).ready( function(){
	$j("#sandbeckOverlay").height = 0;
	
	
	
	
	$j("#dialogueImage").bind( "click", function(){
			//alert("Nice click");
		
		$j("#sandbeckOverlay").show();		
		$j("#sandbeckOverlay").height( $j(document).height() );
		var ox = $j("#pageContainer").offset().left + 20;		
		$j("#sandbeckOverlay").animate( {height: $j(document).height()}, 800, function(){
			$j("#featureLoader").css( { "left" : ox } );
			$j("#featureLoader").html('');
			$j("#featureLoader").fadeIn( 800 );	
			$j("#featureLoader").load( "/blocks/popupContentForside.php" );
		});
		
		
			
	});
		
	
	$j("#popupCloseButton").bind( "click", function(){
		$j(".popup").hide();
		$j("#sandbeckOverlay").hide();
		$j("#sandbeckOverlay").fadeTo( "fast", 0.1 );
	});	
	
	
	
	//Forside buttons
	$j( ".forsideBtn" ).bind( "mouseenter", function(){
		$j(this).animate( {opacity: 0.5}, 300 );
	});
	
	$j( ".forsideBtn" ).bind( "mouseleave", function(){
		$j(this).animate( {opacity: 1.0}, 300 );
	});
	
	
	
	
	//Ansatt thumbs
	$j( ".ansattWrapper" ).bind( "click", function(){
		var id = $j( this ).children( ".ansattArtikkel").attr("id").split("aa")[1];
		$j("#sandbeckOverlay").animate( {height: $j(document).height()}, 800, function(){
			var ox = $j("#pageContainer").offset().left + 20;		 
			$j("#ansattLoader").css( { "left" : ox } );
			$j("#ansattLoader").html('');
			$j("#ansattLoader").fadeIn( 800 );		
			$j("#ansattLoader").load( "/blocks/popupContent.php?ansattId=" + id);
		});		
		
		//$j("#sandbeckOverlay").height( $j(window).height() );
				
	});
	
	$j( ".ansattWrapper" ).bind( "mouseenter", function(){ 
		//console.log( "Hei" );
		$j(this).children( ".ansattThumb" ).hide();
		$j(this).children( ".ansattArtikkel" ).fadeIn( 800 );
	});
	
	$j( ".ansattWrapper" ).bind( "mouseleave", function(){
		//console.log( "Hade" );
		$j( ".ansattThumb" ).show();
		$j( ".ansattArtikkel" ).hide();
	});
	
	
	//Prosjekt thumbs
	$j( ".prosjektWrapper" ).bind( "mouseenter", function(){ 
		//console.log( "Hei" );
		$j(this).children( ".prosjektThumb" ).hide();
		$j(this).children( ".prosjektArtikkel" ).fadeIn( 800 );
	});
	
	$j( ".prosjektWrapper" ).bind( "mouseleave", function(){
		//console.log( "Hade" );
		$j( ".prosjektThumb" ).show();
		$j( ".prosjektArtikkel" ).hide();
	});
	
	$j( "#prosjekterNextBtn" ).bind( "click", function(){
		$j( this ).parent().parent().animate( {left: -($j( this ).parent().width()+8)}, 1000); //($j( this ).parent().css( "offset" ).left - $j( this ).parent().width()) }
	});
	
	$j( "#prosjekterFirstBtn" ).bind( "click", function(){
		$j( this ).parent().parent().animate( {left: 0}, 1000); //($j( this ).parent().css( "offset" ).left - $j( this ).parent().width()) }
	});
	
 	
	//Image thumbs
	$j( "img.tumb" ).bind( "mouseenter", function(){
		//alert( "Nice ");
		$j( this ).animate( {opacity: 0.5}, 300 );
	});
	
	$j( "img.tumb" ).bind( "mouseleave", function(){
		$j( this ).animate( {opacity: 1.0}, 300 );
	});
	
});
