$(document).ready(function() {
	
	// Shadowbox
	Shadowbox.init({players: ['img', 'html', 'iframe', 'qt', 'wmp', 'swf', 'flv']});
	
	/**
	 * Slider
	 */
	
	// Settings
	var speed = 800;
	var ease = "easeOutBack";
	var start_pos = 44;
	var step_distance = 215;
	var expected_pos = start_pos;
	var item_count = $("#slider td").size();
	var item_count_calc_value = item_count;
	if (item_count_calc_value > 3) { item_count_calc_value = item_count_calc_value - 4; } else { item_count_calc_value = -1; }
	var max_pos = 0-((item_count_calc_value*step_distance)+start_pos);
	
	// Start
	$("div#slider_items").stop().animate({"marginLeft":start_pos+"px"}, speed, ease);
	
	// Button action previous	
	$("a#slider_btn_prev").click(function () {

		// Current pos
		current_pos = parseInt($("div#slider_items").css("marginLeft"));		

		// Change if previous action is completed and if new previous pos is allowed
		if (expected_pos == current_pos && current_pos < start_pos) {
		
			// New pos
			new_pos = current_pos + step_distance;
			expected_pos = new_pos;
			
			// Set new position
			$("div#slider_items").stop().animate({"marginLeft":new_pos+"px"}, speed, ease);
		}
	});
	
	// Button action next	
	$("a#slider_btn_next").click(function () {

		// Current pos
		current_pos = parseInt($("div#slider_items").css("marginLeft"));	

		// Change if previous action is completed and if new next pos is allowed
		if (expected_pos == current_pos && current_pos > max_pos) {

			// New pos
			new_pos = current_pos - step_distance;
			expected_pos = new_pos;
			
			// Set new position
			$("div#slider_items").stop().animate({"marginLeft":new_pos+"px"}, speed, ease);
		}
	});	

	
	$('.jcaroussel').jCarouselLite({
	    btnNext: '.next',
	    btnPrev: '.prev',
	    visible: 3,
	    auto: 1500,
	    speed: 1000

	});
	
	$('.jcaroussel_home').jCarouselLite({
	    vertical: true,
	    visible: 3,
	    auto: 1500,
	    speed: 1000

	});
	
});
