/* Collection Items - dynamically attaches events to each collection item within the results */

function displayItemPhoto(obj) {
    var img = document.getElementById('ctl00_cphContent_main_photo');
    var imgright = document.getElementById('ctl00_cphContent_right_photo');
    var image_wrap = document.getElementById('image_wrap');
    collection_photo = img.src
    if (img!=null && images!=null && image_wrap!=null && imgright!=null){
        img.src = images[obj.id]; 
        img.className = 'show';
        imgright.style.display = 'none';
        blendimage('ctl00_cphContent_right_photo','ctl00_cphContent_main_photo', images[obj.id],300);       
    }
}

function resetCollectionPhoto() {
    var img = document.getElementById('ctl00_cphContent_main_photo');
    var imgright = document.getElementById('ctl00_cphContent_right_photo');
    if (img!=null && collection_photo!=null){ 
        img.className = 'hidden';
        imgright.style.display = '';
    }
}

function applyEventsToCarousel() {
  var elementUL = document.getElementById('carousel');
  var elementsHyperLink= getElementByClass('item_img');
  var collectionCount = elementsHyperLink.length;
  
  if (elementUL!=null && elementsHyperLink!=null){
    for (counter = 0; counter < collectionCount; counter++)
        {
            elementsHyperLink[counter].onmouseover = function () { displayItemPhoto(this);}
            elementsHyperLink[counter].onmouseout = function () { resetCollectionPhoto(); }
        }
  }
}

addLoadEvent(applyEventsToCarousel);
