//START:
$(document).ready(function() {
	$("#parent_name").attr("size", "65");
	lockEnter();
	$("input[value='Zobacz dziennik zmian']").hide();
	window.onbeforeunload = confirmExit;
	$("#register_date").prop("disabled", true);
	$("#assigned_user_name").prop("disabled", true);		
	$("#btn_assigned_user_name").hide();			
	$("#btn_clr_assigned_user_name").hide();
	if($("#document_no").val()==''){
		EcmDocumentNumberGenerator_getNumberTemplate('document_no', 'EcmServiceNews');
	}else{
		if($("[name='duplicateSave']").val() == 'true'){
			EcmDocumentNumberGenerator_getNumberTemplate('document_no', 'EcmServiceNews');
		}else{
			$("#document_no").prop('disabled', true);
		}
		
	}
	DrawHeaders();
	getItems();
});

function createProduct() {
	var newProdId = document.getElementById("newProductId");
	newProduct  = window.open('index.php?module=EcmProducts&action=EditView&IamPopup=1', 'newProduct', 'toolbar=no,menubar=no,scrollbars=yes,scrollbars=1');
	newProduct.newProdId = newProdId;
	newProduct.focus();
}

function confirmExit() {
	return "";
}

function lockEnter() {
	// prevent default
	$(window).keydown(function(event) {
		if (event.keyCode == 13 && $(":focus").prop('tagName')!='TEXTAREA') {
			event.preventDefault();
			return false;
		}
	});
}
var check_form_ = check_form;
check_form = function(formname) {
	clearEmpty();
	$("#position_list").val(JSON.stringifyNoSecurity(items));
	window.onbeforeunload = null;
	$(".loading_panel").css("display", "block");
	$("#register_date").prop("disabled", false);
	$("#assigned_user_name").prop("disabled", false);	
	$(".loading_panel").css("display", "none");
	if (check_form_(formname) == false) {
		$("#register_date").prop("disabled", true);
		$("#assigned_user_name").prop("disabled", true);
		window.onbeforeunload = confirmExit;
		$(".loading_panel").css("display", "none");
		return false;
	} else {
		return true;
	}

};