//Скрол
$(function(){
	//Get our elements for faster access and set overlay width
	var div = $('#lenta_films_1'),
		ul = $('#lenta_films_1_1'),
		ulPadding = 15;

	//Get menu width
	var divWidth = div.width();

	//Remove scrollbars
	div.css({overflow: 'hidden'});

	//Find last image container
	var lastLi = ul.find('li:last-child');

	div.scrollLeft(150);
	//When user move mouse over menu
	div.mousemove(function(e){
		//As images are loaded ul width increases,
		//so we recalculate it each time
		var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;
		var left2 = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
		div.scrollLeft(left2);
		//div.animate({scrollLeft: left2}, 1, 'easeOutBack');
	});
});


//Скрол
$(function(){
	//Get our elements for faster access and set overlay width
	var div = $('#lenta_films_2'),
		ul = $('#lenta_films_2_1'),
		ulPadding = 15;

	//Get menu width
	var divWidth = div.width();

	//Remove scrollbars
	div.css({overflow: 'hidden'});

	//Find last image container
	var lastLi = ul.find('li:last-child');

	div.scrollLeft(150);
	//When user move mouse over menu
	div.mousemove(function(e){
		//As images are loaded ul width increases,
		//so we recalculate it each time
		var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;
		var left2 = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
		div.scrollLeft(left2);
		//div.animate({scrollLeft: left2}, 1, 'easeOutBack');
	});
});




//Вкладки фильмов
function vkl(type) {
	if (type==0) {
		$("#lenta_films_1").hide();
		$("#lenta_films_2").show();
		$(".div_vkl_c_empty").remove();
		$(".div_vkl_l").before('<div class="div_vkl_c_empty"><a class="kinoprimery" href="javascript:vkl(1)">Расписание киносеансов</a></div>');
		$(".div_vkl_c").html('<a class="all_afisha" href="/skoro_na_ekrane">Вся афиша</a><br clear="all"/>Ожидаемые кинопремьеры');
	}
	 else {
		$("#lenta_films_2").hide();
		$("#lenta_films_1").show();
		$(".div_vkl_c_empty").remove();
		$(".div_vkl_r").after('<div class="div_vkl_c_empty"><a class="kinoprimery" href="javascript:vkl(0)">Ожидаемые кинопремьеры</a></div>');
		$(".div_vkl_c").html('<a class="all_afisha" href="/smotrite_segodnya">Вся афиша</a><br clear="all"/>Расписание киносеансов');
	}
}




//Опрос
  $(document).ready(function(){

    $("#opros_c").click(function () {
		appends('div_opros_v');
	  $("#div_opros_v").width($("#div_opros").width());
      $("#div_opros_v").show();

    });
    $("#opros_c").hover(function () {
     $(this).attr("class","div_opros_c_act");
     $(".div_opros_l").attr("class","div_opros_l_act");
     $(".div_opros_r").attr("class","div_opros_r_act");
    }, function () {
      $(this).attr("class","div_opros_c");
	  $(".div_opros_l_act").attr("class","div_opros_l");
	  $(".div_opros_r_act").attr("class","div_opros_r");
    });
});



function votings(id){
	var vote_num = $("#vote_num").val();
	$("#answes_data").load("/voting/go_vote/"+vote_num+"/0/"+id);
}



function votings_more(){
	var vote_num = $("#vote_num").val();

 root = document.getElementById("answes_data");
 els = root.getElementsByTagName("input");
 var mask = '';
   for(i = 0; i < els.length; i++)
     if (els[i].type == "checkbox"  )
	   if (els[i].checked == true  )
	      mask =   mask+els[i].value+',';

   $("#answes_data").load("/voting/go_vote/"+vote_num+"/1/"+mask);

}


