// JavaScript Document

/*
	x = url
	y = postBody
	z = id to update
*/

function ajax_call(x,y,z,u){

	new Ajax.Request(x,
		{
			method:'post',
			postBody:y,
			on404: function(t){
				alert('404 Error: '+ t.statusText)
			},
			
			onFailure: function(t){ 
				alert('Error ' + t.status + ' - ' + t.statusText); 
			},
			
			onSuccess: function(t){ 
				new Insertion.After(z,t.responseText);
				Effect.BlindDown(u, {duration:1, 
						fps: 100, 
						afterFinish: function(t){
							Effect.Puff(u, {duration:1, fps: 100});
								afterFinish: function(t){
								Element.remove(u);
							}
						}
				});
			}
			
		}
	); 
}



function ajax_update(x,y,z){

	new Ajax.Updater(z,x,
		{
			method:'post',
			postBody:y,
			on404: function(t){
				alert('404 Error: '+ t.statusText)
			},
			
			onFailure: function(t){ 
				alert('Error ' + t.status + ' - ' + t.statusText); 
			},
			
			onSuccess: function(t){
				Effect.SlideDown(z, {duration:1, fps: 60});
				//new Insertion.Before(z,t.responseText);
			}
		} 
	); 
}

function updateEnquiryFinal(x,y,z){
	ajax_call('ajax/update_enquiry.php','enquiry_id='+x+'&value='+y+'&elm='+z,'pageForm');
}

function ajax_update_no_trans(x,y,z){

	new Ajax.Updater(z,x,
		{
			method:'post',
			postBody:y,
			on404: function(t){
				alert('404 Error: '+ t.statusText)
			},
			
			onFailure: function(t){ 
				alert('Error ' + t.status + ' - ' + t.statusText); 
			},
			
			onSuccess: function(t){
				//new Insertion.After(z,t.responseText);
			}
		} 
	); 
}


function updateEnquiry(a,v,e){
	new Ajax.Updater(a,'ajax/update_enquiry.php',
	{ 
		method:'post',   
		postBody: 'id='+a+'&value='+v+'&elm='+e,
		asynchronous: true,
		on404: function(t){
				alert('404 Error: '+ t.statusText)
			},
	
		onFailure: function(t){ 
				alert('Error ' + t.status + ' - ' + t.statusText); 
			},
		onSuccess: function(t){  
				new Insertion.Before('holder',t.responseText);
			}
	});
}
