var ask_question_html = '<h2>Ask a question</h2><textarea style=\'margin: 10px 0 10px 0\' rows=\'3\' cols=\'40\' id=\'question\' name=\'question\'></textarea><a href=\'javascript:submit_question()\'><img src=\'/images/submit-button.gif\' alt=\'submit\' /></a><div id=\'info\' style=\'display: none\'></div>';
var url = 'ask-question-js.php';
var http_obj;

function init_question() {
	http_obj = getHttpObj();
	http_obj.onreadystatechange = handle_response;
}

function submit_question() {
	var x = document.getElementById('question');
	
	if(x.value == '')
		return;

	var y = document.getElementById('info');
	y.style.display = 'block';
	y.innerHTML = 'Please wait...';
	
	http_obj.open("GET", url + '?action=submit&question=' + encodeURIComponent(x.value) + '&r=' + Math.floor(Math.random() * 1000000), true);
	http_obj.send(null);
}

function handle_response() {
	var x = document.getElementById('info');
	x.style.display = 'block';
	if(http_obj.readyState == 4 && http_obj.status == 200) {
		result = http_obj.responseText;
		if(result) {
			x.innerHTML = 'Thank you. Your question was submitted successfully.';
		}
		else {
			x.innerHTML = 'Error! We will investigate this problem as soon as possible.';
		}
	}

}

//initiates the XMLHttpRequest object
//as found here: http://www.webpasties.com/xmlHttpRequest
function getHttpObj() {
	var xmlhttp;
	/*@cc_on
	@if(@_jscript_version >= 5)
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				xmlhttp = false;
			}
		}
	@else
		xmlhttp = false;
	@end @*/
	if(!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp = false;
		}
	}
	return xmlhttp;
}