jQuery(document).ready(function(){
 
jQuery("#content a").each(function(){
jQuery(this).removeAttr('title');
})
 
jQuery("#content .featured img").each(function(){
jQuery(this).removeAttr('title');
})

jQuery(".timeline-event-icon").each(function(){
jQuery(this).removeAttr('title');
})

jQuery(".timeline-event-tape").each(function(){
jQuery(this).removeAttr('title');
})

jQuery(".timeline-event-label").each(function(){
jQuery(this).removeAttr('title');

/*
window.setTimeout(function(){
jQuery(".timeline-event-label, .timeline-event-icon, .timeline-event-tape").removeAttr("title")}, 5000));
*/

/*
setInterval(function() {
    $(".timeline-event-label, .timeline-event-icon, .timeline-event-tape").removeAttr("title");
}, 5000);
*/

/*
$(function() {
  setInterval(update, 5000);
});
*/

/*
function update() {
  jQuery(".timeline-event-label, .timeline-event-icon, .timeline-event-tape").removeAttr("title")}, 5000));
}
*/

/*
$(".timeline-event-icon").attr('title', '');

$(".timeline-event-icon").mouseover(function(e){ preventdefault();} );
*/

});

window.setTimeout(function(){
jQuery(".timeline-event-label, .timeline-event-icon, .timeline-event-tape").removeAttr("title")}, 5000);

});



$(function(){

    if(typeof console === "undefined") {
        console = { log: function() { } };
    }
    
    var $ = jQuery;
    
    var SKLIM =   {


        ui: function(){   
			//PATTERN SLIDE
			$('.overlay').hover(
				function() {
					$(this).parent().find('.rotated').animate({ 'margin-left' : '-120px' }, 300);
				}, 
				function() {
					$(this).parent().find('.rotated').animate({ 'margin-left' : '0px' }, 100);
				}
			);
			
			//DESATURATE
			$('.desaturate img').each(function(i, ui) {
				$(this).parent().parent().data('orig', ui);
				$(this).pixastic("desaturate", { average : true });
			});
			 
			$('.desaturate').mouseover(function() {
				$(this).find('.wp-post-image').remove();
				$(this).find('a').append($(this).data('orig'));
			});
			
			$('.desaturate').mouseout(function() {
				$(this).find('img').pixastic("desaturate");
			});
			
			$('.featured .desaturate-front img').each(function(i, ui) {
				$(this).parent().parent().data('orig', ui);
				$(this).pixastic("desaturate", { average : true });
			});
			/* added by Bento */
			
			$('.featured .desaturate-front img').pixastic("desaturate");
			
			/* End - added by Bento */
            $('.desaturate-front').hover(
                function() {
                    $(this).find('.attachment-content-thumb').remove();
    				$(this).find('a').append($(this).data('orig'));
                },
                function() {
				    $(this).find('img').pixastic("desaturate");
                }
            );    
			
			
			//GALLERY
			if($('.gallery li').length > 0) {
                
			    var first = $('.gallery li:first');
    			var length = $('.gallery li').length;

    			first.addClass('active');

                first.next().addClass('next');
                first.next().find('a').append('<span class="arrow"></span>');
                $('.caption').append('<span class="right">1 / ' + length + '</span>');
                $('.caption').append('<span class="left">' + first.find('img').attr('title') + '</span>');

    			$('.gallery li a').click(function(event) {
    				event.preventDefault();
    				$('#content header img').attr('src', $(this).attr('href'));

    				$('#content .active').removeClass('active');
    				$('.gallery .prev').removeClass('prev');
    				$('.gallery .next').removeClass('next');
    				$('.arrow').remove();

                    var num = $(this).parent().index()+1;

                    $('.caption .right').replaceWith('<span class="right">' + num +  ' / ' + length + '</span>');
                    $('.caption .left').replaceWith('<span class="left">' + $(this).find('img').attr('title') + '</span>');

    				var prev = $(this).parent().prev().addClass('prev').find('img').attr('src');
    				var next = $(this).parent().next().addClass('next').find('img').attr('src');

    				$(this).parent().prev().find('a').append('<span class="arrow"></span>');
    				$(this).parent().next().find('a').append('<span class="arrow"></span>');
                    
                    $('.the-thumbnail .navigation').remove();

                    
    				return false;
    			});
    			
    			if($('.gallery li').length <= 1) {
                    $('.gallery').remove();
                }
                
                
                
                $('.the-thumbnail').mouseenter(function(event) {
                    event.stopPropagation();
                    $('.the-thumbnail').append('<span class="navigation"></span>');
                    
                    SKLIM.addnav($(this));
                    
                    $('.the-thumbnail .navigation a').click(function(event) {
                        event.preventDefault();
        				$('#content header img').attr('src', $(this).attr('href')); 
        				
                        if($(this).attr('class') == 'next') {
                            $('.gallery .next a').click();
                        } else {
                            $('.gallery .prev a').click();
                        }
        				SKLIM.addnav($('.the-thumbnail'));

        				return false;

                    });
                });
                
                $('.the-thumbnail').mouseleave(function(event) {
                    event.stopPropagation();
                    $('.the-thumbnail .navigation').remove();
                });
                
                    
			} else {
			        $('.gallery').remove();
			}
			
			
			//OPEN EDIT LINKS IN NEW TAB/WINDOW
			$('.post-edit-link').attr('target', '_BLANK');
			

			
        },
        
        addnav: function($this) {
            if($('.gallery .next').length > 0) {
                $next = $('.gallery .next').find('a').attr('href');
                $this.find('.navigation').append('<a href="'+$next+'" class="next">Next</a>');
            }
            
            if($('.gallery .prev').length > 0) {
                $prev = $('.gallery .prev').find('a').attr('href');
                $this.find('.navigation').append('<a href="'+$prev+'" class="prev">Previous</a>');
            }
            
            
        },

        init: function(){
			$(window).load(function() {
				SKLIM.ui();
			});
			
        }
            
    };
    

	SKLIM.init();


});
