$('html').removeAttr('class');
$.platform = {};
var browserConfig = { init: function () { this.browser = this.searchString(this.dataBrowser) || 'An unknown browser'; this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || 'an unknown version'; this.OS = this.searchString(this.dataOS) || 'an unknown OS'; }, searchString: function (data) { for (var i = 0; i < data.length; i++) { var dataString = data[i].string; var dataProp = data[i].prop; this.versionSearchString = data[i].versionSearch || data[i].identity; if (dataString) { if (dataString.indexOf(data[i].subString) != -1) return data[i].identity; } else if (dataProp) return data[i].identity; } }, searchVersion: function (dataString) { var index = dataString.indexOf(this.versionSearchString); if (index == -1) return; return parseFloat(dataString.substring(index + this.versionSearchString.length + 1)); }, dataBrowser: [{ string: navigator.userAgent, subString: 'Chrome', identity: 'Chrome' }, { string: navigator.userAgent, subString: 'OmniWeb', versionSearch: 'OmniWeb', identity: 'OmniWeb' }, { string: navigator.vendor, subString: 'Apple', identity: 'Safari', versionSearch: 'Version' }, { prop: window.opera, identity: 'Opera' }, { string: navigator.vendor, subString: 'iCab', identity: 'iCab' }, { string: navigator.vendor, subString: 'KDE', identity: 'Konqueror' }, { string: navigator.userAgent, subString: 'Firefox', identity: 'Firefox' }, { string: navigator.vendor, subString: 'Camino', identity: 'Camino' }, { string: navigator.userAgent, subString: 'Netscape', identity: 'Netscape' }, { string: navigator.userAgent, subString: 'MSIE', identity: 'Explorer', versionSearch: 'MSIE' }, { string: navigator.userAgent, subString: 'Gecko', identity: 'Mozilla', versionSearch: 'rv' }, { string: navigator.userAgent, subString: 'Mozilla', identity: 'Netscape', versionSearch: 'Mozilla'}], dataOS: [{ string: navigator.platform, subString: 'Win', identity: 'Windows' }, { string: navigator.platform, subString: 'Mac', identity: 'Mac' }, { string: navigator.userAgent, subString: 'Android', identity: 'Android' }, { string: navigator.userAgent, subString: 'iPhone', identity: 'iPhone/iPod' }, { string: navigator.userAgent, subString: 'iPad', identity: 'iPad' }, { string: navigator.platform, subString: 'Linux', identity: 'Linux'}] }; var cLoad = '#loader'; var pLoad = 0; var iFrame = 0; var aVimeo = []; var cContainer = '#content'; var extLinks = []; var dataSource = []; var dTitles = []; var dCount = 0; var hCount = 0; var intval = ''; var currentLoc = window.location.href.replace('http://localhost', '').replace('http://www.linney.com', '').replace('http://dev.linney.com', ''); var fBrowser = 0; var vTooltip = 0; var vContinuous = 0; var xlLoc = 0; var pHeight = 340; var recruitmentID = 'recruitment-list'; var gDelay1 = 500; var gDelay2 = 1000; var gCounter = 0; var pTop = 370; var timeoutValue = 1000; var $navcontrol, $next, $previous; var initNav = 0; var tClass, loadURL, userOSAgent, userPlatform, sWidth, sHeight, vPortrait, vLandscape, winWidth, winHeight = 0; var filelinks = [/<link [^>]*href *= *"[^"]+\.css[^"]*(?="[^<]*>)/gi, /<script [^>]*src *= *"[^"]+\.js[^"]*(?="[^<]*>)/gi, /.*(href|src) *= *"/i]; var exclusionlinks = ['baisnbk-stylesheet.css', 'bembo-stylesheet.css', 'layout.css', 'site.css', 'large.css', 'feeds.css', 'jquery-1.6.min.js', 'jquery-1.6.2.min.js', 'collated-plugins.js', 'website.js', 'html5.js']; var addEvent = function (elem, type, eventHandle) { if (elem == null || elem == undefined) return; if (elem.addEventListener) { elem.addEventListener(type, eventHandle, false); } else if (elem.attachEvent) { elem.attachEvent("on" + type, eventHandle); } };

$(document).ready(function () {
    blogInited = false; applicationConfig(); initOverlay(0); formatLayout(); $('body').show(); var $body = $('body'), $wrapper = $('#wrapper'), $navigationwrapper = $('#navigation-wrapper'), $footerwrapper = $('#page-footer'), $parentpanel = $body.find('section[data-controller=panel]'), $panels = $body.find('article[data-parent=panel]'), $category = $body.attr('data-category'), $targetwidth = 960, $plainwidth = 0, $activePanels = [], currentIndex = 0, viewwidth = 0, blogshow = 0, $bloglayout = $('#blogtab-layout'), $blogbutton = $('#blogtab'), $twitter = $('#twitterscrape'), $blog = $('#blog-content'), $linneyBlog = $('#linney-tagged-content'); var nContainer = '#navigation-wrapper', nOffsetHeight = 0; switch ($.platform.OS) { case 'Windows': var uKeyboard = true; var uClick = true; var uTouch = false; break; case 'Mac': var uKeyboard = true; var uClick = true; var uTouch = false; break; case 'iPad': var uKeyboard = false; var uClick = true; var uTouch = true; $('body').attr('onorientationchange', 'updateOrientation();'); break; }

    window.History.Adapter.bind(window, "statechange", function () {
        var d = window.History.getState();
        if (d.data.blogState == "open") {
            blogshow = 0; actionBlog(false);
        } else {
            blogshow = 1; actionBlog(false);
        }
    });

    $navUtility = $('#navigation-utility');
    if (pType == 0 || pType == 2 || pType == 5 || pType == 6) {
        initNav = 1;
        var $navcontrollayout = $('<div/>', { 'id': 'content-nav-layout' }).appendTo(cContainer);


        var $navcontrol = $('<div/>', { 'id': 'content-nav' }).appendTo($navcontrollayout), $previous = $('<a/>', { 'id': 'previous-item', 'href': '#previous', 'class': 'arrow-left floatleft', 'title': 'Scroll to the previous item', 'text': '<' }).prependTo($navUtility), $next = $('<a/>', { 'id': 'next-item', 'href': '#next', 'class': 'arrow-right floatleft', 'title': 'Scroll to the next item', 'text': '>' }).prependTo($navUtility); $navcontrol.css({ 'width': $targetwidth + 'px' }); if (uKeyboard != false) { enableKeyboard(); } if (uClick != false) { $previous.click(function (e) { e.preventDefault(); if ($(this).hasClass('arrow-left')) { initLeft(); } }); $next.click(function (e) { e.preventDefault(); if ($(this).hasClass('arrow-right')) { initRight(); } }); } if (uTouch != false) { enableTouch(); }
    } if (pType == 1 || pType == 4 || pType == 7) {


        // create disabled nav:
        var $navcontrol = $('<div/>', { 'id': 'content-nav' }).appendTo($navcontrollayout), $previous = $('<span/>', { 'id': 'previous-item', 'class': 'arrow-left-disabled floatleft', 'text': '<' }).prependTo($navUtility), $next = $('<span/>', { 'id': 'next-item', 'class': 'arrow-right-disabled floatleft', 'text': '>' }).prependTo($navUtility); $navcontrol.css({ 'width': $targetwidth + 'px' });




        if (uKeyboard != false) { enableKeyboard(); }
    } if (pType == 0 || pType == 2) { calibrateInterface('All', 1, 1, 0); addEvent(window, 'resize', function () { if ($(window).width() != winWidth || $(window).height() != winHeight) { calibrateInterface('All', null, 1, 0); } }); } else if (pType == 1 || pType == 3 || pType == 4 || pType == 7) { calibrateInterface(null, null, 0, null); addEvent(window, 'resize', function () { if ($(window).width() != winWidth || $(window).height() != winHeight) { calibrateInterface(null, null, 0, null); } }); } else if (pType == 5) { calibrateInterface('All', 1, 1, 1); addEvent(window, 'resize', function () { if ($(window).width() != winWidth || $(window).height() != winHeight) { calibrateInterface('All', null, 1, 1); } }); } else if (pType == 6) { calibrateInterface('Contact', 1, 1, 0); addEvent(window, 'resize', function () { if ($(window).width() != winWidth || $(window).height() != winHeight) { calibrateInterface('Contact', null, 1, 0); } }); } initFeedTab(1); initOverlay(1); if (pType == 1 && initNav == 1) { loadLinks(loadURL, $previous, $next); } if (pType == 7 && initNav == 1) { lDataSetup(tClass, $previous, $next, 1); } if ($.platform.OS == 'iPad') { updateOrientation(); }
    function calibrateInterface(filter, init, type, style) { initSiteWrapper(); getBrowserSize(); var viewwidth = wWidth(); var viewwidth = ($(window).width() > $targetwidth) ? $(window).width() : $targetwidth; if (init == undefined || init == null) { applicationConfig(); initFeedTab(); } else if (!(init == null)) { $activePanels.lenght = 0; $activePanels = new Array(); } if (jQuery.browser.msie) { $panels.each(function (i) { $(this).css({ 'display': 'inline-block', 'width': 'auto' }); }); } if ($.platform.OS == 'iPad') { $panels.each(function (i) { $(this).css({ 'display': 'inline-block', 'width': 'auto' }); }); } if (type == 0) { $('section.container').css({ 'width': viewwidth + 'px' }); $('section.panel').css({ 'margin': '0 auto', 'width': $targetwidth + 'px' }); articlePadTop = parseInt($('section.container article').css('padding-top')); articlePadBottom = parseInt($('section.container article').css('padding-bottom')); $('.panel-item').css({ 'margin': '0 auto', 'width': $targetwidth + 'px', 'position': 'relative' }); } else if (type == 1) { $panels.each(function (i) { if (!(init == null)) { if (filter) { if ($(this).attr('data-filter') == filter) { $activePanels.push($(this)); } else { $activePanels.push($(this)); } } } switch (style) { case 0: $activePanels[i].css({ 'width': viewwidth - 1 + 'px', 'margin': '0 auto', 'float': 'left' }); break; case 1: break; } }); if (vContinuous == 0) { if (viewwidth <= $targetwidth) { $plainwidth = parseFloat($targetwidth) * $panels.length; } else { $plainwidth = parseFloat(viewwidth) * $panels.length; } } else { var outerWidth = 0; $panels.each(function (index) { outerWidth = outerWidth + cWidth($(this)); }); $plainwidth = outerWidth; } $parentpanel.css({ 'width': $plainwidth + 'px', 'min-width': $plainwidth + 'px' }); $('.inner-white').each(function (i) { $(this).css({ 'width': $targetwidth + 'px' }); }); } if (initNav == 1) { mPosition(null); updateNavigation(); } }
    function wWidth() { var browserWindowSize = getBrowserWindowSize(); if (browserWindowSize.width <= 980) { return 980; } else { if (document.body.offsetWidth <= browserWindowSize.width) { return document.body.offsetWidth; } else { return browserWindowSize.width; } } }
    function cWidth(target) { var oWidth = 0; $(target).children().each(function () { oWidth = oWidth + $(this).outerWidth(true); }); return oWidth; }



    function mPosition(a) {
        $target = $activePanels[currentIndex]; if (pType == 0 || pType == 2) { accessTarget = $body.find("article:eq(" + currentIndex + ") div").attr("id") } if (pType == 0) { if ($("#" + accessTarget).attr("rel") != "imported") { accessLink = $body.find("article:eq(" + currentIndex + ") p a.content-link").attr("href"); externalLoad("#" + accessTarget, accessLink, 0, '<p class="returnlink"><a href="/design/" title="Return to Linney Design">Linney Design</a></p>', 1) } } else if (pType == 2) {

            if (accessTarget == recruitmentID) {
                if (!($("#recruitment-list").hasClass("cloned"))) {
                    externalLoad("#recruitment-list-clone section", $("#" + accessTarget + " nav a:eq(0)").attr("href"), 1, '<p class="returnlink"><a href="/careers/" title="Return to Linney Group careers page">Return to Linney Group Careers</a></p>', 1); $("#recruitment-list nav ul").clone().appendTo("#recruitment-list-clone nav"); $("#recruitment-list").addClass("cloned");


                } $("#recruitment-list-clone nav a").bind({ click: function (a) { externalLoad("#recruitment-list-clone section", $(this).attr("href"), 1, '<p class="returnlink"><a href="/careers/" title="Return to Linney Group careers page">Return to Linney Group Careers</a></p>', 0); a.preventDefault() } }); $("#recruitment-list nav a").bind({ click: function (a) { initRight(); externalLoad("#recruitment-list-clone section", $(this).attr("href"), 1, '<p class="returnlink"><a href="/careers/" title="Return to Linney Group careers page">Return to Linney Group Careers</a></p>', 0); a.preventDefault() } })
            }
        } if (pType == 0 || pType == 2 || pType == 6) { locTrans = -wWidth() * currentIndex } else { locTrans = -($target.position().left - parseInt((wWidth() - $targetwidth) / 2)) } $parentpanel.stop().animate({ marginLeft: locTrans }, gDelay1, function () { updateNavigation(); updateInterface(2) })
    }


    $(window).load(
    function () { updateInterface(2); }
);

    function updateNavigation() { if (!$('#content-nav-location').length) { $navlocation = $('<div/>', { 'id': 'content-nav-location' }).appendTo($navcontrol); tmpStr = '<div id="content-position" class="floatleft"><ul id="cnl">'; for (var i = 0; i < $activePanels.length; i++) { var cData = $('article[data-id="wjl-' + i + '"] h3').attr('title'); dTitles.push('Find out more, click here to view ' + cData); if (cData === 'undefined') { tmpStr += '<li id="cnl' + i + '" class="cnl-item" title="View ' + cData + '">' + (i + 1) + '</li>'; } else { tmpStr += '<li id="cnl' + i + '" class="cnl-item">' + (i + 1) + '</li>'; } } if (vTooltip != 1) { tmpStr += '</ul><div class="clearer"></div></div>'; } if (vTooltip == 1) { tmpStr += '</ul><div class="clearer"></div><div id="navigation-tooltip" style="opacity:0;"><div id="navigation-marker"></div><div id="navigation-message">' + dTitles[1] + '</div></div></div>'; $('#navigation-tooltip').css({ 'opacity': '0' }); intval = window.setInterval('trackNavigation()', timeoutValue); } $navlocation.append(tmpStr); } if (document.getElementById('content-nav-location')) { $('#content-nav-location li').bind({ click: function (e) { currentIndex = parseInt($(this).attr('id').substring(3, $(this).attr('id').length)); $('.cnl-item').removeClass('cnl-selected'); $(this).addClass('cnl-selected'); mPause(); mPosition(0); dCount = 1; }, mouseenter: function (e) { $(this).css({ 'cursor': 'pointer', 'background-position': '0px -16px' }) }, mouseleave: function (e) { var sClass = $(this).attr('class'); if (sClass.indexOf('cnl-selected') == -1) { $(this).css({ 'background-position': '0px 0px' }); } } }); for (var i = 0; i < $activePanels.length; i++) { if (i == currentIndex) { $('#cnl' + i).addClass('cnl-selected').css({ 'background-position': '0px -16px' }); } else { $('#cnl' + i).css({ 'background-position': '0px 0px' }); } } } switch (currentIndex) { case 0: $previous.removeClass('arrow-left').addClass('arrow-left-disabled'); $next.removeClass('arrow-right-disabled').addClass('arrow-right'); break; case parseFloat($activePanels.length - 1): $previous.removeClass('arrow-left-disabled').addClass('arrow-left'); $next.removeClass('arrow-right').addClass('arrow-right-disabled'); break; default: $previous.removeClass('arrow-left-disabled').addClass('arrow-left'); $next.removeClass('arrow-right-disabled').addClass('arrow-right'); break; } }
    function updateInterface(value) { if (value == 0) { if (initNav == 0) { $(cContainer).css({ 'height': $parentpanel.parent().outerHeight(true) }); } else { $(cContainer).css({ 'height': $parentpanel.parent().outerHeight(true) + $navcontrol.outerHeight(true) }); } } else if (value == 1) { $(cContainer).css({ 'height': $bloglayout.outerHeight(true) }); } else if (value == 2) { if (initNav == 0) { if ($(cContainer).height() != $parentpanel.parent().outerHeight(true)) { hsNavigation(0); $(cContainer).stop().animate({ 'height': $parentpanel.parent().outerHeight(true) }, gDelay1, function () { hsNavigation(1); }); } } else { if ($(cContainer).height() != $parentpanel.parent().outerHeight(true) + $navcontrol.outerHeight(true)) { hsNavigation(0); $(cContainer).stop().animate({ 'height': $parentpanel.parent().outerHeight(true) + $navcontrol.outerHeight(true) }, gDelay1, function () { hsNavigation(1); }); } } } }
    function externalLoad(target, url, type, replacestr, initvalue) { renderLoad(target, initvalue); $.ajax({ type: 'GET', url: url, contentType: 'text/html; charset=utf-8', dataType: 'html', success: function (data) { var $articleSource = data.match(/<article[^>]*>([^<]*(?:(?!<\/?article)<[^<]*)*)<\/article\s*>/i)[1]; var $articleData = $(data.match(/<body[^>]*>([^<]*(?:(?!<\/?body)<[^<]*)*)<\/body\s*>/i)[1]).find('article').attr('class').replace('panel-item', '').replace(' ', '').replace('paddingtop', ''); if ($articleData != '') { $(target).parent().addClass($articleData); } if (fBrowser == 0) { $articleSource = innerShiv($articleSource.replace(replacestr, '')); } else { $articleSource = $articleSource.replace(replacestr, ''); } var linkedFiles = processString(data); if (type == 0) { $(target).html(''); $(target).html($articleSource); if (linkedFiles != '') { var tmpArray = linkedFiles.toString().split(","); $('body').append('<div id="jsph"></div>'); for (var i = 0; i < tmpArray.length; i++) { if (tmpArray[i].substring(tmpArray[i].length - 3, tmpArray[i].length) == 'css') { renderLinkCSS(tmpArray[i], 'imported'); } else if (tmpArray[i].substring(tmpArray[i].length - 2, tmpArray[i].length) == 'js') { $('#jsph').append($('<script src="' + tmpArray[i] + '" />')); } } } updateInterface(2); } else if (type == 1) { $('link[label="imported"]').remove(); if (linkedFiles != '') { var tmpArray = linkedFiles.toString().split(","); for (var i = 0; i < tmpArray.length; i++) { if (tmpArray[i].substring(tmpArray[i].length - 3, tmpArray[i].length) == 'css') { renderLinkCSS(tmpArray[i], 'imported'); } } } $(target).html(''); $(target).html($articleSource); var descriptionHeight = $('#roledescription').outerHeight(true); $('#rolecontact').css({ 'height': descriptionHeight + 'px', 'min-height': descriptionHeight + 'px' }); $(target).parent().css({ 'height': $(target).outerHeight(true) + 'px', 'min-height': descriptionHeight + 'px' }); updateInterface(2); } showData(target, type, initvalue); }, error: function (xhr, status, error) { } }); }
    function renderLinkCSS(targetHREF, targetLabel) {
        if (targetHREF != "/assets/css/IE6.css") {
            $('head').append('<link>');
            var css = $('head').children(':last');
            css.attr({ 'rel': 'stylesheet', 'type': 'text/css', 'href': targetHREF, 'label': targetLabel });
        }
    }
    function renderLoad(target, initvalue) { pLoad = 1; $(cLoad).remove(); $(target).css({ 'opacity': '0' }); if (initvalue == 1) { $(target).parent().append('<div id="loader">LOADING...</div>').css({ 'min-height': pHeight }); $(cLoad).fadeTo(500, 1.00); } else { $(target).fadeTo(100, 0.00); } }
    function showData(target, type, initvalue) { if (initvalue == 1) { if (type == 0) { $(target).attr('rel', 'imported'); } else if (type == 1) { $(target).parent().attr('rel', 'imported'); } removeLoad(target); } else { $(target).fadeTo(250, 1.00, function () { pLoad = 0; $(this).parent().attr('rel', 'imported'); }); } }
    function removeLoad(target) { $(cLoad).delay(gDelay1).fadeTo(350, 0.00, function () { pLoad = 0; $(target).fadeTo(350, 1.00); $(cLoad).remove(); }); }
    function enableTouch() { if (uTouch == false) { disableTouch(); } else { uTouch = $parentpanel.touchwipe({ wipeLeft: function () { initRight(); }, wipeRight: function () { initLeft(); }, min_move_x: 200, preventDefaultEvents: false }); } }
    function disableTouch() { if (uTouch != false) { uTouch.touchwipe('destroy'); uTouch = false; } }
    function enableKeyboard() { $(document).bind('keydown', initKeyDown).bind('keyup', initKeyUp); }
    function disableKeyboard() { $(document).unbind('keydown', initKeyDown).unbind('keyup', initKeyUp); uKeyboard = false; };
    function initKeyDown(e) { var keyCode = e.which; if (!(pType == 1 || pType == 4 || pType == 7)) { switch (keyCode) { case 37: initLeft(e); e.preventDefault(); break; case 39: initRight(e); e.preventDefault(); break; } } };
    function initKeyUp(a) { $(document).focus(); };
    function initLeft(e) { if (blogshow == 0) { if (pType == 0 && pLoad == 0 || pType == 2 && pLoad == 0 || pType == 5 && pLoad == 0 || pType == 6 && pLoad == 0) { currentIndex--; if (currentIndex < 0) currentIndex = 0; mPause(); mPosition(0); } else if (pType == 1) { xlLoc--; if (xlLoc < 0) xlLoc = extLinks.length - 1; window.location = extLinks[xlLoc]; } else if (pType == 7 && pLoad == 0) { gCounter--; if (gCounter < 0) gCounter = 0; lDataSetup(tClass, $previous, $next, 0); } } };
    function initRight(e) { if (blogshow == 0) { if (pType == 0 && pLoad == 0 || pType == 2 && pLoad == 0 || pType == 5 && pLoad == 0 || pType == 6 && pLoad == 0) { currentIndex++; if (currentIndex >= $activePanels.length) currentIndex = $activePanels.length - 1; mPause(); mPosition(1); } else if (pType == 1) { xlLoc++; if (xlLoc >= extLinks.length) xlLoc = 0; window.location = extLinks[xlLoc]; } else if (pType == 7 && pLoad == 0) { gCounter++; if (gCounter >= dataSource.length) gCounter = dataSource.length - 1; lDataSetup(tClass, $previous, $next, 0); } } };
    function mPause() { if (iFrame == 1) { resetVimeo() }; }
    function returnIndex(productid) { for (var i = 0; i < $activePanels.length; i++) { if ($activePanels[i].attr('data-id') == productid) return i; } return -1; }
    function returnProductID(index) { return $activePanels[index].attr('data-id'); }
    function initStripesFlash() { var flashvars = {}; var params = {}; params.menu = "false"; params.quality = "high"; params.wmode = "transparent"; var attributes = {}; swfobject.embedSWF("/assets/swf/stripes.swf", "lines", "225", "15", "7.0.0", "/assets/swf/expressInstall.swf", flashvars, params, attributes); }
    function initSiteWrapper(value) {
        var viewwidth = wWidth(); $navigationwrapper.css({ 'width': viewwidth, 'min-width': viewwidth }); $footerwrapper.css({ 'width': viewwidth, 'min-width': viewwidth }); initFeedTab(); if (!$('#stripe').length) {
            stripeInsert = "<div id='stripe'><div id='lines-layout'><div id='lines' class='lines" + getRandomInt(1, 5) + "'></div></div></div>"; initStripesFlash(); $(nContainer).css({ 'overflow': 'hidden', 'top': '18px' }).parent().prepend(stripeInsert); nOrginalHeight = $(nContainer).outerHeight(true); $blogbutton.fadeTo(250, 1.00);


        }
    }

    function directionFade(tElement, tOpacity, tTime) { if (tElement.substring(0, 1) != '#') { tElement = '#' + tElement; } $(tElement).stop().animate({ 'opacity': tOpacity }, tTime); }

    function initFeedTab(init) {
        if (!(init == null)) {
            $twitter.css({ 'opacity': '0' });
            $blog.css({ 'opacity': '0' });
            $blogbutton.bind({ click: function (e) { actionBlog(true); return false; } });
        } blogshow = 0; nOffsetHeight = $(nContainer).outerHeight() + $('#stripe').outerHeight(); updateInterface(0);
        $bloglayout.css({ 'position': 'absolute', 'top': nOffsetHeight, 'left': (wWidth() - 36), 'width': $blogbutton.css('width'), 'height': $blogbutton.css('height') });
        $parentpanel.css({ 'opacity': '1' }); $('#blog-link').hide();


        // see if blog needs to be open:

        // standards return ?show=blog
        // others return #?show=blog&_suid=132982047502503754934575533979

        if (window.location.search) {

            var queryState = window.location.search.substr(6);
            if (queryState = "blog") {
                actionBlog(false);
            }
        } else if (window.location.hash) {
            indexOfAmpersand = window.location.hash.indexOf("&");
            hashState = window.location.hash.substring(7, indexOfAmpersand);
            if (hashState = "blog") {
                actionBlog(false);
            }
        }


    }
    function actionBlog(storeHistory) {
        if (blogshow == 0) {
            findBlogStreams();
            $bloglayout.animate({ 'width': (((wWidth() - 960) / 2) + 960) + 'px', 'left': (wWidth() - 960) / 2 }, gDelay1, function () {



                $('#blog-content iframe').each(function (itemcount) {
                    var ifWidth = $(this).attr('title'); var ifHeight = $(this).attr('alt');
                    if (ifWidth) {
                        // rescale to 222 wide:
                        var newHeight = (222 * ifHeight) / ifWidth;
                        $(this).removeAttr('title').removeAttr('alt').css({ 'width': '222px', 'height': newHeight + 'px' }).attr('width', '222').attr('height', newHeight);
                    }
                });

                $('#linney-tagged-content iframe').each(function (itemcount) {
                    var ifWidth = $(this).attr('title'); var ifHeight = $(this).attr('alt');
                    if (ifWidth) {
                        // rescale to 393 wide:
                        var newHeight = (393 * ifHeight) / ifWidth;
                        $(this).removeAttr('title').removeAttr('alt').css({ 'width': '393px', 'height': newHeight + 'px' }).attr('width', '393').attr('height', newHeight);
                    }
                });







                var blogHeight = ($linneyBlog.outerHeight() > $blog.outerHeight()) ? $linneyBlog.outerHeight() : $blog.outerHeight();



                $bloglayout.css({ 'height': (blogHeight + 40) + 'px' }); updateInterface(1);
                var maxTweets = 10;
                $.getJSON('http://twitter.com/status/user_timeline/linneyforum.json?callback=?', function (data) { var content = ''; for (var n = 0; n < maxTweets; n++) { var tweet = data[n]; content += '<div class="tweet"><p><a href="http://twitter.com/#!/linneyforum/status/' + tweet.id_str + '" >' + tweet.text + '</a></p><p class="small">' + tweet.created_at.toString().replace(" +0000", ",") + '</p><p>from ' + tweet.source + '</p></div>'; } $twitter.html(content); $twitter.parent().parent().removeClass('twitterload'); }); $twitter.animate({ 'opacity': '1' }, gDelay1); $blog.animate({ 'opacity': '1' }, gDelay1); $blogbutton.addClass('expanded'); $parentpanel.css({ 'opacity': '0.35' }); $parentpanel.bind({ click: function (e) { actionBlog(true); } }); hsNavigation(0); blogshow = 1; $('#blog-link').show();



                if (storeHistory) {

                    window.History.pushState({ blogState: "open" }, "Welcome to Linney Group | Linney Group Ltd", "?show=blog");
                }

            });
        } else {
            $('#blog-link').hide(); $twitter.animate({ 'opacity': '0' }, gDelay1); $blog.animate({ 'opacity': '0' }, gDelay1); $bloglayout.animate({ 'height': $blogbutton.css('height') }, gDelay2); updateInterface(0); $bloglayout.animate({ 'left': wWidth() - $blogbutton.outerWidth(), 'width': $blogbutton.css('width') }, gDelay1, function () {
                $blogbutton.removeClass('expanded'); $parentpanel.css({ 'opacity': '1' }); $parentpanel.unbind(); hsNavigation(1); blogshow = 0; $twitter.parent().parent().addClass('twitterload');
                if (storeHistory) {

                    window.History.pushState({ blogState: "closed" }, "Welcome to Linney Group | Linney Group Ltd", "?show=page");
                }
            });
        }
    }
    function hsNavigation(value) { if (initNav == 1) { if (value == 0) { $navcontrollayout.hide(); } else { $navcontrollayout.fadeIn(250); } } }
    $('#blogNavLink, #homePnlBlog a').click(function () { actionBlog(true); return false; });
    $('#homePnlDifferent a').click(function () { initRight(); return false; });
    $('#homePanels ').addClass('marginright-grid01');
    $('#homePanels ').find(".setPanel").hide();
    $('#homePanels ').find(".set" + getRandomInt(0, 6)).show();

    
});
function initOverlay(value){if (value == 0){$('#wrapper').append("<div id='content-mask'></div>");var viewwidth = ($(window).width() > $('#wrapper').outerWidth()) ? $(window).width() : $('#wrapper').outerWidth();var viewheight = ($(window).height() > $('#wrapper').outerHeight()) ? $(window).height() : $('#wrapper').outerHeight();$("#content-mask").css({width:viewwidth,height:viewheight});} else if (value == 1){$("#content-mask").fadeOut(250,function(){$(this).remove();});}}
function formatLayout(){$("a.pagelink").each(function(){titleContent = $(this).attr('title');$(this).attr('title','Click here to access "'+titleContent+'"');});}
function applicationConfig(){browserConfig.init();userOSAgent = navigator.userAgent.toLowerCase();userPlatform = navigator.platform;sWidth = screen.width;sHeight = screen.height;if (sHeight > sWidth){vPortrait = true;vLandscape = false;} else {vPortrait = false;vLandscape = true;}$.platform = {Platform:userPlatform,OS:browserConfig.OS,BrowserName:browserConfig.browser,BrowserVersion:browserConfig.version,ScreenRectWidth:sWidth,ScreenRectHeight:sHeight,Portrait:vPortrait,Landscape:vLandscape};if (!($.platform.BrowserName == 'Explorer' && $.platform.BrowserVersion <= 8)){fBrowser = 1;}}
function processString(data){var itemlist = (data.match(filelinks[0]) || []).concat(data.match(filelinks[1]) || []);var outputArray = [];$.each(itemlist, function(count,value){cValue = confirmExclusion(value.replace(filelinks[2],''));if(cValue != false){outputArray[count] = cValue;}});if (itemlist != "" || itemlist != null || typeof(itemlist) != 'undefined'){return outputArray;}}
function confirmExclusion(data){var mValue = 0;for (var i=0;i< exclusionlinks.length; i++){check = data.search(exclusionlinks[i]);if(check != -1){mValue++}}if(mValue == 0){return data;} else {return false;}}
function loadLinks(url,previous,next){$.ajax({type:'GET',url:url,contentType:'text/html; charset=utf-8',dataType:'html',success:function(data){$bodySource = $(data.split(/(<body[^>]*>|<\/body>)/ig)[2]).find('#content').html();$bodyLinks = data.match(/<a[^>]* class="content-link">[\s\S]+?<\/a>?/ig);for (var i=0;i< $bodyLinks.length; i++){tmpStr = $($bodyLinks[i]).attr('href');if(tmpStr.substring((tmpStr.length - 1),tmpStr.length) != '/'){tmpStr = tmpStr + '/';}extLinks.push(tmpStr);}xlLoc = parseFloat(findIndex(extLinks,currentLoc));renderNextPrevious(xlLoc,extLinks,previous,next);},error:function(xhr,status,error){}});}
function findIndex(array,item){for (var i = 0; i < array.length; i++){if (array[i] === item){return i;}}return -1;}	
function lDataSetup(target,previous,next,init){if(init == 1){dataSource.length = 0;$('.'+target).each(function(itemcount){dataSource.push($(this).attr('href'));$(this).parent().hide();});}if(dataSource.length >= 1){$('#'+target+' section').html('');loadData('#'+target+' section',previous,next,'<p class="returnlink"><a href="/whatsnew/" title="Return to Linney Group Whats new page">Return to Whats new</a></p>');}}
function loadData(target,previous,next,replacestr){renderLoad(target,0);$.ajax({type:'GET',url:dataSource[gCounter],contentType:'text/html; charset=utf-8',dataType:'html',success:function(data){var $articleSource = data.match(/<article[^>]*>([^<]*(?:(?!<\/?article)<[^<]*)*)<\/article\s*>/i)[1];if(fBrowser == 0){$articleSource = innerShiv($articleSource.replace(replacestr,''));} else {$articleSource = $articleSource.replace(replacestr,'');}$(target).html('');$(target).html($articleSource);renderNextPrevious(gCounter,dataSource,previous,next);showData(target,1,0);},error:function(xhr,status,error){}});}
function renderNextPrevious(counter,array,previous,next){switch(counter){case 0:previous.hide();next.show();break;case (array.length - 1):previous.show();next.hide();break;default:previous.show();next.show();break;}}
function sNextPrevious(previous,next){previous.delay(gDelay1).show();next.delay(gDelay1).show();}
function trackNavigation(){window.clearInterval(intval);$tooltip = $('#navigation-tooltip'), i = 0;$tooltip.css({'opacity':'0'});$helptext = $('#navigation-message');$marker = $('#navigation-marker');$marker.css({'width':'19px','height':'10px'});var slideshow = setInterval(function(){if(dCount != 1){if(i >=  dTitles.length - 1 || dTitles[i] == 'Find out more, click here to view undefined'){dCount = 1;clearInterval(slideshow);$tooltip.hide();} else {var val = dTitles[++i];var listLoc = 18 * i;$marker.css({'margin-left':listLoc - 18 + 'px'});$helptext.text(val);$tooltip.fadeTo(250,0.60).delay(2000).fadeTo(250,0.00);}} else {clearInterval(slideshow);$tooltip.hide();}},2500);}
function getBrowserWindowSize(){var myWidth = 0, myHeight = 0;if( typeof( window.innerWidth ) == 'number'){myWidth = window.innerWidth;myHeight = window.innerHeight;} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight)){myWidth = document.documentElement.clientWidth;myHeight = document.documentElement.clientHeight;} else if( document.body && ( document.body.clientWidth || document.body.clientHeight )){myWidth = document.body.clientWidth;myHeight = document.body.clientHeight;}return {width:myWidth,height:myHeight};}
function initVimeo(){$('.inlineVideo').each(function(evt){aVimeo.push($(this).parent().attr('id'));});$('.inlineVideo').click(function(index,iframe){index.preventDefault();var iFrameString = '<iframe height="270" width="460" class="vimeo-player" id="'+$(this).parent().attr('id')+'-vp" src="http://player.vimeo.com/video/'+$(this).attr('data-vimeo')+'?title=0&api=1&player_id='+$(this).parent().attr('id')+'-source&autoplay=1&byline=0&portrait=0&color=ffffff;" frameborder="0" webkitallowfullscreen></iframe>';$(index.target).replaceWith(iFrameString);iFrame = 1;$(document).focus();});}
function resetVimeo(){for (var i = 0; i < aVimeo.length; i++){var isIframe = $('#'+aVimeo[i]).html().toLowerCase().search(new RegExp(/iframe/i));if(isIframe != -1){var cURL = $('#'+aVimeo[i]+' iframe').attr('src').toString().replace('autoplay=1','autoplay=0');$('#'+aVimeo[i]+' iframe').attr('src',cURL);iFrame = 0;}}}
function getBrowserSize(){winWidth = $(window).width();winHeight = $(window).height();}
function getRandomArbitary(min,max){return Math.random() * (max - min) + min;}
function getRandomInt(min,max){return Math.floor(Math.random() * (max - min + 1)) + min;}
function isInDocument(el){var html = document.body.parentNode;while (el){if(el === html){return true;}el = el.parentNode;}return false;}
function calWidth(target){var totalWidth = 0;$(target).children().each(function(){totalWidth = totalWidth + $(this).outerWidth();});return totalWidth;}
jQuery.fn.fadeIn = function(speed,callback){return this.animate({opacity:'show'},speed,function(){if(jQuery.browser.msie)this.style.removeAttribute('filter');if(jQuery.isFunction(callback))callback();});};
jQuery.fn.fadeOut = function(speed,callback){return this.animate({opacity:'hide'},speed,function(){if(jQuery.browser.msie)this.style.removeAttribute('filter');if (jQuery.isFunction(callback))callback();});};
jQuery.fn.fadeTo = function(speed,to,callback){return this.animate({opacity:to},speed,function(){if(to == 1 && jQuery.browser.msie)this.style.removeAttribute('filter');if(jQuery.isFunction(callback))callback();});};
function updateOrientation(){var viewport = $('meta[name="viewport"]');var dNavigator = navigator.userAgent;if ((dNavigator.match(/iPad/i)) || (dNavigator.match(/iPhone/i)) || (dNavigator.match(/iPod/i))){viewport.attr('content','width=device-width,minimum-scale=1.0,maximum-scale=1.0');$('body')[0].addEventListener("gesturestart",gestureStart,false);}switch(window.orientation){case 0:vPortrait = true;vLandscape = false;break;case -90:vPortrait = false;vLandscape = true;break;case 90:vPortrait = false;vLandscape = true;break;case 180:vPortrait = true;vLandscape = false;break;}if (pType == 0 || pType == 2){calibrateInterface('All',1,1,0);} else if (pType == 1 || pType == 3 || pType == 4 || pType == 7){calibrateInterface(null,null,0,null);} else if (pType == 5){calibrateInterface('All',1,1,1);} else if (pType == 6){calibrateInterface('Contact',1,1,0);}}
function gestureStart(){viewport.attr('content', 'width=device-width, minimum-scale=0.25, maximum-scale=1.6');}
function addDebug(){$('body').append('<div id="debug" style="position:absolute;z-index:9999;bottom:0px;left:0px;width:400px;height:120px;background:#FFFFFF;display:block;padding:5px;overflow:scroll;"><p></p></div>');}


function findBlogStreams() {
if(blogInited !== true) {
var $thisHeader, $thisExcerpt;

$('#blog-content').find('.headline').each(function (index) {
   
    $thisHeader = $(this);
    $thisExcerpt = $thisHeader.next();

    var thisLink = $thisHeader.find('h1 a').attr('href');
    // search tag content:
    var foundLinneyArticle = false;
    $thisExcerpt.find('a[rel=tag]').each(function () {

        if ($(this).text().toLowerCase() == "linney") {
            // move header and excerpt
            $('#linney-tagged-content').append($thisHeader).append($thisExcerpt);
            foundLinneyArticle = true;
        }
    });

    if (!foundLinneyArticle) {
        //  create MORE link
        var newLinkMarkup = '<a href="' + thisLink + '" class="readMore" title="Click to read the full article">Read more &gt;</a>';
        $thisExcerpt.append(newLinkMarkup);
        // move images out

        var $thisImg = $thisExcerpt.find('img').not('.sociable-hovers').eq(0);
        $thisExcerpt.prepend($thisImg);

        var $thisIframe = $thisExcerpt.find('iframe').eq(0);
        if ($thisIframe.length > 0) {
            $thisExcerpt.prepend($thisIframe);
        }

        $thisExcerpt.find('img').eq(0).wrap('<a href="' + thisLink + '" title="Click to read the full article"></a>');

    }
});
// deactivate anchors from images:
$('#linney-tagged-content').find('a img').each(function () {
    $(this).parent().attr('href',$(this).parents('.excerpt').prev().find('h1 a').attr('href')).removeAttr("onclick");
    
});

// remove all width and height attributes:
$('#blogcontent-layout').find('img').removeAttr('width').removeAttr('height');



blogInited = true;
}
}


