$(document).ready(
	function() {

		// Open links with rel="external" in new window - like ye ole' target="_blank"
		$('a[rel="external"]').click(function() {window.open( $(this).attr('href') ); return false;});


		// Zebra-stripe data tables
		$("table.data tbody").each(function() {
			$(this).removeClass("odd even");
			$("tr:odd", this).addClass("odd");
			$("tr:even", this).addClass("even");
		});


		// Initialize Lightbox
		$(".lightbox").lightbox();

		// Portfolio Scroller
		$.easing.slider = function (x, t, b, c, d, s) {s = .8; if (s == undefined) s = 1.70158; if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;};
		$('#homeslider').before('<ul id="proceed"><li class="prev"><a style="display:none;" href="#"><span>Previous</span></a></li><li class="next"><a href="#"><span>Next</span></a></li></ul>');

		$('#homeslider li').each(function(i){
			$('#proceed li.next').before('<li class="p'+ i +'"><a href="#" onclick="$(\'#homeslider\').trigger( \'goto\', [ ' + i + ' ] ); return false;">' + i + '</a></li>');
		});
		$('#proceed li.p0').addClass('active');
		$('#proceed li.p1').addClass('active');


		$('#homeslider').serialScroll({items:'li', prev:'#proceed li.prev a', next:'#proceed li.next a', offset:0, start:0, duration:1200, force:true, stop:true, lock:false, cycle:false, easing:'slider', jump: false,
		onBefore:function( e, elem, $pane, $items, pos ){
			var $prev = $('#proceed li.prev a'), $next = $('#proceed li.next a');
			$prev.add($next).show();
			if( pos <= 0 ) $prev.hide();
			else if( pos >= $items.length-2 ) $next.hide();
			$('#proceed li').removeClass('active');
			$('#proceed li.p' + pos).addClass('active');
			$('#proceed li.p' + (pos + 1)).addClass('active');
		}
		});

		// Smoothly scroll to anchor links using ScrollTo.
		$.localScroll();

		// Align images that have align=right attribute value to the right by adding a class and styling via css
		$("#internalcontent img[align=right]").addClass("right");


	}
);
