/* SUBSTANDARD BROWSER DETECTION */ var IEDetect = {} IEDetect.isIE6 = false; IEDetect.isIE7 = false; IEDetect.init = function() { IEDetect.isIE6 = $.browser.msie && $.browser.version.charAt(0) == 6; IEDetect.isIE7 = $.browser.msie && $.browser.version.charAt(0) == 7; } /* SCROLLING NAV */ var Scroller = {} Scroller.CLASS_SELECTED = 'selected'; Scroller.init = function() { Scroller.goToPage(location.hash, false); $('ul#nav li').not('ul#nav li ul li').mouseover( function() { $(this).addClass('hover'); } ); $('ul#nav li').not('ul#nav li ul li').mouseout( function() { $(this).removeClass('hover'); } ); $('ul#nav li a').click(Scroller.clickHandler); $('h1 a').click(Scroller.clickHandler); //$("a[href^=#]").click(function() { Scroller.goToPage(this.attr('href'), true); } ) $("a[href^=#]").not(".decor-info").not(".product-info").not(".material-info").click(Scroller.clickHandler); } Scroller.clickHandler = function(e) { e.preventDefault(); var hash = $(this).attr('href'); Scroller.goToPage(hash, true); DecorInfo.hideDecorInfo(); ProductInfo.hideProductInfo(); } Scroller.goToPage = function(hash, animate) { var p = $(hash).position(); var l = p.left; var t = p.top; if(animate == true) { $('#pages').animate ( {left:-l, top:-t}, 2000, 'easeInOutQuart', function() { //location.hash = hash; // we don;t use location.hash as it causes jumping around when you reload. location.href = location.href.slice(0, location.href.indexOf('#')) + hash; Scroller.assignSelectedState(); ColourChange.adjustColoursForPage(hash); } ); } else { $('#pages').css('left', -l); $('#pages').css('top', -t); location.href = location.href.slice(0, location.href.indexOf('#')) + hash; Scroller.assignSelectedState(); ColourChange.adjustColoursForPage(hash); } } Scroller.assignSelectedState = function() { var thisLink = $("a[href=" + location.hash + "]"); $('ul#nav li').removeClass(Scroller.CLASS_SELECTED); thisLink.parent().parent().parent().addClass(Scroller.CLASS_SELECTED); thisLink.parent().addClass(Scroller.CLASS_SELECTED); } /* COLOUR CHANGES */ var ColourChange = {} ColourChange.FLOURISH_MARKUP = ''; ColourChange.init = function() { $('body').append(ColourChange.FLOURISH_MARKUP); } ColourChange.adjustColoursForPage = function (pageid) { $(pageid).delay(200, function() { var h2Color = $(pageid).find('h2').css('color'); if(h2Color.indexOf('rgb') != -1) { h2Color = ColourChange.rgbToHex(h2Color); } if(h2Color.charAt(0) == '#') { // IE7 adds a hash to the start of the color value... h2Color = h2Color.slice(1); } // IE7 converst the hex code to lowercase... h2Color = h2Color.toUpperCase(); $('li.' + Scroller.CLASS_SELECTED).css('border-color', '#' + h2Color); $('#flourish').removeClass('xF89D57'); $('#flourish').removeClass('xFFDE6C'); $('#flourish').removeClass('xD4DB90'); $('#flourish').removeClass('xF9C6DC'); $('#flourish').removeClass('xFBB040'); $('#flourish').removeClass('xC8B18B'); $('#flourish').removeClass('xCAAAD1'); $('#flourish').removeClass('xF48887'); $('#flourish').removeClass('xE5E76C'); $('#flourish').removeClass('x8BCFBA'); $('#flourish').removeClass('xEE80B3'); $('#flourish').addClass('x' + h2Color); }); } ColourChange.rgbToHex = function(rgb) { rgb = rgb.slice(rgb.indexOf('(') + 1, rgb.indexOf(')')).split(','); return ColourChange.toHex(rgb[0]) + ColourChange.toHex(rgb[1]) + ColourChange.toHex(rgb[2]); } ColourChange.toHex = function(n) { if (n==null) return "00"; n=parseInt(n); if (n==0 || isNaN(n)) return "00"; n=Math.max(0,n); n=Math.min(n,255); n=Math.round(n); return "0123456789ABCDEF".charAt((n-n%16)/16) + "0123456789ABCDEF".charAt(n%16); } /* DROPSHADOWS */ var Shadows = {}; Shadows.init = function() { $('ul#nav').shadow('img/bkg/shadow-18px.png', 18); $('ul#nav li ul').each( function(i) { $(this).shadow('img/bkg/shadow-18px.png', 18); } ) //$('table').each( function(i) { $(this).shadow('img/bkg/table-shadow-18px.png', 18); } ) } /* PRODUCT INFO TABLE */ var ProductInfo = {}; ProductInfo.init = function() { ProductInfo.moveProductInfo(); $('a.product-info').attr('href', 'javascript:void(0);') $('a.product-info').click(ProductInfo.showProductInfo); $('div#pages').mousedown(ProductInfo.hideProductInfo); } ProductInfo.moveProductInfo = function() { //takes the product table and just moves it elsewhere in the markup so our clever javascript will work; var table = $('table#product-info'); $('table#product-info').remove(); $('body').append(table); } ProductInfo.showProductInfo = function(e) { if(IEDetect.isIE6) { $('table#product-info').css('display', 'block'); } else { $('table#product-info').fadeIn(600); } } ProductInfo.hideProductInfo = function(e) { if(IEDetect.isIE6) { $('table#product-info').css('display', 'none'); } else { $('table#product-info').fadeOut(600); } } /* */ var MaterialInfo = {}; MaterialInfo.init = function() { MaterialInfo.moveMaterialInfo(); $('a.material-info').attr('href', 'javascript:void(0);') $('a.material-info').click(MaterialInfo.showMaterialInfo); $('div#pages').mousedown(MaterialInfo.hideMaterialInfo); } MaterialInfo.moveMaterialInfo = function() { //takes the decor table and just moves it elsewhere in the markup so our clever javascript will work; var div = $('div#material-info'); $('div#material-info').remove(); $('body').append(div); } MaterialInfo.showMaterialInfo = function(e) { if(IEDetect.isIE6) { $('div#material-info').css('display', 'block'); } else { $('div#material-info').fadeIn(600); } } MaterialInfo.hideMaterialInfo = function(e) { if(IEDetect.isIE6) { $('div#material-info').css('display', 'none'); } else { $('div#material-info').fadeOut(600); } } /* DECOR INFO TABLE */ var DecorInfo = {}; DecorInfo.init = function() { DecorInfo.moveDecorInfo(); $('a.decor-info').attr('href', 'javascript:void(0);') $('a.decor-info').click(DecorInfo.showDecorInfo); $('div#pages').mousedown(DecorInfo.hideDecorInfo); } DecorInfo.moveDecorInfo = function() { //takes the decor table and just moves it elsewhere in the markup so our clever javascript will work; var table = $('table#decor-info'); $('table#decor-info').remove(); $('body').append(table); } DecorInfo.showDecorInfo = function(e) { if(IEDetect.isIE6) { $('table#decor-info').css('display', 'block'); } else { $('table#decor-info').fadeIn(600); } } DecorInfo.hideDecorInfo = function(e) { if(IEDetect.isIE6) { $('table#decor-info').css('display', 'none'); } else { $('table#decor-info').fadeOut(600); } } if(location.hash.length == 0) { location.hash = '#home'; } function init() { IEDetect.init(); Scroller.init(); Shadows.init(); ProductInfo.init(); DecorInfo.init(); MaterialInfo.init(); ColourChange.init(); $("#accordion").accordion({ collapsible: true, active:false }); } $(document).ready( init );