  $(document).ready(function () {
	
	    
	$(".home-blog-post:last-child").addClass('last');
		 $("#page .column-3:nth-child(3n)").addClass('last');
		  $(".contact-section:nth-child(3n) ").addClass('last');
	 $(".contact-section:nth-child(3n) ").addClass('last');
	$(".column:last-child").addClass('last');
		$(".column-2:nth-child(2n)").addClass('last');
$(".column-4:nth-child(4n)").addClass('last');

	// We are listening to the window.load event, so we can be sure
	// that the images in the slideshow are loaded properly.


	// The canvas manipulations of the images are CPU intensive,
	// this is why we are using setTimeout to make them asynchronous
	// and improve the responsiveness of the page.

	var slides = $('#slideshow .header-li'),
		current = 0,
		slideshow = {width:0,height:0};

	$(".arrow").click(function(event){

event.preventDefault();});
		
		window.console && window.console.time && console.time('Generated In');			
		window.console && window.console.timeEnd && console.timeEnd('Generated In');
		
		$('.arrow').click(function(e){ 
		
		
			var li			= slides.eq(current),
				nextIndex	= 0;

			// Depending on whether this is the next or previous
			// arrow, calculate the index of the next slide accordingly.
			
			if($(this).hasClass('next')){
				nextIndex = current >= slides.length-1 ? 0 : current+1;
			}
			else {
				nextIndex = current <= 0 ? slides.length-1 : current-1;
			}

			var next = slides.eq(nextIndex);
			
		
					current = nextIndex;

					next.addClass('slideActive').fadeIn();
					
					li.fadeOut(function(){
						li.removeClass('slideActive');
						next.addClass('slideActive');

				});
			
		});
		


	
	
	var timeOut = null;
	


	$('.arrow').click(function(e,simulated){

		if(!simulated){
			
			// A real click occured. Cancel the
			// auto advance animation.
			
			clearTimeout(timeOut);
		}
	});

	// A self executing named function expression:
	 setTimeout(
	(function autoAdvance(){
		
		// Simulating a click on the next arrow.
		$('.next').trigger('click',[true]);

		timeOut = setTimeout(autoAdvance,4000);		
	}),4000);;
});

function generateAddress( alias ) {
	var root = 'reincubate.com';
	document.write( '<a href="mailto:' + reverse(alias) + unescape('%40') + root + '">' + reverse(alias) + unescape('%40') + root + '</a>' );
}

// Reverse string 
function reverse( data ) { 
	var output = '';

	for( i = 0; i <= data.length; i++ )
		output = data.charAt (i) + output; 
	

	return output;
}

function showHide( layerRef ) {
	var state = 'none';

	if( document.all ) { // IE 4, 5 or 6
		state = eval( "document.all." + layerRef + ".style.display" );
	} else if( document.layers ) { // NS 4
		state = document.layers[ layerRef ].display;
	} else if( document.getElementById && ! document.all ) {
		hza = document.getElementById( layerRef );
		state = hza.style.display
	}

	if( state == 'block' ) {
		state = 'none';
	} else {
		state = 'block';
	}

	if( document.all ) { // IE 4, 5 or 6
		eval( "document.all." + layerRef + ".style.display = state" );
	} else if( document.layers ) { // NS 4
		document.layers[ layerRef ].display = state;
	} else if( document.getElementById && ! document.all ) {
		hza = document.getElementById( layerRef );
		hza.style.display = state;
	}
}

