var ef_root_url = '/wp-content/plugins/estimate-form/';

Event.observe(window, 'load', getContactForm, false);

function getEstimateForm(){
	if($F('ef_id') != 0){
		new Ajax.Updater("ef_input_area",
							ef_root_url + 'get_estimate_form.php',
							{ method: 'post',
							parameters: 'ef_id=' + $F('ef_id')
							}
		);
		$('ef_confirm').style.display = 'inline';
	}
}

function getContactForm(){
	if($('ef_contact_form')){
		new Ajax.Updater("ef_contact_form",
							ef_root_url + 'ef_check_contact_form.php',
							{ method: 'get' }
		);
	}
}

function checkContactForm(){
	new Ajax.Request(ef_root_url + 'ef_check_contact_form.php',
		{method: 'post',
		parameters: Form.serialize('ef_contact_form'),
		onComplete: function(httpObj){
			if(httpObj.responseText == 'OK'){
				$('ef_contact_form').action = ef_root_url + 'print_pdf.php';
				$('ef_contact_form').submit();
			}else{
				$('ef_contact_form').innerHTML = httpObj.responseText;
			}
		}
		}
	);
}
