	function add_demoview() {
		NProgress.start();
		var token = $('#token').val();
		var server = $('#server').val();
		var nick = $('#nick').val();
		var img = $('#screens').val();
		var demo = $('#demo').val();
		img=encodeURIComponent(img);
		demo=encodeURIComponent(demo);

		$.ajax({
			type: "POST",
			url: "../modules_extra/demoview/ajax/actions.php",
			data: "phpaction=1&add_demoview=1&token=" + token + "&server=" + server + "&nick=" + nick + "&img=" + img + "&demo=" + demo,
			dataType: "json",

			success: function (result) {
				NProgress.done();
				if (result.status == 1) {
					$('#create_btn').addClass('disabled');
					$('#create_btn').text('Добавление...');
					$('#create_btn').attr('onclick', '');
					setTimeout("$('#create_btn').text('Готово')", 500);
					setTimeout(show_ok, 500);
					setTimeout(function () {
						document.location.href = "demo?id=" + result.id;
					}, 2000);
				} else {
					setTimeout(show_error, 500);
					show_input_error(result.input, result.reply);
				}
			}
		});	
	}
function close_demoview(id,type){
	if(confirm("Вы уверены?")){
		NProgress.start();
		var token=$("#token").val();
		$.ajax({
			type:"POST",
			url: "../modules_extra/demoview/ajax/actions.php",
			data:"phpaction=1&close_demoview=1&token="+token+"&id="+id+"&type="+type,
			dataType:"json",
			success:function(result){
				NProgress.done();
				if(result.status==1){
					setTimeout(show_ok,500);
					$("#closed").html('<p><span class="m-icon icon-user"></span> <b>Просмотрел: </b><a href="../profile?id='+result.closed+'">'+result.closed_a+'</a></p>');
					$("#status").removeClass("label-default");$("#status").removeClass("label-success");$("#status").removeClass("label-danger");
					$("#status").addClass("label-success");$("#status").html("Демо просмотрено");
				}
				if(result.status==2){
					setTimeout(show_error,500);
				}
			}
		})
	}
}
function dell_demoview(id){
	if(confirm("Вы уверены?")){
		NProgress.start();
		var token=$("#token").val();
		$.ajax({
			type:"POST",
			url: "../modules_extra/demoview/ajax/actions.php",
			data:"phpaction=1&token="+token+"&dell_demoview=1&id="+id,
			dataType:"json",
			success:function(result){
				NProgress.done();
				if(result.status==1){
					setTimeout(show_ok,500);
					location.href='../demoview';
				}else{
					setTimeout(show_error,500);
				}
			}
		})
	}
}
function load_demoview_comments(id){var token=$('#token').val();$.ajax({type:"POST",url: "../modules_extra/demoview/ajax/actions.php",data:"phpaction=1&token="+token+"&load_demoview_comments=1&id="+id,success:function(html){$("#comments").html(html);}});}
function send_demoview_comment(id){NProgress.start();var token=$('#token').val();var text=tinymce.get("text").getContent();text=$.trim(text);text=encodeURIComponent(text);$.ajax({type:"POST",url: "../modules_extra/demoview/ajax/actions.php",data:"phpaction=1&token="+token+"&send_demoview_comment=1&text="+text+"&id="+id,dataType:"json",success:function(result){NProgress.done();if(result.status==1){clean_tiny('text');stop_button('#send_btn',1000);load_demoview_comments(id);setTimeout(show_ok,500);}else{setTimeout(show_error,500);show_input_error(result.input,result.reply,null);}}});}
function dell_demoview_comment(id){NProgress.start();var token=$('#token').val();$.ajax({type:"POST",url: "../modules_extra/demoview/ajax/actions.php",data:"phpaction=1&token="+token+"&dell_demoview_comment=1&id="+id,dataType:"json",success:function(result){NProgress.done();if(result.status==1){$("#message_id_"+id).fadeOut();setTimeout(show_ok,500);}
if(result.status==2){setTimeout(show_error,500);}}});}
