/*
    Coded by Steven Bower (cc) 2010
    TurnWheel Designs http://turnwheel.com/
*/

$(function() {
    // Handle external links
    $('a[rel="external"]').click(function() {
        var href = $(this).attr('href');
        
        // Send external link event to Google Analaytics
        try {
            pageTracker._trackEvent('External Links', href.split(/\/+/g)[1], href);
        } catch (e) {};
        
        window.open(href,'clr_'+Math.round(Math.random()*11));
        return false;
    });
    
    // Check for lightbox and create
    if ($('a.lightbox').length > 0) {
        $.getCSS('/css/jquery.lightbox.css');
        $.getScript('/js/jquery.lightbox.min.js',function() {
            // Load lightbox on all elemeents
            $('a.lightbox').lightBox({
                imageLoading: '/images/lightbox-ico-loading.gif',
                imageBtnClose: '/images/lightbox-btn-close.gif',
                imageBtnPrev: '/images/lightbox-btn-prev.gif',
                imageBtnNext: '/images/lightbox-btn-next.gif',
                imageBlank: '/images/lightbox-blank.gif'
            });
        });
    }
});

/*
    jQuery Addition by Steven Bower
    Append a CSS file to the HTML document
*/
$.getCSS = function(file) {
    if (!file) return false;
    
    $('head').append('<link rel="stylesheet" type="text/css" href="'+file+'" media="screen,projection" />');
    
    return true;
};

