/*
 * phpWebThings addon javascript file
 * 
 * You can use this file for your own scripts.
 */

function reload_captcha() {
    var now = new Date();
    if (document.images) {
        document.images.captcha_img.src = 'contact_sec.php?' + now.getTime();
    }
	//sendRequest();
}

function createRequestObject() {
	var req;
	
	if(window.XMLHttpRequest){
		// Firefox, Safari, Opera...
		req = new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		// Internet Explorer 5+
		req = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		// There is an error creating the object,
		// just as an old browser is being used.
		alert('Problem creating the XMLHttpRequest object');
	}
	return req;
}

// Make the XMLHttpRequest object
var http = createRequestObject();

function sendRequest() {
	http.open('get','contact_captcha.php');
	http.onreadystatechange = handleResponse;
	http.send(null);
}

function handleResponse() {
	if(http.readyState == 4 ) {
		if ( http.status == 200 ) {
			// Text returned FROM the PHP script
			var response = http.responseText;
	
			if(response) {
				// UPDATE ajaxTest content
				document.getElementById('captcha_debug').innerHTML = response;
			}
		}
	}
}

