var cimage=0;var totalimage=0;function galleryactive(){var gcont=$('#gallery-content');var gscroll=$('#gallery-scroll');gimage=$('#gallery-photo > img');if($('#title-photo-val').html().length)$('.title-photo').show();totalimage=$('#gallery-scroll a').length-1;cimage=$('#gallery-scroll td.active').attr('pid');if(cimage>0)arrowgal(cimage);gscroll.find('a').click(function(){thisimage=$(this);if($(this).parent().hasClass('active')){return false}else{openimageclick(thisimage)}
return false});$('#arr-nav-right-link').click(function(){rightphoto();return false;});$('#arr-nav-left-link').click(function(){leftphoto();return false;});function rightphoto(){if(cimage!=totalimage){cimage=cimage+1;arrowgal(cimage)}}
function leftphoto(){if(cimage!=0){cimage=cimage-1;arrowgal(cimage)}}
function arrowgal(cimage){thisimage=$("#gallery-scroll a").eq(cimage);openimageclick(thisimage);$("#gallery-scroll").stop().scrollTo(thisimage,800,{axis:'x',margin:true,offset:{left:-250}})}
function openimageclick(thisimage){gscroll.find('td').removeClass('active');thisimage.parent().addClass('active');newImg=thisimage.attr('href');newTitle=thisimage.attr('title');gimage.fadeOut('slow',function(){gimage.remove();$('#gallery-photo').html('<img src='+newImg+' />').find('img').bind('load',function(){$(this).attr('height',$(this).height()).attr('width',$(this).width());newHeightImg=$(this).attr('height');if($('gallery-photo').height()!=newHeightImg){$('#gallery-photo').animate({height:newHeightImg},300,function(){$('#gallery-photo > img').fadeIn('100');$('#gallery-photo').css('height',$(this).attr('height'))})}else{$('#gallery-photo > img').fadeIn('100');$('#gallery-photo').css('height',$(this).attr('height'))}});if(newTitle.length)
{$('#title-photo-val').html(newTitle);$('.title-photo').show();}
else
{$('.title-photo').hide();}});cimage=$("#gallery-scroll a").index(thisimage);switch(cimage){case 0:$('#arr-nav-left-link').addClass('disabled');if(cimage<totalimage)
$('#arr-nav-right-link').removeClass('disabled');break;case totalimage:$('#arr-nav-right-link').addClass('disabled');if(cimage>0)
$('#arr-nav-left-link').removeClass('disabled');break;default:$('#arr-nav-right-link,#arr-nav-left-link').removeClass('disabled');break}}}