$(document).ready(function() {
    /* 
    * attach a function to open all links with a class of "external" in a new window 
    * this avoids the use of target="_blank" and allows us to validate as XHTML strict
    */
    $("a[rel^='external']").click( function() {
        window.open(this.href);
        return false;
    });
    
    $("a[rel^='prettyPhoto']").prettyPhoto();
    
    $('#slideshow').cycle({ 
        speed:  2000,
        timeout:  5000
    });
    
    $("#nav a").hover(function(){
        var $marginLefty = $("span", this);
        $marginLefty.animate({
            marginLeft: parseInt($marginLefty.css('marginLeft'),0) == 0 ? $marginLefty.outerWidth() : 0 
        }, 'fast');
    },function(){
        var $marginLefty = $("span", this);
        $marginLefty.animate({
            marginLeft: parseInt($marginLefty.css('marginLeft'),0) == 0 ? $marginLefty.outerWidth() : 0 
        }, 'fast', function() { $marginLefty.css('marginLeft',170); });
    });
       
    /* needed for renderings swap */
    $('a.folioLinkGraphic').click(function(){
        // get the ID of the image to fade in
        var targetID = $(this).attr("id").replace("thumb-", "");
        
        $('a.folioLinkGraphic').each(function (i) {
            $('a.folioLinkGraphic').removeClass('activeFolioLink');
        });
        
        $('a.folioLinkGraphic').removeClass('activeFolioLink');
        $(this).addClass('activeFolioLink');
        // if there are any active images in the container
        if ($('#folioAfterPhoto img.active').length > 0){
            // fade them out (and remove the flag)
            $('#folioAfterPhoto img.active').fadeOut(200, function(){
                // when the fade out is done, fade in the new image and flag it
                $('#'+targetID).fadeIn(200).addClass('active');
            }).removeClass('active');

        } else {
            // just fade in the target image and flag it
            $('#'+targetID).fadeIn('normal').addClass('active');
        }
    });
	
         
});


