
	function moveMarker(id){
		$('#marker').removeClass();
		if(id>2){
			if(id=='3')
			id=0
			else if(id=='4')
			id=1
			else if(id=='5')
			id=2
			else if(id=='6')
			id=0
			else if(id=='7')
			id=1
		}
		$('#marker').addClass('markerPosition_'+ id);  
  	}
	 
	 function onAfter (curr, next, opts){
		/*$("#descriptions .slide").eq(opts.currSlide).animate({marginLeft:'0px', opacity:1},600);*/
		$("#c_images img").eq(opts.currSlide).animate({marginLeft:'0px', opacity:1},600);
		currentActiveID = opts.currSlide;
		
		
	}

	function onBefore (curr, next, opts){
		moveMarker(opts.currSlide+1);
		$("#c_images img").eq(opts.nextSlide).css({opacity:'0',marginLeft:'5px'});
	/*	$("#descriptions .slide").eq(opts.nextSlide).css({opacity:'0',marginLeft:'5px'});*/
	
	} 
var currentActiveID = 0;
// execute your scripts when DOM is ready. 
$(function() {
	$('#carousel #c_images').cycle({ 
    	fx: 'custom', 
		cssBefore: {
		top:0,
		left: 20,
		opacity:0,
		display:'block'
		},
		animIn: {
		left:0,
		opacity:1
		},
		animOut: {
		top: 0,
		left: -10,
		opacity:0
		}, 		
		before: onBefore,
		after:onAfter,
		timeout:6000,
		speed:600, cleartype: true, cleartypeNoBg: true,
		next: "#c_next",
		prev: "#c_prev",
		
		before: function(curr, next, opts) {
			var x = opts.nextSlide; 
			
			moveMarker(opts.nextSlide);
			$("#c_buttons a").removeClass("activeSlide active_"+currentActiveID); 
			if(opts.nextSlide>opts.currSlide){
				if(x>5){
					$('#c_buttons').cycle(2);
				}
				else if(x>2){
					$('#c_buttons').cycle(1);
				}
			}
			else if(opts.nextSlide<opts.currSlide){
					if(x==5) {
					$('#c_buttons').cycle(1);
					}
					else if((x==2) || (x==0)){
					$('#c_buttons').cycle(0);
					}
				}
			$('#btn_'+x).addClass('activeSlide active_'+x);
			$('#ticker, #descriptions').cycle(x);
			}
	});

	$('#carousel #descriptions').cycle({ 
    	fx: 'fade',  
		timeout:0,
		speed:1100, 
		cleartype: true,  
		cleartypeNoBg: true,
		/*next: "#c_next",
		prev: "#c_prev", */
		startingSlide: 0 
	});
	 
	moveMarker(0);
	$("#c_buttons a").removeClass("activeSlide active_1");
	$('#btn_0').addClass('activeSlide active_0');
	
	$(".slide_button").click(function(evt){
		 if(!$(this).hasClass('activeSlide')) {
			var slideID = $(this).attr('id').split('_');
			var slideID = parseFloat(slideID[1]);
			$(' #carousel #c_images').cycle(slideID);
			evt.preventDefault();
			$("#c_buttons a").removeClass("activeSlide active_"+currentActiveID); 
			return false;
			}
	});
	
	/* buttons cycling */
	$('#c_buttons').cycle({
		speed: 1100,
		fx: 'scrollHorz',
		cleartypeNoBg: true,
		timeout:0
	});
	/* news cycling */
	$('#ticker').cycle({
		speed: 1100,
		cleartype: true, 
		cleartypeNoBg: true,
		timeout:6000
	}); 
	
});
