$(document).ready(function () {
							
	//Apply dynamic CSS classes
    $("#nav li:last").addClass("no-bg");	
	$("#nav li.active").prev().addClass("no-bg");
	$("#sub-nav li:last").addClass("last");	
    $("#news-list li:first").addClass("first");
    $("#news-list li:last").addClass("last");
    $("#intro p:last").addClass("last");
    $("#service-columns .service-col:last").addClass("last");
	
	//Homepage feature rotator
	$('#rotator').cycle({ 
        fx: 'scrollHorz',
        speed: 'slow',     
        timeout: 8000,
		next: '#btn-next', 	
    	prev: '#btn-prev',
		pause: 1,
	    pauseOnPagerHover: 0, //Set this to 1 if you want it to pause when hovering over one of the three boxes //
        pager: '#rotator-controls', 
        pagerEvent: 'click',
        easing: 'expoinout',
		before: onBefore,    
        random: 0,
        pagerAnchorBuilder: function(idx, slide) { 
            return '#rotator-controls li:eq(' + idx + ') '; 
        } 
    });	
	
	//Sector hub page tabs
	$("#tabs").tabs();
});

//Determine which of the three boxes will be selected to appropriately display the separator lines
function onBefore(curr, next, opts) {
	var index = opts.currSlide;
	index = parseInt($(this).attr("id").substr($(this).attr("id").length - 1, 1));
	if(index == 3) {
		$("#control-2").addClass("left");}
	else {
		$("#control-2").removeClass("left");}
}

// CYCLE TRANSITION
(function($) {
$.fn.cycle.transitions.scrollHorz = function($cont, $slides, opts) {
	$cont.css('overflow','hidden').width();
	opts.before.push(function(curr, next, opts, fwd) {
		$.fn.cycle.commonReset(curr,next,opts);
		opts.cssBefore.left = fwd ? (next.cycleW-1) : (1-next.cycleW);
		opts.animOut.left = fwd ? -curr.cycleW : curr.cycleW;
	});
	opts.cssFirst = { left: 0 };
	opts.cssBefore= { top: 0 };
	opts.animIn   = { left: 0 };
	opts.animOut  = { top: 0 };
};
})(jQuery);
