var ServerReturnValue
function GetHTTPRequest() {
	var xmlHTTP = false ;
	if (window.XMLHttpRequest) {
		try {
		  xmlHTTP = new XMLHttpRequest();
		} catch (e) {
		 xmlHTTP = false;
		}
	  } else if (window.ActiveXObject) {
		// For Internet Explorer on Windows
		try {
		  xmlHTTP = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		  try {
			xmlHTTP = new ActiveXObject("Microsoft.XMLHTTP");
		  } catch (e) {
			xmlHTTP = false;
		  }
		}
	  }
return xmlHTTP;
}
function captchaValidation(url,  method, thisForm) {
	if ( ( thisForm.Captcha.value == null ) ||  ( thisForm.Captcha.value == '' ) ) {
	alert ('Enter Word Verification Code');	
	thisForm.Captcha.focus();
	return false;
	}
		if (  typeof(method) == 'undefined')  method = 'POST' ;
		if (  typeof(url) == 'undefined')  url = '../captcha/captchavalidation.jsp' ; 
		var dat =  new Date();
		postval ='Captcha='+thisForm.Captcha.value+'&rand='+parseInt(Math.random()*10000);
		//alert (postval);
		 // For Safari, Firefox, and other non-MS browsers
		  var req = GetHTTPRequest();
		  if (req) {
			// Synchronous request, wait till we have it all
			if (method.toUpperCase() == 'POST') {
			req.open(method, url, true);
			req.onreadystatechange = function() { captchacallback(req, thisForm); } ;
			req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			req.send(postval); }
			if (method.toUpperCase() == 'GET') {
			req.open(method, url+'?'+postval, true);
			req.onreadystatechange = function() { captchacallback(req, thisForm); } ;
			req.send(null); }	
		 //   element.innerHTML = req.responseText;
		  }
		  else {
			element.innerHTML =    "Sorry, your browser does not support " +   "XMLHTTPRequest objects. This page requires " +     "Internet Explorer 5 or better for Windows, " + "or Firefox for any system, or Safari. Other " +       "compatible browsers may also exist.";
		  }
}
function  captchacallback(myreq, thisForm)
{
	if (myreq.readyState == 4 ){
	//	alert('Thanks For Visiting...');
	ServerReturnValue = myreq.responseText;
//	alert ( 'Server Return Value : ' + ServerReturnValue ) ; 
	if ( ServerReturnValue.indexOf('Passed')  >= 0  ) {
//		alert (' Going to Submit ' );
		thisForm.submit();
//thankYouOnSamePage(thisForm);

		}
	else {
		/*document.getElementById('InvalidCaptcha').innerHTML = 'Invalid Code. Try Again' ;*/
alert ('Invalid Word Verification Code');
		document.getElementById('CaptchaImage').src = document.getElementById('CaptchaImage').src;	
		thisForm.Captcha.focus();
		/*		var newSrc =  document.getElementById('CaptchaImage').src;
		alert(newSrc);
		document.images['CaptchaImage'].src = newSrc ;*/
		}
	}
}

function reloadCaptcha() {
//document.getElementById('CaptchaImage').src = document.getElementById('CaptchaImage').src;	
	var oldSrc = document.getElementById('CaptchaImage').src;
	var oldUrl = oldSrc.split('?')[0] ;
	var newUrl = oldUrl+'?rand='+parseInt(Math.random()*10000);
	document.getElementById('CaptchaImage').src = newUrl;
	document.getElementById('InvalidCaptcha').innerHTML = '' ;
}