').appendTo("body").css({ backgroundColor:setup.overlayBgColor, opacity:setup.overlayOpacity, width:dimensions.pWidth, height:dimensions.pHeight }).click(function() {
closeOverlay();
}).fadeIn();
viewer = '
').html(viewer).appendTo("body").css({ top:dimensions.posTop, left:dimensions.posLeft }).click(function() {
closeOverlay();
}).show();
$("#imgInfoBox").click(function(event){
event.stopPropagation();
});
//myPlayer = _V_("videoPlayer");
if(setup.imageInfo)
{
$('
').appendTo('#imgInfo');
$('
'+setup.txtImageInfo+'').appendTo('#viewExif').click(function(event) {
imageInfo();
return false;
});
}
if(setup.shareEnabled)
{
var jv2Share = $('#jv2Share');
var jv2ShareLinks = $('#jv2ShareLinks');
$('

').click(function(event){$('#jv2ShareLinks').slideToggle();return false;}).appendTo(jv2Share);
if(setup.shareFacebook)
$('

').click(function(event){share('facebook');return false;}).appendTo(jv2ShareLinks);
if(setup.shareGoogleplus)
$('

').click(function(event){share('googleplus');return false;}).appendTo(jv2ShareLinks);
if(setup.shareTwitter)
$('

').click(function(event){share('twitter');return false;}).appendTo(jv2ShareLinks);
if(setup.shareLinkedIn)
$('

').click(function(event){share('linkedin');return false;}).appendTo(jv2ShareLinks);
if(setup.shareStumbleupon)
$('

').click(function(event){share('stumbleupon');return false;}).appendTo(jv2ShareLinks);
if(setup.sharePinterest)
$('

').click(function(event){share('pinterest');return false;}).appendTo(jv2ShareLinks);
}
if(setup.customShare)
{
$('
').appendTo('#imgInfo');
$('
'+setup.txtShare+'').appendTo('#viewShare').click(function(event) {
customShare();
return false;
});
}
if(setup.showDownloadLink)
$('
'+setup.txtDownload+'').appendTo('#imgInfo');
if(setup.downloadOptions && !setup.openInNewTab)
$('
S/M/L').appendTo('#downloadLink');
if(setup.showPrintLink)
{
$('
').appendTo('#imgInfo');
$('
'+setup.txtPrint+'').appendTo('#printLink').click(function(event) {
printImage();
return false;
});
}
if(setup.disqus_enabled)
{
$('

').click(function(){
toggleGalleryDisqus();
return false;
}).appendTo('#jv2Comments');
$('').click(function() {
toggleGalleryDisqus();
return false;
}).appendTo('#jv2Comments');
}
if(setup.slideshow)
{
var ssLink = $('

').appendTo("#imgSlideShow").click(function() {
startSlideShow();
}).show();
if(setup.slideshowAutoStart)
ssLink.trigger('click');
}
$('

').appendTo("#viewerClose").click(function() {
closeOverlay();
}).show();
// resizing window
$(window).resize(function() {
getWindowDimensions();
$('#gJv2overlay').css({ width:dimensions.wWidth, height:dimensions.wHeight });
if(resizing != true)
{
resizing = true;
$.gDoTimeout( 'resize', 1000 , function(){
resizeViewer(false);
resizing = false;
});
}
});
}
function getWindowDimensions()
{
dimensions.wWidth = $(window).width();
dimensions.wHeight = $(window).height();
dimensions.pWidth = $(document).width();
dimensions.pHeight = $(document).height();
dimensions.scroll = $(window).scrollTop();
dimensions.posTop = dimensions.scroll + (dimensions.wHeight / 10);
dimensions.posLeft = $(window).scrollLeft();
}
function videoPlayer()
{
$('#imgDiv').hide();
if(myPlayer != null)
{
if(myPlayer.techName == "html5")
{
myPlayer.tag.src = "";
myPlayer.tech.removeTriggers();
myPlayer.load();
}
//myPlayer.tech.destroy();
myPlayer.destroy();
$(myPlayer.el).remove();
}
var code = '
';
$(code).prependTo('#imgDivWrap');
$("#gJv2videoPlayerWrap").click(function(event){
event.stopPropagation();
});
myPlayer = _V_("videoPlayer");
}
function viewImage()
{
getUrlVars();
var uf = jv2getAlbumFromUrl();
if(uf!=null)
{
setup.folder = uf;
setup.folderPath = uf + '/';
}
removeImageInfo();
hideGalleryDisqus();
$('#imgLoading').show();
$('#imgImg, #imgNav, #imgInfoBox').hide();
if(setup.imageArray[setup.currentImage].video != null)
videoPlayer();
else
{
$('#gJv2videoPlayerWrap').remove();
myPlayer = null;
var preloadImage = new Image();
preloadImage.onload = function() {
$('#imgDiv').show();
$('#imgImg').attr('src', setup.imageArray[setup.currentImage].href);
origImgWidth = preloadImage.width;
origImgHeight = preloadImage.height;
resizeViewer(true);
};
preloadImage.src = setup.imageArray[setup.currentImage].href;
}
currentImage = setup.imageArray[setup.currentImage].orig;
updateURL({i:setup.imageArray[setup.currentImage].orig});
if(setup.disqus_enabled)
{
$(document).ready (function () {
getUrlVars();
var uf = jv2getAlbumFromUrl();
var identifier = disqus_identifier_prefix+(uf!=null?uf.replace('/','_')+'_':'')+urlVars.fparam('i');
$('#disqusCount').attr('data-disqus-identifier',identifier);
loadDisqusCount(identifier);
});
}
}
function imageMaxSize(imgWidth,imgHeight,widthAdjust,heightAdjust)
{
if(typeof(widthAdjust)=='undefined')
widthAdjust = 0;
if(typeof(heightAdjust)=='undefined')
heightAdjust = 0;
var extraHeight = 60;
var imgTotalMargin = (setup.containerBorderSize*4);
var maxHeight = dimensions.wHeight - imgTotalMargin + heightAdjust - extraHeight;
var maxWidth = dimensions.wWidth - imgTotalMargin + widthAdjust;
if( imgHeight > maxHeight )
{
var newHeight = maxHeight;
var newWidth = Math.floor((newHeight / imgHeight) * imgWidth);
if( newWidth > maxWidth )
{
newWidth = maxWidth;
newHeight = Math.floor((newWidth / imgWidth) * imgHeight);
}
dimensions.imgHeight = newHeight;
dimensions.imgWidth = newWidth;
}
else if( imgWidth > maxWidth )
{
var newWidth = maxWidth;
var newHeight = Math.floor((newWidth / imgWidth) * imgHeight);
if( newHeight > maxHeight )
{
newHeight = maxHeight;
newWidth = Math.floor((newHeight / imgHeight) * newWidth);
}
dimensions.imgHeight = newHeight;
dimensions.imgWidth = newWidth;
}
else
{
dimensions.imgHeight = imgHeight;
dimensions.imgWidth = imgWidth;
}
}
function resizeViewer(initImg,addHeight)
{
var widthAdjust = 0;
var heightAdjust = 0;
if(typeof(addHeight)!='undefined' && addHeight == true)
{
heightAdjust = $('#imgCaption').height() * -1;
}
var extraHeight = 60;
var imgMargin = (setup.containerBorderSize*2);
imageMaxSize(origImgWidth,origImgHeight,widthAdjust,heightAdjust);
var imgWrapWidth = (dimensions.imgWidth + imgMargin);
var imgWrapHeight = (dimensions.imgHeight + imgMargin);
dimensions.posTop = dimensions.scroll + ((dimensions.wHeight - imgWrapHeight)/2) - (extraHeight/2) + (heightAdjust/2);
if(dimensions.posTop < imgMargin)
dimensions.posTop = imgMargin;
$('#gJv2imgViewer').animate({ top: dimensions.posTop }, setup.containerResizeSpeed);
//$('#disqusBg').animate({ top:dimensions.posTop+setup.containerBorderSize }, setup.containerResizeSpeed);
if(!initImg)
$('#imgImg').animate({ width:dimensions.imgWidth, height:dimensions.imgHeight }, setup.containerResizeSpeed);
$('#imgDivWrap').animate({ width: imgWrapWidth });
$('#imgNav').css({ height: imgWrapHeight });
$('#imgDiv, #disqusBg').animate({ width: dimensions.imgWidth, height: dimensions.imgHeight }, setup.containerResizeSpeed, function() {
if(initImg)
showImg(dimensions.imgWidth,dimensions.imgHeight);
});
$('#disqus_thread').animate({ width: (dimensions.imgWidth-40), height: (dimensions.imgHeight-40) }, setup.containerResizeSpeed, function() {
if(initImg)
showImg(dimensions.imgWidth,dimensions.imgHeight);
});
if(myPlayer != null)
{
myPlayer.width(dimensions.imgWidth);
myPlayer.height(dimensions.imgHeight);
}
$('#imgInfoBox').css({ width: dimensions.imgWidth });
$('#imgPrevious, #imgNext').css({ height: dimensions.imgHeight + (setup.containerBorderSize * 2) });
};
function showImg(w,h)
{
$('#imgLoading').hide();
$('#imgImg').css({width:w,height:h}).fadeIn(function()
{
$('#imgNav').show();
$('#imgPrevious, #imgNext').unbind().css({'background':'transparent url(' + setup.imageBlank + ') no-repeat'});
if( (setup.currentImage != 0 || setup.viewerLoop) && setup.imageArray.length>1)
{
$('#imgPrevious').hover(function() {
$('#imgPrevious span').css('display','block');
},function() {
$('#imgPrevious span').css('display','none');
}).show().bind('click',function() {
if(setup.sshowOn)
stopSlideshow();
if(setup.currentImage==0)
setup.currentImage = setup.imageArray.length-1;
else
setup.currentImage--;
viewImage();
return false;
});
}
if( (setup.currentImage != setup.imageArray.length-1 || setup.viewerLoop) && setup.imageArray.length>1)
{
$('#imgNext').hover(function() {
$('#imgNext span').css('display','block');
},function() {
$('#imgNext span').css('display','none');
}).show().bind('click',function() {
if(setup.sshowOn)
stopSlideshow();
if( setup.currentImage == setup.imageArray.length-1 )
setup.currentImage=0;
else
setup.currentImage++;
viewImage();
return false;
});
}
$('#imgInfoBox').slideDown('fast',function(){resizeViewer(false,true)});
if( setup.imageArray[setup.currentImage].title )
{
$('#imgTitle').html(setup.imageArray[setup.currentImage].title).show();
if(setup.imageArray[setup.currentImage].caption!=null)
$('#imgCaption').html(setup.imageArray[setup.currentImage].caption).show();
else
$('#imgCaption').html('').show();
if(setup.imageArray[setup.currentImage].author!=null)
$('#imgAuthor').html(' '+setup.txtAuthor+' '+setup.imageArray[setup.currentImage].author).show();
else
$('#imgAuthor').html('').show();
var origVal = setup.imageArray[setup.currentImage].orig;
$('#imgCurrentOriginal').val(origVal);
if(setup.showDownloadLink)
{
if(setup.openInNewTab)
{
$('#downloadLinkRef').attr('href',setup.galleryfolder+setup.folderPath+origVal).attr('target','_blank');
}
else
{
$('#downloadLinkRef').attr('href',setup.downloadLink+setup.galleryfolder+setup.folderPath+origVal);
$('#downloadLinkRefS').attr('href',setup.downloadLink+setup.galleryfolder+setup.folderPath+origVal+'&size=S');
$('#downloadLinkRefM').attr('href',setup.downloadLink+setup.galleryfolder+setup.folderPath+origVal+'&size=M');
$('#downloadLinkRefL').attr('href',setup.downloadLink+setup.galleryfolder+setup.folderPath+origVal+'&size=L');
}
}
}
if( setup.imageArray.length > 1 )
$('#imgCount').html(setup.txtImage+' '+(setup.currentImage+1)+' '+setup.txtOf+' '+setup.imageArray.length).show();
});
preloadNextPrev();
};
function toggleGalleryDisqus()
{
if($('#disqus_thread').is(':visible'))
hideGalleryDisqus();
else
showGalleryDisqus();
}
function showGalleryDisqus()
{
if(setup.sshowOn)
stopSlideshow();
var w = $('#imgDiv').width();
var h = $('#imgDiv').height();
if($('#disqusBg').length == 0)
$('