﻿var K3CDS = function(){
    var debug = false,
    isIE6 = false,
    minWidth = 980,
    maxWidth = 1600,
    aboutOpen = null,
    map = null,
    firstRun = true,
    headerSize = 92,
    minHeight = 550,
    homeHeight = 450,
    navSize = 39,
    footerSize = 49,
    pageWrapper = null,
    pageSection = null,
    currentSize = {
        x:0,
        y:0
    };
    
    function fnLogDebugMessage(strMessage){
        
        if (debug === true){
            var debugEl = $('debug-log');
            if (debugEl === null){
                debugEl = new Element('div', { id: 'debug-log' });
                debugEl.inject($(document.body));
            }
            
            var d = new Date();    
            var logEl = new Element('p', { html: '<b>' + d.toUTCString() + ' :</b>' + strMessage  });
            logEl.inject(debugEl);
            
            var scroller = new Fx.Scroll(debugEl);
            scroller.toBottom();
        }
        
    }
    
    function fnGetWrapperHeight(){
        var holdHeight = currentSize.y - (headerSize + navSize + footerSize);
            
            
        //do a min height check
        if (holdHeight < minHeight){
            holdHeight = minHeight;
        }
        
        fnLogDebugMessage(holdHeight + ' - ' + minHeight);
        
        return holdHeight;
    }
   
    function fnGetAboutWidths(srcWidth){
        fnLogDebugMessage('srcWidth: ' + srcWidth);
        var objSizes = {
            col1width: fnGetPercentage(srcWidth, 21),
            col1padding: fnGetPercentage(srcWidth, 2),
            col2width: fnGetPercentage(srcWidth, 25),
            col3width: fnGetPercentage(srcWidth, 25),
            col4width: fnGetPercentage(srcWidth, 24)
        };        
        
        var computedWidth = objSizes.col1width + objSizes.col1padding + objSizes.col1padding + objSizes.col2width + objSizes.col3width + objSizes.col4width;
        fnLogDebugMessage('computedWidth: ' + computedWidth);
        if (computedWidth < srcWidth){
            objSizes.col1width = objSizes.col1width  + ((srcWidth - 10) - computedWidth);
        }
        
        return objSizes;        
    }
    
    function fnGetServiceWidths(srcWidth){
        var objSizes = {
            col1width: fnGetPercentage(srcWidth, 16),
            col1padding: fnGetPercentage(srcWidth, 2),
            col2width: fnGetPercentage(srcWidth, 20),
            col3width: fnGetPercentage(srcWidth, 20),
            col4width: fnGetPercentage(srcWidth, 20),
            col5width: fnGetPercentage(srcWidth, 20)
        };        
        
        var computedWidth = objSizes.col1width + objSizes.col1padding + objSizes.col1padding + objSizes.col2width + objSizes.col3width + objSizes.col4width + objSizes.col5width;
        if (computedWidth < srcWidth){
            var ie6Adjustemnt = (isIE6) ? 10 : 0;
            objSizes.col1width = objSizes.col1width  + ((srcWidth - ie6Adjustemnt) - computedWidth);
        }
        
        return objSizes;
    }
    
    function fnGetPercentage(src, percent){
        var tmp = 0;
        if (src !== null && src > 0){
            tmp = src / 100;
            tmp = tmp * percent;
        } 
        
        return Math.floor(tmp); 
    }
    
    function fnResizeHome(){
        
        var rightIntro = $('right-intro');
        var b1Height = $('right-banner-1').getSize().y;
        var b2Height = $('right-banner-2').getSize().y;
        
        var introHeight = pageWrapper.getSize().y - (b1Height + b2Height);
        rightIntro.setStyle('height', introHeight + 'px');
        
        var mask = $('right-mask');
        var rightSideCol = pageWrapper.getChildren('.right-side')[0];
        
        mask.setStyle('height', pageWrapper.getSize().y + 'px');
        mask.setStyle('width', rightSideCol.getSize().x + 'px');
    }
    
    function fnResizeAbout(){
        var height = fnGetWrapperHeight();
        //var holdHeight = currentSize.y - (headerSize + navSize + footerSize);
        fnLogDebugMessage('wrapper height - ' + height);
        var colSizes = fnGetAboutWidths(pageWrapper.getSize().x);
        if (K3CDS.aboutSection === null){
            $('column-1').setStyles({ 'height': (height - fnGetColumnPadding('column-1')) + 'px', 'width': colSizes.col1width + 'px', 'padding-left': colSizes.col1padding + 'px', 'padding-right': colSizes.col1padding + 'px' });
            $('column-2').setStyles({ 'height': (height - fnGetColumnPadding('column-2')) + 'px', 'width': colSizes.col2width + 'px', 'padding': '50px 0 0 0' });
            $('column-3').setStyles({ 'height': (height - fnGetColumnPadding('column-3')) + 'px', 'width': colSizes.col3width + 'px', 'padding': '50px 0 0 0' });
            $('column-4').setStyles({ 'height': (height - fnGetColumnPadding('column-4')) + 'px', 'width': colSizes.col4width + 'px', 'padding': '50px 0 0 0' });  
            
            $$('div.sub-col').each(function(subCol){
                //get parent 'on' div
                var divWrapper = $(subCol.parentNode);
                var headerHeight = 0;
                if (divWrapper !== null){
                    var header = divWrapper.getChildren('div.header')[0];
                    if (header !== null){
                        headerHeight = header.getSize().y;
                    }
                }
                subCol.setStyle('height', (height - headerHeight) + 'px');
            });
        } else {
            fnShowAboutPanel(K3CDS.aboutSection, true);
        }
    }
    
    function fnResizeSuccess(){
//        var threeCols = $$('div.three-columns div.col');
//        if (threeCols !== null){
//            var colHeight = pageWrapper.getSize().y - (threeCols[0].getStyle('height').toInt() + 30);
//            $('intro-text').setStyle('height', colHeight + 'px');
//        }
        var colHeight = pageWrapper.getSize().y - $('intro-text').getStyle('height').toInt();
        
        $$('div.three-columns div.col').each(function(subcol){
            subcol.setStyle('height', colHeight + 'px');
        });
    }
    
    function fnResizeServices(){
        //var height = pageWrapper.getSize().y;
        var height = fnGetWrapperHeight();
        var colSizes = fnGetServiceWidths(pageWrapper.getSize().x);
        
        if (K3CDS.serviceSection === null){
            $('column-1').setStyles({ 'height': (height - fnGetColumnPadding('column-1')) + 'px', 'width': colSizes.col1width + 'px', 'padding-left': colSizes.col1padding + 'px', 'padding-right': colSizes.col1padding + 'px' });
            $('column-2').setStyles({ 'height': (height - fnGetColumnPadding('column-2')) + 'px', 'width': colSizes.col2width + 'px', 'padding': '50px 0 0 0' });
            $('column-3').setStyles({ 'height': (height - fnGetColumnPadding('column-3')) + 'px', 'width': colSizes.col3width + 'px', 'padding': '50px 0 0 0' });
            $('column-4').setStyles({ 'height': (height - fnGetColumnPadding('column-4')) + 'px', 'width': colSizes.col4width + 'px', 'padding': '50px 0 0 0' });  
            $('column-5').setStyles({ 'height': (height - fnGetColumnPadding('column-5')) + 'px', 'width': colSizes.col4width + 'px', 'padding': '50px 0 0 0' });  
            
            $$('div.sub-col').each(function(subCol){
                var divWrapper = $(subCol.parentNode);
                var headerHeight = 0;
                if (divWrapper !== null){
                    var header = divWrapper.getChildren('div.header')[0];
                    if (header !== null){
                        headerHeight = header.getSize().y;
                    }
                }
                subCol.setStyle('height', height + 'px');
            });
        } else {
            fnShowServicePanel(K3CDS.serviceSection, true);
        }
    }
    
    function fnResizeConsultation(){
        for(var i=1;i<=4;i++){
            $('column-' + i).setStyle('height', (fnGetWrapperHeight() - fnGetColumnPadding('column-' + i)) + 'px');
        }
    }
    
    function fnGetColumnPadding(colId){
        var padding = 0;
        
        padding = padding + $(colId).getStyle('padding-top').toInt();
        padding = padding + $(colId).getStyle('padding-bottom').toInt();
        fnLogDebugMessage('padding - ' + colId + ' :' + padding);
        return padding;
    }
    
    function fnResizeContact(){
        var mapHeight = pageWrapper.getSize().y;// - $('downloadlink').getSize().y;
        $('gmap').setStyle('height', mapHeight + 'px');
        
        if (firstRun === true && GBrowserIsCompatible()) {
            map = new GMap2(document.getElementById("gmap"));
            var point = new GLatLng(53.552604, -1.48431);
            var marker = new GMarker(point);
            
            map.addControl(new GLargeMapControl()); 
            map.addControl(new GMapTypeControl());
            
            map.setMapType(G_SATELLITE_MAP);
            
            map.setCenter(new GLatLng(53.552604, -1.48431), 16);
            map.addOverlay(marker);  
            marker.openInfoWindowHtml('<div class="infotip"><img src="./images/contact/k3outside.jpg" /></div>');
            
            GEvent.addListener(marker, "click", function() {
                   marker.openInfoWindowHtml('<div class="infotip"><img src="./images/contact/k3outside.jpg" /></div>');
            });                                                   
          } else if (map) {
            map.setCenter(new GLatLng(53.552604, -1.48431), 16);
          }
    }
    
    function fnCollapseColumns(selectedCol){
        var i = 0;
        for (i=1;i<=4;i++)
        {
            if (selectedCol !== 'column-' + i){
                fnCollapseColumn('column-' + i);
            }
        }        
    }
    
    function fnCollapseServiceColumns(selectedCol){
        var i = 0;
        for (i=1;i<=5;i++)
        {
            if (selectedCol !== 'column-' + i){
                fnCollapseServiceColumn('column-' + i);
            }
        }        
    }
    
    function fnCollapseColumn(colId){
        var objCol = $(colId);
        var text = objCol.getFirst().getChildren('p');
        text.each(function(p){
            p.fade(0);
        });
        
        var height = fnGetWrapperHeight();
        
        var morphCol = new Fx.Morph(objCol, {duration: 'normal', transition: Fx.Transitions.Sine.easeOut});
        
        if (colId == 'column-1'){
            morphCol.start({
                'height': [objCol.getSize().y, (height - fnGetColumnPadding(colId))],
                'padding-left': [objCol.getStyle('padding-left').toInt(), fnGetPercentage(pageWrapper.getSize().x, 2)],
                'padding-right': [objCol.getStyle('padding-right').toInt(), 0],
                'width': [objCol.getSize().x, fnGetPercentage(pageWrapper.getSize().x, 8)]  
            });
        } else {
            morphCol.start({
                'height': [objCol.getSize().y, (height - fnGetColumnPadding(colId))],
                'width': [objCol.getSize().x, fnGetPercentage(pageWrapper.getSize().x, 10)]  
            });
        }
    }
    
    function fnCollapseServiceColumn(colId){
        var objCol = $(colId);
        var text = objCol.getFirst().getChildren('p');
        text.each(function(p){
            p.fade(0);
        });
        
        var height = fnGetWrapperHeight();
        
        var morphCol = new Fx.Morph(objCol, {duration: 'normal', transition: Fx.Transitions.Sine.easeOut});
        
        if (colId == 'column-1'){
            morphCol.start({
                'height': [objCol.getSize().y, (height - fnGetColumnPadding(colId))],
                'padding-left': [objCol.getStyle('padding-left').toInt(), fnGetPercentage(pageWrapper.getSize().x, 2)],
                'padding-right': [objCol.getStyle('padding-right').toInt(), 0],
                'width': [objCol.getSize().x, fnGetPercentage(pageWrapper.getSize().x, 7)]  
            });
        } else {
            morphCol.start({
                'height': [objCol.getSize().y, (height - fnGetColumnPadding(colId))],
                'width': [objCol.getSize().x, fnGetPercentage(pageWrapper.getSize().x, 7)]  
            });
        }
    }
    
    function fnShowAboutPanel(colId, isResize){
        if (K3CDS.aboutSection !== null && isResize !== true){
            var x = new Chain();
            
            x.chain(fnResetAboutPanels);
            
            var boundShowPanel = function(){
                fnShowAboutPanel(colId);
            }.bind(this);
            
            x.chain(boundShowPanel);
            x.callChain();
            x.callChain.delay(1500, x);
            return;
        }
        $('page-hold').setStyle('overflow', 'hidden');
        K3CDS.aboutSection = colId;
        var objCol = $(colId);
        
        var objSummary = objCol.getChildren('div.off')[0];
        var objDetail = objCol.getChildren('div.on')[0];        
        
        //fade out summary content
        objSummary.fade(0);
        
        var extraHeight = (isIE6) ? 37 : 50;
        
        objCol.setStyle('padding-top', '0');
        objCol.setStyle('height', (objCol.getStyle('height').toInt() + extraHeight) + 'px');
        objDetail.setStyle('display', 'block');
        //collapse none selected columns
        fnCollapseColumns(colId);
        
        //change selected column background and width
        var selectedCol = new Fx.Morph(objCol, {
            duration: 750, 
            transition: Fx.Transitions.Sine.easeOut,
            onComplete: function(){
                objSummary.setStyle('display', 'none');
                objDetail.fade(1);
            }
        });
        
        selectedCol.start({
            'background-color': ['#FF6600', '#FFFFFF'],
            'width': [objCol.getSize().x, fnGetPercentage(pageWrapper.getSize().x, 70)]  
        });
        
        $$('div.sub-col').each(function(subCol){
            var height = pageWrapper.getSize().y;
            var divWrapper = $(subCol.parentNode);
            var headerHeight = 0;
            if (divWrapper !== null){
                var header = divWrapper.getChildren('div.header')[0];
                if (header !== null){
                    headerHeight = header.getSize().y;
                }
            }
            
            if (subCol.getStyle('padding-top').toInt() > 0){
                height = height - subCol.getStyle('padding-top').toInt();
            }
            
            subCol.setStyle('height', (height - headerHeight) + 'px');
            
        });

    }
    
    function fnShowServicePanel(colId, isResize){
        if (K3CDS.serviceSection !== null && isResize !== true){
            var x = new Chain();
            
            x.chain(fnResetServicePanels);
            
            var boundShowPanel = function(){
                fnShowServicePanel(colId);
            }.bind(this);
            
            x.chain(boundShowPanel);
            x.callChain();
            x.callChain.delay(1500, x);
            return;
        }
        $('page-hold').setStyle('overflow', 'hidden');
        K3CDS.serviceSection = colId;
        var objCol = $(colId);
        
        var objSummary = objCol.getChildren('div.off')[0];
        var objDetail = objCol.getChildren('div.on')[0];        
        
        //fade out summary content
        objSummary.fade(0);
        
         var extraHeight = (isIE6) ? 37 : 50;
        
        objCol.setStyle('padding-top', '0');
        objCol.setStyle('height', (objCol.getStyle('height').toInt() + extraHeight) + 'px');
        objDetail.setStyle('display', 'block');
        //collapse none selected columns
        fnCollapseServiceColumns(colId);
        
        //change selected column background and width
        var selectedCol = new Fx.Morph(objCol, {
            duration: 750, 
            transition: Fx.Transitions.Sine.easeOut,
            onComplete: function(){
                objSummary.setStyle('display', 'none');
                objDetail.fade(1);
            }
        });
        
        selectedCol.start({
            'background-color': ['#FF6600', '#FFFFFF'],
            'width': [objCol.getSize().x, fnGetPercentage(pageWrapper.getSize().x, 70)]  //Morphs the 'width' style from 900px to 300px.
        });
        
        $$('div.sub-col').each(function(subCol){
            var height = pageWrapper.getSize().y;
            var divWrapper = $(subCol.parentNode);
            var headerHeight = 0;
            if (divWrapper !== null){
                var header = divWrapper.getChildren('div.header')[0];
                if (header !== null){
                    headerHeight = header.getSize().y;
                }
            }
            
            if (subCol.getStyle('padding-top').toInt() > 0){
                height = height - subCol.getStyle('padding-top').toInt();
            }
            
            subCol.setStyle('height', (height - headerHeight) + 'px');
            
        });
    }
    
    function fnResetServicePanels(){
        for (var i=1;i<=5;i++)
        {
            fnResetServiceColumn('column-' + i);
        }      
    }
    
    function fnResetAboutPanels(){
        for (var i=1;i<=4;i++)
        {
            fnResetColumn('column-' + i);
        }      
    }
    
    function fnResetServiceColumn(colId){
        var objCol = $(colId);
        var objSummary = objCol.getChildren('div.off')[0];
        var objDetail = objCol.getChildren('div.on')[0];        
        
        var text = objCol.getFirst().getChildren('p');
        text.each(function(p){
            p.fade(1);
        });
        
        var completeFn = function(){};
        
        if(K3CDS.serviceSection == colId){
            objCol.setStyle('padding-top', '50px');
           completeFn = function(){
                objSummary.setStyle('display', 'block');
                objSummary.fade(1);
                K3CDS.serviceSection = null;
                $('page-hold').setStyle('overflow', 'visible');
            };
        }
        
        if (objDetail){
            objDetail.fade(0);
        }
            
        var morphCol = new Fx.Morph(objCol, {
            duration: 'normal', 
            transition: Fx.Transitions.Sine.easeOut,
            onComplete: completeFn.bind(this)
        });
        
        var bgColour = '#FF6600';
        
        switch(colId){
            case 'column-3':
                bgColour = '#FF791E';
                break;
            case 'column-4':
                bgColour = '#FF8430';
                break;
            case 'column-5':
                bgColour = '#FF9343';
                break;
        }
        
        if (colId == 'column-1'){
            morphCol.start({
                'height': [objCol.getSize().y, (pageWrapper.getSize().y - fnGetColumnPadding(colId))],
                'padding-left': [objCol.getStyle('padding-left').toInt(), fnGetPercentage(pageWrapper.getSize().x, 2)],
                'padding-right': [objCol.getStyle('padding-right').toInt(), fnGetPercentage(pageWrapper.getSize().x, 2)],
                'width': [objCol.getSize().x, fnGetPercentage(pageWrapper.getSize().x, 16)]  
            });
        } else {
            morphCol.start({
                'background-color': [objCol.getStyle('background-color'), bgColour],
                'height': [objCol.getSize().y, (pageWrapper.getSize().y - fnGetColumnPadding(colId))],
                'width': [objCol.getSize().x, fnGetPercentage(pageWrapper.getSize().x,20)]  
            });
        }
    }
    
    function fnResetColumn(colId){
        var objCol = $(colId);
        var objSummary = objCol.getChildren('div.off')[0];
        var objDetail = objCol.getChildren('div.on')[0];        
        
        var text = objCol.getFirst().getChildren('p');
        text.each(function(p){
            p.fade(1);
        });
        
        var completeFn = function(){};
        
        if(K3CDS.aboutSection == colId){
            objCol.setStyle('padding-top', '50px');
           completeFn = function(){
                objSummary.setStyle('display', 'block');
                objSummary.fade(1);
                K3CDS.aboutSection = null;
                $('page-hold').setStyle('overflow', 'visible');
            };
        }
        
        if (objDetail){
            objDetail.fade(0);
        }
            
        var morphCol = new Fx.Morph(objCol, {
            duration: 'normal', 
            transition: Fx.Transitions.Sine.easeOut,
            onComplete: completeFn.bind(this)
        });
        
        var bgColour = '#FF6600';
        
        switch(colId){
            case 'column-3':
                bgColour = '#FF791E';
                break;
            case 'column-4':
                bgColour = '#FF8430';
                break;
        }
        
        if (colId == 'column-1'){
            morphCol.start({
                'height': [objCol.getSize().y, (pageWrapper.getSize().y - fnGetColumnPadding(colId))],
                'padding-left': [objCol.getStyle('padding-left').toInt(), fnGetPercentage(pageWrapper.getSize().x, 2)],
                'padding-right': [objCol.getStyle('padding-right').toInt(), fnGetPercentage(pageWrapper.getSize().x, 2)],
                'width': [objCol.getSize().x, fnGetPercentage(pageWrapper.getSize().x, 21)]  
            });
        } else {
            morphCol.start({
                'background-color': [objCol.getStyle('background-color'), bgColour],
                'height': [objCol.getSize().y, (pageWrapper.getSize().y - fnGetColumnPadding(colId))],
                'width': [objCol.getSize().x, fnGetPercentage(pageWrapper.getSize().x,25)]  
            });
        }
    }
        
    return {
        
        aboutSection: null,
        serviceSection: null,
        
        log: function(strMessage){
            fnLogDebugMessage(strMessage);
        },
        
        init: function(section){
            pageSection = section;
            
            //add body class to allow styling for js only functionality
            var body = $(document.body);
            body.addClass('hasjs');
            
            Shadowbox.init();
            
            pageWrapper = $('page-wrapper');
            
            isIE6 = (Browser.Engine.trident  === true && Browser.Engine.version === 4);
            
            //add handler to browser resize event
            window.addEvent('resize', K3CDS.handleResize);   
            
            //get all text replace elements if IE6
//            if (Browser.Engine.trident && Browser.Engine.version === 4){
//                var textReplaceEls = $$('.hastextreplace');
//                
//                textReplaceEls.each(function(el){
//                    var strFilter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='IMAGESOURCE')";
//                    var newFilter = strFilter.replace('IMAGESOURCE', el.getStyle('background-image'));
//                    newFilter = newFilter.replace('url(', '');
//                    newFilter = newFilter.replace(")'", "'");
//                    
//                    el.setStyles({
//                        'background': "url('images/generic/blank.gif') repeat-x top left",
//                        'filter': newFilter
//                    });

//                });        
//            }
            
            //call our resize handler on first run
            K3CDS.handleResize();
            
            var sendFriend = $('send-to-friend-link');
            
            sendFriend.addEvent('click', function(e){
                e.preventDefault();
                    
                Shadowbox.open({
                    player:'iframe',
                    title: 'Send to a Friend',
                    content: sendFriend.href,
                    height:350,
                    width:452
                });
            });
            
            var callback = $('request-callback-link');
            
            callback.addEvent('click', function(e){
                e.preventDefault();
                    
                Shadowbox.open({
                    player:'iframe',
                    title: 'Request a Callback',
                    content: callback.href,
                    height:200,
                    width:452
                });
            });
            
            var privacy = $('privacy-link');
            
            privacy.addEvent('click', function(e){
                e.preventDefault();
                    
                Shadowbox.open({
                    player:'iframe',
                    title: 'Privacy Policy',
                    content: privacy.href,
                    height:550,
                    width:480
                });
            });
        },
        
        maskHome: function(blnHide){
            var mask = $('right-mask');
            if (blnHide === true){
                mask.fade(0);
            } else{
                mask.fade(0.8);
            }
        },
        
        handleResize: function(){
            
            //get current browser dimesnions
            currentSize = window.getSize();
                
            //work out content area's height by subtracting header, nav and footer from browser height    
            var holdHeight = currentSize.y - (headerSize + navSize + footerSize);
            var holdWidth = currentSize.x - 40; //40 = margin either side
            
            //do a min height check
            if (holdHeight < minHeight){
                holdHeight = minHeight;
            }
            
            if (pageSection === 'home' && holdHeight < homeHeight){
                holdHeight = homeHeight;
            }
            
            if (isIE6 && currentSize.x < minWidth){
                $('page-hold').setStyle('width', minWidth);    
            }            
            else if (isIE6 && currentSize.x > maxWidth){
                $('page-hold').setStyle('width', maxWidth);    
            }
            else {
                $('page-hold').setStyle('width', 'auto');    
            }
            
            //set the content areas height
            pageWrapper.setStyle('height', holdHeight + 'px');
            
            //$('page-hold').setStyle('width', holdWidth + 'px');
            
            //call any custom functions based on section
            switch(pageSection){
                case 'home':
                    fnResizeHome();
                    break;
                case 'about':
                    fnResizeAbout();
                    break;
                case 'success':
                    fnResizeSuccess();
                    break;
                case 'services':
                    fnResizeServices();
                    break;
                case 'consultation':
                    fnResizeConsultation();
                    break;
                case 'contact':
                    fnResizeContact();
                    break;
            }
            
            firstRun = false;
            
        },
        
        
        initAboutColumns: function(){
        
            //hide 'details view' for each column
            $$('div.about-us-wrapper div.on').setStyle('visibility', 'hidden');
            $$('div.about-us-wrapper div.on').setStyle('display', 'none');
            
            //hook up view details links to call show function
            $$('a.more-link').each(function(anchor){
                anchor.addEvent('click', function(e){
                    e.stop();
                    fnShowAboutPanel(anchor.getProperty('rel'));
                });
            });
            
            //make headers clickable too
            $$('div.about-us-wrapper div.off h2').each(function(h2){
                
                var rel = h2.getProperty('rel');
                
                if (rel !== null && rel.length > 0){
                    h2.setStyle('cursor', 'pointer');
                    h2.addEvent('click', function(e){
                        e.stop();
                        fnShowAboutPanel(rel);
                    });
                }
            });
            
            $$('a.close-link').each(function(anchor){
                anchor.addEvent('click', function(e){
                    e.stop();
                    fnResetAboutPanels();
                });
            });
        },
        
        initServiceColumns: function(){
        
            //hide 'details view' for each column
            $$('div.services-us-wrapper div.on').setStyle('visibility', 'hidden');
            
            //hook up view details links to call show function
            $$('a.more-link').each(function(anchor){
                anchor.addEvent('click', function(e){
                    e.stop();
                    fnShowServicePanel(anchor.getProperty('rel'));
                });
            });
            
            //make headers clickable too
            $$('div.services-us-wrapper div.off h2').each(function(h2){
                var rel = h2.getProperty('rel');
                
                if (rel !== null && rel.length > 0){
                    h2.setStyle('cursor', 'pointer');
                    h2.addEvent('click', function(e){
                        e.stop();
                        fnShowServicePanel(rel);
                    });
                }
            });
            
            $$('a.close-link').each(function(anchor){
                anchor.addEvent('click', function(e){
                    e.stop();
                    fnResetServicePanels();
                });
            });
        }
    };
}();