$(document).ready(function(){

	if( $(window).width() < 1200 ){
		$("h1").stop().fadeTo(0,0);
	}
	
	$(window).resize(function(){
		if( $(window).width() < 1200 ){
			$("h1").stop().fadeTo(400,0);
		} else {
			$("h1").stop().fadeTo(400,1);
		}
	});

	$("a.info").click(function(){
		$(this).toggleClass("active");
		$(this).parent().parent().next(".info-content").slideToggle(200);
		return false;
	});

	$(".ngg-galleryoverview a").fancybox({
		'padding'		:	'0',
		'centerOnScroll':	true,
		'overlayShow'	:	true,
		'overlayOpacity':	'0.9',
		'overlayColor'	:	'#222',
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'showCloseButton':	false,
//		'titlePosition'	:	'inside',
		'speedIn'		:	500, 
		'speedOut'		:	500, 
		'changespeed'	:	200
	});
	
	var galleryWidth = 0;
	var galleryAreaWidth = 0;
	
	/* $(".gallerycontent").mousemove(function(e){
		var move = e.pageX;
		var galleryAreaWidth = $(this).width();
		var galleryWidth = $(".ngg-galleryoverview", this).width();
		var moveArea = $(".gallerycontent").offset();
		move = ((move-moveArea.left)/galleryAreaWidth)*(galleryWidth-galleryAreaWidth);
		$(".ngg-galleryoverview", this).animate({ left: -move+"px"}, {duration: 400, easing: "linear", queue: false}, { step: function(){

		}
		});
	}); */
	
	
	/*
	$(".gallerycontent a").mouseenter(function(e){
		$(".gallerycontent a").not(this).fadeTo(500,0.3);
		$(this).stop().fadeTo(100,1);
	}).mouseout(function(){
		$(".gallerycontent a").stop().not(this).fadeTo(500,1);
	}); */

	$("#nominees a").click(function(){
		var target = $(this).attr("href");
		var position = $(target).offset();
		$("html, body").animate({scrollTop: position.top-20}, 500);
		return false;
	});
	
	$("#filter a").click(function(){
		$("#filter a").removeClass("active");
		$(this).addClass("active");
		if( $(this).attr("href") == "#all" ){
			$(".leftcolumn .gallery").slideDown(1000);
			$("#nominees h3").slideDown(1000);
		} else {
			$(".leftcolumn .gallery.hide").slideUp(1000);
			$("#nominees h3.hide").slideUp(1000);
		}
		return false;
	});
	
/*	$(".social .mail").click(function(){
		$("#send_email").slideToggle(300);
		return false;
	}); */

/*	var error = false;

	$("#send_email input[type=submit]").click(function(){
		error = false;
		$("#send_email .required").each(function(){
			$(this).removeClass("error");
			if($(this).val() == ""){ $(this).addClass("error"); error = true; }
		});
		if(error == false){
			var send_email = $("#send_email #email").val();
			var your_email = $("#send_email #your_email").val();
			var your_name = $("#send_email #your_name").val();
			var message = $("#send_email #message").val();
			
			$("#send_email").hide();
			$(".social").append("<div class='message'>hetkinen...</div>");

			var dataString = "email=" + send_email + "&your_name=" + your_name + "&your_email=" + your_email + "&msg=" + message;

			$.ajax({
				type: "POST",
				url: "mail/mailman.php",
				data: dataString,
				success: function() {

					$("#send_email input[type=text], #send_email textarea").val("");
					$(".social .message").html("Kiitos. Viesti lähetetty.");
					setTimeout(function(){
						$(".social .message").slideUp(500, function(){
							$(".social .message").remove();	
						});	
					}, 4000);
				
				}
			});
		}
		return false;
	}) */


});
