$(document).ready(function(){
$(".imgBorder a").click(function() {
var bigImg = $(this).attr("href");
var bigImgBig = $(this).attr("rel");
var gCur = $(this).attr("count");
$("#imgObj img").attr("src", bigImg);
$("#imgObj a").attr("href", bigImgBig);
$("#imgObj a").attr("count", gCur);
$(".imgBorder a").removeClass('actLink');
$(this).addClass('actLink');
return false;
});
$('.popupImg').click(function(){
var t = $(this);
function popupPosition () {
var brHeight = $(window).height();
var brWidth = $(document).width();
var popupImgLoad = $('.popupImg');
var popupHeight = $('#popupBody img').height()+45;
var popupWidth = $('#popupBody img').width()+20;
var popupTop = ((brHeight-popupHeight)/2);
var popupLeft = ((brWidth-popupWidth)/2);
$('#popup').css({
'left' : popupLeft,
'top' : popupTop,
'width' : popupWidth
});
};
function popupPaint () {
var popupImgSrc = $('.popupImg').attr('href');
var popupImg = '';
var popupTitle = $('.popupImg').attr('title');
var popupCloseImg = '/js/new/lightbox/close.png';
if (popupTitle==''){
popupTitle = '';
}
$('body').append('
');
$('#fancybox-overlay').css({opacity:0.7,display:'block',background:'#fff',height:'100%'}).fadeTo('fast', 0.7);
$('img#popupImg').load(function(){
$('#popupImg').removeClass('imgHide');
popupPosition();
});
$(document).keyup(function(e) {
if (e.which == 27){
$('#popup').remove();
$('#shadow').fadeOut();
}
});
$('.popClose, #fancybox-overlay').click(function(){
$('#popup').remove();
$('#fancybox-overlay').fadeOut();
return false;
});
if('.imgBorder'){
var gTotal = ($('.imgBorder').length) - 1;
var next = $(this).nextAll('.imgBorder').children('a').attr('rel');
var prev = $(this).prevAll('.imgBorder').children('a').attr('rel');
var gCur = parseInt($('.popupImg').attr('count'));
if (gCur == gTotal){
$('.popNext').hide();
}
if (gCur == 0){
$('.popPrev').hide();
}
$('.popNext').click(function(){
if(gCur!=(gTotal-1)){
next = $('.imgBorder a[count=' + (gCur+1) + ']').attr('rel');
$('#popupImg').attr('src', next);
popupTitle = $('.imgBorder a[count=' + (gCur+1) + ']').children().attr('alt');
$('.popTitle').text(popupTitle);
gCur++;
$('.popPrev').show();
}else{
next = $('.imgBorder a[count=' + (gTotal) + ']').attr('rel');
$('#popupImg').attr('src', next);
popupTitle = $('.imgBorder a[count=' + (gTotal) + ']').children().attr('alt');
$('.popTitle').text(popupTitle);
gCur++;
$(this).hide();
}
});
$('.popPrev').click(function(){
if(gCur!=1){
prev = $('.imgBorder a[count=' + (gCur-1) + ']').attr('rel');
$('#popupImg').attr('src', prev);
popupTitle = $('.imgBorder a[count=' + (gCur-1) + ']').children().attr('alt');
$('.popTitle').text(popupTitle);
gCur--;
$('.popNext').show();
}else{
prev = $('.imgBorder a[count=' + (0) + ']').attr('rel');
$('#popupImg').attr('src', prev);
popupTitle = $('.imgBorder a[count=' + (0) + ']').children().attr('alt');
$('.popTitle').text(popupTitle);
gCur--;
$(this).hide();
}
});
}
};
popupPaint();
return false;
});
});