function NewWindow(mypage, myname, w, h, scroll, resizable) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable='+resizable+''
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) {
		win.window.focus();
	}
}

function ajax_connexion_string() {
	var xhr_object = null;
	if (window.XMLHttpRequest) { // Firefox
		xhr_object = new XMLHttpRequest();
	} else if (window.ActiveXObject) { // Internet Explorer
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	} else { // XMLHttpRequest non supporté par le navigateur
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
		return;
	}
	return xhr_object;
}

function printThisPage(id) {
	
	xhr_object = ajax_connexion_string();
	xhr_object.open("POST", "inc/_substract_2_for_1.php", true);
	xhr_object.onreadystatechange = function anonymous() {
		// alert(xhr_object.readyState);
		if (xhr_object.readyState == 4) {
			alert(xhr_object.responseText);
			window.print();
			window.close();
		}
	}

	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	var data = "id=" + id;
	xhr_object.send(data);
}

function buildComboTypeEvent(sel) {
	xhr_object = ajax_connexion_string();
	xhr_object.open("POST", "inc/_build_combo_type_event.php", true);
	xhr_object.onreadystatechange = function anonymous() {
		// alert(xhr_object.readyState);
		if (xhr_object.readyState == 4) {
			document.getElementById("combo_type_event").innerHTML = xhr_object.responseText;
		}
	}

	xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	var data = "sel=" + sel;
	xhr_object.send(data);
}

function buildComboSalles(sel) {
	xhr_object2 = ajax_connexion_string();
	xhr_object2.open("POST", "inc/_build_combo_salles.php", true);
	xhr_object2.onreadystatechange = function anonymous() {
		// alert(xhr_object.readyState);
		if (xhr_object2.readyState == 4) {
			document.getElementById("combo_salles").innerHTML = xhr_object2.responseText;
		}
	}

	xhr_object2.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	var data = "sel=" + sel;
	xhr_object2.send(data);
}

function ChangeParentAndClose(sUrl) {
	opener.parent.location.href = sUrl;
	opener.location.href = sUrl;
	this.close();
	return false;
}