function change_state(id) {	if (document.getElementById(id).style.display == "none") {		document.getElementById(id).style.display = "block";	} else {		document.getElementById(id).style.display = "none";	}}
function activate(obj) {	obj.disabled = false;}
function validateFreeTicket(id,mail,file,id_form) {	var xhr=null;    htmlButton = document.getElementById("button").innerHTML;    if (window.XMLHttpRequest) {         xhr = new XMLHttpRequest();    }    else if (window.ActiveXObject)     {        xhr = new ActiveXObject("Microsoft.XMLHTTP");    }	xhr.onreadystatechange = function() { outputFreeTicket(xhr,file,htmlButton,id_form,id); };	document.getElementById("button").innerHTML="<img src='/img/loading8.gif' width='50' height='10'/><div id='waiting'>Veuillez patienter...</div>";    xhr.open("GET", "/includes/ajax/validateFreeTicket.php?id=" + id + "&mail=" + mail, true);    xhr.send(null);}
// Node cleanerfunction go(c){	if(!c.data.replace(/\s/g,''))		c.parentNode.removeChild(c);}
function cleanXML(d){	var bal=d.getElementsByTagName('*');	for(i=0;i<bal.length;i++){		a=bal[i].previousSibling;		if(a && a.nodeType==3)			go(a);		b=bal[i].nextSibling;		if(b && b.nodeType==3)			go(b);		}	return d;} 
function outputFreeTicket(xhr,file,htmlButton,id_form,id) {	if (xhr.readyState == 4){		if (xhr.status == 200) {			var docXML= cleanXML(xhr.responseXML.documentElement);			if (docXML.getElementsByTagName("code")[0].firstChild.nodeValue == 0) {                /*var popup = window.open(file);				if (!popup) {					change_state(id_form);					change_state("pdflink");				}*/				change_state(id_form);				change_state("pdflink" + id);			} else {				alert(docXML.getElementsByTagName("message")[0].firstChild.nodeValue);			}			document.getElementById("button").innerHTML=htmlButton;		} else {			alert('issue ' + xhr.status);		}	}}
