// Check Browser CSS Compatibility // alert(document.compatMode); // Supress BOM Script Errors function errorsuppressor(){ return true; } window.onerror = errorsuppressor; // Multiple Onload Utility function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { oldonload(); func(); } } } // Insert-after Function function insertAfter(newElement, targetElement) { var parent = targetElement.parentNode; if (parent.lastChild == targetElement) { parent.appendChild(newElement); } else { parent.insertBefore(newElement, targetElement.nextSibling); } } // Load Flash Navigation function prepNav() { document.getElementById("wrapper").style.height = "100%"; document.getElementById("header").style.height = "100%"; if (!document.getElementById("aspnetForm")) return false; document.getElementById("aspnetForm").style.height = "100%"; } addLoadEvent(prepNav); function newsize(y) { // alert(y); document.getElementById("mnav").style.height = y + "px"; // D'oh! You can't access links in FireFox with Flash that is positioned over // other elements so we have to dynamically set z-index // A hack, but it works if (y > 300) { document.getElementById("header").style.zIndex = 1; } else { document.getElementById("header").style.zIndex = ""; } } // Main Navigation (we use SWFObject 2) function createNav() { var flashvars = {xmlPath: "data/navigation.xml", searchBox: 1, TabCount: 3, selectItem: "home", searchpage: "http://dp.duffandphelps.com/search/results.aspx?k="}; var params = {scale: "noscale", salign: "tl", quality: "high", wmode: "transparent", menu: "false"}; var attributes = {}; swfobject.embedSWF("templates/default/flash/navigation.swf", "mnav", "100%", "100%", "8", "media/flash/app_expressinstall.swf", flashvars, params, attributes); } addLoadEvent(createNav); // Load Flash headers on appropriate pages function createFlash() { if (!document.getElementById("imgsrc")) return false; var movie = document.getElementsByTagName("body")[0].getAttribute("id"); var flashvars = {}; var params = {menu: "false", wmode: "opaque", base: "media/default/flash"}; var attributes = {style: "margin: 36px 0 18px"}; swfobject.embedSWF("templates/default/flash/" + movie + ".swf", "imgsrc", "538", "170", "8.0.0", "media/flash/app_expressinstall.swf", flashvars, params, attributes); } addLoadEvent(createFlash); // Where do you fit function myfitFlash() { if (!document.getElementById("myfit")) return false; var flashvars = {}; var params = {menu: "false", wmode: "opaque", base: "media/default/flash"}; var attributes = {}; swfobject.embedSWF("templates/default/flash/myfit-calculator.swf", "myfit", "485", "351", "8", "media/flash/app_expressinstall.swf", flashvars, params, attributes); } addLoadEvent(myfitFlash); // Career Areas function careerAreaFlash() { var movie = document.getElementsByTagName("body")[0].getAttribute("id"); if (movie == "careers-corporate" || movie == "careers-experienced" || movie == "careers-university") { var flashvars = {}; var params = {menu: "false", wmode: "opaque", base: "media/default/flash"}; var attributes = {}; swfobject.embedSWF("templates/default/flash/career-areas.swf", "mediacontent", "480", "340", "8.0.0", "media/flash/app_expressinstall.swf", flashvars, params, attributes); } } addLoadEvent(careerAreaFlash); // Locations // Dynamically resize and set zindex on locations map (same as nav above) function resizeSWF(newHeight, newZ) { newHeight += "px"; document.getElementById("loc-content").style.zIndex = newZ; document.getElementById("loc-content").style.height = newHeight; // alert(newHeight + ", " + newZ); } // Load map through SWFObject function locationsFlash() { if (!document.getElementById("locations")) return false; var flashvars = {}; var params = {menu: "false", wmode: "transparent", base: "media/default/flash", salign: "t", bgcolor: "#ffffff"}; var attributes = {}; swfobject.embedSWF("templates/default/flash/locations-map.swf", "loc-content", "483", "239", "8.0.0", "media/flash/app_expressinstall.swf", flashvars, params, attributes); } addLoadEvent(locationsFlash); //Prep Locations function prepLocations() { if (!document.getElementById("locations")) return false; var parent_div = document.getElementById("copy"); if (parent_div.hasChildNodes()) { // Get all children of node var child_div = parent_div.childNodes; // Loop through the children for(var n=0; n < child_div.length; n++) { if(child_div[n].style) { child_div[n].style.display = "none"; } } } document.getElementById("start").style.display = "block"; } addLoadEvent(prepLocations); function divSwap(element,container){ var div = document.getElementById(container); var switchDiv = document.getElementById(element); var nodeList = div.childNodes; if(switchDiv.style.display == "none"){ for(i=0; i < nodeList.length; i++){ if(nodeList.item(i).nodeName == "DIV"){ nodeList.item(i).style.display = "none"; } } switchDiv.style.display = "block"; } return; } // Toggle, Show/Hide Element(s) function toggleElement(val, obj){ if(document.getElementById(val).style.display == "none") { obj.className = "expandon"; document.getElementById(val).style.display = "block"; } else { obj.className = "expand"; document.getElementById(val).style.display = "none"; } } // Global Pop-up (parse through DOM, if viewpage class exists, append event) function newWinLinks() { for (var i=0; i < document.links.length; i++) { if (document.links[i].className == "newwindow") { document.links[i].onclick = displayNewWindow; } } for (var i=0; i < document.links.length; i++) { if (document.links[i].className == "videowindow") { document.links[i].onclick = displayVideo; } } } addLoadEvent(newWinLinks); function displayNewWindow() { var featureWindow = window.open(this.href,"win", 'toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=yes,resizable=1,top=100,left=100,width=800,height=600'); featureWindow.focus(); return false; } function displayVideo() { var videoWindow = window.open(this.href,"win", 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=0,top=200,left=200,width=350,height=350'); videoWindow.focus(); return false; } // History Links function pageJump(pageto) { window.history.go(pageto); return false; } function addOptionTitle() { // Add title attribute to all select boxes for usability if (!document.getElementsByTagName("select")) return false; var list = document.getElementsByTagName("select"); for(var i = 0; i < list.length; i++) { var option = list[i].getElementsByTagName("option") for(var j = 0; j < option.length; j++) { option[j].setAttribute("title", option[j].text); } } } addLoadEvent(addOptionTitle); // Custom usability enhancment for datagrid. May need a little extra work, but okay for now function gridRowClick() { // But first, a little object detection. If browser does not understand, exit immediately if (!document.getElementsByTagName) return false; var get_grid = document.getElementsByTagName("table"); // Loop through tables in page... for (var i=0; i < get_grid.length; i++) { // ... if table has class value of "datagrid" then... if (get_grid[i].className == "datagrid") { var rows = get_grid[i].getElementsByTagName("tr"); /* ... look for rows that contain a class of "odd" or "even" (We dont want to accidentaly append onclick to rows in th or thead section or tfoot sections if they exist)... */ for (j=0; j < rows.length; j++) { if (rows[j].className == "even" || rows[j].className == "odd") { /* Add onmouse event for ghetto IE6 rows[j].onmouseover = function(){ this.style.backgroundColor = "#8f979d"; this.onmouseout= function(){ this.style.backgroundColor = ""; }; } */ // ...append pointer style via this script (in event scripting is disabled)... rows[j].style.cursor = "pointer"; // ...append onclick event to each row... rows[j].onclick = function() { // but first, get href from anchor in first cell... var cell = this.getElementsByTagName("td")[0]; if (cell.getElementsByTagName("a").length > 0) { var link = cell.getElementsByTagName("a")[0]; // Now append function with proper link...Done! Next! location.href = link.getAttribute("href"); } } } } // Get value of summary attribute var summary = get_grid[i].getAttribute("summary"); // Append summary as "title" attribute to table get_grid[i].setAttribute("title", summary); /* If you want to append an element to the bottom of the page with the summary instead just uncomment var para = document.createElement("p"); var em = document.createElement("em"); var strtxt = document.createTextNode("Table summary: " + summary); para.appendChild(em); em.appendChild(strtxt); insertAfter(para, get_grid[i]); */ } } } // Fire-off function with Multiple Onload addLoadEvent(gridRowClick); // Show country select navigation function showCountry(obj,evt) { document.getElementById("country-select").getElementsByTagName("ul")[0].style.display = "block"; // Eleminate event bubbling var e=(evt)?evt:window.event; if (window.event) { e.cancelBubble = true; } else { e.stopPropagation(); } } // Hide country select navigation function hideCountry () { document.getElementById("country-select").getElementsByTagName("ul")[0].style.display = ""; } // Append show/hide country select navigation to appropriate elements function changeCountry() { // Body var body = document.body; body.onclick = function() { hideCountry(); } // First list element in country-select var countrylink = document.getElementById("country-select"); var navigation = document.getElementById("mnav"); var list = countrylink.getElementsByTagName("li")[0]; list.onclick = function(event) { showCountry(this, event); } navigation.onclick = function() { hideCountry(); } } addLoadEvent(changeCountry); // Flash Image Replacement addLoadEvent(setIFRFont);