// All rights registred For NEWI.ac.uk by Valentin Auviney

function launch(url,taillew,tailleh)
{
display_overlay_window(taillew,tailleh);
displayExtraContent2(url);
}

function displayExtraContent2(id) {
	closeExtraContent2('window'); // ferme
	var url = "window";
	document.getElementById(url).style.display = ""; // afichage du div
	document.getElementById(url).innerHTML = "<img src='images/loading.gif'>";
	loadHTMLDoc2(id, displayHTMLFile2, url); //load
}

function displayHTMLFile2(content, id) {
	var food = content;
	document.getElementById(id).innerHTML = food;
}

function closeExtraContent2(id) {
	if (document.getElementById(id+"_link")) {
		document.getElementById(id+"_link").style.display = "";
	}
	document.getElementById(id).innerHTML = "";
	document.getElementById(id).style.display = "none";
}

function loadHTMLDoc2(url, doFunc, param) {
	var req;
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	req.onreadystatechange = function() {
		if (req.readyState == 4) {// only if req shows "loaded"
			if (req.status == 200) {// only if "OK"
				doFunc('<table width="100%" border="0" ><tr><td align="right"><a onClick="close_popup()"><img src="images/closepopup.png" alt="close" border="0" style="position:absolute;margin-top:-14px; margin-left:-5px"></a></td></table>'+req.responseText, param);
			} else {
				alert("Probleme de donn?es:\n" + req.statusText);
			}
		}
	}
	req.open("GET", url, true);
	req.send(null);
}


var w3c=document.getElementById && !document.all;
var ie=document.all;
if (ie||w3c) { // ONLY microsoft ?!!
 var overlay;
 var my_window;
}
function display_overlay_window(taillew,tailleh){
	// creation de l'overlay et affichage de l'image
	montreoverlay("<table class = 'image_calque ' valign = 'center' border = '0' align = 'center'><tr><td><img src='img/load.gif'></td></tr>");
	// creation de la fenêtre
	show_popup(taillew,tailleh);
}

function montreoverlay(text) {
  if (w3c||ie){
    overlay = document.all ? document.all["overlay"] : document.getElementById ? document.getElementById("overlay") : ""
	overlay.innerHTML = text; // fixe le code HTML dans l'overlay balise (div)
    overlay.style.visibility = "visible"; // modification du style
  }
}

function show_popup(taillew,tailleh) {
  if (w3c||ie){
    //affichage de la fenetre
	my_window = document.all ? document.all['window'] : document.getElementById ? document.getElementById('window') : ""
    my_window.style.visibility = "visible";
    my_window.style.width = taillew;
	my_window.style.height = tailleh;
	my_window.style.top = tailleh+'px';
	my_window.style.position = 'absolute';
	my_window.style.left = (document.body.offsetWidth/2-taillew/2)-20;
	document.getElementById('window').innerHTML = "<A href=\"javascript:;\" onClick=\"displayExtraContentpopup('index.html');\">Texte1</A>";
  }
}


function close_popup() {
	if (w3c||ie){
	location.reload();
	document.getElementById("window").style.visibility = "hidden";
	document.getElementById("overlay").style.visibility = "hidden";
	}


}

function SendFormMail(formulaire){
	destinataire = formulaire.destinataire.value;
	subject = formulaire.subject.value;
	mail = formulaire.mail.value;
	monmail = formulaire.monmail.value;
	nom = formulaire.nom.value;
	top = formulaire.top.value;
	id = formulaire.idannonce.value;
	launch('modules/envoiannonce/envoidumail.php?destinataire='+destinataire+'&subject='+subject+'&mail='+mail+'&monmail='+monmail+'&nom='+nom+'&id='+id,'400',top);
	
 }

	function SendMDPMail(formulaire){
	destinataire = formulaire.destinataire.value;
	top = formulaire.top.value;
	launch('modules/motdepasseperdu/envoidumail.php?destinataire='+destinataire,'400',top);
	
 }

