$(document).ready(function () {
	$(".green").click(function () {
		this.disabled = true;//this.value='...';
	});

	$('#mainmenu').slicknav({ prependTo: '#topmenu' });

});

function ShowPopInfo($text) {
	$("#popWinBg").css("display", "block");
	$("#popWinBg").css("height", $(document).height() + "px");
	$("#popWin").css("display", "block");
	$("#popWin").html("<div class='e'><img src='/Img/progress.gif'/>" + $text + "</div>");
	var $top = $(window).scrollTop();
	$("#popWin").css("margin-top", $top - 50 + "px");
}

function HidePopInfo() {
	$("#popWinBg").css("display", "none");
	$("#popWin").css("display", "none");
}

/*
 * $text - Textova zprava
 * $time - Kolik vterin ma byt zobrazen
 * $color - 0-zelena, 1-zluta, 2-cervena
 */
function ShowNotify($text, $time, $color) {
	document.getElementById('notify').innerHTML = $text;
	if ($color == 0) {
		$("#notify").css('background-color', '#337AB7');
		$("#notify").css('color', '#fff');
	}
	else if ($color == 1) {
		$("#notify").css('background-color', '#CE881A');
	}
	else if ($color == 2) {
		$("#notify").css('background-color', '#BC1111');
	}
	$("#notify").slideDown("slow").delay($time * 1000).slideUp("slow");
}

function ZobrazitPreklad($id)
{

    if ($("#"+$id).css("display") == "block")
    {
        $("#"+$id).css("display","none");
    }
    else
    {
        $("#"+$id).css("display","block");
    }
}

/* RAZENI SEZNAMU ZAZNAMU V TABULCE */
function SortTable() {

	var fixHelper = function (e, ui) {
		ui.children().each(function () {
			$(this).width($(this).width());
		});
		return ui;
	};
	
	$("#sort tbody").sortable(
    {
		distance: 5,
    	start: function (event, ui) {
    		if (ui.item.hasClass("nodrag")) { return false; }
    		$("#hSort").val(ui.item.index()); $(ui.item).addClass('sorting');
    	},
    	stop: function (event, ui) { $(ui.item).removeClass('sorting'); var x = $('#sort tbody').sortable('toArray'); $("#hSort").val(x); ShowPopInfo("Probíhá řazení záznamu...");__doPostBack('ajaxSort'); },
    	helper: fixHelper
    }).disableSelection();
}

/* RAZENI SEZNAMU ZAZNAMU V SEZNAMU UL */
function SortUL() {

	var fixHelper = function (e, ui) {
		ui.children().each(function () {
			$(this).width($(this).width());
		});
		return ui;
	};

	$("#sort").sortable(
    {
    	distance: 5,
    	start: function (event, ui) {
    		if (ui.item.hasClass("nodrag")) { return false; }
    		$("#hSort").val(ui.item.index()); $(ui.item).addClass('sorting');
    	},
    	stop: function (event, ui) { $(ui.item).removeClass('sorting'); var x = $('#sort').sortable('toArray'); $("#hSort").val(x); ShowPopInfo("Probíhá řazení záznamu..."); __doPostBack('ajaxSort'); },
    	helper: fixHelper
    }).disableSelection();
}



/* POTVRZENI ODSTRANENI ZAZNAMU */
function ConfirmDelete($titulek, $text, $url, $ok, $storno) {
	if ($titulek == "") { $titulek = "Odstranit záznam?"; }
	if ($text == "") { $text = "Opravdu chcete odstranit záznam?"; }
	if ($ok == "") { $ok = "Odstranit"; }
	if ($storno == "") { $storno = "Storno"; }

	swal(
    {
    	title: $titulek,
    	text: $text,
    	type: "warning",
    	showCancelButton: true,
    	confirmButtonColor: "#DD6B55",
    	confirmButtonText: $ok,
    	cancelButtonText: $storno,
    	closeOnConfirm: false,
    	closeOnCancel: true
    },
    function (isConfirm) {
    	if (isConfirm) {
    		location.href = $url;
    	}
    	else {
    	}
    });
}

function DetailSkoly()
{
	$( "#skoladetail" ).slideToggle();
}

//Widget pro razeni zaznamu na mobilnich zarizenich
!function (a) { function f(a, b) { if (!(a.originalEvent.touches.length > 1)) { a.preventDefault(); var c = a.originalEvent.changedTouches[0], d = document.createEvent("MouseEvents"); d.initMouseEvent(b, !0, !0, window, 1, c.screenX, c.screenY, c.clientX, c.clientY, !1, !1, !1, !1, 0, null), a.target.dispatchEvent(d) } } if (a.support.touch = "ontouchend" in document, a.support.touch) { var e, b = a.ui.mouse.prototype, c = b._mouseInit, d = b._mouseDestroy; b._touchStart = function (a) { var b = this; !e && b._mouseCapture(a.originalEvent.changedTouches[0]) && (e = !0, b._touchMoved = !1, f(a, "mouseover"), f(a, "mousemove"), f(a, "mousedown")) }, b._touchMove = function (a) { e && (this._touchMoved = !0, f(a, "mousemove")) }, b._touchEnd = function (a) { e && (f(a, "mouseup"), f(a, "mouseout"), this._touchMoved || f(a, "click"), e = !1) }, b._mouseInit = function () { var b = this; b.element.bind({ touchstart: a.proxy(b, "_touchStart"), touchmove: a.proxy(b, "_touchMove"), touchend: a.proxy(b, "_touchEnd") }), c.call(b) }, b._mouseDestroy = function () { var b = this; b.element.unbind({ touchstart: a.proxy(b, "_touchStart"), touchmove: a.proxy(b, "_touchMove"), touchend: a.proxy(b, "_touchEnd") }), d.call(b) } } }(jQuery);