

//document.write('<style type="text/css">div.content { display: none }</style>');

$(document).ready(function() {
	
	//$("div.content").hide(0);
	//if ($.browser.mozilla) $("#table-cell-2").css({display: 'table-cell',width: '1px'});
	
	$("#arrow-top").css({display: 'block'});
	$("#arrow-bottom").css({display: 'block'});

	var animeSpeed = 500;
	var ulmargin = 0;
	var kids = $("#gallery ul").children("li");
	var len = kids.length;
	var ulheight = (Math.floor(len/6)) * 96;
	
	arr = $("ul#content li div.active");
	document.current = (arr[0] != "") ? arr[0] : "";
	
	//$("li#last div.content").insertBefore("li#last h2");
			
	$("ul#content li h2 a").click(function() {
		/*if (document.current == this) {
			$(this).parent().parent().children("div").animate( { height: 'hide' } , animeSpeed );
			//$(this).parent().parent().children("div").removeClass("active");
			document.current = "";
		} else {
			//$(this).parent().parent().parent().children("li").children("div").removeClass("active"); 
			//$(this).parent().parent().children("div").addClass("active"); 
			$(this).parent().parent().parent().children("li").children("div").animate( { height: 'hide' } , animeSpeed );
			$(this).parent().parent().children("div").animate( { height: 'show' } , animeSpeed );
			document.current = this;
		}*/
		return false;
	});
	
	$("#arrow-top").click(function(e) {
      e.preventDefault();
		if (ulmargin<0) {
			ulmargin = ulmargin + 96;
			$("#gallery ul").animate( { marginTop: ulmargin+"px" }, animeSpeed);
		}
	});
	
	$("#arrow-bottom").click(function(e) {
      e.preventDefault();
		if ( ulheight>288 && (ulmargin*-1)<(ulheight-288) )
		{
			ulmargin = ulmargin - 96;
			$("#gallery ul").animate( { marginTop: ulmargin+"px" }, animeSpeed);
		}
	});
	
	$(document).keydown(function(event) {
		
		if (!($("body").hasClass("noscroll")))
		{
		switch (event.keyCode) {
			
			case (38):
				if (ulmargin<0) {
					ulmargin = ulmargin + 96;
					$("#gallery ul").animate( { marginTop: ulmargin+"px" }, animeSpeed);
				}
				break;
			
			case (40):
				if ( ulheight>288 && (ulmargin*-1)<(ulheight-288) )
				{
					ulmargin = ulmargin - 96;
					$("#gallery ul").animate( { marginTop: ulmargin+"px" }, animeSpeed);
				}
				break;
		}
			
		}
		
	});
	
	$("#contact").submit(function(){
		$.ajax({
			url: 'mail.php',
			type: 'POST',
			data: { name: $("#name").val(), from: $("#email").val(), body: $("#body").val() },
			dataType: 'script',
			timeout: 1000,
			error: function() { alert('Error'); },
			success: function() { 
				$("#name").val('');
				$("#email").val('');
				$("#body").val('');
			}
		});
		return false;
	});
	
	$("#thanks a.x-close").click(function() {
		ibclose();
		return false;
	});
	
	$("div#gallery").css({height: '288px'});
	
});


