$(document).ready(function() {
	$('div#logoman').hover(function(){
		$(this).fadeOut(20);
		$(this).next('div#logoman_logo').fadeIn(50);
	},
	function(){
		return false;
	});
//_________ end flying man _________\\
	$('img.project-image-on').css('opacity',0);
//_________ end image opacity _________\\
	$('div.project a img.project-image-off').addClass('off');
	$('div.project a').hover(function(){
		if($(this).children('img.project-image-off').hasClass('on')){
			$(this).children('img.project-image-off').stop().fadeTo(500,1).removeClass('on').addClass('off');
			$(this).children('img.project-image-on').stop().fadeTo(500,0).removeClass('off').addClass('on');
		}
		else if($(this).children('img.project-image-off').hasClass('off')){
			$(this).children('img.project-image-off').stop().fadeTo(500,0).removeClass('off').addClass('on');
			$(this).children('img.project-image-on').stop().fadeTo(500,1).removeClass('on').addClass('off');
		}
	}, 
	function() {
		// empty mouse off function
	});
//_________ end work grid hover _________\\
	$('#grid_container div').hover(function(){
		var workID = $(this).attr('id');
		$('#grid a span.'+workID).addClass('on');
	},function(){
		var workID = $(this).attr('id');
		$('#grid a span.'+workID).removeClass('on').addClass('off');
	});
//________ grid hover mini _________\\
	$('div#image_container').cycle({ //nested slideshow...this one cycles through the slides 0.25 sec each with no transition.
	    speed:  1, 
		timeout: 300,
		backwards: true,
	    autostop: 1, 
	    end:      
			function() {  // when that is done, this one is called and creates a pager which has an immediate transition.
		        $('div#image_container').cycle({
					timeout: 0,
					speed: 1,
					slideExpr: 'img',
					pager:  '#work_nav', 
				    pagerAnchorBuilder: function(idx, slide) { 
				        return "<li><a class='"+ idx +"' href='#'></a></li>"; 
				    }
				});  
	    	} 
	});
//_________ end work image slideshow _________\\
	$('div#before_after').cycle({ //nested slideshow...this one cycles through the slides 0.25 sec each with no transition.
	    speed:  1, 
		timeout: 300,
		backwards: true,
	    autostop: 1, 
	    end:      
			function() {  // when that is done, this one is called and creates a pager which has an immediate transition.
		        $('div#before_after').cycle({
					timeout: 0,
					speed: 1,
					slideExpr: 'img',
					pager:   '#box_nav',
					pagerAnchorBuilder: pagerFactory,
					manualTrump:     false,
					before:  onBefore,
					after: onAfter
				});  
	    	} 
	});
//_________ end work image slideshow _________\\
});
//_________ end doc ready _________\\
function pagerFactory(idx, slide) {
    var s = idx > 20 ? ' style="display:none"' : '';
    return '<a'+s+' href="#"></a>';
};
//var first = true;
function onBefore() {
	// if (first) { // ignores the onBefore function the first time
	// 	var caption = $(this).find('img').attr('title');
	// 	$('#ba_title').html('<p>'+caption+'</p>');
	// 	first = false; 
	//         return true; 
	//     }
	var caption = $(this).attr('title');
	$('#ba_title').html('<p>'+caption+'</p>');
	$('#ba_description').text($(this).attr('alt'));
}
function onAfter() {
	$('#ba_description').text($(this).attr('alt'));
}
$.fn.delay = function(time, callback){
    // Empty function:
    jQuery.fx.step.delay = function(){};
    // Return meaningless animation, (will be added to queue)
    return this.animate({delay:1}, time, callback);
}
