
function ObjectDetailHeaderGallery()
{this.thumbElementWidth=0;this.thumbElementHeight=0;this.thumbPageSize=4;this.currentPageIndex=0;this.thumbElementWidth=0;this.isScrolling=false;this.pageCount=0;this.Initialize=function()
{this.thumbElementWidth=this.GetThumbElementWidth();this.pageCount=this.GetPageCount();}
this.ClickThumbnail=function(lnkThumbnailObj)
{var thumbURL=$(lnkThumbnailObj).children("img")[0].src;this.LoadNormalViewPicture(this.ConvertURL(thumbURL,"normal"));return false;}
this.LoadNormalViewPicture=function(newNormalViewURL)
{var testImage=new Image();$(testImage).load(function(target,myUrl){return function(){target.ChangeNormalViewPicture(myUrl);};}(this,newNormalViewURL));testImage.src=newNormalViewURL;}
this.ChangeNormalViewPicture=function(newNormalViewUrl)
{$("#divHeaderNormalView img")[0].src=newNormalViewUrl;}
this.ConvertURL=function(urlToConvert,viewType)
{var oldViewType=urlToConvert.substring(urlToConvert.indexOf("picViewType="),urlToConvert.indexOf("picViewType=")+13);switch(viewType)
{case"normal":return urlToConvert.replace(oldViewType,"picViewType=1");break;case"thumb":return urlToConvert.replace(oldViewType,"picViewType=2");break;}}
this.ScrollThumbnails=function(direction)
{if(!this.isScrolling)
{this.isScrolling=true;if(direction=='left')
{if(this.currentPageIndex==(this.pageCount-1))
{this.isScrolling=false;return false;}
$("#divHeaderGalleryThumbs").animate({"left":"-="+this.GetScrollDistancePerPage()+"px"},"slow",function(target){target.isScrolling=false;}(this));this.currentPageIndex++;}
else
{if(this.currentPageIndex==0)
{this.isScrolling=false;return false;}
$("#divHeaderGalleryThumbs").animate({"left":"+="+this.GetScrollDistancePerPage()+"px"},"slow",function(target){target.isScrolling=false;}(this));this.currentPageIndex--;}}
return false;}
this.GetThumbElementWidth=function()
{return parseInt($("#divHeaderGalleryThumbs div").css("width"));}
this.GetScrollDistancePerPage=function()
{return this.thumbPageSize*this.thumbElementWidth;}
this.GetPageCount=function()
{var numberOfThumbs=$("#divHeaderGalleryThumbs div img").length;return(numberOfThumbs%this.thumbPageSize==0)?numberOfThumbs/this.thumbPageSize:parseInt((numberOfThumbs/this.thumbPageSize))+1;}
this.SetArrowVisibility=function(direction,visibility)
{if(direction=='right')
$("a[id$='lnkGalleryArrowRight']").css("visibility",visibility);else
$("a[id$='lnkGalleryArrowLeft']").css("visibility",visibility);}}