<!-- 
$(document).ready(function()
{
	// Your code here	
	
	/** 
	 * calculates max left position
	 * @param object scrollable_object
	 * @return int 
	 */
	function getMaxLeft(obj)
	{
		var parent_width = parseInt(obj.parent().css('width'));
		if(isNaN(parent_width))
		{
			parent_width = 0;
		}
		
		var obj_width = parseInt(obj.css('width'));
		if(isNaN(obj_width))
		{
			obj_width = 0;
		}
		
		var max_left = obj_width - parent_width;
		return max_left;
	} // end of function getMaxLeft(obj)
	
	
	// manage preporucujemo
	var todays_recommendations = $('ul#todays_recommendations');
	
	// calculate width for todays_recommendations
	var todays_recommendations_width = (todays_recommendations.find('li.lista-clan').length * 162);
	todays_recommendations.css('width', todays_recommendations_width + 'px');
	
	var rec_parent_width 	= parseInt(todays_recommendations.parent().css('width'));
	if(isNaN(rec_parent_width))
	{
		rec_parent_width = 486;
	}
	
	var rec_max_left 		= todays_recommendations_width - rec_parent_width;
	var rec_common_step		= 486;
	
	// handle right_arrow_small
	$('a#right_arrow_small_1').click(function()
	{
		// check num of elements
		if(todays_recommendations.find('li.lista-clan').length < 4)
		{
			return false;
		}
		
		// get current left
		var curr_left = Math.abs(parseInt(todays_recommendations.css('left')));
		
		if(isNaN(curr_left))
		{
			curr_left = 0;
		}
		
		// calculate step
		var step  		= rec_common_step;
		var temp_left 	= curr_left + rec_common_step;
		if(temp_left > rec_max_left)
		{
			//step = temp_left - rec_max_left;
			step = rec_common_step - (temp_left - rec_max_left);
		}
		
		//if((curr_left + step) > rec_max_left)
		if(step == 0)
		{
			// scroll back to beginning - rewind
			todays_recommendations.animate({"left": "0px"}, 200);
		}
		else
		{
			todays_recommendations.animate({"left": "-=" + step + "px"}, 200);
		}
		
		$(this).blur();
		return false;
	});
	
	
	// handle left_arrow_small 
	$('a#left_arrow_small_1').click(function()
	{
		// get current left
		var curr_left = Math.abs(parseInt(todays_recommendations.css('left')));
		if(isNaN(curr_left))
		{
			curr_left = 0;
		}
		
		if(curr_left == 0)
		{
			// just exit
			return false;
		}
		
		// calculate step
		var step  		= rec_common_step;
		var temp_left 	= curr_left + rec_common_step;
		
		if(temp_left > todays_recommendations_width)
		{
			step = temp_left - todays_recommendations_width;
		}
		
		
		//if((todays_recommendations_width - (curr_left + step)) > rec_parent_width)
		if(curr_left < rec_parent_width)
		{
			// scroll back to beginning - rewind
			todays_recommendations.animate({"left": "0px"}, 200);
		}
		else
		{
			todays_recommendations.animate({"left": "+=" + step + "px"}, 200);
		}
		
		$(this).blur();
		return false;
	});
});
-->