/********************************************************************************** * Author: David Millar (www.rTraction.com) * * Date: January. 4, 2007 * * Purpose: To adjust the header background based on the mainpage/sub sections * * * ********************************************************************************** * Revision 1.0: create a script that adjusts the header based on the current url * **********************************************************************************/ // Save the current url var url = window.document.location.toString(); // Grab header so we can swap the background image var header = document.getElementById('header'); // Determine what site section we are in var section = ""; if( url.indexOf( "/about-us/" ) > -1 ) { section = "about-us"; } else if( url.indexOf( "/getting-settled/" ) > -1 ) { section = "getting-settled"; } else if( url.indexOf( "/living/" ) > -1 ) { section = "living"; } else if( url.indexOf( "/working/" ) > -1 ) { section = "working"; } else if( url.indexOf( "/learning/" ) > -1 ) { section = "learning"; } else if( url.indexOf( "/government-services/" ) > -1 ) { section = "government-services"; } // Select a random image based on the specific sub-header or the main header switch( section ) { case "about-us": if( headerSectionAboutUs != null ) { var randomImage = Math.floor( Math.random() * headerSectionAboutUs.length ); header.style.background = "url(/images/layout/sub-headers/" + section + "/" + headerSectionAboutUs[randomImage] + ") no-repeat"; } break; case "getting-settled": if( headerSectionGettingSettled != null ) { var randomImage = Math.floor( Math.random() * headerSectionGettingSettled.length ); header.style.background = "url(/images/layout/sub-headers/" + section + "/" + headerSectionGettingSettled[randomImage] + ") no-repeat"; } break; case "living": if( headerSectionLiving != null ) { var randomImage = Math.floor( Math.random() * headerSectionLiving.length ); header.style.background = "url(/images/layout/sub-headers/" + section + "/" + headerSectionLiving[randomImage] + ") no-repeat"; } break; case "working": if( headerSectionWorking != null ) { var randomImage = Math.floor( Math.random() * headerSectionWorking.length ); header.style.background = "url(/images/layout/sub-headers/" + section + "/" + headerSectionWorking[randomImage] + ") no-repeat"; } break; case "learning": if( headerSectionLearning != null ) { var randomImage = Math.floor( Math.random() * headerSectionLearning.length ); header.style.background = "url(/images/layout/sub-headers/" + section + "/" + headerSectionLearning[randomImage] + ") no-repeat"; } break; case "government-services": if( headerSectionGovernmentServices != null ) { var randomImage = Math.floor( Math.random() * headerSectionGovernmentServices.length ); header.style.background = "url(/images/layout/sub-headers/" + section + "/" + headerSectionGovernmentServices[randomImage] + ") no-repeat"; } break; default: if( headerSectionDefault != null ) { var randomImage = Math.floor( Math.random() * headerSectionDefault.length ); header.style.background = "url(/images/layout/headers/" + headerSectionDefault[randomImage] + ") no-repeat"; } break; }