//global vars
var easingMethod = 'easeInOutCubic';
var ol;

/*------------------------------------------------------------------
modules
------------------------------------------------------------------*/


var aboutIndexNav = function(){
	var an = $('#specialMarqueeNav');
	var lis = an.find('li');
	var animVals = [];
	//the order of the values is liWidth, imgMarg, cpWidth
	var vals1 = [];
	var vals2 = [];
	var vals3 = [];
	var dur = 500;
	
	var init = function(){
		lis.bind('mouseenter', function(){ hoverOn($(this)); });
		an.bind('mouseleave', function(){hoverOff();});
	}
	
	var hoverOn = function(t){
		var cl = t.attr('class');
		var ind = cl.charAt(cl.length - 1);
		switch(ind){
			case '1':     
			vals1 = [400, 0, null];
			vals2 = [288, 0, null];
			vals3 = [288, -70, 264];
			break;
			
			case '2':
			vals1 = [288, -50, null];
			vals2 = [400, 0, null];
			vals3 = [288, -70, 264];
			//$('.s2').html("abs");
			break;
			
			case '3':
			vals1 = [288, -50, null];
			vals2 = [288, -40, null];
			vals3 = [400, 0, 376];
			break;
			
		}
		animVals = [vals1, vals2, vals3];
		moveEm(ind);
	}
	
	var hoverOff = function(){
		vals1 = [326, 0, null];
		vals2 = [326, 0, null];
		vals3 = [326, -70, 300];
		
		animVals = [vals1, vals2, vals3];
		
		//$('.s2').html("Our weekly specials will keep you excited!");
		moveEm();
	}
	
	var moveEm = function(ind){
		var curr = ind != null ? ind : 0;
		
		for(var i = 0;i<lis.length;i++){
			var l = $(lis[i]);
			var img = $(l.find('img'));
			var cp = $(l.find('.copy'));
			if(animVals[i][0] != null){
				l.stop().animate({width:animVals[i][0]}, {duration:dur+12, easing:easingMethod, queue:false});
			}
			if(animVals[i][1] != null){
				img.stop().animate({marginLeft:animVals[i][1]}, {duration:dur, easing:easingMethod, queue:false});
			}
			if(animVals[i][2] != null){
				cp.stop().animate({width:animVals[i][2]}, {duration:dur, easing:easingMethod, queue:false});
			}
			
			if(i != curr-1 && curr != 0 ){
				l.fadeTo(dur, .4);
			}else{
				l.fadeTo(dur, 1);
			}
		}
	}
	init();
}


/*------------------------------------------------------------------
initialize!!
------------------------------------------------------------------*/
$(document).ready(function() {
	if(document.getElementById('specialMarqueeNav')){ var vo = new aboutIndexNav();}
	
});

$("a#special_2").fancybox({
	'titleShow'     : false
});

$("a#special_3").fancybox({
	'titleShow'     : false
});


