/* Page Layout Behaviours by Chris Constandinou, chris@constantology.com, please give me credit if you use this, good karma to you regardless... */ // You don't need to touch this... var ieWidthStyle = "narrow"; // run function on load and resize if ( got.dom ) window.onload = init; if ( got.dom && got.ie && widthStyle == "liquid") window.onresize = resize; // All browser sniffing is limited to this init() function only. function init() { var regex = /\s*/g; var url = window.location.href; url = url.substring( url.lastIndexOf( "/" ) + 1, url.lastIndexOf( "." ) ); // declare objects // Hack for Netscape 6 & 7 which won't create an array object if you use getElementsByTagName if ( got.ns ) var oBody = document.getElementsByTagName( "body" ); else var oBody = document.getElementsByTagName( "body" )[0]; var oMasterWpr = document.getElementById( "master-wpr" ); var oTitle = document.getElementById( "title" ); var oHeading = document.getElementById( "heading" ); var oNavigation = document.getElementById( "navigation" ); var oCopy = document.getElementById( "copy" ); var oTable = document.getElementsByTagName( "table" ); var oQuote = document.getElementById( "q" ); var oRight = document.getElementById( "right" ); var oFacts = document.getElementById( "facts" ); if ( got.ie && widthStyle == "liquid" ) resize(); else oBody.className = alignStyle + " " + widthStyle; if ( oRight.innerHTML == "" ) columnStyle = "l-c"; oMasterWpr.className = columnStyle; // Change text heading for image heading oTitle.getElementsByTagName( "a" )[0].innerHTML += '' + oTitle.getElementsByTagName( '; oHeading.getElementsByTagName( "h1" )[0].innerHTML += '' + oHeading.getElementsByTagName( '; if ( oNavigation != null ) { expandNav( oNavigation, url ); highlightNav( oNavigation, url ); } if ( oTable != null ) formatDataTables( oTable ); if ( oQuote != null ) createQuote( oQuote, oCopy ); if ( oRight != null && !got.ns ) { addMediaViewer( oRight ); makePopUps( oRight ); } if ( oFacts != null ) { oFacts.className = "hide"; if ( !got.ns ) createDidyouknow( oFacts, oRight ); } } function resize() { // declare objects var oBody = document.getElementsByTagName( "body" )[0]; oBody.clientWidth < 1024 ? ieWidthStyle = "narrow" : ieWidthStyle = "wide"; oBody.className = alignStyle + " " + ieWidthStyle; } // JavaScript Functions function openWindow( url, winName, winAttr ) { var popup = window.open( url, winName, winAttr ); } // DOM Mutator methods function expandNav( obj, url ) { var oItem = obj.getElementsByTagName( "li" ); for ( i = 0 ; i < oItem.length ; i++ ) { if ( oItem[i].getElementsByTagName( "a" )[0].href.indexOf( url + ".shtml" ) > -1 ) { if ( oItem[i].getElementsByTagName( "ul" )[0] != null ) oItem[i].getElementsByTagName( "ul" )[0].style.display = "block"; else oItem[i].parentNode.style.display = "block"; } } } function highlightNav( obj, url ) { var oAnchor = obj.getElementsByTagName( "a" ); for ( i = 0 ; i < oAnchor.length ; i++ ) if ( oAnchor[i].href.indexOf( url + ".shtml" ) > -1 && oAnchor[i].href.indexOf( "/pub/iag/index.shtml" ) < 0 ) oAnchor[i].className = "selected"; } function formatDataTables( obj ) { // make all tables with class="data-table" have interlaced rows if ( obj != null ) { for ( i = 0 ; i < obj.length ; i++ ) { // if the table is well formatted and has a tbody tag then do this if ( obj[i].className.indexOf( "data-table" ) > -1 ) { tbodyTemp = obj[i].getElementsByTagName( "tbody" ); if ( tbodyTemp != null ) { for ( j = 0 ; j < tbodyTemp.length ; j++ ) { trTemp = tbodyTemp[j].getElementsByTagName( "tr" ); for ( k = 0 ; k < trTemp.length ; k++ ) if ( k % 2 != 0 ) trTemp[k].className += "even"; } } // if this the table is not well formated do this else { trTemp = obj[i].getElementsByTagName( "tr" ); // starts at (j = 1) because I'm assuming that the first row is a table header (th) tag for ( j = 1 ; j < trTemp.length ; j++ ) if ( j % 2 == 0 ) trTemp[j].className += "even"; } } } } } function createQuote( oQuote, oCopy ) { var elQuote = document.createElement( "div" ); elQuote.id = "quote"; elQuote.innerHTML = "

" + oQuote.innerHTML + "

"; var oParagraph = oCopy.getElementsByTagName( "p" ); if ( oParagraph.length > 3 ) { var i = parseInt( oParagraph.length / 3 ); if ( oParagraph[i].className == "top" ) i++; if ( i > 1 ) oCopy.insertBefore( elQuote, oParagraph[i] ); else if ( i == 1 ) oCopy.insertBefore( elQuote, oParagraph[2] ); else oCopy.insertBefore( elQuote, oCopy.firstChild ); } else oCopy.insertBefore( elQuote, oCopy.firstChild ); } function addMediaViewer( obj ) { var anchorList = obj.getElementsByTagName( "a" ); var regex = /media\/.*\.(gif|jpg|png)$/i; for ( var i = 0 ; i < anchorList.length ; i++ ) if ( regex.test( anchorList[i].href ) ) anchorList[i].href = "mediaviewer.html?media=" + anchorList[i].href + "?title=" + anchorList[i].title; } var imagePopupAttr = "location=0,menubar=0,personalbar=0,resizable=1,scrollbars=1,status=0,titlebar=0,toolbar=0,height=500,width=700"; function makePopUps( obj ) { var anchorList = obj.getElementsByTagName( "a" ); var aRel, aHref; for ( var i = 0 ; i < anchorList.length ; i++ ) { if ( anchorList[i].rel.indexOf( "popup" ) > -1 ) { aRel = anchorList[i].rel.split( "|" ); if ( anchorList[i].rel.indexOf( "image" ) > -1 ) anchorList[i].setAttribute( "href", "javascript:openWindow( '" + anchorList[i].href + "','" + aRel[1] + "','" + imagePopupAttr + "' );" ); else anchorList[i].setAttribute( "href", "javascript:openWindow( '" + anchorList[i].href + "','" + aRel[1] + "','" + aRel[2] + "' );" ); anchorList[i].target = ""; } } }