// CREATING THE REQUEST

function createRequestObject()
{
	try
	{
		xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch(e)
	{
		alert('Sorry, but your browser doesn\'t support XMLHttpRequest.');
	}
	return xmlhttp;
}

var http = createRequestObject();
var sess = createRequestObject();

// IMAGE REFRESHING

//function refreshimg()
//{
//	var url = 'includes/image_req.php';
//	dorefresh(url, displayimg);
//}

//function dorefresh(url, callback)
//{
//	sess.open('POST', 'includes/newsession.php', true);
//	sess.send(null);
//	http.open('POST', url, true);
//	http.onreadystatechange = displayimg;
//	http.send(null);
//}

//function displayimg()
//{
//	if(http.readyState == 4)
//	{
//		var showimage = http.responseText;
//		document.getElementById('captchaimage').innerHTML = showimage;
//	}
//}

// SUBMISSION

//function check()
//{
//
//	var submission = document.getElementById('captcha').value;
//	var url = 'includes/process.php?captcha=' + submission;
//	docheck(url, displaycheck);
//}

//function docheck(url, callback)
//{
//		
//	http.open('GET', url, true);
//	http.onreadystatechange = displaycheck;
//	http.send(null);
//}

//SUBMIT THE FORM, IF THE CAPTCHA IS CORRECT
function submitform(){
//	mydate=new Date();
//year=mydate.getFullYear();
//
//document.write("Copyright<SUP>_</SUP> 2002-"+ year + ", ");
//alert('aaaaaa');
var textfield3 = document.getElementById("textfield3").value;
var textfield4 = document.getElementById("textfield4").value;
var textfield5 = document.getElementById("textfield5").value;
var textfield6 = document.getElementById("textfield6").value;
var textfield7 = document.getElementById("textfield7").value;
if(document.getElementById("Vendor").checked==true){
var Vendor = "Non- Food Vendors";
}
if(document.getElementById("Vendor1").checked==true){
var Vendor = "Food Vendors";
}
//var Vendor1 = document.getElementById("Vendor1").checked;
//var button3 = document.getElementById("button3").value;
//document.getElementById('loading').style.display = 'block';
//alert(name);
//document.captchaform.submit.disabled = 'true'; //DISABLE THE SUBMIT BUTTON

http.open('GET', 'sendmail.php?textfield3=' +textfield3 +'&textfield4='+ textfield4 +'&textfield5=' +textfield5 +'&textfield6=' + textfield6 +'&Vendor=' +Vendor +'&textfield7='+escape(textfield7)); 


	http.onreadystatechange = printit;
	http.send(null);

}
//PRINT THE RESPONSE FROM PHP
function printit()
{
	if(http.readyState == 4)
	{
	
	//document.getElementById('loading').style.display = 'none';
	document.getElementById('results').innerHTML = http.responseText; //PRINT THE PHP'S RESPONSE IN THE RESULTS DIV
	}
}	
//function displaycheck()
//{
//	
//	if(http.readyState == 4)
//	{
//		var showcheck = http.responseText;
//		if(showcheck == '1') //CAPTCHA IS CORRECT
//		{
//			document.getElementById('captcha').style.border = '1px solid #49c24f';
//			document.getElementById('captcha').style.background = '#bcffbf';
//			document.getElementById('captchaerror').innerHTML = '';
//
//			submitform(); //SUBMIT THE FORM
//		}
//		if(showcheck == '0')
//		{
//			document.getElementById('captcha').style.border = '1px solid #c24949';
//			document.getElementById('captcha').style.background = '#ffbcbc';
//			document.captchaform.captcha.value = ''; //RESET THE CAPTCHA INPUT'S VALUE
//			document.captchaform.captcha.focus(); //CHANGE THE FOCUS TO CAPTCHA INPUT
//			document.getElementById('captchaerror').innerHTML = '<font color="#c24949"><b>Please Re-enter the CAPTCHA</b></font>';
//		}
//	}
//}