// Random code String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,""); } String.prototype.ltrim = function() { return this.replace(/^\s+/,""); } String.prototype.rtrim = function() { return this.replace(/\s+$/,""); } // Namespace the FirstFolio code FF = {}; // Variables FF.overrides = ['/partnering-services/systems/', 'http://www.eChoice.com.au', 'http://www.newloan.com.au', 'http://www.firstfolio.connectnow.com.au', 'http://www.ffproperty.com.au', '/partnering-services/partner-login/', '/?ACT=10']; FF.setup = function() { $(document).ready(function() { FF.setupMenu(); FF.setupNavigation(); FF.setupSearchBar(); FF.setupContent(); FF.externalLinks(); FF.cufon(); FF.setupFooterSearch(); FF.CustomScrollBars.setup(); FF.setupNewsTickers(); }); } FF.setupHome = function() { $(document).ready(function() { FF.setupMenu(); FF.setupHomeMenu(); FF.preloadImages(); FF.setupSearchBar(); FF.externalLinks(); FF.cufonHome(); FF.setupFooterSearch(); FF.setupNewsTickers(); }); }; FF.setupMenu = function() { // Assign attribute so when menu is displayed again, we know which menu item to apply the 'current-page' class jQuery('#menu-active a.current-page').attr('current_page', 'true'); jQuery('#menu-control').toggle( function() { jQuery('#menu-control img').attr('src', '/media/img/menu/menu_show.jpg'); jQuery('#menu').hide('slide', {'direction': 'left' }); jQuery('#menu-active a.current-page').hide('scale', {'percent': 0}, 150); jQuery('#menu-active a.current-page').removeClass('current-page'); }, function() { jQuery('#menu-control img').attr('src', '/media/img/menu/menu_hide.jpg'); jQuery('#menu').show('slide', { 'direction': 'left' }); jQuery('#menu-active a.active').show('scale', { 'percent': 100 }, 500); jQuery('#menu-active a[current_page=true]').show('scale', {'percent': 100}, 150) jQuery('#menu-active a[current_page=true]').addClass('current-page'); }); jQuery('#customers, #investors-shareholders, #partnering-service, #our-brands, #contact-us').mouseenter(function() { FF.showMenuItem(jQuery('#' + jQuery(this).attr('id') + '-active')); }); jQuery('#customers, #investors-shareholders, #partnering-service, #our-brands, #contact-us').mouseleave(function() { jQuery('#menu-active a').removeClass('active'); jQuery('#home #menu div').removeClass('active'); }); jQuery('#customers-active, #investors-shareholders-active, #partnering-service-active, #our-brands-active, #contact-us-active').mouseleave(function() { if($(this).attr('class').indexOf('current-page') == -1) { FF.hideMenuItem(jQuery(this)); } }); }; FF.isOverride = function(url) { for(i=0; i= 0) { return true; } } return false; } FF.setupNavigation = function() { // Turn off auto-scroll as JS is handling the nav jQuery('#navigation').css('overflow', 'hidden'); // Setup control for showing and hiding left nav jQuery('#navigation-control').toggle(function() { jQuery('#navigation-control img').attr('src', '/media/img/navigation/navigation_show.jpg'); jQuery('#navigation').hide('slide', { 'direction': 'up' }); }, function() { jQuery('#navigation-control img').attr('src', '/media/img/navigation/navigation_hide.jpg'); jQuery('#navigation').show('slide', { 'direction': 'up' }); }); // Setup accordion bahaviour for tertiary navigation - http://www.i-marco.nl/weblog/jquery-accordion-menu/ jQuery('#navigation ul').hide(); /** * Take the root elements and disable their links, copying their links to their child list * * This seemed like a good idea at the time but in hindsight, I don't think it works * * jQuery('#navigation ul').each(function() { jQuery(this).prepend('
  • '+ jQuery(this).prev().html() +' Overview
  • '); jQuery(this).prev().attr('href', '#show-sub-menu'); });*/ // Setup up AJAX loading of content behaviour jQuery('#navigation a').click(function(event) { if(FF.isOverride(jQuery(this).attr('href'))) { return true; } if(jQuery(this).attr('href').indexOf('#') != -1) { return false; } event.preventDefault(); // See if we've clicked on a link to expand to tertiary level navigation var checkElement = jQuery(this).next(); if((checkElement.is('ul')) && (checkElement.is(':visible'))) { return false; } if((checkElement.is('ul')) && (!checkElement.is(':visible'))) { jQuery('#navigation li ul:visible').slideUp('fast'); checkElement.slideDown('fast'); return false; } // Hide content, show loading FF.CustomScrollBars.hideContent(); FF.hideFeatureContent(); jQuery('#navigation a').removeClass('current'); jQuery(this).addClass('current'); jQuery.get(jQuery(this).attr('href'), { dt: new Date().getTime() }, function(data) { var htmlAsString = data.replace(/[\n\r]*/g, ''); // Use regex to get title, secondary title and content as the below code doesn't work in IE7 and IE6 var re = new RegExp('(.*?)', 'im'); title = re.exec(htmlAsString)[1]; var re = new RegExp('(.*?)', 'im'); secondary_title = re.exec(htmlAsString)[1]; // Blank paragraph is to provide a buffer from the bottom of the content area var re = new RegExp('
    (.*?)
    ( )*( )*', 'im'); main_content = re.exec(htmlAsString)[1] + '

     

    '; var re = new RegExp('(.*?)', 'im'); feature_panel = re.exec(htmlAsString)[1]; /* * This code works in Firefox 3.5, IE8 and Safari 4 but not in IE7. Must be something to do with * innnerHTML and not creating the child nodes correctly? * *jQuery('body').append(''); title = jQuery('#hidden-content-container #second-line').html(); secondary_title = jQuery('#hidden-content-container #first-line').html(); html_content = jQuery('#hidden-content-container #content').html(); jQuery('#hidden-content-container').remove(); */ document.title = 'Firstfolio - '+ title; jQuery('#first-line').html(secondary_title); jQuery('#second-line').html(title); FF.CustomScrollBars.loadContent(main_content); FF.loadFeatureContent(feature_panel); FF.cufon(); }); return false; }); // Hide loading box until it's needed jQuery('#content-loader').fadeOut(); // If a sub-menu item is selected, reveal it jQuery('#navigation ul a.current').parent().parent().slideDown(''); // If we've landed on a page that has a tertiary nav, reveal it if(jQuery('#navigation a.current').parent().find('ul').length != 0) { // Put a slight delay in so user notices the movement and identifies tertiary nav with the current page setTimeout("jQuery('#navigation a.current').parent().find('ul').slideDown('slow')", 750); } }; FF.setupSearchBar = function() { jQuery('#search').focus(function() { if(jQuery(this).val() == ' enter search keyword') jQuery(this).val(''); }); jQuery('#search').blur(function() { if(jQuery(this).val() == '') { jQuery(this).val(' enter search keyword'); } }); }; FF.hideMenuItem = function(element) { if(element.attr('class') == 'active') { return; } element.addClass('hidden'); element.hide(); }; FF.showMenuItem = function(element) { if(element.attr('class') == 'active') { return; } element.removeClass('hidden'); element.show(); }; FF.setupFooterSearch = function() { jQuery('#who').change(function() { jQuery('#looking-for option').hide(); css_class = jQuery('#who option:selected').attr('value'); jQuery('#looking-for option.'+ css_class).show(); }); jQuery('#looking-for').change(function() { a_href = jQuery('#looking-for option:selected').attr('value'); FF.goToLink(a_href); }); } FF.setupHomeMenu = function() { $('#menu div').click(function() { id = '#' + $(this).attr('id').substring(0, ($(this).attr('id').indexOf('-active'))); window.location = $(id).attr('href'); }); }; FF.externalLinks = function() { jQuery('#menu a[rel="external"], #menu-active a[rel="external"]').click(function(event) { event.preventDefault(); window.open(jQuery(this).attr('href')); return false; }); } FF.formValidation = function(theID) { jQuery(document).ready(function() { jQuery.metadata.setType("attr", "validate"); jQuery.validator.messages.required = ""; jQuery(theID).validate( { invalidHandler: function(e, validator) { var errors = validator.numberOfInvalids(); if (errors) { var message = errors == 1 ? 'You missed 1 field. It has been highlighted below' : 'You missed ' + errors + ' fields. They have been highlighted below'; jQuery("#errors-summary span").html(message); jQuery("#errors-summary").show(); } else { jQuery("#errors-summary").hide(); } } }); }); } FF.cufon = function() { Cufon.replace('#content-headings h1 span'); Cufon.replace('#page-title'); Cufon.replace('#features h2'); } FF.cufonHome = function() { Cufon.replace('#content h1'); } FF.setupLoginForm = function() { // If an item is selected, show form, otherwise hide altogether if(jQuery('#login-select select option:selected').val() != '') { jQuery('#'+ jQuery('#login-select select option:selected').val()).fadeIn(); } jQuery('#login-select select').bind('change', function() { jQuery('.stylin-form').hide(); jQuery('#'+jQuery('#login-select select option:selected').val()).fadeIn('slow'); }); }; FF.hideFeatureContent = function() { jQuery('#features').hide(); } FF.loadFeatureContent = function(html_content) { if(jQuery('#features').html() != html_content) { jQuery('#features').html(html_content); if(html_content.indexOf('news-feed') > -1) { if(FF.FeatureNews != null && FF.FeatureNews != undefined) { FF.FeatureNews.destruct(); FF.FeatureNews = null; } FF.setupNewsTickers(); } } jQuery('#features').fadeIn(); }; FF.internetBankingForm = function() { jQuery(document).ready(function() { jQuery('#internet-banking-selector').bind('submit', function(event) { if(jQuery('input[name="internetbanking-selection"]:checked').length == 0) { alert('Please choose which internet banking service you\'d like to access'); return false; } a_href = jQuery('input[name="internetbanking-selection"]:checked').val(); FF.goToLink(a_href); event.preventDefault(); return false; }); }); } FF.goToLink = function(a_href) { if(a_href.indexOf('http') != -1) { start_index = window.location.href.indexOf('://') + 3; end_index = window.location.href.substring(start_index).indexOf('/'); base_url = window.location.href.substring(start_index, end_index + start_index); if(a_href.indexOf(base_url) == -1) { win = window.open(a_href); win.focus(); return false; } } window.location = a_href; return false; } FF.setupContent = function() { $('#content-container').append('
     
    '); $('#content-container').append('
     
    '); } FF.setupNewsTickers = function() { if(FF.FeatureNews == null || FF.FeatureNews == undefined) { FF.FeatureNews = new NewsTicker('#news-feed', '1.35em'); } if(FF.FooterNews == null || FF.FooterNews == undefined) { FF.FooterNews = new NewsTicker('#footer-news-feed', '1em'); } } FF.preloadImages = function() { jQuery.preloadCssImages(); } NewsTicker = function(id, margin_top) { if(jQuery(id).length == 0) { return false; } this.id = id; this.margin_top = margin_top; this.ticker = jQuery(this.id); var that = this; this.construct = function(id) { //start the ticker this.animator(this.ticker.children(':first')); //set mouseenter this.ticker.mouseenter(function() { //stop current animation that.ticker.children().stop(); }); //set mouseleave this.ticker.mouseleave(function() { //resume animation that.animator(that.ticker.children(':first')); }); } this.nextArticle = function() { try { this.animator(this.ticker.children(':first').parent().children(':first')); } catch(e) { this.destruct(); } } this.animator = function(currentItem) { //work out new anim duration var distance = currentItem.height(); duration = (distance + parseInt(currentItem.css("marginTop"))) / 0.025; //animate the first child of the ticker currentItem.animate({ marginTop: -distance }, duration, "linear", function() { //move current item to the bottom that.ticker.append(currentItem.css("marginTop", that.margin_top)); setTimeout(function() { that.nextArticle(); }, 4000); }); } this.destruct = function() { this.nextArticle = function() {}; }, this.construct(); }; FF.CustomScrollBars = { ui: { handle: jQuery("#content-slider"), value: 100 }, setup: function() { // Remove auto overflow as JS is handling content area jQuery('#content').css('overflow', 'hidden'); jQuery('#close-content').click(function() { jQuery('#content-wrapper').hide(); }); FF.CustomScrollBars.construct(); // Display jQuery("#content-slider").fadeIn(); jQuery("#close-content").fadeIn(); }, construct: function() { // Slider jQuery("#content-slider").slider( { animate: true, orientation: 'vertical', change: FF.CustomScrollBars.change, slide: FF.CustomScrollBars.slide, value: 100 }); // Mousewheel jQuery('#content').bind('mousewheel', function(event, delta) { var dir = delta > 0 ? 1 : -1, vel = Math.abs(delta); change = Math.floor(dir * 10 * vel); FF.CustomScrollBars.ui.value += change; if(FF.CustomScrollBars.ui.value < 0) { FF.CustomScrollBars.ui.value = 0; } if(FF.CustomScrollBars.ui.value > 100) { FF.CustomScrollBars.ui.value = 100; } FF.CustomScrollBars.slide({}, FF.CustomScrollBars.ui); $('#content-slider').slider('value', FF.CustomScrollBars.ui.value); return false; }); }, destruct: function() { jQuery('#content').unbind('mousewheel'); jQuery("#content-slider").slider('destroy'); }, hideContent: function() { jQuery('#content-wrapper').hide(); jQuery('#content-loader').fadeIn(); FF.CustomScrollBars.destruct(); }, loadContent: function(html_content) { jQuery('#content-loader').fadeOut(); jQuery('#content-container #content').html(html_content); FF.CustomScrollBars.construct(); jQuery('#content-wrapper').fadeIn(); }, change: function(e, ui) { /*FF.CustomScrollBars.ui = ui; var maxScroll = jQuery("#content").attr("scrollHeight") - jQuery("#content").height(); jQuery("#content").animate({ scrollTop: (100-ui.value) * (maxScroll / 100) }, 250);*/ }, slide: function(e, ui) { FF.CustomScrollBars.ui = ui; var maxScroll = jQuery("#content").attr("scrollHeight") - jQuery("#content").height(); jQuery("#content").attr({ scrollTop: (100-ui.value) * (maxScroll / 100) }); } };