function getHTTPObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest(); //Mozilla, Safari ...
	} 
	else if (window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP"); //IE
	} 
	else {
		alert("Your browser doesn't support the XmlHttpRequest object.");
		return null;
	}
}

function captchaMatches(inputText) {
	var xmlHttp = getHTTPObject();
	if (xmlHttp == null) {return false;}
	var captchaKey=document.getElementById('captcha').alt;
	xmlHttp.open("GET","/misc/captcha/verifyCaptcha.php?captchaKey="+captchaKey+"&inputText="+inputText,false);
	xmlHttp.send(null);
	var response = xmlHttp.responseText;
	var returnValue = false;
	if (response == 'true') {
		returnValue = true;
	}
	else {
		newImg = document.getElementById('captcha');
		postImgName = document.getElementById('captchaImageName');
		newImg.src = 'http://www.songsoftheheart.net/' + response;
		newImg.alt = '/home/dreamedu/public_html/songsoftheheart/' + response;
		postImgName.value = '/home/dreamedu/public_html/songsoftheheart/' + response;
	}
	return returnValue;
}


function getDifferentImage() {
	captchaMatches("WRONGTEXT");
}

function destroyCaptcha() {
	var xmlHttp = getHTTPObject();
	if (xmlHttp == null) { return false; }
	
	var captchaKey=document.getElementById('captcha').alt;
	xmlHttp.open("GET","/misc/captcha/destroyCaptcha.php?captchaKey="+captchaKey,true);
	xmlHttp.send(null);
}
