function setquestion() {
	document.getElementById("question").value = '';
	document.getElementById('question').style.color='#333';
}
function setname() {
	document.getElementById("qname").value = '';
	document.getElementById('qname').style.color='#333';
}
function setemail() {
	document.getElementById("qemail").value = '';
	document.getElementById('qemail').style.color='#333';
}

// send question
var sendQuestion = createQuestionObject();

function sendquestion(squestion,sname,semail) {
	var url = "/feedback/askus.inc.php";
	var params = "question="+squestion+"&qname="+sname+"&qemail="+semail;
	sendQuestion.open("POST", url, true);

	//Send the proper header information along with the request
	sendQuestion.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	sendQuestion.setRequestHeader("Content-length", params.length);
	sendQuestion.setRequestHeader("Connection", "close");

	sendQuestion.onreadystatechange = function() {//Call a function when the state changes.
		if(sendQuestion.readyState == 1){
			document.getElementById('askus').innerHTML = 'Sending...';
		}
		if(sendQuestion.readyState == 4 && sendQuestion.status == 200) {
			var response = sendQuestion.responseText;
			document.getElementById('askus').innerHTML = response;
		}
	}

	sendQuestion.send(params);
}

function createQuestionObject(){
	var request_;
	var browser = navigator.appName;

	if(browser == "Microsoft Internet Explorer"){
		request_ = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		request_ = new XMLHttpRequest();
	}
	return request_;
}


// check ask a question form before submitting
function gotaquestion() {
	question = document.getElementById("question").value;
	qname = document.getElementById("qname").value;
	qemail = document.getElementById("qemail").value;
 	
	if (question == "" || question == "Question") {
		hideSigninErrors();
		document.getElementById("questionerror").style.display = "block";
		document.getElementById("questionerror").select;
		document.getElementById("questionerror").focus;
  		return false;
	} else if (qname == "" || qname == "Name") {
		hideSigninErrors();
		document.getElementById("qnameerror").style.display = "block";
		document.getElementById("qnameerror").select();
		document.getElementById("qnameerror").focus();
		return false;
	} else if (qemail == "" || qemail == "Email") {
		hideSigninErrors();
		document.getElementById("qemailerror").style.display = "block";
		document.getElementById("qemailerror").select();
		document.getElementById("qemailerror").focus();
		return false;
	}
	sendquestion(question,qname,qemail);
	return true;
}
 
function hideSigninErrors() {
	document.getElementById("questionerror").style.display = "none";
	document.getElementById("qnameerror").style.display = "none";
	document.getElementById("qemailerror").style.display = "none";
}