$(function() { $('.popupImg').click(function(){ var t = $(this); function popupPosition () { var brHeight = $(window).height(); var brWidth = $(window).width(); var popupImgLoad = $('.popupImg'); var popupHeight = $('#popupBody img').height()+40; var popupWidth = $('#popupBody img').width()+14; var popupTop; var popupLeft; if (popupHeight > brHeight) { popupTop = 10; } else { popupTop = ((brHeight-popupHeight)/2); } if (popupWidth > brWidth) { popupLeft = 10; //popupImgWidth = "style='width:"+(brWidth - 66)+"px'"; } else { popupLeft = (((brWidth-popupWidth)/2)-16); } $('#popup').css({ 'left' : popupLeft, 'top' : popupTop, 'width' : popupWidth }); }; function popupPaint () { var popupImgWidth; var popupImgSrc = t.attr('href'); var popupImg = ''; var popupTitle = t.attr('title'); var imgDescr = t.children().attr('alt'); var popupCloseImg = '/html/i/popup/popup-close.png'; var imgWrapp = t.parent().parent().attr('id'); var popupDescr; var numImg; var allImg; if($('#'+imgWrapp+' .imgBorder').length){ numImg = parseInt(t.attr('count')); numImg = numImg+' / '; allImg = $('#'+imgWrapp+' .imgBorder').length; } else { numImg = ' '; allImg = ' '; } if (popupTitle==''){ popupTitle = ''; } if (popupDescr==''){ popupDescr = ''; } else { popupDescr = '

'+imgDescr+'

'; } //var numImg = parseInt(t.attr('count')); $('body').append(''); $('#shadow').css({opacity:0.6,display:'block'}).fadeTo('fast', 0.6); $('img#popupImg').load(function(){ $('#popupImg').removeClass('imgHide'); popupPosition(); }); $(document).keyup(function(e) { if (e.which == 27){ $('#popup').remove(); $('#shadow').fadeOut(); } }); $('.popClose a, #shadow').click(function(){ $('#popup').remove(); $('#shadow').fadeOut(); return false; }); if($('#'+imgWrapp+' .imgBorder').length){ var gTotal = $('#'+imgWrapp+' .imgBorder').length; var next = $(this).nextAll('.'+imgWrapp+' .imgBorder').children('a').attr('rel'); var prev = $(this).prevAll('.'+imgWrapp+' .imgBorder').children('a').attr('rel'); var gCur = parseInt(t.attr('count')); if ((gCur != 1) && (gCur != gTotal)) { $('.popNext').show(); $('.popPrev').show(); } if (gCur == gTotal){ $('.popNext').hide(); $('.popPrev').show(); } if (gCur == 1){ $('.popPrev').hide(); $('.popNext').show(); } $('.popNext').click(function(){ if(gCur!=(gTotal-1)){ next = $('#'+imgWrapp+' .imgBorder a[count=' + (gCur+1) + ']').attr('rel'); $('#popupImg').attr('src', next); popupTitle = $('#'+imgWrapp+' .imgBorder a[count=' + (gCur+1) + ']').attr('title'); $('.popTitle').text(popupTitle); imgDescr = $('#'+imgWrapp+' .imgBorder a[count=' + (gCur+1) + ']').children().attr('alt'); $('.popupDescr').text(imgDescr); gCur++; $('.popClose #numImg').text(gCur+' / '); $('.popPrev').show(); }else{ next = $('#'+imgWrapp+' .imgBorder a[count=' + (gTotal) + ']').attr('rel'); $('#popupImg').attr('src', next); popupTitle = $('#'+imgWrapp+' .imgBorder a[count=' + (gTotal) + ']').attr('title'); $('.popTitle').text(popupTitle); imgDescr = $('#'+imgWrapp+' .imgBorder a[count=' + (gTotal) + ']').children().attr('alt'); $('.popupDescr').text(imgDescr); gCur++; $('.popClose #numImg').text(gCur+' / '); $(this).hide(); $('.popPrev').show(); } }); $('.popPrev').click(function(){ if(gCur!=2){ prev = $('#'+imgWrapp+' .imgBorder a[count=' + (gCur-1) + ']').attr('rel'); $('#popupImg').attr('src', prev); popupTitle = $('#'+imgWrapp+' .imgBorder a[count=' + (gCur-1) + ']').attr('title'); $('.popTitle').text(popupTitle); imgDescr = $('#'+imgWrapp+' .imgBorder a[count=' + (gCur-1) + ']').children().attr('alt'); $('.popupDescr').text(imgDescr); gCur--; $('.popClose #numImg').text(gCur+' / '); $('.popNext').show(); }else{ prev = $('#'+imgWrapp+' .imgBorder a[count=' + (1) + ']').attr('rel'); $('#popupImg').attr('src', prev); popupTitle = $('#'+imgWrapp+' .imgBorder a[count=' + (1) + ']').attr('title'); $('.popTitle').text(popupTitle); imgDescr = $('#'+imgWrapp+' .imgBorder a[count=' + (1) + ']').children().attr('alt'); $('.popupDescr').text(imgDescr); gCur--; $('.popClose #numImg').text(gCur+' / '); $(this).hide(); $('.popNext').show(); } }); } }; popupPaint(); return false; }); $("area[rel^='ipopUp']").ipopUp(); $(".gallery:first a[rel^='ipopUp']").ipopUp({animation_speed:'normal',theme:'light_rounded',slideshow:3000, autoplay_slideshow: false}); });