/* * This script assumes that the file which has been loaded is actually a "driver" * for the real photos. The URL of this page should be in the form * ?. I.e. photo page is specified as a "search" * string in the URL of the page. */ var index_file = unescape(location.search).substr(1); // Lose ? at start //alert('File: ' + index_file); ////// ua.ja is incorporated into this script to avoid having to load it explicitly // ua.js - Detect Browser // Requires JavaScript 1.1 // work around bug in xpcdom Mozilla 0.9.1 window.saveNavigator = window.navigator; function detectBrowser() { var oldOnError = window.onerror; var element = null; //window.onerror = defaultOnError; navigator.OS = ''; navigator.version = 0; navigator.org = ''; navigator.family = ''; var platform; if (typeof(window.navigator.platform) != 'undefined') { platform = window.navigator.platform.toLowerCase(); if (platform.indexOf('win') != -1) navigator.OS = 'win'; else if (platform.indexOf('mac') != -1) navigator.OS = 'mac'; else if (platform.indexOf('unix') != -1 || platform.indexOf('linux') != -1 || platform.indexOf('sun') != -1) navigator.OS = 'nix'; } var i = 0; var ua = window.navigator.userAgent.toLowerCase(); if (ua.indexOf('opera') != -1) { i = ua.indexOf('opera'); navigator.family = 'opera'; navigator.org = 'opera'; navigator.version = parseFloat('0' + ua.substr(i+6), 10); } else if ((i = ua.indexOf('msie')) != -1) { navigator.org = 'microsoft'; navigator.version = parseFloat('0' + ua.substr(i+5), 10); if (navigator.version < 4) navigator.family = 'ie3'; else navigator.family = 'ie4' } else if (typeof(window.controllers) != 'undefined' && typeof(window.locationbar) != 'undefined') { i = ua.lastIndexOf('/') navigator.version = parseFloat('0' + ua.substr(i+1), 10); navigator.family = 'gecko'; if (ua.indexOf('netscape') != -1) navigator.org = 'netscape'; else if (ua.indexOf('compuserve') != -1) navigator.org = 'compuserve'; else navigator.org = 'mozilla'; } else if ((ua.indexOf('mozilla') !=-1) && (ua.indexOf('spoofer')==-1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera')==-1)&& (ua.indexOf('webtv')==-1) && (ua.indexOf('hotjava')==-1)) { var is_major = parseFloat(navigator.appVersion); if (is_major < 4) navigator.version = is_major; else { i = ua.lastIndexOf('/') navigator.version = parseFloat('0' + ua.substr(i+1), 10); } navigator.org = 'netscape'; navigator.family = 'nn' + parseInt(navigator.appVersion); } else if ((i = ua.indexOf('aol')) != -1 ) { // aol navigator.family = 'aol'; navigator.org = 'aol'; navigator.version = parseFloat('0' + ua.substr(i+4), 10); } navigator.DOMCORE1 = (typeof(document.getElementsByTagName) != 'undefined' && typeof(document.createElement) != 'undefined'); navigator.DOMCORE2 = (navigator.DOMCORE1 && typeof(document.getElementById) != 'undefined' && typeof(document.createElementNS) != 'undefined'); navigator.DOMHTML = (navigator.DOMCORE1 && typeof(document.getElementById) != 'undefined'); navigator.DOMCSS1 = ( (navigator.family == 'gecko') || (navigator.family == 'ie4') ); navigator.DOMCSS2 = false; if (navigator.DOMCORE1) { element = document.createElement('p'); navigator.DOMCSS2 = (typeof(element.style) == 'object'); } navigator.DOMEVENTS = (typeof(document.createEvent) != 'undefined'); window.onerror = oldOnError; } detectBrowser(); ////// End of ua.js /* * This script assumes the Netscape Practical Browser Sniffer (ua.js) has been * previously loaded and defined navigator properties for browser capabilities * * Note: for convenience, "is_netscape" will be defined to mean "is Netscape Navigator 4" */ var is_netscape = (navigator.family == 'nn4'); var is_gecko = (navigator.family == 'gecko'); var first_photo_link = null, next_photo_link = null, prev_photo_link = null; var original_title = "Photos"; var Photo, Index, Control; var index_links, index_images; // Collections of links amd images in the index var photo_timer = 0; var temp_window, delay_for_index, total_delay, max_delay; /* There screen is divided into three areas in this architecture: the "index" area which * displays the thumbnails, the "photo" area which displays the enlarged photos * and the "control" area which displays the control buttons. * */ /* photo_view * * View a photo in a fullscreen window. The photo is sized to fit the window but with * the aspect ratio preserved. Click on the large image to close the window and return * to the index. * * This function is designed to be called from the tag using onclick="return photo_view(this)" * * The logic depends on the fact that Thumber embeds a thumbnail, with the correct * aspect ratio, within the tag. If the browser cannot provide access to the * embedded image info then the photo will still be displayed but it will not fit * in the window nicely. In this case scrollbars will be provided. * */ function photo_view(anchor_obj) { // Link/Anchor object passed as parameter var thumb_obj, ref, pic_width=0, pic_height=0, obj_index; var avail_height, avail_width, ratio, actual_height=0, actual_width=0; var photo_html; if (anchor_obj == null) // Shouldn't normally happen, but... { alert('null'); next_photo_link = null; prev_photo_link = null; return true; // Continue link processing as normal } /* Find the index of our link in the document.links collection */ for (obj_index=0;obj_index=index_links.length) // Shouldn't normally happen, but... { alert('Link not found'); next_photo_link = null; prev_photo_link = null; return true; // Continue link processing as normal } /* Note the next link (if any) */ next_photo_link = ((obj_index+1)=0) ? index_links[obj_index-1] : null ; /* Find the URL of the photo to display and check it is a picture */ ref = anchor_obj.href; if (ref.toLowerCase().indexOf(".jpg")<0 && ref.toLowerCase().indexOf(".jpeg")<0) { alert('Not an image -- href: ' + ref); return true; // Continue link processing as normal } /* Find the caption text */ /* NOTE: this hack depends crucially on the layout of tags used by Thumber * such that the text is in the fourth tag (which is ) following the link * and only works on MSIE (where document.all is defined). Fortunately it isn't * the end of the world if we don't have a caption */ caption_text = document.all ? document.all(anchor_obj.sourceIndex + 4).innerText : ''; if ( (!caption_text) && is_gecko) { /* Alternative mechanism for gecko * Find the FONT tag corresponding to this link * Walk down its children looking for text and concatenate it */ var text_coll=IndexDiv.getElementsByTagName('FONT')[obj_index].childNodes; var i; for (i=0;i tag is found ) { thumb_obj = anchor_obj.children.tags("IMG")[0]; /* Get the photo aspect ratio */ pic_width = thumb_obj.width; pic_height = thumb_obj.height; } /* If that didn't work, try the Netscape way: find the document.images * element corresponding to the provided document.link element */ if ( (! (pic_width && pic_height)) // Not got height and width yet && document.images && document.links) { if (obj_index < index_images.length) { thumb_obj = index_images[obj_index]; /* Get the photo aspect ratio */ pic_width = thumb_obj.width; pic_height = thumb_obj.height; } } // alert("photo_view(" + ref + "," + pic_width + "," + pic_height + ")"); // Just to see we got here /* Open the photo area */ hide_index(); show_photo(); /* Get the window size to scale the image correctly Netsape uses window.inner..., MS uses document.body.client... */ avail_height = (window.innerHeight || (document.body.clientHeight - 15)) - 65; avail_width = (window.innerWidth || document.body.clientWidth) - 40; /* Work out how big the photo can be and still be in the correct aspect ratio */ if (pic_width && pic_height) { ratio = Math.min(avail_height/pic_height, avail_width/pic_width); actual_height = ratio * pic_height; actual_width = ratio * pic_width; /* alert("avail = (" + avail_height + "," + avail_width + ")" + " picture = (" + pic_height + "," + pic_width + ")" + " ratio = " + ratio + " actual = (" + actual_height + "," + actual_width + ")" ); */ } /* Display the photo */ photo_html = // '' + caption_text + '\n' '\n' + '0) ? ' height=' + actual_height : '') + ((actual_height>0) ? ' width=' + actual_width : '') + ' alt="Click to close"' + '>' + ''; // alert(photo_html); if (is_netscape) { Photo.document.open(); Photo.document.write(photo_html); Photo.document.close(); } else { PhotoDiv.innerHTML = photo_html; } if (caption_text) window.defaultStatus = caption_text; if (caption_text) window.status = caption_text; if (caption_text) document.title = caption_text; return false; // Do not follow link } /* doc_click_test * * Document event handler, This needs to determine if the user * clicked on a photo link in which case call photo_view. * Otherwise allow default processing. * * This is completely different for Netscape and IE */ function doc_click_test(evt) { if (is_netscape) { /* Event passed as parameter. * evt.target is the link, if any. */ // alert (evt.target + " " + evt.target.href); if (evt.target && evt.target.href) {return photo_view(evt.target)} else return true; } else if (is_gecko) { var link; /* Event passed as parameter. * evt.target may be link or image */ link = evt.target; if (link.tagName == 'IMG') {link = link.parentNode;} if (link.tagName != 'A') return true; /* Call photo_view and stop propagation if necessary */ if (! photo_view(link) ) { evt.stopPropagation(); evt.preventDefault(); } return true; } else { // alert (window.event.srcElement + " " + window.event.srcElement.tagName); /* Handler can be called anywhere on page. Check if this is an image. */ if (IndexDiv.contains(window.event.srcElement) && window.event.srcElement.tagName == "IMG" && window.event.srcElement.parentElement.tagName == "A") { return photo_view(window.event.srcElement.parentElement); } return true; } } /* next_photo_loop & start_photo_loop * * Scroll through all photos */ var photo_loop_interval = 10; // Seconds function next_photo_loop() { photo_timer = 0; if (next_photo_show()) /* Check that we have another photo to display and that the photo window has not been closed */ { photo_timer = setTimeout("next_photo_loop()",photo_loop_interval*1000); } } function start_photo_loop(link) { if (link == null) { /* * If a photo is currently displayed, start the loop at the next photo. * Otherwise start with the first photo. */ if ( (Photo.visibility == "show") || (Photo.visibility == "visible")) { next_photo_loop(); // Displays next photo and starts timer } else { photo_view(first_photo_link) photo_timer = setTimeout("next_photo_loop()",photo_loop_interval*1000); } } else { photo_view(link) photo_timer = setTimeout("next_photo_loop()",photo_loop_interval*1000); } } /* next_photo_show & next_photo * * Display next photo */ function next_photo_show() { /* Check that we have another photo to display and that the photo window has not been closed */ if (next_photo_link != null) { photo_view(next_photo_link); return true; // Photo shown } else { close_photo(); return false; // No more photos } } function next_photo() { next_photo_show(); } // Do not return a value /* prev_photo_show & prev_photo * * Display previous photo */ function prev_photo_show() { /* Check that we have another photo to display and that the photo window has not been closed */ if (prev_photo_link != null) { photo_view(prev_photo_link); return true; // Photo shown } else { close_photo(); return false; // No more photos } } function prev_photo() { prev_photo_show(); } // Do not return a value /* doc_dblclick_test * * Double click event handlers DO NOT WORK in Netscape or IE! * * Document event handler, This needs to determine if the user * double clicked on a photo link in which case call start_photo_loop. * Otherwise allow default processing. * * This is completely different for Netscape and IE */ function doc_dblclick_test(evt) { alert ('Double Click'); if (is_netscape) { /* Event passed as parameter. * evt.target is the link, if any. */ // alert (evt.target + " " + evt.target.href); if (evt.target && evt.target.href) { start_photo_loop(evt.target); return false; } else return true; } else { // alert (window.event.srcElement + " " + window.event.srcElement.tagName); /* Handler can be called anywhere on page. Check if this is an image. */ if (window.event.srcElement.tagName == "IMG" && window.event.srcElement.parentElement.tagName == "A") { start_photo_loop(window.event.srcElement.parentElement); return false; } return true; } } /* key_test * * Event handler for keydown events in photo window * Page Down and Page Up events cause next/previous photo and are cancelled. * Other keys are allowed to be processed */ function key_test(evt) { var PageUp=33, PageDown=34, Enter=13, BS=8, Space=32; // Key codes // Event is ignored unless the photo window is visible if (is_netscape) { // alert ('Key : '+evt.which+Photo.visibility); if (Photo.visibility == "show") { if ( (evt.which == PageUp) || (evt.which == BS)) { prev_photo_show(); return false; } if ((evt.which == PageDown) || (evt.which == Enter) || (evt.which == Space)) { next_photo_show(); return false; } // If photo is visible then all other keys are ignored as they tend to cause the window to move around return false; } } else if (is_gecko) { // alert ('Key : '+evt.charCode+Photo.visibility); if (Photo.visibility == "visible") { if ( (evt.charCode == PageUp) || (evt.charCode == BS)) { prev_photo_show(); evt.stopPropagation(); evt.preventDefault(); return false; } if ((evt.charCode == PageDown) || (evt.charCode == Enter) || (evt.charCode == Space)) { next_photo_show(); evt.stopPropagation(); evt.preventDefault(); return false; } return true; } } else { // alert ('Key : '+window.event.keyCode); if (Photo.visibility == "visible") { if ((window.event.keyCode == PageUp) || (window.event.keyCode == BS)) { prev_photo_show(); window.event.returnValue = false; } if ((window.event.keyCode == PageDown) || (window.event.keyCode == Enter) || (window.event.keyCode == Space)) { next_photo_show(); window.event.returnValue = false; } } } return true } /* show_index hide_index show_photo hide_photo close_photo * * Show/hide areas */ function show_index() { Index.display = "block"; Index.visibility = "visible"; document.title = original_title; window.defaultStatus = "Click on a thumbnail to see the picture full size"; Index.zIndex=100; } function hide_index() { Index.display = "none"; Index.visibility = "hidden"; Index.zIndex=1; } function show_photo() { Photo.display = "block"; Photo.visibility = "visible"; Photo.zIndex=100; } function hide_photo() { Photo.display = "none"; Photo.visibility = "hidden"; Photo.zIndex=1; } function close_photo() { if (photo_timer) clearTimeout(photo_timer); hide_photo(); show_index(); } /* complete_load * * This function loads the index and then completes initialisation */ function complete_load () { if (!index_file) { // Display error message if (is_netscape) { document.IndexDiv.document.write('

Please do not load this document directly

'); document.IndexDiv.document.close(); } else { IndexDiv.innerHTML='

Please do not load this document directly

'; } return; } if (is_netscape) { /* In Netscape the index can be loaded using a tag with the SRC parameter */ document.IndexDiv.document.write(''); document.IndexDiv.document.close(); /* init_handlers() is called when the layer has loaded */ } else if (is_gecko) { IndexDiv = document.getElementById('IndexDiv'); /* In IE there is no SRC parameter on the
tag so the index is loaded into a new window and the contents read out */ temp_window = window.open(index_file,null, "height=1,width=1,channelmode=no,directories=no,fullscreen=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,toolbar=no"); /* We need the index_file to have been loaded before we continue, * although the images it contains (the thumbnails) do not need to * have loaded. Unfortunately there is no variable to tell us whether * it is ready so we wait for a while */ delay_for_index = 500; total_delay=0; max_delay=60000; setTimeout("finish_ie_complete_load();",delay_for_index); } else { var bgColor, fgColor, linkColor, vlinkColor; // IndexDiv.innerHTML=''; // IndexDiv.innerHTML=''; /* In IE there is no SRC parameter on the
tag so the index is loaded into a new window and the contents read out */ temp_window = window.open(index_file,null, "height=1,width=1,channelmode=no,directories=no,fullscreen=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,toolbar=no"); /* We need the index_file to have been loaded before we continue, * although the images it contains (the thumbnails) do not need to * have loaded. Unfortunately there is no variable to tell us whether * it is ready so we wait for a while */ delay_for_index = 500; total_delay=0; max_delay=60000; setTimeout("finish_ie_complete_load();",delay_for_index); } } function finish_ie_complete_load () { /* We need the index_file to have been loaded before we continue, * although the images it contains (the thumbnails) do not need to * have loaded. Unfortunately there is no variable to tell us whether * it is ready so we check several things: * 1) the tag is present -- unfortunately IE is too clever and if it has seen it assumes the file should end with
* 2) readyState is "complete" -- this means the file AND ALL ITS IMAGES have loaded -- which can take a long time * 3) the HTML contains " at the end * 4) just in case all else fails -- if the maximum delay has occurred just continue */ var temp_html; total_delay += delay_for_index; temp_html = temp_window.document.body.innerHTML; /* contents of body */ //alert(temp_window.document.readyState); if ( (total_delay < max_delay) && ( (temp_html.toLowerCase().indexOf("") < 0) || ( (temp_window.document.readyState != "complete") && (temp_html.toLowerCase().indexOf("