/** * Body Onload functions */ function init_page() { initPopups(); } window.onload = init_page; function setActiveFeature(title) { var anchors = document.getElementsByTagName("a"); for (var i = 0; i < anchors.length; i++) { if (anchors[i].innerHTML.toLowerCase() == title.toLowerCase()) { anchors[i].className = "active"; } } } /** * These functions will convert all anchor tags with the classname "popupImage" * and add an onclick event to load the image specified in the href attribute * in a new window with the window size set proportionate to the image size. */ function initPopups() { var anchors = document.getElementsByTagName("a"); for (var i = 0; i < anchors.length; i++) { if (anchors[i].className == "popupImage") { anchors[i].onclick = popupImage; if (anchors[i].title) var label = anchors[i].title; else var label = "Click to see a larger image"; anchors[i].innerHTML += "
" + label; } } } /* var arrTemp = self.location.href.split("?"); var picUrl = (arrTemp.length>0)?arrTemp[1]:""; var NS = (navigator.appName=="Netscape")?true:false; function FitPic() { iWidth = (NS) ? window.innerWidth : document.body.clientWidth; iHeight = (NS) ? window.innerHeight : document.body.clientHeight; iWidth = document.images[0].width - iWidth; iHeight = document.images[0].height - iHeight; window.resizeBy(iWidth, iHeight); self.focus(); } */ function popupImage() { // load the popup image into a temporary Image structure // once it's finished loading, open the window with the correct Image dimensions // pulled from the Image structure var img = new Image(); img.src = this.href; // This must take time to load because it doesn't get the image width the first time... if (!img.src) img.src = this.href; var width = img.width+25; var height = img.height+25; if (width <= 50) width = 600; if (height <= 50) height = 500; var NS = (navigator.appName=="Netscape")?true:false; iWidth = (NS) ? window.innerWidth : document.body.clientWidth; iHeight = (NS) ? window.innerHeight : document.body.clientHeight; if (width > iWidth) width = iWidth; if (height > iHeight) height = iHeight; var imgWin = window.open(img.src, "popup", "width="+width+",height="+height+"+,resizable=true"); imgWin.focus(); // with (imgWin.document) // { // writeln('Image'); // writeln(''); // writeln(''); // title = img.src.substring(img.src.lastIndexOf("/")+1); // close(); // } // prevent the hyperlink from doing its default behaviour return false; } /* function popupImage() { // for now - delete this when you have it working. return true; // load the popup image into a temporary Image structure // once it's finished loading, open the window with the correct Image dimensions // pulled from the Image structure var imgWin = window.open('about:blank','imgWin','width=10, height=10, left=100, top=100'); with (imgWin.document) { writeln('Loading...'); writeln(''); writeln(''); close(); } var img = new Image(); img.onload = function() { //fitPic(imgWin, img); sizeImgWin(imgWin, img); }; img.src = this.href; // prevent the hyperlink from doing its default behaviour return false; } function sizeImgWin(win, img) { var new_w = img.width; var new_h = img.height; alert("Inner Width: " + win.innerWidth); alert("Offset: " + win.document.body.offsetWidth); var old_w = win.innerWidth || win.document.body.offsetWidth; var old_h = win.innerHeight || win.document.body.offsetHeight; //alert(new_w); if (!new_w) { new_w = old_w; } if (!new_h) { new_h = old_h; } new_w -= old_w; new_h -= old_h; //alert(new_w); win.resizeBy(new_w,new_h); win.document.title = img.src.substring(img.src.lastIndexOf("/")+1); var pic = win.document.getElementById('pic'); pic.src = img.src; pic.style.display = 'block'; sw=screen.width; sh=screen.height; var leftPos=((sw-new_w)/2)-100; // Exactly centered. var topPos=((sh-new_h)/2)-(100+(((sh-new_h)/2)*0.1)); // Centered, then moved up 10% win.moveTo(leftPos, topPos); self.focus(); } function fitPic(win, img) { // Get current window size if (win.innerWidth){ iWidth = win.innerWidth; iHeight = win.innerHeight; }else{ iWidth = win.document.body.clientWidth; iHeight = win.document.body.clientHeight; } var pic = win.document.getElementById('pic'); pic.src = img.src; pic.style.display = 'block'; // get Image window size iWidth = win.document.images[0].width;// - iWidth; iHeight = win.document.images[0].height;// - iHeight; win.resizeBy(iWidth, iHeight); win.document.title = img.src.substring(img.src.lastIndexOf("/")+1); } */