/** image carousel effects **/
var curidx = 1;
var maxidx = 0;

var curidx_prom = 1;
var maxidx_prom = 0;


var calgo = true;
var calgo_prom = true;

$(document).ready(
	function() {
		maxidx = $('#mygallery .belt .panel').length;				
		
		$('#gallerynextlink').click(function() {
			if(calgo == false) return false;
			calgo = false;
			curidx++;
			if(curidx>maxidx) curidx=1;
			hiliteDot(curidx);
			stepcarousel.stepBy('mygallery', 1);
			return false;
		});

		$('#galleryprevlink').click(function() {
			if(calgo == false) return false;
			calgo = false;
			curidx--;
			if(curidx<1) curidx=maxidx;
			hiliteDot(curidx);
			stepcarousel.stepBy('mygallery', -1);
			return false;
		});
		
		maxidx_prom = $('#mypromotions .belt .panel').length;		

		$('#promotionsnextlink').click(function() {
			if(calgo_prom == false) return false;
			calgo_prom = false;
			curidx_prom++;
			if(curidx_prom>maxidx_prom) curidx_prom=1;
			hiliteDot_prom(curidx_prom);
			stepcarousel.stepBy('mypromotions', 1);
			return false;
		});

		$('#promotionsprevlink').click(function() {
			if(calgo_prom == false) return false;
			calgo_prom = false;
			curidx_prom--;
			if(curidx_prom<1) curidx_prom=maxidx_prom;
			hiliteDot_prom(curidx_prom);
			stepcarousel.stepBy('mypromotions', -1);
			return false;
		}

		
		);
	}			  
);

function hiliteDot(idx) {
	var ss = '#gallerynav'+idx;
	for(i=1;i<=maxidx;i++) $('#gallerynav'+i).attr('src','images/ad_nav/dot_b.gif');
	$(ss).attr('src','images/ad_nav/dot_a.gif');
}

function hiliteDot_prom(idx) {
	var ss = '#promotionsnav'+idx;
	for(i=1;i<=maxidx;i++) $('#promotionsnav'+i).attr('src','images/ad_nav/dot_b.gif');
	$(ss).attr('src','images/ad_nav/dot_a.gif');
}


stepcarousel.setup({
	galleryid: 'mygallery', //id of carousel DIV
	beltclass: 'belt', //class of inner "belt" DIV containing all the panel DIVs
	panelclass: 'panel', //class of panel DIVs each holding content
	autostep: {enable:true, moveby:1, pause:2500, resumeautostep:false},
	panelbehavior: {speed:500, wraparound:true, persist:false},
	defaultbuttons: {enable: false},
	statusvars: ['startA', 'startB', 'total'], //register 3 variables that contain current panel (start), current panel (last), and total panels
	onslide:function() {
		calgo = true;
		curidx = startA;
		hiliteDot(startA);
	},
	contenttype: ['inline'] //content setting ['inline'] or ['external', 'path_to_external_file']
});

stepcarousel.setup({
	galleryid: 'mypromotions', //id of carousel DIV
	beltclass: 'belt', //class of inner "belt" DIV containing all the panel DIVs
	panelclass: 'panel', //class of panel DIVs each holding content
	autostep: {enable:true, moveby:1, pause:2500, resumeautostep:false},
	panelbehavior: {speed:500, wraparound:true, persist:false},
	defaultbuttons: {enable: false},
	statusvars: ['startA_Prom', 'startB_Prom', 'total_Prom'], //register 3 variables that contain current panel (start), current panel (last), and total panels
	onslide:function() {
		calgo_prom = true;
		curidx_prom = startA_Prom;
		hiliteDot_prom(startA_Prom);
	},
	contenttype: ['inline'] //content setting ['inline'] or ['external', 'path_to_external_file']
});
