(function($) {
	$.extend(
	{
		doMENU : function(lan,start,zona) // '525', '350', flv=trailer.flv
		{
			w = 980;
			h = 160;
			var flashvars = {
				lan 		: lan,
				started		: start,
				zona		: zona
			};
			var params = {
				menu			: "false",
				wmode			: "window",
				allowFullScreen	: "false" 
			};
			swfobject.embedSWF("swf/hzt_menu.swf", "flash_menu", w, h, "9.0.0","expressInstall.swf", flashvars, params);
		},
		shwFoto : function(obj)
		{
			imgID = obj.find("img").attr("id");
			src = obj.find("img").attr("src");
			tit = obj.find("img").attr("alt");
			src = String(src).replace("_s","");
			$("#img_big").fadeOut(function(){
				$("div.loader_img").html("<img src='imago/fixed/loader.gif' />");
				$.ajax({
					url			: "inc/getfotoinfo.php",
					type		: "GET",
					dataType	: "html",
					timeout 	: 1000,
					data		: {id:imgID},
					success: function(data)
					{
						des = data;
						$("#img_big").find("img").attr({"src":src,"alt":tit}).bind("load", function() {
							$("#img_big").find("h1").text(tit);
							$("#img_footer").text(des);
							$("div.loader_img").html("");
							$("#img_big").fadeIn();
						});
					}
				});				
			});
		}
	});
})(jQuery);
$(document).ready(function()
{
	$.hzt = {
		oldW : null
	};
	$("a.open_btn").toggle(function(e){
		$.hzt.oldW = $(this).parent().find("img").css("width");
		$(this).parent().find("div.img_txt").hide();
		$(this).html("&lt;").css({top:'5px'});
		dv = $(this).parent();
		nwidth = parseInt(dv.width())-25;
		if(nwidth>550)
			nwidth = 550;
		$(this).parent().find("img").animate({width:nwidth+'px'},100);
		e.preventDefault();
	},function(e){
		$(this).parent().find("img").animate({width:$.hzt.oldW},100);
		$(this).html("&gt;").css({top:'',bottom:'5px'});
		$(this).parent().find("div.img_txt").show();
		e.preventDefault();
	});
	$("a.image_thumbs").click(function(e){
		$.shwFoto($(this));
		e.preventDefault();
	});
	$("a.pset").click(function(e){
		set = this.id.split("#");
		page = parseInt(set[0]);
		gall = set[1];
		tpages = parseInt(set[2]);
		$("#right_gallery div.set").fadeOut(function(){
			$("div.loader_set").html("<img src='imago/fixed/loader.gif' />");
			$.ajax({
				url			: "inc/getsetinfo.php",
				type		: "POST",
				dataType	: "html",
				timeout 	: 1000,
				data		: {page:page,gall:gall},
				success: function(data)
				{
					$("#img_navi .sx").attr({"id":(page-1)+"#"+gall+"#"+tpages})
					$("#img_navi .dx").attr({"id":(page+1)+"#"+gall+"#"+tpages})
					if(page==1)
						$("#img_navi .sx").css({visibility: "hidden"});
					else if(page>1)
						$("#img_navi .sx").css({visibility: "visible"});
					if(page<tpages)
						$("#img_navi .dx").css({visibility: "visible"});
					else
						$("#img_navi .dx").css({visibility: "hidden"});
					$("div.loader_set").html("");
					$("#right_gallery div.set").html(data).fadeIn();
					$("a.image_thumbs").click(function(e){
						$.shwFoto($(this));
						e.preventDefault();
					});
				}
			});
		});
		e.preventDefault();
	});
	$("#language_choose img").mouseover(function(){
		$(this).attr({"src":"imago/fixed/"+$(this).attr("alt")+"_hover.png"});
	});
	$("#language_choose img").mouseout(function(){
		$(this).attr({"src":"imago/fixed/"+$(this).attr("alt")+".png"});
	});
});
