$(document).ready(function() {
	
})
function search_submit(){
	document.search.submit();
}
function update(id,amount){
	qty=$('#' + id + '_qty').attr("value");
	if(typeof(qty)!="undefined"){
		if((amount % qty) == 0){
			$.ajax({ 
				url: "ajax.php", 
				type: "POST", 
				dataType: "html",
				data: ({"id": id, "amount" : amount}),
				async: true,
				success: function(data) { 
						if(data=="!"){
							$('#' + id).attr("value",'');	
						}		
					}
				});
		}
		else{
			$('#' + id).attr("value",'');
			alert("A beírt mennyiség nem a \"rendelési darabszám\" többszöröse");
		}
	}
	else{
		$.ajax({ 
			url: "ajax.php", 
			type: "POST", 
			dataType: "html",
			data: ({"id": id, "amount" : amount}),
			async: true,
			success: function(data) { 
					if(data=="!"){
						$('#' + id).attr("value",'');	
					}		
				}
			});
	
	}
}

function updatecomment(id,comment){
	$.ajax({ 
	url: "ajax.php", 
	type: "POST", 
	dataType: "html",
	data: ({"id": id, "comment" : comment}),
	async: true,
	success: function(data) { 
		}
	});
}
function do_nothing(){
	return false;
}
function del_search(){
	$.ajax({ 
	url: "ajax.php", 
	type: "POST", 
	dataType: "html",
	data: ({"session": 'del'}),
	async: false,
	success: function(data) { 
				
		}
	});
	window.location.href=window.location.href;
}
function pad2(numb){
	return (numb < 10 ? '0' : '') + numb;
}

function deliver_date(){
	var tomorrow="";
	$.ajax({ 
	url: "ajax.php", 
	type: "POST", 
	dataType: "html",
	data: ({"tomorrow": "1"}),
	async: false,
	success: function(data) { 
			tomorrow=data;
				
			}	
		});
	
	var res=false;
	var txt = 'Kért szállítási dátum (ééé-hh-nn)' + '<div class="field"><input type="text" id="editdate" name="editdate" value="' + tomorrow + '" /></div>';
	$.prompt(txt,
		{buttons:{Megrendelés:true, Mégsem:false},
		 callback: function(v,m,f){
		 	if(v){
				if(f.editdate!=null){
					
					$.ajax({ 
						url: "ajax.php", 
						type: "POST", 
						dataType: "html",
						data: ({"date": f.editdate}),
						async: false,
						success: function(data) { 
							if(data=="sikeres"){
								res=true;
								window.location.href="/SubmitOrder.php";
							}	
						}
						});
				}
				
			}
		 }});
	//var datum = prompt('Kért szállítási dátum (éééé-hh-nn):',tomorrow);
	/*
	if(datum!=null){
	$.ajax({ 
	url: "ajax.php", 
	type: "POST", 
	dataType: "html",
	data: ({"date": datum}),
	async: false,
	success: function(data) { 
			if(data=="sikeres"){
				res=true;
				
			}	
		}
	});
	}
	*/
	return res;
}

function splitStock(recordid, qty, type) {
	   var newqty = prompt('Dátum','2010-10-10');
       if (newqty != null) {
               if (!isNaN(newqty) && newqty > 0 && newqty <= qty) {
                      alert("jeee");
               } else {
                       alert(alert_arr.VALID_DATA);
               }
       }
}


