/* ---------------------------- */
/* XMLHTTPRequest Enable */
/* ---------------------------- */
function createObject() {
var request_type;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
request_type = new ActiveXObject("Microsoft.XMLHTTP");
}else{
request_type = new XMLHttpRequest();
}
return request_type;
}

var http = createObject();

/* -------------------------- */
/* INSERT */
/* -------------------------- */
/* Required: var nocache is a random number to add to request. This value solve an Internet Explorer cache issue */
var nocache = 0;
function insertresult() {
// Optional: Show a waiting message in the layer with ID login_response
//document.getElementById('insert_response').innerHTML = "Just a second..."
// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
var name= document.bunnyquiz.name.value;
var comment = document.bunnyquiz.comment.value;
var result = document.bunnyquiz.result.value;
labelname = document.getElementById('labelname');
labelcomment = document.getElementById('labelcomment');
if((name == "")&&(comment != ""))
{
labelname.style.color = "#ff00ff";
labelcomment.style.color = "#666666";
}
else
{
if((name != "")&&(comment == ""))
{
labelname.style.color = "#666666";
labelcomment.style.color = "#ff00ff";
}
else
{
if((name == "")&&(comment == ""))
{
labelname.style.color = "#ff00ff";
labelcomment.style.color = "#ff00ff";
}
else
{
// Set te random number to add to URL request
nocache = Math.random();
// Pass the login variables like URL variable
http.open('get', 'http://hoppelz.com/bunnyquiz/results/insert.php?name='+name+'&comment=' +comment+'&result=' +result+'&nocache = '+nocache);
http.onreadystatechange = insertReply;
http.send(null);
return true;
}
}
}
}
function insertReply() {
if(http.readyState == 4){
var response = http.responseText;
// else if login is ok show a message: "Site added+ site URL".
$ajaxreplace('addresult', 'http://hoppelz.com/bunnyquiz/results/thanks.php');
SANAjax('Listing','1');
}
}

