// JavaScript Document

/* ---------------------------- */
/* 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 insert() {
// Optional: Show a waiting message in the layer with ID login_response
document.getElementById('insert_response').innerHTML = "<span class=\"style10\">Adding Comment...</span><br><img src=\"images/ajax-loader.gif\" width=\"16\" height=\"16\" />"
document.getElementById('showform').style.display = "none";
//document.getElementById('comm').style.display = "none";
// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
var user_id = encodeURI(document.getElementById('uname').value);
var notes = encodeURI(document.getElementById('comm').value);
var video_id = encodeURI(document.getElementById('video_id').value);
// Set te random number to add to URL request
nocache = Math.random();
// Pass the login variables like URL variable
http.open('post', 'submit_comm.php?user_id='+user_id+'&notes='+notes+'&video_id='+video_id+'&nocache='+nocache);
http.onreadystatechange = insertReply;
http.send(null);
}
function insertReply() {
if(http.readyState == 4){ 
var response = http.responseText;
// else if login is ok show a message: "Site added+ site button2URL".
document.getElementById('insert_response').innerHTML = response;
}
}




function toggle_visibility(){
       var e = document.getElementById('showform');
	   
       if(e.style.display == 'block')
          
		  e.style.display = 'none';
       else
          e.style.display = 'block';
    } 
