/** * imgBox() * Populates and displays the imgBox element, setting up the previous and next buttons for easy browsing * @param string targetEl The ID of the target imgBox element * @param string imgName The filename of the target image * @param string path The path to the folder containing the target image * @param string gName The Name of the gallery * @param object prev The object that is the previous one to the image beign displayed within the DOM * @param object next The object that is the next one to display * @access public * @return void **/ function imgBox(targetEl,imgName,path,gName,prev,next){ try { if (checkElementExists(targetEl)) { // Set the Gallery Title if (checkElementExists(targetEl+'Title')) { document.getElementById(targetEl+'Title').innerHTML = gName+imgName; } // Set the previous button if (checkElementExists(targetEl+'Prev')) { // The RIGHT way. Only IE does not like setAttribute with event handlers :( //document.getElementById(targetEl+'Prev').setAttribute('onclick',"imgBox('imgBox','"+prev.id+"','"+path+"','"+gName+"',getPreviousSibling(document.getElementById('"+prev.id+"'),true),getNextSibling(document.getElementById('"+prev.id+"'),true) )"); // The IE friendly way document.getElementById(targetEl+'Prev').onclick = function() { imgBox('imgBox',prev.id,path,gName,getPreviousSibling(document.getElementById(prev.id),true),getNextSibling(document.getElementById(prev.id),true) ); }; } // Set the next button if (checkElementExists(targetEl+'Next')) { // The RIGHT way. Only IE does not like setAttribute with event handlers :( // document.getElementById(targetEl+'Next').setAttribute('onclick',"imgBox('imgBox','"+next.id+"','"+path+"','"+gName+"',getPreviousSibling(document.getElementById('"+next.id+"'),true),getNextSibling(document.getElementById('"+next.id+"'),true))"); // The IE friendly way document.getElementById(targetEl+'Next').onclick = function() { imgBox('imgBox',next.id,path,gName,getPreviousSibling(document.getElementById(next.id),true),getNextSibling(document.getElementById(next.id),true) ); }; } // Set the full image if (checkElementExists(targetEl+'Img')) { document.getElementById(targetEl+'Img').setAttribute('src',path+imgName); document.getElementById(targetEl+'Img').setAttribute('alt',imgName); } // Ensure the image box is displayed setStyleById(targetEl,'display','block'); // Set the focus on the target element document.location.hash = targetEl+"Nav"; } } catch(err) { handleException(err); } }