// copyright Greg Lynch 2008-2009 http://www.cpurigs.com/ greg at lakecs.com Do not distribute!
var maximagewidth=200;var maximageheight=200;var maxthumbstoshow=4;function showhand(e){obj=document.getElementById(e.srcElement.id);obj.style.cursor="hand"}function showpointer(e){obj=document.getElementById(e.srcElement.id);obj.style.cursor="pointer"}var imageDivpar=null;var imageDivInner=null;var debugdiv=null;var vbpgScroll=null;var handleObj;var isButton=0;var vbpg_scrollShow=function(){var openInNewWin=1;var imageWidths=new Array();var imageHeights=new Array();var imageURLs=new Array();var imageDests=new Array();var imageDescs=new Array();var scrollTime=scrollshowtime;var scrollAmount=scrollshowpixels;var scroller;var scrollActive=false;var stopCounter=1;var goleft=true;var goright=false;var thumbsTotal;var thumbsToshow=maxthumbstoshow;var i_height=maximageheight;var i_width=maximagewidth;var marginRight=10;var marginLeft=0;var offsetLeft=((parseInt((this.i_width+marginRight),10)*(thumbsToshow+1)));var newoffsetLeft=offsetLeft;var maxrangeLeft;var maxrangeRight;this.addImage=function(imgW,imgH,imgURL,imgDest,imgDesc){imageWidths[imageWidths.length]=imgW;imageHeights[imageHeights.length]=imgH;imageDests[imageDests.length]=imgDest;imageDescs[imageDescs.length]=imgDesc;imageURLs[imageURLs.length]=imgURL};this.buildScroller=function(){var imageAnchor=null;var imageTag=null;var imageDiv=null;var newwidth;var newheight;var totalimagewidth=0;var imagediff;var imagepad;var divpar_w;var divinner_w;thumbsTotal=imageURLs.length;if(thumbsToshow>thumbsTotal)thumbsToshow=thumbsTotal;maxrangeLeft=0-((thumbsTotal-thumbsToshow)*(i_width+marginRight));maxrangeRight=0-marginRight;divpar_w=Math.round((thumbsToshow*i_width)+(marginRight*thumbsToshow));imageDivpar.style.width=divpar_w+"px";imageDivpar.style.height=i_height+"px";divinner_w=Math.round(thumbsTotal*(marginRight+i_width));imageDivInner.style.width=Math.round((divinner_w+marginRight))+"px";imageDivInner.style.left=(0-marginRight);for(i=0;i<thumbsTotal;i++){if(imageWidths[i]>i_width||imageHeights[i]>i_height){if(imageWidths[i]>i_width){newwidth=i_width;newheight=Math.round(imageHeights[i]*(i_width/imageWidths[i]));if(newheight<5)newheight=5;imageHeights[i]=newheight;imageWidths[i]=newwidth}if(imageHeights[i]>i_height){newheight=i_height;newwidth=Math.round(imageWidths[i]*(i_height/imageHeights[i]));if(newwidth<5)newwidth=5;imageHeights[i]=newheight;imageWidths[i]=newwidth}}if(imageDests[i]!=''){imageAnchor=document.createElement("a");if(openInNewWin==1)imageAnchor.target="vbpgImageDisplay";imageAnchor.href=imageDests[i];imageAnchor.title=imageDescs[i]}imageTag=document.createElement("img");imageTag.src=imageURLs[i];imageTag.width=imageWidths[i];imageTag.height=imageHeights[i];imagepad=0;if(imageWidths[i]<i_width){imagediff=Math.round(i_width-imageWidths[i]);imagepad=Math.ceil(imagediff/2)}if(imagepad>0)imageTag.style.marginRight=imagepad+"px";imageTag.style.marginLeft=Math.round(imagepad+marginRight)+"px";imageTag.alt=imageDescs[i];imageTag.border=0;if(imageDests[i]!=''){imageAnchor.appendChild(imageTag);imageDivInner.appendChild(imageAnchor)}else{imageDivInner.appendChild(imageTag)}}this.startScroll()};this.startScroll=function(){if(scrollActive==false){marginLeft=-(((i_width+marginRight)*(thumbsTotal-thumbsToshow)+marginRight));newoffsetLeft=(0-marginRight);goleft=true;scrollActive=true;scroller=setTimeout(scrollLeft,2500)}};function scrollRight(){offLeft=newoffsetLeft;if(offLeft<(0-marginRight)){trigger=scrollTime;if((stopCounter++%(i_width+marginRight))==0)trigger=2000;imageDivInner.style.left=offLeft+scrollAmount+"px";newoffsetLeft=offLeft+scrollAmount;scroller=setTimeout(scrollRight,trigger)}else if(scrollActive==false){stopCounter=1;return}else{newoffsetLeft=(0-marginRight);stopCounter=1;goleft=true;goright=false;scroller=setTimeout(scrollLeft,scrollpausetime)}};function scrollLeft(){offLeft=newoffsetLeft;if(offLeft>marginLeft){trigger=scrollTime;if((stopCounter++%(i_width+marginRight))==0)trigger=2000;imageDivInner.style.left=offLeft-scrollAmount+"px";newoffsetLeft=offLeft-scrollAmount;scroller=setTimeout(scrollLeft,trigger)}else if(scrollActive==false){stopCounter=1;return}else{stopCounter=1;goleft=false;goright=true;scroller=setTimeout(scrollRight,scrollpausetime)}};this.pauseScroll=function(c){if(isButton==1&&c==0)return;if(c==1)handleObj.innerHTML=" > ";scrollActive=false;clearTimeout(scroller)};this.restartScroll=function(c){if(isButton==1&&c==0)return;if(c==1)handleObj.innerHTML=" || ";scrollActive=true;isButton=0;if(goright)scroller=setTimeout(scrollRight,1);else scroller=setTimeout(scrollLeft,1)};this.handleAction=function(c){if(c==1)isButton=1;if(c==0&&isButton==1)return;if(scrollActive==true)this.pauseScroll(c);else this.restartScroll(c)};this.advLeft=function(){if(scrollActive==true)this.handleAction(1);if(newoffsetLeft<=maxrangeLeft){alert("All the way Left! "+newoffsetLeft);return}if(goleft){tempoff=newoffsetLeft;moveleft=(newoffsetLeft%(i_width+marginRight));if(moveleft==(0-marginRight)){newoffsetLeft=newoffsetLeft-(i_width+marginRight);stopCounter=1}else{stopCounter=1;moveleft=(i_width+marginRight)+moveleft+marginRight;newoffsetLeft=newoffsetLeft-(0+moveleft)}imageDivInner.style.left=newoffsetLeft+"px"}else{tempoff=newoffsetLeft;moveright=(newoffsetLeft%(i_width+marginRight));if(moveright==(0-marginRight)){newoffsetLeft=newoffsetLeft-(i_width+marginRight);stopCounter=1}else{stopCounter=1;adjust=(i_width+(2*marginRight))+moveright;newoffsetLeft=newoffsetLeft+(0-adjust)}imageDivInner.style.left=newoffsetLeft+"px"}};this.advRight=function(){if(scrollActive==true)this.handleAction(1);if(newoffsetLeft>=(0-marginRight)){alert("All the way Right! "+newoffsetLeft);return}if(goright){tempoff=newoffsetLeft;moveright=(newoffsetLeft+marginRight)%(i_width+marginRight);if(moveright==0){newoffsetLeft=newoffsetLeft+(i_width+marginRight)}else{stopCounter=1;newoffsetLeft=newoffsetLeft+(0-moveright)}imageDivInner.style.left=newoffsetLeft+"px"}else{tempoff=newoffsetLeft;moveright=(newoffsetLeft+marginRight)%(i_width+marginRight);if(moveright==0){newoffsetLeft=newoffsetLeft+(i_width+marginRight)}else{stopCounter=1;newoffsetLeft=newoffsetLeft-moveright}imageDivInner.style.left=newoffsetLeft+"px"}}};function openwin(theurl){var thewin;try{thewin=window.open(theurl,'vbpgphotowin','resizable=yes,scrollbars=yes,status=yes,width=1024,height=768')}catch(e){alert(e.data)}}window.onDomReady=DomReady;function DomReady(fn){if(document.addEventListener)document.addEventListener("DOMContentLoaded",fn,false);else document.onreadystatechange=function(){readyState(fn)}}function readyState(fn){if(document.readyState=="interactive")fn()}function init_pause(handle){handleObj=document.getElementById("handleButton")}function onloadInits(){imageDivpar=document.getElementById("vbpgScrollFrame");imageDivInner=document.getElementById("vbpgScrollImageRow");vbpgScroll=new vbpg_scrollShow();init_pause(vbpgScroll);loadscrollimages();vbpgScroll.buildScroller()}try{window.onload=onloadInits}catch(e){window.onDomReady(onloadInits)}
