/*
Author: Bjarne Christensen // Stupid Studio
*/


$(window).load(function(){
	$("div.preloader").fadeOut('slow',function(){$(this).remove();});
});


//LARGE BGS
function backgroundImage(){
	jQuery('img.maxImage').maxImage({
		maxFollows:'both',
		verticalOffset:(0),
		horizontalOffset:(0),
		leftSpace:(0),
		topSpace:(0),
		rightSpace:(0),
		bottomSpace:(0),
		overflow:'auto',
		position:'absolute',
		isBackground: true,
		zIndex:(-10),
		verticalAlign: 'center',
		horizontalAlign: 'center',
		maxAtOrigImageSize: false,
		slideShow: false
	});
}



//FEATURED SLIDER
function featuredSlider(){
	$('#featured').anythingSlider({
		startStopped    : false, // If autoPlay is on, this can force it to start stopped
		autoPlayLocked  : false,  // If true, user changing slides will not stop the slideshow
		resumeDelay     : 10000, // Resume slideshow after user interaction, only if autoplayLocked is true (in milliseconds).
		easing			: "easeOutCirc",
		delay			: 4000,
		animationTime	: 1000
	});
}


//EVENTS LIST ADDING EVEN AND ODD TO ENTRIES
function eventListStyle(){
	$ ('div#list div.entry:even').addClass('even');
	$ ('div#list div.entry:odd').addClass('odd');
}


//FADES
function fades(){
	$("#list .fade, ul .fade").fadeTo("fast", 0.5);
	$("#list .fade, ul .fade").hover(function(){
	$(this).fadeTo(250, 0.0);},

	function(){
		$(this).fadeTo(400, 0.5);
	});
	
	
	$("#blog_list .thumb_holder .overlay").fadeTo("fast", 0.2);
	$("#blog_list .thumb_holder .overlay").hover(function(){
	$(this).fadeTo(500, 0.0);},

	function(){
		$(this).fadeTo(500, 0.2);
	});
	
	
	
	$("#events_list #list .entry .overlay").fadeTo(0, 0.5);
	$("#events_list #list .entry").hover(function(){
	$(".overlay",this).fadeTo(500, 0.0);},

	function(){
		$(".overlay",this).fadeTo(500, 0.5);
	});
	
	
	/*
	$("#jp_interface_1").fadeTo(0, 0.2);
	$(".jp-video").hover(function(){
	$("#jp_interface_1",this).fadeTo(500, 0.9);},

	function(){
		$("#jp_interface_1",this).fadeTo(500, 0.2);
	});
	
	
	
	
	$(".jp-video-play").click(
  		function() {
  		$(this).toggleClass("hide");
    	$(".jp-pause").toggle();
    });
    
    
    $(".jp-pause").click(
  		function() {
    	$(this).toggle();
    	$(".jp-video-play").toggleClass("hide");
    });
    
    */
	
}

//ANIM PADDING
function animatedPadding(){
	var animDuration = 150; //time in milliseconds
	
	$("ul#cats li a").hover(function() {
		$(this).animate({ paddingLeft: "24px" }, animDuration);
	}, function() {
      	$(this).animate({ paddingLeft: "20px" }, animDuration);
	});
}






//940 MEDIA SLIDER ON EVENTS SINGLES
function mediaAutoSlider() {
	// Trigger mouse move event over the 'menu_holder'.
	$("#info-media #thumbs").mousemove(function(e) {
		// Enable scroll function only when the height of the 'slider' or menu is greater than the 'menu_holder'.
		if($(this).width() < $(".slide_content").width()) {
			// Calculate the distance value from the 'menu_holder' y pos and page Y pos.
			var distance = e.pageX - $(this).offset().left;
			// Get the percentage value with respect to the Mouse Y on the 'menu_holder'.
			var percentage = distance / $(this).width();
			// Calculate the new Y position of the 'slider'.
			var targetX = -Math.round(($(".slide_content").width() - $(this).width()) * percentage);
			// With jQuery easing funtion from easing plugin.
			$('.slide_content').animate({left: [targetX+"px", "easeOutCirc"]}, { queue:false, duration:200 });
			// Without easeing function. by default jQuery have 'swing'.
			//$('#slider').animate({top: [targetY+"px", "easeOutCirc"]}, { queue:false, duration:200 });
		}
	});
	
	
	
	$("#media ul li.article:first").fadeIn(
  		
  		function() {
    	$(this).addClass('active');
    });
    
    
    
	$('#thumbs a.tricker').click(function () {
    	
    	var linkID = $(this).attr('id');
    	var mediaPane = linkID.replace("link_","pane_");

    	$('#media ul li.active').fadeOut(
    	
    	function() {
    	$(this).removeClass('active');
    	});
    	
		$('li#'+mediaPane).delay(800).fadeIn(
		
			function() {
    		$(this).addClass('active');
    	});
    	return false;

	});
}




//JQ POPUPS
function jqPopups(){
	$('.ticket_popup').popupWindow({ 
		height:500,
		width:800,
		top:50,
		left:50,
		menubar:1,
		resizable:0,
		scrollbars:1,
		status:0,
		centerBrowser:1
	}); 
}







$(document).ready(function(){
	backgroundImage();
	featuredSlider();
	eventListStyle();
	fades();
	animatedPadding();
	mediaAutoSlider();
	jqPopups();
	
	$(".columnize").columnize();

});





