// crea l'oggetto per la comunicazione AJAX con il server
// compatibile con tutti i browser che supportano AJAX
function crea_http_req() {
	var req = false;
	if (typeof XMLHttpRequest != "undefined")
		req = new XMLHttpRequest();
	if (!req && typeof ActiveXObject != "undefined") {
		try {
			req=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e1) {
			try {
				req=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2) {
				try {
					req=new ActiveXObject("Msxml2.XMLHTTP.4.0");
				} catch (e3) {
					req=null;
				}
			}
		}
	}

	if(!req && window.createRequest)
		req = window.createRequest();

	if (!req) alert("Il browser non supporta AJAX");

	return req;
}

function carica_video(i, lng, tipo) {
	var xmlhttp = crea_http_req();
	var codice_video = 'codice_video=' + i;

	document.forms[0].codice_video.value = i;
	if (lng == 'it') {
	document.getElementById('video').innerHTML = "<img src=\"./i/loader.gif\" alt=\"\" title=\"\" style=\"margin: 193px auto 0 auto;\" />";
	} else {
	document.getElementById('video').innerHTML = "<img src=\"../i/loader.gif\" alt=\"\" title=\"\" style=\"margin: 193px auto 0 auto;\" />";
	}
	xmlhttp.onreadystatechange=function() {
  		if (xmlhttp.readyState==4) {
			document.getElementById('video').innerHTML = xmlhttp.responseText;
   		}
  }
 if (lng == 'it') {
	if (tipo == 'GV') {
		xmlhttp.open("GET", "./video.html", true);
	} else if (tipo == 'YT') {
		xmlhttp.open("GET", "./video_youtube.html", true);
	}
 } else {
	if (tipo == 'GV') {
		xmlhttp.open("GET", "../video_en.html", true);
	} else if (tipo == 'YT') {
		xmlhttp.open("GET", "../video_en_youtube.html", true);
	}
 }
 xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 xmlhttp.setRequestHeader("Content-length", codice_video.length);
 xmlhttp.setRequestHeader("Connection", "close");
 xmlhttp.send(codice_video);
}