<!-- 
$(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;
	});
	
	
	if(window.i_day != window.i_def_day)
	{
		return ;	
	}
	
	
	var i = 0;
	
	var lists = $('li.listTV1-inner');
	var max_ind = 0;
	
	if(lists.length > 0)
	{
		max_ind = lists.length - 1;
	}
	
	var date     	 = new Date();
	var unix_time  	 = parseInt(date.getTime() / 1000);
	
	$.each(lists, function(j, li)
	{
		var time_str = $(this).attr('id');
		var time_str_arr = time_str.split(' ');
		
		var year_month_day = time_str_arr[0].split('-');
		var year 	= year_month_day[0];
		var month 	= year_month_day[1] - 1;
		var day		= year_month_day[2];
		
		var hour_min_sec = time_str_arr[1].split(':');
		var hour		 = hour_min_sec[0];
		var minute		 =  hour_min_sec[1];
		
		
		var temp_time = new Date(year, month, day, hour, minute, 0, 0);
		var time = parseInt(temp_time.getTime() / 1000);
		
		if(time > unix_time)
		{
			i = j - 1;
			
			if(i >= 0)
			{
				lists.eq(i).parent().parent().css('background-color', '#EEEEEE');
			}
			return false;
		}
		
		if(j == max_ind && max_ind > 0)
		{
			// highlight last
			lists.eq(max_ind).parent().parent().css('background-color', '#EEEEEE');
			return false;
		}
	});
	/*
	if(i >= 0)
	{
		lists.eq(i).parent().parent().css('background-color', '#EEEEEE');
	}*/
});
-->