// Contains all Javascript to be executed on pageload
(function($) {
    function detailTxt (symbol) {
        var symbol = symbol || '+';
        return '[&nbsp;Details&nbsp;'+symbol+'&nbsp;]';
    }
    
    $(document).ready(function() {
        // Browser testing for defunct browsers
        // Informs IE/Mac users to GET A NEW BROWSER (If using IE/Mac && it's your first time viewing a page on this site)
        if ((navigator.appName.indexOf('Internet Explorer') > -1 && navigator.appVersion.indexOf('Mac') > -1) && document.referrer.indexOf(location.hostname) == -1) {
            alert("You are using an out of date browser and as such, this site may not display correctly.\n\nWe recommend you download a newer browser such as Firefox (www.mozilla.com) and use that.");
        }

        // Enable offsite link window opening
        $('a.offsite, a[rel=external]').click(function() {
            var $t = $(this);
            window.open($t.attr('href'));
            return false;
        });

        // Enable show/hide case studies
        $('div.caseStudy').hide().before('<a class="toggle">'+detailTxt('+')+'</a>');

        $('div#content a.toggle').click(function() {
            var $t = $(this);

            if($t.next('div.caseStudy').is(':hidden'))
                // $t.html('[Case Study -]').next('div.caseStudy').slideDown('slow', function() {
                //     $('div#content').redrawShadow();
                // });
                $t.html(detailTxt('-')).next('div.caseStudy').slideDown('slow');
            else
                // $t.html('[Case Study +]').next('div.caseStudy').slideUp('slow', function() {
                //     $('div#content').redrawShadow();
                // });
                $t.html(detailTxt('+')).next('div.caseStudy').slideUp('slow');
        });

        // Enable Service page functionality
        // resetServices();
        $('#services #design h3:first-child, #services #development h3:first-child, #services #optimization h3:first-child').hide();
    
        // $('#services a[rel="design"], #services a[rel="development"], #services a[rel="optimization"]').click(function() {
        //     resetServices();
        // 
        //     var _t = $(this);
        //     _t.parent().parent().addClass('active');
        // 
        //     $('#services #' + _t.attr('rel')).show();
        //     $('div#content').redrawShadow();
        //     return false;
        // });

        // Enable rounded corners and drop shadow layout
    //    if(jQuery.browser.mozilla || jQuery.browser.msie || jQuery.browser.opera) {
    //        $('#nav li a').corner('tr bl');
    //        $('div#header, div#content, div#sidebar').corner('tr bl');
    //    }
    
    //    if(jQuery.browser.mozilla || (jQuery.browser.msie && jQuery.browser.version === '7.0')) {
    //        $('div#header, div#content, div#sidebar').dropShadow({ left: 8, top: 8, blur: 4, color: '#CCC' });
    //    }
    //     $('#header').corner('tr bl').dropShadow({ left: 8, top: 8, blur: 4, color: '#CCC' });
    //     $('#content').corner('tr bl').dropShadow({ left: 8, top: 8, blur: 4, color: '#CCC' });
    //     $('#sidebar').corner('tr bl').dropShadow({ left: 8, top: 8, blur: 4, color: '#CCC' });
    //     $('#header, #content, #sidebar').dropShadow({ left: 8, top: 8, blur: 4, color: '#CCC' });

    });
})(jQuery);
