var currentButton; var currentPanel; var speed = 666; var resizeCounter = 0; $(window).resize(function() { makeFullScreen('bg', true); }); function loadBackgroundImage(location) { if (location === undefined) { var backgrounds = getBackgroundImages(); loadRandomImage('bg', backgrounds); } else { loadImage('bg', location) } makeFullScreen('bg', true); } function centerPrimaryNavigation() { //center primary navigation by adding padding to the first and last buttons //get the elements var primaryNavigation = document.getElementById("primaryNavigation"); var banner = document.getElementById("banner"); //get the element widths var totalWidth = banner.offsetWidth; var topNavWidth = primaryNavigation.offsetWidth; //get the first and last button var lastButton = primaryNavigation.lastChild.firstChild; var firstButton = primaryNavigation.firstChild.firstChild; var currentPadding; //get the padding from the stylesheet if (window.getComputedStyle) { currentPadding = parseInt(window.getComputedStyle(firstButton, null).paddingLeft); } else { currentPadding = parseInt(firstButton.currentStyle.paddingLeft); } //calculate the new padding var newPadding = (totalWidth / 2) - (topNavWidth / 2) + currentPadding; //apply padding to the first and last buttons firstButton.style.paddingLeft = newPadding + "px"; lastButton.style.paddingRight = newPadding + "px"; //highlight the selected button $("#topNav a#id").addClass("selected"); } function createAccordion() { var button = $("#accordion .button"); var panel = $("#accordion .panel"); var activePanel = $("#panel"); var panelButton = $("#panel .panelButton"); var activePanelButton = $("#id"); var activePanelSelectedCategory = $("#id"); activePanel.show(); activePanelButton.addClass("selected"); activePanelSelectedCategory.addClass("selected"); button.click(function(){ var previousPanel = window.currentPanel; var previousButton = window.currentButton; window.currentButton = $(this); window.currentPanel = window.currentButton.next(); button.removeClass("selected"); currentButton.addClass("selected"); //animate the panels if (previousPanel != undefined) { previousPanel.animate( {height:'hide'}, {duration: speed, queue:false} ); } currentPanel.animate( { height:'toggle' }, { duration: speed } ) }) panelButton.click(function(){ button.removeClass("selected"); panelButton.removeClass("selected"); currentButton.addClass("selected"); }) } function getBackgroundImages() { var backgrounds = [];backgrounds[0] = '../images/pageElements/bg/home.jpg'; return backgrounds;} function loadImage(id, img) { document.images[id].src = img; $('#' + id).fadeIn(speed * 2); } function loadRandomImage(id, imgs) { var index = Math.floor(Math.random() * imgs.length); document.images[id].src = imgs[index]; $('#' + id).fadeIn(speed * 2); } function makeFullScreen(id, holdPosition) { var object = document.getElementById(id); var holdPosition = (holdPosition === undefined) ? false : ""; var h = object.offsetHeight; var w = object.offsetWidth; var imageRatio = w / h; var maxHeight; if (typeof(window.innerWidth) == 'number') { //Non-IE maxHeight = window.innerHeight; } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) { //IE 6+ in 'standards compliant mode' maxHeight = document.documentElement.clientHeight; } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) { //IE 4 compatible maxHeight = document.body.clientHeight; } maxHeight -= object.offsetTop; var maxWidth = document.body.offsetWidth; var windowRatio = maxWidth / maxHeight; if (imageRatio > windowRatio) { var newWidth = w * maxHeight / h; object.style.height = maxHeight + "px"; object.style.width = newWidth + "px"; object.style.overflowX = "hidden"; object.style.left = (newWidth / -2) + (maxWidth / 2) + "px"; } else { var newHeight = h * maxWidth / w; object.style.height = Math.floor(newHeight) + "px"; object.style.width = maxWidth + "px"; object.style.left = 0 + "px"; } object.style.display = "block"; if (holdPosition === false) { object.style.position = "absolute"; object.style.top = "0px"; object.style.zIndex = "10000"; } } function scrollToLocation(id, buffer) { (buffer === undefined) ? buffer = 0 : ""; var location = id.offset().top - buffer; var speed; if (location <= 0) { //scroll back to the top location = 0; //calculate the speed from the last location speed = (window.previousId != undefined) ? window.previousId.offset().top - buffer : 1500; } else { speed = location; } $(document).scrollTo(location, speed, {axis:'y', onAfter: function(){ (previousId) ? previousId.removeClass("selectedLocation") : ""; id.addClass("selectedLocation"); window.previousId = id; }}); }