﻿// JScript File

google.load("prototype", "1.6.0.2");

google.setOnLoadCallback(function() {

    if (($$('.hidImageType')[0] != null) && $$('.hidImageType')[0].value == 'IMAGE') {

        var photoScrollerImageColl = $$('.divImageScrollerInternal ul li a');

        photoScrollerImageColl.each(function(photoScrollerImage) {

            Event.observe(photoScrollerImage, 'click', photoScrollerImageSelect.bindAsEventListener(this, photoScrollerImage));
            photoScrollerImage.onclick = function() { return false; };

        });

        if ($$('.divImageScrollerInternal')[0] != null) {

            var imageCollCount = $$('.divImageScrollerInternal ul li').length;
            var scrollerWidth = 128 * imageCollCount;
            
            $$('.divImageScrollerInternal')[0].setStyle({ 'width' : scrollerWidth + 'px' });
        }
    
    }

});

photoScrollerImageSelect = function(e, item) {

    clearSelectedImages();

    var photoImageItem = item.childElements()[0];

    if (photoImageItem != null) {
        $$('.imgDisplay')[0].writeAttribute({ 'src' : item.readAttribute('href') });
        $$('.imgDisplay')[0].writeAttribute({ 'alt' : photoImageItem.readAttribute('alt') });
        $$('.imgDisplay')[0].writeAttribute({ 'title' : photoImageItem.readAttribute('title') });
        
        photoImageItem.setStyle({ 'borderColor' : 'red' });
    }

}

clearSelectedImages = function() {

    var photoScrollerImageColl = $$('.divImageScrollerInternal ul li a img');

    photoScrollerImageColl.each(function(photoScrollerImage) {

        photoScrollerImage.setStyle({ 'borderColor' : 'black' });

    });

}
