$(document).ready(function() 
{
	// poll
  $("#right .poll input[type=button]").click(function() {
	id = $("#right .poll input[name=answer]:checked").val();
	if (id)
	{
		$("#right .poll ul").html("<li><p style=\"margin: 30px 0; text-align: center;\"><img src=\"" + _appPath + "/images/loader.gif\" alt=\"\" /></p></li>");
		$.post(_appPath + "/vote.aspx", {id:id}, function(data){
			$("#right .poll ul").hide().html(data).fadeIn("slow") 
		}, "html");
	}
	});
	
	// comments
	$("#toggleComments").click(function(){  $(".comment").toggle("slow"); ;});
	$("#toggleAddComments").click(function(){  $("#add-comment").toggle("slow"); ;});
	
	// gallery slice
	$(".gallery-slice").each(function(){$(this).find("img:gt(4)").hide();});
	$(".gallery-slice .more-images").click( function(){$(this).parents(".gallery-slice").find("img:gt(4)").toggle("slow");});
	//$(".gallery-slice").filter("img:gt(4)").hide();
	//$(".gallery-slice .more-images").click( function(){$(".gallery-slice img:gt(4)").toggle("slow"); });
	
	// image preloading
	$.preloadImages(_appPath + "/images/loader.gif", _appPath + "/images/" + _lang + "/menu-active.png",  _appPath + "/images/" + _lang + "/menu-hover.png");
	
	//fancybox init
	var fb_opt = {'overlayShow': true, 'overlayOpacity': 0.70, 'zoomSpeedIn' : 300, 'zoomSpeedOut' : 400};
	$(".gallery a:not(.project):not(.more-images), .object a.main").fancybox(fb_opt); 
});

jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}