// JavaScript Document
//  Developed by Roshan Bhattarai 
//  Visit http://roshanbh.com.np for this script and more.
//  This notice MUST stay intact for legal use

$(document).ready(function()
{
	$("#queryForm1").submit(function()
	{
	//	alert($('#txtCaptcha').val());
		//remove all the class add the messagebox classes and start fading
		//$("#msgbox").removeClass().addClass('messagebox').text('Validating....').fadeIn(1000);
		//check the username exists or not from ajax
		$.post("quick-query.asp",{ name:$('#txtName').val(),email:$('#txtEmail').val(),phone:$('#txtPhone').val(),comments:$('#txtComments').val(),code:$('#txtCode').val(),codeCheck:$('#txtCaptcha').val(),rand:Math.random() } ,function(data)
        {
		  if(data=='done') //if correct login detail
		  {
//			  alert("Thank you for contacting us.");
			  DrawCaptcha();
			  $('#txtName').val('');
			  $('#txtEmail').val('');
			  $('#txtPhone').val('');
			  $('#txtComments').val('');
			  $('#txtCode').val('');
			  document.getElementById('queryform').innerHTML='<p><br><br><br>Thank you for contacting us. We will get back to you within 24 hours.</p>';
		  }
		  else 
		  {
			  //alert(data);
			  document.getElementById('msgbox').innerHTML='&nbsp;&nbsp;'+data;			  
			  DrawCaptcha();
          }
				
        });
 		return false; //not to post the  form physically
	});





	$("#contantForm1").submit(function()
	{
		//remove all the class add the messagebox classes and start fading
		//$("#msgbox").removeClass().addClass('messagebox').text('Validating....').fadeIn(1000);
		//check the username exists or not from ajax
		$.post("contact-submit.asp",{ firstName:$('#txtFirstName').val(),lastName:$('#txtLastName').val(),etitle:$('#txtTitle').val(),company:$('#txtCompany').val(),email:$('#txtEmail').val(),comments:$('#txtQuery').val(),code:$('#txtCode').val(),codeCheck:$('#txtCaptcha').val(),rand:Math.random() } ,function(data)
        {
		  if(data=='done') //if correct login detail
		  {
	//		  alert("Thank you for contacting us.");
			  DrawCaptcha();
			  $('#txtFirstName').val('');
			  $('#txtLastName').val('');
			  $('#txtTitle').val('');
			  $('#txtCompany').val('');
			  $('#txtEmail').val('');
			  $('#txtQuery').val('');
			  $('#txtCode').val('');
			  document.getElementById('contact').innerHTML='<p><br><br><br><strong>Thank you for contacting us. We will get back to you within 24 hours.</strong><br><br><br></p>';
		  }
		  else 
		  {
			  document.getElementById('msgbox').innerHTML=' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '+data;
			 // alert(data);
			  DrawCaptcha();
          }
				
        });
 		return false; //not to post the  form physically
	});

});

