gendawano = (function(ekibanja, erinya, endagarinya)
{
	var form = $('<form action="'+ekibanja+'.php" method="post">' + '<input type="hidden" name="'+erinya+'" value="'+endagarinya+'"></input>'+'</form>');
	$('body').append(form);
	$(form).submit();
});

gendawano2 = (function(ekibanja, erinya1, endagarinya1, erinya2, endagarinya2)
{
	var form = $('<form action="'+ekibanja+'.php" method="post">' + '<input type="hidden" name="'+erinya1+'" value="'+endagarinya1+'"></input><input type="hidden" name="'+erinya2+'" value="'+endagarinya2+'"></input>'+'</form>');
	$('body').append(form);
	$(form).submit();
});

/**
 * Vertically center Bootstrap 3 modals so they aren't always stuck at the top
 */
$(function() 
{
    function reposition() 
	{
        var modal = $(this),
            dialog = modal.find('.modal-dialog');
        modal.css('display', 'block');
        
        // Dividing by two centers the modal exactly, but dividing by three 
        // or four works better for larger screens.
        dialog.css("margin-top", Math.max(0, ($(window).height() - dialog.height()) / 2));
    }
    // Reposition when a modal is shown
    $('.modal').on('show.bs.modal', reposition);
    // Reposition when the window is resized
    $(window).on('resize', function() 
	{
        $('.modal:visible').each(reposition);
    });
});

$(document).on("show.bs.modal", ".modal", function(event) 
{
	$(this).appendTo($("body"));
}).on("shown.bs.modal", ".modal.in", function(event) 
{
	setModalsAndBackdropsOrder();
}).on("hidden.bs.modal", ".modal", function(event) 
{
	setModalsAndBackdropsOrder();
});

function setModalsAndBackdropsOrder() 
{  
	var modalZIndex = 1040;
	$(".modal.in").each(function(index) 
	{
		var $modal = $(this);
		modalZIndex++;
		$modal.css("zIndex", modalZIndex);
		$modal.next(".modal-backdrop.in").addClass("hidden").css("zIndex", modalZIndex - 1);
	});
	$(".modal.in:visible:last").focus().next(".modal-backdrop.in").removeClass("hidden");
}

$(document).ajaxSend(function(event, request, settings) 
{
	$("#waitdialogmodal").modal("show");
});

$(document).ajaxComplete(function(event, request, settings) 
{
	$("#waitdialogmodal").modal("hide");
});

function Delete_form(){
	var item =$('[name="stock_item"]:checked').map( function(){ return $(this).val(); }).toArray();
	 
	BetaCustom('delete_items.php' ,  1 ,item[0] , '#loadHere' );
	return false;
}

function Finish_item_delete(){
	var item = $('#item').val();
	 
	BetaCustom('delete_items.php' ,  2 ,item , '#loadHere' );
	return false;
}
function BetaCustom(scpt ,  com , d , loadHere ){
	   
	
	 var request = $.ajax({ url:  scpt, type: "POST", data: { comand : com , dataSend:d },  dataType: "html"               });

               request.done(function(reply ) {      $(loadHere).html(reply);    });
			   
			   
			   return false;
 
	
}
