

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}
}



function myXMLHttpRequest ()
{
  var xmlhttplocal;
  try {
  	xmlhttplocal = new ActiveXObject ("Msxml2.XMLHTTP")}
  catch (e) {
	try {
	xmlhttplocal = new ActiveXObject ("Microsoft.XMLHTTP")}
	catch (E) {
	  xmlhttplocal = false;
	}
  }

  if (!xmlhttplocal && typeof XMLHttpRequest != 'undefined') {
	try {
	  var xmlhttplocal = new XMLHttpRequest ();
	}
	catch (e) {
	  var xmlhttplocal = false;
	}
  }
  return (xmlhttplocal);
}

function vote (id, user)
{
  	if (xmlhttp) {
		url =  "/modules/extra/vote.php";
		var mycontent = "id=" + id + "&user=" + user;

		mnmxmlhttp = new myXMLHttpRequest ();
		if (mnmxmlhttp) {
			mnmxmlhttp.open ("POST", url, true);
			mnmxmlhttp.setRequestHeader ('Content-Type',
					   'application/x-www-form-urlencoded');

			mnmxmlhttp.send (mycontent);
			
			mnmxmlhttp.onreadystatechange = function () {
				if (mnmxmlhttp.readyState == 4) {
					xvotesString = mnmxmlhttp.responseText;
					if ( xvotesString == 'error' ) {
						alert("Eroare. Ne cerem scuze pentru inconveniente");
					}else if ( xvotesString == 'yourself' ) {
						alert("Nu aveti voie sa votati propria casa");
					} else if ( xvotesString == 'time_freeze' ) {	
						alert("Aveti voie sa votati o casa doar o data pe zi");
					} else {
						/* alert("Ati votat cu succes casa lui " + xvotesString); */
						document.getElementById("votat_" + id).innerHTML = 'votat';
						document.getElementById("votul_" + id).innerHTML ++;
					}
				}
			}
		}
	}
}


