try {

    var currentHeightTarget  = 0;
    var scale,hash;
    var processActive = false;
    var domain = 'http://'+document.domain.toString();
    var pathlink = document.location.toString().split('#');
    var path = document.location.pathname.toString();
    var pageStack = new Array();

    checkPath = function() {
        if(pathlink[1]) {
        
            var req = new Request.HTML({
                    
                            url:pathlink[1].replace('/view/','/xhr/'), 
                            urlEncoded: false,
                            onSuccess: function(html) {
                            $('content').set('text', '');
                            $('content').style.height = '0px';
                            //Clear the text currently inside the results div.
                            $('content').adopt(html);
                            $('loading').style.display = 'none';
     
                            setTimeout ( checkResize, 500 );

                    },
            
            
                    onFailure: function() {
            
                        $('content').set('text', 'The request failed. try again?');
                        $('loading').style.display = 'none';
                        setTimeout ( checkResize, 500 );   
            
                    }
            
                }).send();

        }
    }

    checkResize = function() {    
        if($('content').getScrollSize().y != $('content').getSize().y) {
            
            var height = $('content').getScrollSize().y;
            scale.start(height); 
            $('content').set('opacity','1');
            setTimeout ( checkResize, 1000 );
            
            processActive = false;
            
        }
        
    }

    window.addEvent('domready', function() {
        
        var pageTracker = _gat._getTracker("UA-5635080-1");
        pageTracker._trackPageview();
        
        if(pathlink[1]) {$('content').set('text', '');}
        scale = $('content').get('tween', {
            property: 'height', 
            duration: 'long'});
        
        $$('#navigation a').each(function(el) { 
                
                el.addEvent('click',function(event) {
                    event.preventDefault();
                
                if(processActive == false) {
                    processActive = true;
                    $('loading').style.display = 'block';
                    $('content').set('opacity','0.1');
                    $('content').get('tween', {property: 'height', duration: 'long'}).start(0);
                    //remove the active class
                    var targetClassName;

                    $$('#navigation a').each(function(elNav) { 
                        elNav.removeClass('projectActive');
                        if(elNav.className == 'active') {
                            elNav.removeClass('active');
                            elNav.className = 'contentitemNavigation';
                        }
                    });
                    
                    if (el.className != 'contentitemNavigation') { 
                        targetClassName ='projectActive'; 
                    } else { 
                        targetClassName ='active'; 
                    }
                    

                     
                    el.className = targetClassName;
                    hash = event.target.href.replace(domain,''); 
                    document.location = path +'#'+hash;
                    var t = event.target.href.replace('/view/','/xhr/');
                    pageStack.push(t);
                    
                    var req = new Request.HTML({
                    
                            url:t, 
                            urlEncoded: false,
                            onSuccess: function(html) {
                            $('content').set('text', '');
                            
                            //Clear the text currently inside the results div.
                            $('content').adopt(html);
                            $('loading').style.display = 'none';
     
                            setTimeout ( checkResize, 1000 );
                            
                            var pageTracker = _gat._getTracker("UA-5635080-1");
                            pageTracker._trackPageview(t);
            

                    },
            
            
                    onFailure: function() {
            
                        $('content').set('html', '<b>Can\'t connect to the server.</b><br/><br/><i>spam of the day: New Orgassm Enhancer</i><br/><br/>With no scolding voices and no crying children of mystery<br/>and hints of wondrous things they had said the lady hath<br/>the moon changed, that ye all but at starting he said to<br/>my sister, \'i shall no regular salary, reiterated the evangelist..');
                        $('loading').style.display = 'none';
                        setTimeout ( checkResize, 1000 );   
            
                    }
            
                }).send();
            }	
                })
            
        })
    }
    );
    
    checkPath();
} catch(e) {}


