var curImgID = 0; function setImageHeight(w,h,txt) { if (w>0 && h>0) { // var fh = 345*parseInt(h)/parseInt(w); var fh = parseInt(h)+(txt!="" ? 50 : 25); var fw = parseInt(w); $("#fullimage .loading").css({ height:Math.round(fh)+10, width:Math.round(fw)-1 }); $("#close_fullimage").css({"margin-top":-fh/2-26}) $("#fullimage .loading img").css({ "margin-top":Math.round((fh-1))/2-32 }); $("#fullimage").css({ height:Math.round(fh)-1,"margin-top":-fh/2 }).animate({ width: fw, marginLeft:-fw/2 }, 500 ); } } function makeGalleryImage(container,j) { j.each(function() { var link = this; $(this).hover(function() { $("span",this).addClass("jsover"); },function() { $("span",this).removeClass("jsover"); }); $(link).click(function() { $("#overlay").css("opacity",0).show().fadeTo(500,0.9); //var row_index = $(".row",container).index($(this).parent().parent()[0]); var img_index = $("a",container).index(link); $("#fullimage > img.full").attr({ gallery_id:$(container).attr("gallery_id"),"image_index":img_index }); moveToImage(0); $("#fullimage").show(); return false; }); }); } function moveToImage(direction) { var full_image = $("#fullimage > img.full")[0]; var gallery_id = $(full_image).attr("gallery_id"); var container = $(".photos[gallery_id="+gallery_id+"]")[0]; if (!container) return; var img_index = parseInt($(full_image).attr("image_index"))+direction; // var row_index = parseInt($(full_image).attr("row_index")); var newimg = $("a:eq("+img_index+") img",container)[0]; // alert(newimg); if (!newimg) { newimg = $("a:eq("+img_index+") div",container)[0]; } if (!newimg) return; var fw = parseInt($(newimg).attr("rw")); var fh = parseInt($(newimg).attr("rh")); var flag = 0; if (img_index<=0) { $("#prev_fullimage").hide(); flag++; } else { $("#prev_fullimage").show(); } if (img_index>=$("a",container).length-1) { $("#next_fullimage").hide(); flag++; } else { $("#next_fullimage").show(); } if (flag>0) $("#gal_nav .red-delimiter").hide(); else $("#gal_nav .red-delimiter").show(); $("#close_fullimage").show().animate({ marginLeft:fw/2-40},500); /* var img_id = $(newimg).attr("image_id"); if (img_id) $("#fullimage").attr({ "image_id":img_id });*/ var txt = $(".title",$(newimg).parent()[0]).text(); setImageHeight($(newimg).attr("rw"),$(newimg).attr("rh"),txt); $("#fullimage .loading").hide(); $("#fullimage .loading img").hide(); var ival = setInterval(function() { $("#fullimage .loading").show(); $("#fullimage .loading img").show(); $(full_image).hide(); clearInterval(ival); ival = null; },100); $.preload([ $(newimg).parent().attr("href") ], { onFinish: function(data) { clearInterval(ival); ival = null; $("#fullimage > .loading").hide(); $(full_image).attr({ "image_index":img_index,"src":data.image }).fadeIn(300); $("#fullimagedesc").text(txt); // $("#fullimagedesc .desc").text($(".desc",$(newimg).parent()).text()); $("#fullimagedesc").show(); } }) return false; } function closeGallery() { $("#fullimage .loading").stop(); $("#fullimage").stop().css({ width:2,height:150,"margin-left":-1,"margin-top":-1 }).hide(); $("#fullimage > img.full").hide(); $("#next_fullimage").stop().hide(); $("#prev_fullimage").stop().hide(); $("#close_fullimage").stop().css({ "margin-left":0,"margin-top":0 }).hide(); $("#fullimage").stop(); $("#fullimagedesc").hide(); $("#overlay").fadeOut(500); return false; }; function prolog() { if ($(".photos")[0]) { $(".photos").each(function() { makeGalleryImage(this,$("a",this)); }); $("#prev_fullimage").click(function() { return moveToImage(-1); }); $("#next_fullimage").click(function() { return moveToImage(+1); }); $("#overlay").click(closeGallery); $("#close_fullimage").click(closeGallery); } } $(document).ready(function() { prolog(); $("#press .items .item a").hover(function() { $("span",this).addClass("jsover"); },function() { $("span",this).removeClass("jsover"); }); $("#about_gallery").click(function() { $(".photos a:first").trigger('click'); return false; }); $("#response-form input[name='contact_name']") .bind("focus",function() { if (this.value=="Имя" || this.value=="Name") this.value=""; }) .bind("blur",function() { if (!this.value) this.value= (lang=="en" ? "Name" : "Имя"); }); $("#response-form input[name='contact_email']") .bind("focus",function() { if (this.value=="E-mail") this.value=""; }) .bind("blur",function() { if (!this.value) this.value="E-mail"; }); $("#response-form textarea[name='contact_body']") .bind("focus",function() { if (this.value=="Текст сообщения" || this.value=="Message") this.value=""; }) .bind("blur",function() { if (!this.value) this.value= (lang=="en" ? "Message" : "Текст сообщения"); }); });