var http_request = false;
function makePOSTRequest(url, parameters) {
  http_request = false;
  if (window.XMLHttpRequest) {
	 http_request = new XMLHttpRequest();
	 if (http_request.overrideMimeType) {
		http_request.overrideMimeType('text/html');
	 }
  } else if (window.ActiveXObject) {
	 try {
		http_request = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
		try {
		   http_request = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {}
	 }
  }
  if (!http_request) {
	 alert('Cannot create XMLHTTP instance');
	 return false;
  }
  
  http_request.onreadystatechange = alertContents;
  http_request.open('POST', url, true);
  http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http_request.setRequestHeader("Content-length", parameters.length);
  http_request.setRequestHeader("Connection", "close");
  http_request.send(parameters);
}
//
function alertContents() {
  if (http_request.readyState == 4) {
	 document.getElementById('comm_load').style.display = 'none';
	 if (http_request.status == 200) {
		//alert(http_request.responseText);
		result = http_request.responseText;
		document.getElementById('comm_result').style.display = '';
//		document.getElementById('comm_result').innerHTML = result;
	 } else {
		alert('There was a problem with the request.');
	 }
  }
}
//
function ajax_AddComentariu_go(obj) {
  var poststr = "text=" + encodeURI( document.getElementById("adauga_comm_text").value ) +
				"&fid=" + encodeURI( document.getElementById("adauga_comm_fid").value );
  
  document.getElementById('comm_form').style.display = 'none';
  document.getElementById('comm_load').style.display = '';
  
  makePOSTRequest('/ajax/comm_add_film.php', poststr);
}
//
function ajax_AddComentariuNume_go(obj) {
  var poststr = "text=" + encodeURI( document.getElementById("adauga_comm_text").value ) +
				"&nid=" + encodeURI( document.getElementById("adauga_comm_nid").value );
  
  document.getElementById('comm_form').style.display = 'none';
  document.getElementById('comm_load').style.display = '';
  
  makePOSTRequest('/ajax/comm_add_nume.php', poststr);
}
//
function ajax_AddComentariuStiri_go(obj) {
  var poststr = "text=" + encodeURI( document.getElementById("adauga_comm_text").value ) +
				"&sid=" + encodeURI( document.getElementById("adauga_comm_sid").value );
  
  document.getElementById('comm_form').style.display = 'none';
  document.getElementById('comm_load').style.display = '';
  
  makePOSTRequest('/ajax/comm_add_stiri.php', poststr);
}
//
function getDivContent(divu, pagina) {
	var xmlhttp=false;
	try {
			xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
	} catch (e) {
		try {
			xmlhttp = new
			ActiveXObject('Microsoft.XMLHTTP');
		} catch (E) {
			xmlhttp = false;
		}
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	xmlhttp.open('GET', pagina, true);
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			var content = xmlhttp.responseText;
			if( content ){
				var box_content = document.getElementById(divu)
				box_content.innerHTML = content
			}
		}
	}
	xmlhttp.send(null)
	return;
}
//
function voteazaAltFilm() {
	getDivContent('voteaza_filme', '/ajax/vot_index_film.php');
	return;
}
//
function voteazaAltActor() {
	getDivContent('voteaza_actori', '/ajax/vot_index_nume.php');
	return;
}
//
function getDivContent_Fmg(pagina) {
	var xmlhttp=false;
	try {
			xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
	} catch (e) {
		try {
			xmlhttp = new
			ActiveXObject('Microsoft.XMLHTTP');
		} catch (E) {
			xmlhttp = false;
		}
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	xmlhttp.open('GET', pagina, true);
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			var content = xmlhttp.responseText;
			if( content ){
//				alert(content);
				var box_content = document.getElementById("tabs_nume")
				box_content.innerHTML = content
			}
		}
	}
	xmlhttp.send(null)
	return;
}
//
function getFilmografie(paramz) {
//	alert(paramz);
	var rquri = '/ajax/filmografie.php?' + paramz;
	getDivContent_Fmg(rquri);
	return;
}
//
function votIndexChNota(text, divu) {
	var box_content = document.getElementById(divu)
	box_content.innerHTML = text
}
//