$(document).ready(function() {

    // External links with REL
    $('a[rel="external"]').attr('target','_blank');

    // Logo onclick return home
    $('h1#logo').click(function() {
        window.location = "/";
    });

    // Highlight current nav
    $('a[href="' + window.location.pathname + '"]').each(function(){
        $(this).addClass("current")
    })    
    
    // Sidebar fadein/out
    $('#sidebar')
      .fadeTo('fast', .4)
      .mouseover(function() {
        $(this).stop().fadeTo('fast', 1);
    }).mouseout(function() {
        $(this).stop().fadeTo('fast', .4);
    });
    
    // Build gallery nav
    $('.needsnav').after('<ul id="fader-nav"></ul>');
    $('.needsnav li').each(function(index) {
        $('<li class="slide_' + index + '"></li>').appendTo('#fader-nav');
    })
    
    // Gallery nav
    $('#fader-nav')
      .each( function() {
        var width = $(this).width();
        var newwidth = width / 2 + 30;
        $(this).css('margin-left','-' + newwidth + 'px');
    }).fadeTo('fast', .4)
      .mouseover(function() {
        $(this).stop().fadeTo('fast', 1);
    }).mouseout(function() {
        $(this).stop().fadeTo('fast', .4);
    });
});

$(document).ready(
    function(){
    	$('ul#fader').innerfade({
        speed: 1000,
        timeout: 4000,
        type: 'sequence',
        containerheight: 	'100%',
        slide_timer_on: 	'yes',
        slide_ui_parent: 	'fader',
       	slide_nav_id:		'fader-nav'
    	});
    	$.setOptionsButtonEvent();
});

