/* ---------------------------- */
/* 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 = "Asteptati..."
// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
var piesa= encodeURI(document.getElementById('piesa').value);
var user = encodeURI(document.getElementById('user').value);
// Set te random number to add to URL request
nocache = Math.random();
// Pass the login variables like URL variable
http.open('get', 'insert.php?piesa='+piesa+'&user=' +user+'&nocache = '+nocache);
http.onreadystatechange = insertReply;
http.send(null);
}

function insert_report() {
// Optional: Show a waiting message in the layer with ID login_response
document.getElementById('insert_response').innerHTML = "Asteptati..."
// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
var piesa2= encodeURI(document.getElementById('piesa2').value);
var ip= encodeURI(document.getElementById('ip').value);
// Set te random number to add to URL request
nocache = Math.random();
// Pass the login variables like URL variable
http.open('get', 'insert.php?piesa2='+piesa2+'&ip=' +ip+'&nocache = '+nocache);
http.onreadystatechange = insertReply;
http.send(null);
}


function insert_nu_afisa() {
// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
var ip_nu_afisa= encodeURI(document.getElementById('ip_nu_afisa').value);
var id_nu_afisa= encodeURI(document.getElementById('id_nu_afisa').value);
// Set te random number to add to URL request
nocache = Math.random();
// Pass the login variables like URL variable
http.open('get', 'insert.php?id_nu_afisa='+id_nu_afisa+'&ip_nu_afisa=' +ip_nu_afisa+'&nocache = '+nocache);
http.send(null);
}

function vot_poz() {
// Optional: Show a waiting message in the layer with ID login_response
document.getElementById('insert_response').innerHTML = "Asteptati..."
// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
var piesa_vot_poz= encodeURI(document.getElementById('piesa_vot_poz').value);
var user_vot_poz = encodeURI(document.getElementById('user_vot_poz').value);
var cum_vot_poz = encodeURI(document.getElementById('cum_vot_poz').value);
// Set te random number to add to URL request
nocache = Math.random();
// Pass the login variables like URL variable
http.open('get', 'insert.php?piesa_vot_poz='+piesa_vot_poz+'&user_vot_poz=' +user_vot_poz+'&cum_vot_poz=' +cum_vot_poz+'&nocache = '+nocache);
http.onreadystatechange = insertReply;
http.send(null);
}

function vot_neg() {
// Optional: Show a waiting message in the layer with ID login_response
document.getElementById('insert_response').innerHTML = "Asteptati..."
// Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
var piesa_vot_neg= encodeURI(document.getElementById('piesa_vot_neg').value);
var user_vot_neg = encodeURI(document.getElementById('user_vot_neg').value);
var cum_vot_neg = encodeURI(document.getElementById('cum_vot_neg').value);
// Set te random number to add to URL request
nocache = Math.random();
// Pass the login variables like URL variable
http.open('get', 'insert.php?piesa_vot_neg='+piesa_vot_neg+'&user_vot_neg=' +user_vot_neg+'&cum_vot_neg=' +cum_vot_neg+'&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 URL".
document.getElementById('insert_response').innerHTML = response;
}
}
