﻿// JScript File
function MM_swapBGImgRestore(obj) { //v3.0
  obj.style.backgroundImage='url(images/m1.gif)';
  return;
}
function MM_swapBGImage(obj) { //v3.0
  obj.style.backgroundImage='url(images/m1r.gif)';
  return;
}

function showImage(target,imageUrl){
    target.src=imageUrl;
    return;
}

function doMenuNav(page){   
    window.location.href = page;
    return;
}


var bPhotoGalleryInit = false;
var iPhotoIndex = 1;
var NUM_PHOTOS = 32;

var galleryThumbImages = new Array();
var galleryImages = new Array();
    
function initPhotoGallery(){
    if (bPhotoGalleryInit) 
    {
        return;
    }
    var iIndex;

    
    for (iIndex=1;iIndex <= NUM_PHOTOS; iIndex++){
        galleryThumbImages[iIndex] = 'img' + iIndex + '_thmb.jpg';
        galleryImages[iIndex] = 'img' + iIndex + '.jpg';
    }
    
    bPhotoGalleryInit = true;
    
    navGallery(-1);
    
    return;
}

function fred(){
    alert('f');
}

function navGallery(direction){
    /*  
        direction   0 = left, 
                    1 = right,
                    -1 = init
    */
    var bNav = false;
    var iLoopIndex;
    
    
    if (direction == 0 && iPhotoIndex > 1){
        iPhotoIndex--;
        bNav = true;
    }else if (direction == 1 && iPhotoIndex <= (NUM_PHOTOS - 3)){
        iPhotoIndex++;
      
        bNav = true;
    }else if(direction == -1){
        iPhotoIndex = 1;
        bNav = true;
    }
    
    if (bNav){
        for (iLoopIndex = 1;iLoopIndex <= 3 ; iLoopIndex++){        
            document.all['imgBar' + iLoopIndex].style.backgroundImage='url(images/' + galleryThumbImages[(iPhotoIndex - 1) + iLoopIndex] + ')';
            //document.all['imgBar' + iLoopIndex].onclick = showImage(document.all['imgMain'],galleryImages[(iPhotoIndex - 1) + iLoopIndex] );
            addAttribute (document.all['imgBar' + iLoopIndex],'imageurl','images/' + galleryImages[(iPhotoIndex - 1) + iLoopIndex]);
            document.all['imgBar' + iLoopIndex].onclick = function () {doImageBarClick();};
        }
    }
    
    function doImageBarClick(){
       document.all['imgMain'].src = window.event.srcElement.attributes['imageurl'].value;
    }
    
    function addAttribute(element,attrib,value){
        var nnm = element.attributes;
        var namedItem = document.createAttribute(attrib);
        namedItem.value = value;
        nnm.setNamedItem(namedItem);

    }
    return;
}
