var AlbumScroller = function(_AlbumScrollerParentDivID, _AlbumScrollerChildDivID) {
   _AlbumScrollerParentDivID = getElem(_AlbumScrollerParentDivID); 
   _AlbumScrollerChildDivID = getElem(_AlbumScrollerChildDivID); 
   var prPhotoPaths = new Array(); 
   var prPhotoPaths = new Array(); 
   var prPhotoeClicks = new Array(); 
   var prPhotoeDescription = new Array(); 
   var iNumOfPhotosShown = 1; 
   var iNumOfPhotos; 
   
   var bAutoScroll = 0; 
   //0=false, 1=true
   var iAutoScrollDelay = 
   00; 
   var bAutoScrollDirection = 1; 
   //0=back, 1=forward
   var bAutoReverse = 1; 
   //0=false, 1=true
   var iScrollType = 1; 
   //0=horizontal, 1=vertical
   var benablePhotoBorder = 0; 
   //0=no, 1=yes
   var bEnableCurrentCount = 0; 
   //0=no, 1=yes
   var bEnableThumbDescription = 0; 
   //0=no, 1=yes
   var bClickOpenType = 0; 
   //0=same window, 1=new window
   var iImageScrollAmount = 1;
   //number of images to scroll
   
   var objCounterDiv = ""; 
   var objDescriptionDiv = ""; 
   var iSmoothSlideInterval = 3; 
   var iSmoothSlideAmount = 7; 
   var moveTimer; 
   
   this.THUMB_HEIGHT = 80; 
   this.THUMB_WIDTH = 80; 
   this.PHOTO_PADDING = 4; 
   
   var CURRENT_THUMB_INDEX = 1; 
   var NEW_REVERSE_OFFSET = 0; 
   var MAX_REVERSE_OFFSET = 0; 
   var NEW_FORWARD_OFFSET = 0; 
   var IS_SCROLLING = false; 
   //* BEGIN FUNCTIONS *//
   this.setNumOfPhotosToScroll = function(_NumOfPhotosToScroll) {
        iImageScrollAmount = parseInt(_NumOfPhotosToScroll);
   };
   this.enablePhotoDescription = function(_descriptionDivID) {
      bEnableThumbDescription = 1; 
      objDescriptionDiv = _descriptionDivID; 
      }; 
   this.setPhotoScrollType = function(_iType) {
      if (_iType == 0) {
         iScrollType = 0; 
         }
      else {
         iScrollType = 1; 
         }
      }; 
   this.setScrollSpeed = function(_iSpeed) {
      if (_iSpeed > 0 || _iSpeed < 1000) {
         iSmoothSlideInterval = _iSpeed; 
         }
      else {
         iSmoothSlideInterval = 7; 
         }
      }; 
   this.setScrollAmount = function(_iAmount) {
      if (_iAmount > 0 || _iAmount < 1000) {
         iSmoothSlideAmount = _iAmount; 
         }
      else {
         iSmoothSlideAmount = 7; 
         }
      }; 
   this.setPhotoClickOpenType = function(_openType) {
      if (_openType == 0 || _openType == 1) {
         bClickOpenType = _openType; 
         }
      }; 
   this.enableCurrentCount = function(_counterDivID) {
      bEnableCurrentCount = 1; 
      objCounterDiv = _counterDivID; 
      }; 
   this.enablePhotoBorder = function(_boolean) {
      benablePhotoBorder = _boolean; 
      }; 
   this.setPhotosShown = function(_newNumOfThumbsShown) {
      iNumOfPhotosShown = parseInt(_newNumOfThumbsShown); 
      }; 
   this.addPhotos = function(_thumbnailURL, _fullClickURL) {
      prPhotoPaths[prPhotoPaths.length] = _thumbnailURL; 
      prPhotoeClicks[prPhotoeClicks.length] = _fullClickURL; 
      }; 
   this.setPhotoHeight = function(_newThumbHeight) {
      this.THUMB_HEIGHT = _newThumbHeight; 
      }; 
   this.getThumbnailHeight = function() {
      return this.THUMB_HEIGHT; 
      }; 
   this.setPhotoWidth = function(_newThumbWidth) {
      this.THUMB_WIDTH = _newThumbWidth; 
      }; 
   this.getThumbnailWidth = function() {
      return this.THUMB_WIDTH; 
      }; 
   this.setPhotoPadding = function(_newThumbPadding) {
      this.PHOTO_PADDING = _newThumbPadding; 
      }; 
   this.getThumbnailPadding = function() {
      return PHOTO_PADDING; 
      }; 
   this.getCurrentThumbIndex = function() {
      return CURRENT_THUMB_INDEX; 
      }; 
   this.getThumbnailCount = function() {
      return iNumOfPhotos; 
      }; 
   this.renderPhotoScroller = function() {
      iNumOfPhotos = prPhotoPaths.length; 
      if (iNumOfPhotosShown > iNumOfPhotos) {
         iNumOfPhotosShown = iNumOfPhotos; 
         }
      MAX_REVERSE_OFFSET = 0 - (iNumOfPhotos - iNumOfPhotosShown) * this.THUMB_WIDTH; 
      if (this.PHOTO_PADDING > 0) {
         MAX_REVERSE_OFFSET = MAX_REVERSE_OFFSET - (iNumOfPhotos * this.PHOTO_PADDING); 
         }
      if (benablePhotoBorder == 1) {
         MAX_REVERSE_OFFSET = MAX_REVERSE_OFFSET - (iNumOfPhotos * 4); 
         }
      if (iScrollType == 0) {
         _AlbumScrollerParentDivID.style.width = (this.THUMB_WIDTH * iNumOfPhotosShown) + (iNumOfPhotosShown * (this.PHOTO_PADDING * 2)) + "px"; 
         if (benablePhotoBorder == 1) {
            _AlbumScrollerParentDivID.style.width = (parseInt(_AlbumScrollerParentDivID.style.width) + (iNumOfPhotosShown * 4)) + "px"; 
            }
         _AlbumScrollerParentDivID.style.height = this.THUMB_HEIGHT + (this.PHOTO_PADDING * 2) + "px"; 
         if (benablePhotoBorder == 1) {
            _AlbumScrollerParentDivID.style.height = (parseInt(_AlbumScrollerParentDivID.style.height) + 4) + "px"; 
            }
         _AlbumScrollerChildDivID.style.width = (this.THUMB_WIDTH * iNumOfPhotos) + (iNumOfPhotos * (this.PHOTO_PADDING * 2)) + "px"; 
         if (benablePhotoBorder == 1) {
            _AlbumScrollerChildDivID.style.width = (parseInt(_AlbumScrollerChildDivID.style.width) + (iNumOfPhotos * 4)) + "px"; 
            }
         }
      else if (iScrollType == 1) {
         _AlbumScrollerParentDivID.style.width = (this.THUMB_WIDTH) + ((this.PHOTO_PADDING * 2)) + "px"; 
         if (benablePhotoBorder == 1) {
            _AlbumScrollerParentDivID.style.width = (parseInt(_AlbumScrollerParentDivID.style.width) + (4)) + "px"; 
            }
         _AlbumScrollerParentDivID.style.height = (this.THUMB_HEIGHT * iNumOfPhotosShown) + (iNumOfPhotosShown * (this.PHOTO_PADDING * 2)) + "px"; 
         if (benablePhotoBorder == 1) {
            _AlbumScrollerParentDivID.style.height = (parseInt(_AlbumScrollerParentDivID.style.height) + (iNumOfPhotosShown * 4)) + "px"; 
            }
         _AlbumScrollerChildDivID.style.width = (this.THUMB_WIDTH) + (this.PHOTO_PADDING * 2) + "px"; 
         if (benablePhotoBorder == 1) {
            _AlbumScrollerChildDivID.style.width = (parseInt(_AlbumScrollerChildDivID.style.width) + 4) + "px"; 
            }
         }
      //*** [Begin] Image Cacheing code ***//
      var PhotoHref;
      var openhouse_Image;
        PhotoHref = document.createElement("a");
        openhouse_Image = document.createElement("img");
        
      for (i = 0; i < iNumOfPhotos; i++) {
        PhotoHref = document.createElement("a");
       // PhotoHref.href = prPhotoeClicks[i];
        //PhotoHref.onclick= function(){scrollPhotoClick(prPhotoPaths[i]);};
       // PhotoHref.title = prPhotoPaths[i];
        
        if (bClickOpenType == 1) {
            PhotoHref.target = "_blank";
        }
        
        openhouse_Image = document.createElement("img");
            openhouse_Image.src = prPhotoPaths[i];
           // openhouse_Image.alt = prPhotoPaths[i];
            openhouse_Image.onclick=function(){scrollPhotoClick(this.src);};
            openhouse_Image.border = 0;
            openhouse_Image.style.cursor="pointer";
            openhouse_Image.style.cursor="hand";
            openhouse_Image.width = this.THUMB_WIDTH;
            openhouse_Image.height = this.THUMB_HEIGHT;
            //openhouse_Image.style.padding = this.PHOTO_PADDING;
             openhouse_Image.style.margin = "2px";
            
          PhotoHref.appendChild(openhouse_Image);
          _AlbumScrollerChildDivID.appendChild(PhotoHref);
            
      }
      //*** [End]   Image Cacheing code ***//
      
      if (bEnableCurrentCount == 1) {
         addAnEvent(window, "load", this.updateCurrentCount); 
         }
      if (bEnableThumbDescription == 1) {
         addAnEvent(window, "load", this.updateCurrentDescription); 
         }
      }; 
   this.scrollUp = function() {
      _origOffset = parseInt(_AlbumScrollerChildDivID.style.top); 
      _currentOffset = parseInt(_AlbumScrollerChildDivID.style.top); 
      _newOffset = _currentOffset - (this.THUMB_HEIGHT * iImageScrollAmount); 
      if (this.PHOTO_PADDING > 0) {
         _newOffset = _newOffset - (2 * this.PHOTO_PADDING); 
         }
      if (benablePhotoBorder == 1) {
         _newOffset = _newOffset - 4; 
         }
      if (IS_SCROLLING == false && _newOffset >= MAX_REVERSE_OFFSET) {
         NEW_FORWARD_OFFSET = _newOffset; 
         moveScrollerUp(); 
         }
      }; 
   this.scrollDown = function() {
      _origOffset = parseInt(_AlbumScrollerChildDivID.style.top); 
      _currentOffset = parseInt(_AlbumScrollerChildDivID.style.top); 
      _newOffset = _currentOffset + (this.THUMB_HEIGHT * iImageScrollAmount); 
      if (this.PHOTO_PADDING > 0) {
         _newOffset = _newOffset + (2 * this.PHOTO_PADDING); 
         }
      if (benablePhotoBorder == 1) {
         _newOffset = _newOffset + 4; 
         }
      if (_newOffset <= 0) {
         if(_currentOffset > (_origOffset - this.THUMB_HEIGHT)) {
            if (IS_SCROLLING == false && _newOffset >= MAX_REVERSE_OFFSET) {
               NEW_REVERSE_OFFSET = _newOffset; 
               moveScrollerDown(); 
               }
            }
         }
      }; 
   this.scrollTop = function() {
      if (IS_SCROLLING == false) {
         NEW_FORWARD_OFFSET = ( - 1 * (iNumOfPhotos - iNumOfPhotosShown) * this.THUMB_HEIGHT); 
         CURRENT_THUMB_INDEX = iNumOfPhotos - iNumOfPhotosShown; 
         moveScrollerUp(); 
         }
      }; 
   this.scrollBottom = function() {
      if (IS_SCROLLING == false) {
         NEW_REVERSE_OFFSET = 0; 
         CURRENT_THUMB_INDEX = iNumOfPhotos - iNumOfPhotosShown; 
         moveScrollerDown(); 
         }
      }; 
   this.scrollToPrevious = function() {
      _origOffset = parseInt(_AlbumScrollerChildDivID.style.left); 
      _currentOffset = parseInt(_AlbumScrollerChildDivID.style.left); 
      _newOffset = _currentOffset + (this.THUMB_WIDTH * iImageScrollAmount); 
      if (this.PHOTO_PADDING > 0) {
         _newOffset = _newOffset + (this.PHOTO_PADDING * (2 * iImageScrollAmount)); 
         }
      if (benablePhotoBorder == 1) {
         _newOffset = _newOffset + 4; 
         }
      if (_newOffset <= 0) {
         if(_currentOffset > (_origOffset - (this.THUMB_WIDTH * iImageScrollAmount))) {
            if (IS_SCROLLING == false) {
               NEW_REVERSE_OFFSET = _newOffset; 
               moveScrollerRight(); 
               }
            }
         }
      }; 
   this.scrollToNext = function() {
      _origOffset = parseInt(_AlbumScrollerChildDivID.style.left); 
      _currentOffset = parseInt(_AlbumScrollerChildDivID.style.left); 
      _newOffset = _currentOffset - (this.THUMB_WIDTH * iImageScrollAmount); 
      if (this.PHOTO_PADDING > 0) {
         _newOffset = _newOffset - ((2 * iImageScrollAmount) * this.PHOTO_PADDING); 
         }
      if (benablePhotoBorder == 1) {
         _newOffset = _newOffset - 4; 
         }
      if (IS_SCROLLING == false && _newOffset >= MAX_REVERSE_OFFSET) {
         NEW_FORWARD_OFFSET = _newOffset; 
         movePhotoScrollerLeft(); 
         }
      }; 
   this.scrollTolast = function() {
      if (IS_SCROLLING == false) {
         NEW_FORWARD_OFFSET = MAX_REVERSE_OFFSET; 
         CURRENT_THUMB_INDEX = iNumOfPhotos - iNumOfPhotosShown; 
         movePhotoScrollerLeft(); 
         }
      }; 
   this.scrollFirst = function() {
      if (IS_SCROLLING == false) {
         NEW_REVERSE_OFFSET = 0; 
         CURRENT_THUMB_INDEX = 2; 
         moveScrollerRight(); 
         }
      }; 
   this.updateCurrentDescription = function() {
      getElem(objDescriptionDiv).innerHTML = prPhotoeDescription[CURRENT_THUMB_INDEX - 1]; 
      }; 
   this.updateCurrentCount = function() {
      getElem(objCounterDiv).innerHTML = CURRENT_THUMB_INDEX + "/" + iNumOfPhotos; 
      }; 
   function moveScrollerUp() {
      _ElementObj = _AlbumScrollerChildDivID; 
      _currentOffset = parseInt(_ElementObj.style.top); 
      if (_currentOffset > NEW_FORWARD_OFFSET && (_currentOffset - iSmoothSlideAmount) >= NEW_FORWARD_OFFSET) {
         _ElementObj.style.top = _currentOffset - iSmoothSlideAmount + "px"; 
         IS_SCROLLING = true; 
         moveTimer = window.setTimeout(moveScrollerUp, iSmoothSlideInterval); 
         }
      else if (_currentOffset > NEW_FORWARD_OFFSET) {
         _ElementObj.style.top = _currentOffset - 1 + "px"; 
         IS_SCROLLING = true; 
         moveTimer = window.setTimeout(moveScrollerUp, iSmoothSlideInterval); 
         }
      else {
         IS_SCROLLING = false; 
         CURRENT_THUMB_INDEX++; 
         window.clearTimeout(moveTimer); 
         if (bEnableThumbDescription == 1) {
            getElem(objDescriptionDiv).innerHTML = prPhotoeDescription[CURRENT_THUMB_INDEX - 1]; 
            }
         if (bEnableCurrentCount == 1) {
            getElem(objCounterDiv).innerHTML = CURRENT_THUMB_INDEX + "/" + iNumOfPhotos; 
            }
         }
      }; 
   function moveScrollerDown() {
      _ElementObj = _AlbumScrollerChildDivID; 
      _currentOffset = parseInt(_ElementObj.style.top); 
      if (_currentOffset < NEW_REVERSE_OFFSET && (_currentOffset + iSmoothSlideAmount) <= NEW_REVERSE_OFFSET) {
         _ElementObj.style.top = _currentOffset + iSmoothSlideAmount + "px"; 
         IS_SCROLLING = true; 
         moveTimer = window.setTimeout(moveScrollerDown, iSmoothSlideInterval); 
         }
      else if (_currentOffset < NEW_REVERSE_OFFSET) {
         _ElementObj.style.top = _currentOffset + 1 + "px"; 
         IS_SCROLLING = true; 
         moveTimer = window.setTimeout(moveScrollerDown, iSmoothSlideInterval); 
         }
      else {
         IS_SCROLLING = false; 
         CURRENT_THUMB_INDEX--; 
         window.clearTimeout(moveTimer); 
         if (bEnableThumbDescription == 1) {
            getElem(objDescriptionDiv).innerHTML = prPhotoeDescription[CURRENT_THUMB_INDEX - 1]; 
            }
         if (bEnableCurrentCount == 1) {
            getElem(objCounterDiv).innerHTML = CURRENT_THUMB_INDEX + "/" + iNumOfPhotos; 
            }
         }
      }; 
   function moveScrollerRight() {
      _ElementObj = _AlbumScrollerChildDivID; 
      _currentOffset = parseInt(_ElementObj.style.left); 
      if (_currentOffset < NEW_REVERSE_OFFSET && (_currentOffset + iSmoothSlideAmount) <= NEW_REVERSE_OFFSET) {
         _ElementObj.style.left = _currentOffset + iSmoothSlideAmount + "px"; 
         IS_SCROLLING = true; 
         moveTimer = window.setTimeout(moveScrollerRight, iSmoothSlideInterval); 
         }
      else if (_currentOffset < NEW_REVERSE_OFFSET) {
         _ElementObj.style.left = _currentOffset + 1 + "px"; 
         IS_SCROLLING = true; 
         moveTimer = window.setTimeout(moveScrollerRight, iSmoothSlideInterval); 
         }
      else {
         IS_SCROLLING = false; 
         CURRENT_THUMB_INDEX--; 
         window.clearTimeout(moveTimer); 
         if (bEnableThumbDescription == 1) {
            getElem(objDescriptionDiv).innerHTML = prPhotoeDescription[CURRENT_THUMB_INDEX - 1]; 
            }
         if (bEnableCurrentCount == 1) {
            getElem(objCounterDiv).innerHTML = CURRENT_THUMB_INDEX + "/" + iNumOfPhotos; 
            }
         }
      }; 
   function movePhotoScrollerLeft() {
      _ElementObj = _AlbumScrollerChildDivID; 
      _currentOffset = parseInt(_ElementObj.style.left); 
      if (_currentOffset > NEW_FORWARD_OFFSET && (_currentOffset - iSmoothSlideAmount) >= NEW_FORWARD_OFFSET) {
         _ElementObj.style.left = _currentOffset - iSmoothSlideAmount + "px"; 
         IS_SCROLLING = true; 
         moveTimer = window.setTimeout(movePhotoScrollerLeft, iSmoothSlideInterval); 
         }
      else if (_currentOffset > NEW_FORWARD_OFFSET) {
         _ElementObj.style.left = _currentOffset - 1 + "px"; 
         IS_SCROLLING = true; 
         moveTimer = window.setTimeout(movePhotoScrollerLeft, iSmoothSlideInterval); 
         }
      else {
         IS_SCROLLING = false; 
         CURRENT_THUMB_INDEX++; 
         window.clearTimeout(moveTimer); 
         if (bEnableThumbDescription == 1) {
            getElem(objDescriptionDiv).innerHTML = prPhotoeDescription[CURRENT_THUMB_INDEX - 1]; 
            }
         if (bEnableCurrentCount == 1) {
            getElem(objCounterDiv).innerHTML = CURRENT_THUMB_INDEX + "/" + iNumOfPhotos; 
            }
         }
      }; 
   function addAnEvent(_obj, _eventName, _functionName) {
      if (window.addEventListener) {
         _obj.addEventListener(_eventName, _functionName, false); 
         }
      else {
         _obj.attachEvent("on" + _eventName, _functionName); 
         }
      }; 
   function getElem(_elemID) {
      return document.getElementById(_elemID); 
      }; 
   };


function scrollPhotoClick(imgUrl)
      {

       if(imgUrl!="")
       { 

         document.getElementById("SlideshowImg").src=imgUrl;	
         
         document.getElementById("SlideshowImg").style.width="318px";
         document.getElementById("SlideshowImg").style.height="200px";
              document.getElementById("SlideshowImg").style.marginLeft="0px";

       
       }
       if(imgUrl=="Image/noImageBig.jpg")
       {
         document.getElementById("SlideshowImg").style.width="250px";
         document.getElementById("SlideshowImg").style.height="150px";
         document.getElementById("SlideshowImg").style.marginLeft="10px";
         }
      }