var nsv=document.layers;
var iev=document.all;
if(!iev) var mov=document.getElementById;
var MouseX=0;
var MouseY=0;
var ScrollX=0;
var ScrollY=0;
function GetScrollPosX()
{
	var curScrollX=ScrollX;
	if(nsv)
	{
		ScrollX=window.pageXOffset;
	}
	else
	{
		if(document.documentElement.scrollLeft)
			ScrollX=document.documentElement.scrollLeft;
		else
			ScrollX=document.body.scrollLeft;
	}
	return ScrollX;
}
function GetScrollPosY()
{
	var curScrollY=ScrollY;
	if(nsv)
	{
		ScrollY=window.pageYOffset;
	}
	else
	{
		if(document.documentElement.scrollTop)
			ScrollY=document.documentElement.scrollTop;
		else
			ScrollY=document.body.scrollTop;
	}
	return ScrollY;
}
function view_hint(e)
{
	e = (document.all ? window.event : e );
	cx = (document.all?e.x:e.clientX);
	cy = (document.all?e.y:e.clientY);
	hint = document.createElement('div');
	hint.id = 'captcha_hint';
	hint.className = 'hints';
	hint.style.width = '180px';
	hint.style.position = 'absolute';
	hint.style.top = (cy-160)+parseInt(GetScrollPosY())+'px';
	hint.style.left = (cx-(parseInt(hint.style.width)+15))+parseInt(GetScrollPosX())+'px';
	hint.innerHTML = 'Si vous n\'arrivez pas à lire la séquence de lettres et chiffres, cliquez sur l\'image pour la recharger.<br /><br /><small>NB: Cette image nommée "image CAPTCHA" est un système de protection pour éviter des inscriptions par des robots considérés comme "spam".<br />De telles mesures sont nécessaires pour vous fournir un service de qualité.<br />Merci de votre compréhension.</small>';
	document.body.appendChild(hint);
}
function hide_hint()
{
	hint = (document.all?document.all('captcha_hint'):document.getElementById('captcha_hint'));
	document.body.removeChild(hint);
}
function checkInscription()
{
	oForm = (document.all?document.all('dde_inscription'):document.getElementById('dde_inscription'));
	for(a=0;a<oForm.length;a++)
	{
		if(oForm.elements[a].type != 'button' && oForm.elements[a].tagName != 'BUTTON')
		{
			oForm.elements[a].style.border = '1px solid #008b4d';
			formLabel = (document.all?document.all('lbl_'+oForm.elements[a].id):document.getElementById('lbl_'+oForm.elements[a].id));
			formLabel.style.fontWeight = 'normal';
			formLabel.style.color = '#777777';
		}
	}
	bePatientBg = document.createElement('div');
	bePatientBg.id = 'bePatientBg';
	bePatientBg.style.position = 'absolute';
	bePatientBg.style.height = '100%';
	bePatientBg.style.width = document.getElementsByTagName('body')[0].scrollWidth+'px';
	bePatientBg.style.backgroundColor = '#ffffff';
	bePatientBg.style.top = '0px';
	bePatientBg.style.left = '0px';
	bePatientBg.style.MozOpacity = 0.7;
	bePatientBg.style.opacity = 0.7;
	document.getElementsByTagName('body')[0].appendChild(bePatientBg);
	if(iev) bePatientBg.style.filter = 'alpha(opacity=70);';
	bePatient = document.createElement('div');
	bePatient.id = 'bePatient';
	bePatient.style.width = '400px';
	bePatient.style.height = '20px';
	bePatient.style.position = 'absolute';
	bePatient.style.textAlign = 'center';
	bePatient.innerHTML = 'Veuillez patienter...';
	bePatient.style.fontFamily = 'Arial';
	bePatient.style.fontSize = '14px';
	bePatient.style.fontWeight = 'bold';
	bePatient.style.color = '#00514e';
	bPH = parseInt((parseInt(bePatientBg.offsetHeight)-20)/2);
	if(iev) bPH = bPH-125;
	bePatient.style.top = bPH+'px';
	bePatient.style.left = (parseInt(parseInt(bePatientBg.style.width)-400)/2)+'px';
	document.getElementsByTagName('body')[0].appendChild(bePatient);
	setAjaxRequest(['/lib/set_inscription_manifestation.lib.php','dde_inscription','returnInscTreatment']);
}
function returnInscTreatment(http)
{
	response = http.responseXML.getElementsByTagName('response')[0];
	error = response.getAttribute('error');
	bePatient = (document.all?document.all('bePatient'):document.getElementById('bePatient'));
	bePatientBg = (document.all?document.all('bePatientBg'):document.getElementById('bePatientBg'));
	document.getElementsByTagName('body')[0].removeChild(bePatient);
	document.getElementsByTagName('body')[0].removeChild(bePatientBg);
	if(error!='')
	{
		str_alert = "";
		arr_input = error.split(/;/);
		for(a=0;a<arr_input.length;a++)
		{
			formElmnt = (document.all?document.all(arr_input[a]):document.getElementById(arr_input[a]));
			formElmnt.style.border = '2px solid #cc0000';
			formLabel = (document.all?document.all('lbl_'+arr_input[a]):document.getElementById('lbl_'+arr_input[a]));
			formLabel.style.fontWeight = 'bold';
			formLabel.style.color = '#cc0000';
			str_alert += "\t - "+formLabel.innerHTML.replace(/:/,'')+"\n";
		}
		alert("Les champs suivants ne sont pas renseignés.\nIls sont obligatoires.\n Merci de les remplir.\n"+str_alert);
	}
	else if(response.getAttribute('value')==1)
	{
		dest = (document.all?document.all('manif_inscr_form'):document.getElementById('manif_inscr_form'));
		dest.innerHTML = "<strong>Votre inscription a &eacute;t&eacute; prise en compte.<br />Une fois celle-ci validée par Pays du Nord, vous recevrez vos login et mot de passe par email pour vous connecter &agrave; l'interface d'administration de vos manifestations.</strong>";
//		alert('Inscription effectuée');
	}
	else
	{
		alert("Un problème est survenue");
	}
}
include('/js/ajax.lib.js');