/******************************/
/* Основные функции JS, QQcms */
/******************************/

/* Открытие и закрытие слоёв */
function animate(Show, Hide, HideAlways, Speed, InsertInput) {
	var Input = document.getElementById("animateShowed").value;
	
	if(Show == Input){
	return false;
	} else {
	if(Show != '')
	$("#"+Show).animate({height: "show"}, Speed);
	if(Hide != '' && Input == '')
	$("#"+Hide).animate({height: "hide"}, Speed);
	else if(Hide == '' && Input != '')
	$("#"+Input).animate({height: "hide"}, Speed);
	if(InsertInput == '1')
	document.getElementById("animateShowed").value = Show;
	}
	if(HideAlways != '')
	$("#"+HideAlways).animate({height: "hide"}, Speed);
}


/* Рейтинг */
function rating_set(Id, Post_id) {
  $.post(
  home_page+'/kernel/ajax/rating.php',
  {
    type: "post",
    id: Id,
	post_id: Post_id
  },
  onAjaxSuccess
);
	function onAjaxSuccess(data)
	{
	if(data){
	  document.getElementById("QQrating").innerHTML = data;
	  return true;
	} else {
	  return false;	
	}
	}
}

function rating_select(Id) {
	for(i=1;i<=Id;i++)
	document.getElementById("rating_"+i).className = "rating_3";
}
function rating_unselect(Id, Class) {
	for(i=1;i<=Id;i++)
	document.getElementById("rating_"+i).className = "rating_"+Class;
	//alert("_"+Class);
}

/* Избранные фильмы */
Favorite = {
	
	Add: function(Id) {
		  $.post(
		  home_page+ '/kernel/ajax/favorite.php',
		  {
			type: "post",
			id: Id,
			add: '1'
		  },
		  onAjaxSuccess
		);
		function onAjaxSuccess(data)
		{
		document.getElementById("QQfavorite").innerHTML = data;
	    }
	},
	
	Remove: function(Id) {
		  $.post(
		  home_page+'/kernel/ajax/favorite.php',
		  {
			type: "post",
			id: Id,
			remove: '1'
		  },
		  onAjaxSuccess
		);
		function onAjaxSuccess(data)
		{
		document.getElementById("QQfavorite").innerHTML = data;
	    }
	}
	
}