function setNavText(newText){ if(document.getElementById('nav_text')){ document.getElementById('nav_text').innerHTML = newText; } } function clearNavText(){ if(document.getElementById('nav_text')){ document.getElementById('nav_text').innerHTML = ' '; } } function getNavText(elemID){ var strNavText = ' '; switch(elemID){ case 'nav_filmmore': strNavText = 'transcript, further reading, film credits'; break; case 'nav_sfeature': strNavText = 'online poll, Q&A about the Third Reich, Nazi feature films, diary entries of Joseph Goebbels...'; break; case 'nav_peopleevents': strNavText = 'more about the people and events featured in the film'; break; case 'nav_gallery': strNavText = 'propaganda posters made for German and American civilian audiences'; break; case 'nav_timeline': strNavText = 'chronologies of World War II'; break; case 'nav_tguide': strNavText = 'how to use this site in your classroom'; break; case 'nav_amex': strNavText = 'American Experience home'; break; case 'nav_home': strNavText = 'The Man Behind Hitler home'; break; } return strNavText; } function initNavLinks() { if (!document.getElementsByTagName || !document.getElementById('main_nav')) return; var anchors = document.getElementById('main_nav').getElementsByTagName('a'); for (var i = 0; i < anchors.length; i++) { var anchor = anchors[i]; if (anchor.getAttribute('href')){ // ignores named anchors anchor.onmouseover = function(){ try{ setNavText(getNavText(this.id)); }catch(e){ if(typeof debug=='function'){ debug(e); } } }; anchor.onmouseout = function(){ try{ clearNavText(); }catch(e){ if(typeof debug=='function'){ debug(e); } } }; } } } function initNavMaps() { if (!document.getElementsByTagName || !document.getElementById('main_Map')) return; var areas = document.getElementById('main_Map').getElementsByTagName('area'); for (var i = 0; i < areas.length; i++) { var area = areas[i]; if (area.getAttribute('href')){ // ignores named anchors area.onmouseover = function(){ try{ setNavText(getNavText(this.id)); }catch(e){ if(typeof debug=='function'){ debug(e); } } }; area.onmouseout = function(){ try{ clearNavText(); }catch(e){ if(typeof debug=='function'){ debug(e); } } }; } } } // for preloading images and rollovers var aryLoadImg = new Array(); var ncImgOver = '_over'; var ncClsRoll = 'roll'; function loadImg(imgFile, imgType){ var i = aryLoadImg.length; aryLoadImg[i] = new Image(); aryLoadImg[i].src = imgFile + '.' + imgType; return i; } function swapImg(imgId, imgSrc){ if(document.images){ document.images[imgId].src = imgSrc; } } function initImages() { if (!document.getElementsByTagName) return; var aryImages = document.getElementsByTagName('img'); var regex_roll = new RegExp('\\b'+ncClsRoll+'\\b'); for (var i = 0; i < aryImages.length; i++) { var thisImg = aryImages[i]; // this is used for single image roll overs if(thisImg.className.match(regex_roll)){ var imgFile = thisImg.src.substr(0, thisImg.src.length-4); var imgType = thisImg.src.substr(thisImg.src.length-3, thisImg.src.length); var roll_idx = loadImg(imgFile+ncImgOver, imgType); thisImg.roll_idx = roll_idx; thisImg.onmouseover = function(){ try { swapImg( this.id, aryLoadImg[this.roll_idx].src ); }catch(e){ if(typeof debug=='function'){ debug(e); } } }; thisImg.onmouseout = function(){ try { var regex_ncImgOver = new RegExp(ncImgOver+'\.'); swapImg( this.id, this.src.replace(regex_ncImgOver, '.') ); }catch(e){ if(typeof debug=='function'){ debug(e); } } }; } } } function swap(elemID, imgSrc){ if(document.images){ document.images[elemID].src = imgSrc; } } window.onload=function(){ initNavLinks(); initNavMaps(); initImages(); };