// JavaScript Document
function livecallbackfunction()
{
	var form = document.getElementById('callbackform');
	var name = form.name;
	var phone = form.phone;
	var place = form.place;
	var emailid = form.emailid;
	var product = form.product;
	var contact = form.contact;
	var state = form.state;
	var description = form.description;
	if(name.value == '')
	{
		alert("Enter your Name."); name.focus(); return false;
	}
	if(phone.value == '')
	{
		alert("Enter the Phone Number."); phone.focus(); return false;
	}
	else if(phone.value) { if(!validatephone(phone.value)) { alert("Please Enter a valid Phone Number"); phone.focus(); return false;}}
	if(!emailid.value) { alert("Please Enter the Email ID");emailid.focus(); return false;}
	if(emailid.value) { if(!emailvalidation(emailid.value)) { alert("Please Enter a valid Email ID"); emailid.focus(); return false;}}
	if(place.value == '')
	{
		alert("Enter the Place."); place.focus(); return false;
	}
	if(product.value == '')
	{
		alert("Select A Product."); product.focus(); return false;
	}
	if(contact.value == '')
	{
		alert("Select a Contact Type."); contact.focus(); return false;
	}
	if(state.value == '')
	{
		alert("Select a State."); state.focus(); return false;
	}
	else
	{
	passData = "type=callback&name=" + encodeURIComponent(name.value) + "&phone=" + encodeURIComponent(phone.value)  + "&place=" +encodeURIComponent(place.value)+ "&emailid=" +encodeURIComponent(emailid.value)+ "&product=" +encodeURIComponent(product.value)+ "&contact=" +encodeURIComponent(contact.value)+ "&state=" +encodeURIComponent(state.value)+ "&description=" +encodeURIComponent(description.value);
	document.getElementById('placecall').style.disabled = true;
	var ajaxcall2 = createajax();
	queryString = "../ajax/callback_thankyou.php";
	ajaxcall2.open("POST", queryString, true);
	ajaxcall2.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	ajaxcall2.onreadystatechange = function()
	{
		if(ajaxcall2.readyState == 4)
		{
			if(ajaxcall2.status == 200)
			{
				var response = ajaxcall2.responseText;
				alert(response);
				resetcallbackform();
			}
			else
				alert("ERROR");
		}
	}
	ajaxcall2.send(passData);
	}
}


function resetcallbackform()
{
	var form = document.getElementById('callbackform');
	form.name.value = '';
	form.phone.value = '';
	form.place.value = '';
	form.emailid.value = '';
	form.product.value = '';
	form.contact.value = '';
	form.state.value = '';
	form.description.value = '';
	document.getElementById('callbackform').reset();
}