var name;
var email;
var phone;		
var time_of_call;
var procedure;
var problem;	

function sendmail(){
	name = document.getElementById('name').value;
	email = document.getElementById('email').value;
	phone = document.getElementById('phone').value;		
	time_of_call = document.getElementById('time_of_call').value;
	//procedure = document.getElementById('procedure').value;
	problem = document.getElementById('problem').value;
	
	call_ajax('./mail/send_mail.php');
}

function call_ajax(url){
		xmlhttp = (window.XMLHttpRequest ? new XMLHttpRequest(): ((window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : null    ) );
		xmlhttp.onreadystatechange=state_change
		xmlhttp.open("POST",url,false)
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		
		//var send_val = '1=1&name='+name+'&email=' + email + '&phone=' + phone + '&time_of_call=' + time_of_call + '&procedure=' + procedure + '&problem=' + problem;
		var send_val = '1=1&name='+name+'&email=' + email + '&phone=' + phone + '&time_of_call=' + time_of_call + '&problem=' + problem;
			
		xmlhttp.send(send_val);
		var mail_send_response = xmlhttp.responseText;
		if (mail_send_response == 'ok'){
			location.href = '/thanks.htm';	
		}
		else{
			alert(mail_send_response);	
		}
		//document.getElementById(target_slide_to_load_matched_slide).innerHTML = xmlhttp.responseText;	
}

function state_change(){
	if (xmlhttp.readyState==4){
		//code		
	}
}
