



function lgClick(){
	$.ajax({
		type: 'POST',
		url: "../access/login.jsp",
		 cache: false,
	    	success: function (data, textStatus, XMLHttpRequest){
		 $("#mdShowCntr").html(data);
		 $("#mdShowCntr").dialog({
			 autoOpen: false,
			 modal: true,
			 draggable: false,
			 buttons: {
			 	'Anulează':function() {
					$(this).dialog('close');
				},
				'Autentifică': function() {
					$("#lgnFrm").submit();
					$(this).dialog('close');
				}
		 	},
		 	show: 'drop',
		 	hide: 'drop',
		 	width: 300,
		 	title: 'Autentificare',
		 	open: function(event, ui) {
				 $("#lgnUNm").focus();
		 	}
			});
		 $("#mdShowCntr").dialog('open');
	}
	});
}

function regClick(){
	$.ajax({
	type: 'POST',
	url: "../access/register.jsp",
		 cache: false,
	    success: function (data, textStatus, XMLHttpRequest){
		 $("#mdShowCntr").html(data);
		 $("#mdShowCntr").dialog({
			 autoOpen: false,
			 modal: true,
			 draggable: false,
			 buttons: {

				'Anulează':function() {
					$(this).dialog('close');
				},	
				'Crează Cont': function() {
				$.ajax({
					type: 'POST',
					cache: false,
					url: "../Register",
					data: $("#regFrm").serialize(),
					dataType: 'json',
					success: function (data, textStatus, XMLHttpRequest){
						if("1"==data.s){
							$("#mdShowCntr").dialog('close');
							window.location = "../";
						}else{
							$.each(data, function(key, val) {
								$("#"+key).html(val);
								if(val.length>0){
									$("#"+key).show();
								}else{
								$("#"+key).hide();
								}
							});
						}
					}
					});
					//$(this).dialog('close');
				}
		 	},
		 	show: 'drop',
		 	hide: 'drop',
		 	width: 450,
		 	title: 'Creare cont'
			});
		 $("#mdShowCntr").dialog('open');
	}
	});
}
function act(){
	$.ajax({
		type: 'POST',
		url: "../access/activate.jsp",
		 cache: false,
	    	success: function (data, textStatus, XMLHttpRequest){
		 $("#mdShowCntr").html(data);
		 $("#mdShowCntr").dialog({
			 autoOpen: false,
			 modal: true,
			 draggable: false,
			 buttons: {
			 	'Anulează':function() {
					$(this).dialog('close');
				},
				'Validează': function() {
					$.ajax({
						type: 'POST',
						url: "../ActivateFirm",
						data: $("#frmact").serialize(),
						dataType: 'json',
						cache: false,
					    success: function (data, textStatus, XMLHttpRequest){
					    	$("#mdShowCntr").html(data.msg);
					    	$("#mdShowCntr").dialog( "option", "buttons", 
					    		{
							        'Prima pagină': function() {
							        	$(this).dialog("close");
							        	document.location="/"; 
							        }
							    }
							 );
					    }
				    	});
				}
		 	},
		 	show: 'drop',
		 	hide: 'drop',
		 	width: 350,
		 	title: 'Activare cont',
		 	open: function(event, ui) {
				 $("#actcd").focus();
		 	}
			});
		 $("#mdShowCntr").dialog('open');
	}
	});
}
function getUmList(){
	$.ajax({
	type: 'POST',
	url:"../um/umList.jsp",
		cache: false,
		success: function (data, textStatus, XMLHttpRequest){
		 $("#umCntn").html(data);
		}
	});	
}

function editUm(idUm){
	$.ajax({
	type: 'POST',
	url: "../um/edit.jsp",
		 cache: false,
		 data: 'idUm='+idUm,
	    	success: function (data, textStatus, XMLHttpRequest){
		 $("#mdShowCntr").html(data);
		 $("#mdShowCntr").dialog({
			 autoOpen: false,
			 modal: true,
			 draggable: false,
			 buttons: {
				'Anulează':function() {
					$(this).dialog('close');
				},
				'Salvează': function() {
					$.ajax({
					type: 'POST',
					url:"../SaveUM",
						cache: false,
						data: $("#umFrm").serialize(),
						success: function(){
							getUmList();
						}
					});
					$(this).dialog('close');
				}	
		 	},
		 	show: 'drop',
		 	hide: 'drop'
			});
		 $("#mdShowCntr").dialog('open');
	}
	});
}

function dUm(idUm){
	$.ajax({type: 'POST',
	url:"../DeleteUM",
		cache: false,
		data: 'idUm='+idUm,
		success: function(data){
			showInfo(data);
			getUmList();
		}
	});
}

function getVATList(){
	$.ajax({
	type: 'POST',
	url:"../vat/vatList.jsp",
		cache: false,
		success: function (data, textStatus, XMLHttpRequest){
		 $("#vatCntn").html(data);
		}
	});	
}

function eVAT(idVat){
	$.ajax({
	type: 'POST',
	url: "../vat/edit.jsp",
		 cache: false,
		 data: 'idVat='+idVat,
	    	success: function (data, textStatus, XMLHttpRequest){
		 $("#mdShowCntr").html(data);
		 $("#mdShowCntr").dialog({
			 autoOpen: false,
			 modal: true,
			 draggable: false,
			 buttons: {
				'Anulează':function() {
					$(this).dialog('close');
				},
				'Salvează': function() {
					$.ajax({
					type: 'POST',
					url:"../SaveVAT",
						cache: false,
						data: $("#vatFrm").serialize(),
						success: function(data){
							showInfo(data);
							getVATList();
						}
					});
					$(this).dialog('close');
				}	
		 	},
			show: 'drop',
			hide: 'drop',
			title: $("#title").val()
			});
		 $("#mdShowCntr").dialog('open');
	}
	});
}

function dVAT(idVat){
	$.ajax({
	type: 'POST',
	url:"../DeleteVAT",
		cache: false,
		data: 'idVat='+idVat,
		success: function(data){
			showInfo(data);
			getVATList();
		}
	});
}

function addInvPrd(){
	$.ajax({
	type: 'POST',
	url:"../SaveInvoiceProduct",
		cache: false,
		data: $("#invPrdFrm").serialize()+"&"+$("#invFrm").serialize()+"",
		success: function(){
			getInvPrdLst();
		}
	});
}

function getInvPrdLst(){
	$.ajax({
	type: 'POST',
	url:"../invoice/invoiceProdList.jsp",
		cache: false,
		data: $("#invFrm").serialize(),
		success: function(data){
			$("#invProd").html(data);
		}
	});
}

function getPrdList(){
	$.ajax({
	type: 'POST',
	url:"../product/productList.jsp",
		cache: false,
		data: $("#schProdFrm").serialize(),
		success: function(data){
			$("#prdList").html(data);
		}
	});
}

function dInvProd(invProdGuid){
	$.ajax({
	type: 'POST',
	url:"../DeleteInvoiceProduct",
		cache: false,
		data: "eguid="+$("#eguid").val()+"&invProdGuid="
		+invProdGuid+"&idInvCat="+$("#idInvCat").val()+"",
		success: function(data){
		getInvPrdLst();
		}
	});
}

function editProduct(idPrd){
	$.ajax({
	type: 'POST',
	url: "../product/edit.jsp",
		 cache: false,
		 data: 'idProd='+idPrd,
	    success: function (data, textStatus, XMLHttpRequest){
		 $("#mdShowCntr").html(data);
		 $("#mdShowCntr").dialog({
			 autoOpen: false,
			 modal: true,
			 draggable: false,
			 buttons: {
				'Anulează':function() {
					$(this).dialog('close');
				},
				'Salvează': function() {
					$.ajax({
						type: 'POST',
						url:"../SaveProduct",
						cache: false,
						data: $("#invPrdFrm").serialize(),
						success: function(){
							getPrdList();
						}
					});
					$(this).dialog('close');
				}	
		 	},
			show: 'drop',
			hide: 'drop',
		 	width: 650
			});
		 $("#mdShowCntr").dialog('open');
	}
	});
}

function deleteProd(idPrd){
	$.ajax({
	type: 'POST',
	url: "../DeleteProduct",
		 cache: false,
		 data: 'idProd='+idPrd,
	    success: function (data, textStatus, XMLHttpRequest){
	    	showInfo(data);
	    	getPrdList();
	    }
	});
}

function sInv(){
	$.ajax({
	type: 'POST',
	url:"../SaveInvoiceClient",
		cache: false,
		data: $("#clntFrm").serialize(),
		success: function(){
		//$("#invFrm").submit();
		
		$.ajax({
		type: 'POST',
		url:"../SaveInvoice",
				data: $("#invFrm").serialize()+"&"+$("#invDispFrm").serialize()+"&"+$("#frmInvTpl").serialize(),
				cache: false,
				dataType: 'json',
				success: function(data){
					$("#idinv").val(data.idinv);
					$("#idInvProd").val(data.idinv);
					$("#idClnt").val(data.idClnt);
					showInfo(data.msg);
				},
				error:function(data){
				 showInfo(data);
				 }
				
			});
		
		}
	});
}

function getInvSrList(){
	$.ajax({
	type: 'POST',
	url:"../serie/serieList.jsp",
		cache: false,
		data: 'idObj='+$('#idObj').val(),
		success: function(data){
			$("#invSrCntn").html(data);
		}
	});
}

function eSr(idInvSr)
{
	$.ajax({
	type: 'POST',
	url: "../serie/edit.jsp",
		 cache: false,
		 data: 'idInvSr='+idInvSr+'&idObj='+$('#idObj').val(),
	    	success: function (data, textStatus, XMLHttpRequest){
		 $("#mdShowCntr").html(data);
		 $("#mdShowCntr").dialog({
			 autoOpen: false,
			 modal: true,
			 draggable: false,
			 buttons: {
				'Anulează':function() {
					$(this).dialog('close');
				},
				'Salvează': function() {
					$.ajax({
					type: 'POST',
					url:"../SaveInvoiceSerie",
						cache: false,
						data: $("#invSrFrm").serialize(),
						success: function(){
							getInvSrList();
						}
					});
					$(this).dialog('close');
				}	
		 	},
			show: 'drop',
			hide: 'drop',
			title: $("#title").val()
			});
		 $("#mdShowCntr").dialog('open');
	}
	});
}

function dSr(idInvSr){
$.ajax({
type: 'POST',
url: "../DeleteSerie",
		 cache: false,
		 data: 'idInvSr='+idInvSr+'&idObj='+$('#idObj').val(),
	    	success: function (data, textStatus, XMLHttpRequest){
		 	$("#mdShowCntr").html(data);
		 	showInfo(data);
		 	getInvSrList();
		 }
	});
}

function getClientList()
{
	$.ajax({
	type: 'POST',
	url:"../client/clientList.jsp",
		cache: false,
		data: $("#schClntFrm").serialize(),
		success: function(data){
			$("#clntCntn").html(data);
		}
	});
}

function editClient(idClnt){
	$.ajax({
	type: 'POST',
	url: "../client/edit.jsp",
		 cache: false,
		 data: 'idClnt='+idClnt,
	    	success: function (data, textStatus, XMLHttpRequest){
		
		 $("#mdShowCntr").html(data);
		 $("#mdShowCntr").dialog({
			 autoOpen: false,
			 modal: true,
			 draggable: false,
			 title: 'Editare client',
			 buttons: {
				'Anulează':function() {
					$(this).dialog('close');
				},
				'Salvează': function() {
					$.ajax({
					type: 'POST',
					url:"../SaveClient",
						cache: false,
						data: $("#clntFrm").serialize(),
						success: function(){
							getClientList();
						}
					});
					$(this).dialog('close');
				}	
		 	},
		 	width: 250,
			show: 'drop',
			hide: 'drop'
			});
		 $("#mdShowCntr").dialog('open');
	}
	});
}

function dClnt(idClnt){
	$.ajax({
	type: 'POST',
	url: "../DeleteClient",
		 cache: false,
		 data: 'idClnt='+idClnt,
	    	success: function (data, textStatus, XMLHttpRequest){
	    		showInfo(data);
	    		getClientList();
	    	}
	});
}

function vInv(idInv, idInvCat, idInvTpl){
if(!idInvCat){
	idInvCat=2;
}
	$.ajax({
	type: 'POST',
		url: "../invoice/view.jsp",
		data: "idinv="+idInv+"&idInvCat="+idInvCat+"&idInvTpl="+idInvTpl+"",
		cache: false,
		success: function (data, textStatus, XMLHttpRequest){
			 $("#mdShowCntr").html(data);
			 $("#mdShowCntr").dialog({
				 autoOpen: false,
				 modal: true,
				 draggable: false,
				 buttons: {
					'Anulează':function() {
						$(this).dialog('close');
					}
			 	},
			 	width: 900,
			 	show: 'drop',
				hide: 'drop'
			 });
			 $("#mdShowCntr").dialog('open');
			 }
	});
}

function getBlList(){
	$.ajax({
	type: 'POST',
	url:"../bill/billList.jsp",
		cache: false,
		data: $("#schBlFrm").serialize(),
		success: function(data){
			$('#blCtnr').html(data);
		}
	});
}

function sBl(){
	$.ajax({
	type: 'POST',
	url:"../SaveBill",
		cache: false,
		data: $("#bFrm").serialize(),
		success: function(data){
			showInfo(data);
		}
	});
}

function showInfo(data)
{
	$("#mdShowCntr").html(data);
	 $("#mdShowCntr").dialog({
		 autoOpen: false,
		 modal: true,
		 draggable: false,
		 buttons: {
			'Ok':function() {
				$(this).dialog('close');
			}
	 	},
		show: 'drop',
		hide: 'drop'
	 });
	 $("#mdShowCntr").dialog('open');
}

function getInvList(){
	$.ajax({
	type: 'POST',
	url:"../invoice/invoiceList.jsp",
		cache: false,
		data: $("#schInvFrm").serialize(),
		success: function(data){
			$('#invCntn').html(data);
		}
	}
	);
}

function deleteInv(idInv, idInvCat){
if(!idInvCat){
	idInvCat=1;
}
	$.ajax({
	type: 'POST',
	url:"../DeleteInvoice",
		cache: false,
		data: "idinv="+idInv+"&idInvCat="+idInvCat+"",
		success: function(data){
			getInvList();
			}
		}
		);
}

function vBill(idBl){
	$.ajax({
	type: 'POST',
		url: "../bill/view.jsp",
		data: 'idBl='+idBl,
		cache: false,
		success: function (data, textStatus, XMLHttpRequest){
			 $("#mdShowCntr").html(data);
			 $("#mdShowCntr").dialog({
				 autoOpen: false,
				 modal: true,
				 draggable: false,
				 buttons: {
					'Anulează':function() {
						$(this).dialog('close');
					}
			 	},
			 	title: 'Chitanta',
			 	width: 900,
			 	show: 'drop',
				hide: 'drop'
			 });
			 $("#mdShowCntr").dialog('open');
			 }
	});
}

function dBl(idBl){
	$.ajax({
	type: 'POST',
		url: "../DeleteBill",
		data: "idBl="+idBl,
		success: function (data, textStatus, XMLHttpRequest){
			getBlList();
		}
	});
}
function getRpt(rpt){
	$.ajax({
	type: 'POST',
	url:"../reports/"+rpt+".jsp",
		cache: false,
		data: $("#rptFrm").serialize(),
		success: function(data){
			$('#rpdCtnr').html(data);
		}
	}
	);
}

function getSrNextNo(idSr,idObj){
	$.ajax({
	type: 'POST',
		url: "../GetSerieNextNo",
		data: "idInvSr="+idSr+"&idObj="+1,
		success: function (data, textStatus, XMLHttpRequest){
			$("#invNo").val(data.nextNo);
		}
	});
}
function sCrr(){
	$.ajax({
	type: 'POST',
	url:"../SaveCurrencies",
		cache: false,
		data: $("#crrFrm").serialize(),
		success: function(data){
			showInfo(data);
		}
	});
}

function checkAll(val){
	$("input[type='checkbox']:not([disabled='disabled'])").attr('checked', val);	
}
function checkPrdCrr(){
	var idPrdCrr=$("#idCrr").val();
	var idInvCrr=$("#invIdCrr").val();
	var rtCtn=$('#prdExRtCtnr');
	if(idPrdCrr!=idInvCrr){
		rtCtn.show();
		$('#prdExRt').addClass('loading');
		$.ajax({
		type: 'POST',
				url:"/GetExhangeRate",
				cache: false,
				data: "fromIdCrr="+idPrdCrr+"&toIdCrr="+idInvCrr,
				success: function(data){
					$('#prdExRt').val(data.exRt);
					$('#newPrdCrr').html(data.fromCrr);
					$('#newPrdInvCrr').html(data.toCrr);
					$('#prdExRt').removeClass('loading');
				}
			});
	}else{
		rtCtn.hide();
		$('#prdExRt').val(1);
	}
}
function invRtChanged(){
	var invExRtCtnr=$("#invExRtCtnr");
	if($("#invIdCrr").val()!='1'){
		invExRtCtnr.show();
		$('#invExRt').addClass('loading');
		$.ajax({
		type: 'POST',
				url:"/GetExhangeRate",
				cache: false,
				data: "fromIdCrr="+$("#invIdCrr").val()+"&toIdCrr=1",
				success: function(data){
					$('#invExRt').val(data.exRt);
					$('#invCrrCode').html(data.fromCrr);
					$('#invExRt').removeClass('loading');
					checkPrdCrr();
				}
			});
	}else{
		invExRtCtnr.hide();
		checkPrdCrr();
	}
	showInfo('PreÅ£urile produselor deja adÄƒugate la aceastÄƒ facturÄƒ vor fi considerate ca fiind introduse Ã®n noua monedÄƒ (preÅ£urile nu se vor converti automat).');
}
function blRtChanged(){
	var invExRtCtnr=$("#blExRtCtnr");
	if($("#idCrr").val()!='1'){
		invExRtCtnr.show();
		$('#blExRt').addClass('loading');
		$.ajax({
		type: 'POST',
				url:"/GetExhangeRate",
				cache: false,
				data: "fromCrr="+$("#idCrr").val()+"&toCrr=1",
				success: function(data){
					$('#blExRt').val(data.exRt);
					$('#blExRt').removeClass('loading');
				}
			});
	}else{
		invExRtCtnr.hide();
	}
}
function getAmountStr(amount,idCrr){
	$.ajax({
	type: 'POST',
		url:"/GetAmountString",
		cache: false,
		data: "amount="+amount+"&idCrr="+idCrr,
		success: function(data){
			$("#amountStr").html(data.str);
		}
	});
}

function sendToMail(idInv,idInvCat){
if(!idInvCat){
	idInvCat=1;
}
$.ajax({
type: 'POST',
		url:"/invoice/sentToMail.jsp",
		cache: false,
		data:  "idinv="+idInv+"&idInvCat="+idInvCat+"",
		success: function(data){
			$("#mdShowCntr").html(data);
			 $("#mdShowCntr").dialog({
				 autoOpen: false,
				 modal: true,
				 draggable: false,
				 buttons: {
					'Anulează':function() {
						$(this).dialog('close');
					},
					'Trimite':function(){
						$.ajax({
						type: 'POST',
						url: "/SendInvToMail",
						data: $("#invSendMailFrm").serialize(),
						beforeSend: function(){
							$("#mdShowCntr").html('<div class="loadDiv"></div>');
						},
						success: function (data)
						{
							showInfo(data);
						}
						});
					}
			 	},
			 	title: 'Trimite prin email',
			 	width: 400,
			 	show: 'drop',
				hide: 'drop'
			 });
			 $("#mdShowCntr").dialog('open');
		}
	});
}
function sendBlToMail(idBl){
$.ajax({
type: 'POST',
		url:"/bill/sentToMail.jsp",
		cache: false,
		data: "idBl="+idBl+"",
		success: function(data){
			$("#mdShowCntr").html(data);
			 $("#mdShowCntr").dialog({
				 autoOpen: false,
				 modal: true,
				 draggable: false,
				 buttons: {
					'Anulează':function() {
						$(this).dialog('close');
					},
					'Trimite':function(){
						$.ajax({
						type: 'POST',
						url: "/SendBlToMail",
						data: $('#invSendMailFrm').serialize(),
						beforeSend: function(){
							$("#mdShowCntr").html('<div class="loadDiv"></div>');
						},
						success: function (data)
						{
							showInfo(data);
						}
						});
					}
			 	},
			 	title: 'Trimite prin email',
			 	width: 400,
			 	show: 'drop',
				hide: 'drop'
			 });
			 $("#mdShowCntr").dialog('open');
		}
	});
}

function titleTooltip(){
$(".tooltipItem[title]").tooltip(
				{
					effect:'slide',
					events: {
						def: "focus mouseenter,blur mouseleave mouseout click"
					}
				});
}
function toogleFade(selector)
{
var sel=$(selector);
	if(sel.css("display") == "none"){
		sel.show('fast');
	}else{
		sel.hide('fast');
	}
}
function vCrr(){
	$.ajax({
	type: 'POST',
		url:"/include/items/bnrRates.jsp",
		cache: false,
		data: "vAll=1",
		success: function(data){
			showInfo(data);
		}
		});
}

function vCrrConv(){
	$.ajax({
	type: 'POST',
		url:"/include/items/convertor.jsp",
		cache: false,
		success: function(data){
			showInfo(data);
		}
		});
}

function compute(){
$.ajax({
type: 'POST',
		url:"/include/items/rateConvertor.jsp",
		cache: false,
		data: $("#calcFrm").serialize(),
		success: function(data){
			$("#idCalcCtnr").html(data);
		}
		});
}
function uploadPrd(){
	$("#loadinInfDiv").toggle();
	$("#loadingDiv").toggle();
	return true;
}
function uploadEnd(fileName)
{
	$.ajax({
	type: 'POST',
		url:"/ProcessProductsFile",
		cache: false,
		data: "fileName="+fileName+"",
		success: function(data){
			$("#loadinInfDiv").toggle();
			$("#loadingDiv").toggle();
			$("#mdShowCntr").html(data);
			 $("#mdShowCntr").dialog({
				 autoOpen: false,
				 modal: true,
				 draggable: false,
				 buttons: {
					'Anulează':function() {
						$(this).dialog('close');
					},
					'Trimite':function(){
						$.ajax({
						type: 'POST',
						url:"/ProcessProductsFile",
						cache: false,
						data: "fileName="+fileName+"&save=1",
						success: function(data){
							getPrdList();
							$("#mdShowCntr").html(data);
							$('#mdShowCntr').dialog('option', 'position', 'center');
							$('#mdShowCntr').dialog('option', 'buttons', {'Ok':function() {
									$(this).dialog('close');
								}}); 
						}
						});
					}
			 	},
			 	width: 535,
			 	show: 'drop',
				hide: 'drop'
			 });
			 $("#mdShowCntr").dialog('open');
		}
		});
}

function uploadClientsEnd(fileName)
{
	$.ajax({
	type: 'POST',
		url:"/ProcessClientsFile",
		cache: false,
		data: "fileName="+fileName+"",
		success: function(data){
			$("#loadinInfDiv").toggle();
			$("#loadingDiv").toggle();
			$("#mdShowCntr").html(data);
			 $("#mdShowCntr").dialog({
				 autoOpen: false,
				 modal: true,
				 draggable: false,
				 buttons: {
					'Anulează':function() {
						$(this).dialog('close');
					},
					'Trimite':function(){
						$.ajax({
						type: 'POST',
						url:"/ProcessClientsFile",
						cache: false,
						data: "fileName="+fileName+"&save=1",
						success: function(data){
							getClientList();
							$("#mdShowCntr").html(data);
							$('#mdShowCntr').dialog('option', 'position', 'center');
							$('#mdShowCntr').dialog('option', 'buttons', {'Ok':function() {
									$(this).dialog('close');
								}}); 
						}
						});
					}
			 	},
			 	width: 535,
			 	show: 'drop',
				hide: 'drop'
			 });
			 $("#mdShowCntr").dialog('open');
		}
		});
}

function sSug(){
	$.ajax({
	type: 'POST',
		url:"/SaveSuggestion",
		cache: false,
		data: $("#contFrm").serialize(),
		success: function(data){
			$("#contCntr").html(data);			
		}
		});
}
function vUsrMan(idHelp){
	$.ajax({
	type: 'POST',
		url:"/GetHelp",
		cache: false,
		data: "idHlp="+idHelp+"",
		success: function(data){
			$("#hlpCtnr").html(data);			
		}
		});
}

function chkInvNo(){
	$.ajax({
	type: 'POST',
		url:"/CheckInvoiceField",
		cache: false,
		dataType: 'json',
		data: "fld=1&val="+$("#invNo").val()+
		"&"+"idInvSr="+$("#idInvSr").val()+"",
		success: function(data){
		if(data.code=='1'){
			$("#mdShowCntr").html(data.msg);
			$("#mdShowCntr").dialog({
				 autoOpen: false,
				 modal: true,
				 draggable: false,
				 buttons: {
					'Ok':function() {
						$(this).dialog('close');
						$("#invNo").focus();
					}
					}
				});
			$("#mdShowCntr").dialog('open');
			}
		}
		});
}
function chkInvDate(){
	$.ajax({
	type: 'POST',
		url:"/CheckInvoiceField",
		cache: false,
		dataType: 'json',
		data: "fld=2&val="+$("#invDate").val()+"",
		success: function(data){
			if(data.code=='1'){
			$("#mdShowCntr").html(data.msg);
			$("#mdShowCntr").dialog({
				 autoOpen: false,
				 modal: true,
				 draggable: false,
				 buttons: {
					'Ok':function() {
						$(this).dialog('close');
						$("#invDate").focus();
					}
					}
				});
				$("#mdShowCntr").dialog('open');
			}
		}
		});
}
function eSgt(){
$.ajax({
type: 'POST',
		url:"/suggestion/edit.jsp",
		cache: false,
		data: $("#calcFrm").serialize(),
		success: function(data){
			$("#mdShowCntr").html(data);
			$("#mdShowCntr").dialog({
				 autoOpen: false,
				 modal: true,
				 draggable: false,
				 buttons: {
					'Ok':function() {
						$(this).dialog('close');
					},
					'Trimite':function(){
						$.ajax({
							type: 'POST',
							url: "/SaveSuggestion",
							data: $("#sgtFrm").serialize(),
							success: function(data){
								$("#mdShowCntr").html(data);
							}
							});
							$('#mdShowCntr').dialog('option', 'buttons', {'Ok':function() {
									$(this).dialog('close');
								}});
						}
					}
				});
				$("#mdShowCntr").dialog('open');
			}
	});
}
function sFrm(){
	$.ajax({
	type: 'POST',
		url:"/SaveFirm",
		data: $("#fdt").serialize(),
		cache: false,
		dataType: 'json',
		success: function(data){
			showInfo(data.msg);
		}
		});
}

