var exit_popup_act = 0;

function exit_display(url)
{
	if(navigator.userAgent.indexOf("Firefox") != -1){
		exit_win = window.open(url, '_blank', 'width=1024, height=950 , toolbar=1, location=1, directories=1, status=1, scrollbars=1, resizable=1, copyhistory=1, menuBar=1');
		if (exit_win != null)
			exit_win.blur();
	}else if(navigator.userAgent.indexOf("MSIE 7") != -1 || navigator.userAgent.indexOf("MSIE 8") != -1){
		setTimeout(function() { exit_win = window.open(url, '_blank', 'width=1024, height=950 , toolbar=1, location=1, directories=1, status=1, scrollbars=1, resizable=1, copyhistory=1, menuBar=1'); if (exit_win != null) exit_win.blur(); }, 300);
	}else if(navigator.userAgent.indexOf("MSIE 6") != -1){
		setTimeout(function() { window.open(url, '_blank', 'width=1024, height=950 , toolbar=1, location=1, directories=1, status=1, scrollbars=1, resizable=1, copyhistory=1, menuBar=1'); self.focus(); }, 300);
	}else{
		window.open(url, '_blank', 'width=1024, height=950 , toolbar=1, location=1, directories=1, status=1, scrollbars=1, resizable=1, copyhistory=1, menuBar=1');
		self.focus();
	}
}


/* ----------------------- */

function hideDhtml(){
	stop_blink();
	document.getElementById('overlay').style.display = 'none';
    document.getElementById('div_dhtml').style.display = 'none';
}

function showDhtml(){
	start_blink();
	
	if (navigator.userAgent.indexOf("MSIE 6") != -1) {
		document.getElementById('div_dhtml').style.position = 'absolute';
		window.scrollTo(0,0);
	}
	else
		document.getElementById('overlay').style.display = 'block';
		
	document.getElementById('div_dhtml').style.display = 'block';
}


var blink_timer;
var text_visible = 1;
var text_tmp;


function blink()
{
	if (text_visible)
	{
		text_tmp = document.dhtml_form.email.value;
		document.dhtml_form.email.value = '';
		text_visible = 0;
	}
	else
	{
		if (text_tmp != document.dhtml_form.email.value)
			document.dhtml_form.email.value = text_tmp;
		text_visible = 1;
	}
}

function start_blink()
{
	if (document.dhtml_form.email.value=='@')
		blink_timer = setInterval('blink()', 500);
}

function stop_blink()
{
	if (blink_timer)
		clearInterval(blink_timer);
}

function email_focus(this_form, blink)
{
	if (blink == 1)
		stop_blink();
	e = this_form.email;
	if (e.value == '@') e.value = '';
}

function email_blur(this_form, blink)
{
	var e = this_form.email;
	if (e.value == '@' || e.value == '')
	{
		e.value = '@';
		if (blink == 1)
			start_blink();
	}
}

/* ----------------------- */


function check_email(this_form)
{
	var email = this_form.email.value;
	var filter = /^([\w-]+(?:\.[\w-_]+)*)@((?:[\w-]+\.)*\w[\w-]{0,100})\.([a-z]{2,8}(?:\.[a-z]{2})?)$/i;
	
	if (!filter.test(email))
	{
		alert('Merci d\'entrer un email valide !');
		return false;
	}
	
	return true;
}

/* ----------------------- */

function blink_from_element(max) {
	blink_from_element_core(0,0,max);
}

function blink_from_element_core(current_color, current_i, max_i) {
	if(current_i < max_i ) {
		if(current_color == 0 ) {
			document.dhtml_form.email.style.backgroundColor = '#FA0000';
			current_color = 1;
		} else {
			document.dhtml_form.email.style.backgroundColor = '#FFFFFF';
			current_color = 0;
		}
		current_i++;
		setTimeout("blink_from_element_core("+current_color+","+current_i+","+max_i+")", 100);
	}
	else {
		document.dhtml_form.email.style.backgroundColor = '#FFFFFF';
	}
}

function blink_from_element_new(max, color1, color2, id_form) {
	blink_from_element_core_new(0,0,max, color1, color2, id_form);
}

function blink_from_element_core_new(current_color, current_i, max_i, color1, color2, id_form) {
	if(current_i < max_i ) {
		if(current_color == 0 ) {
			document.getElementById(id_form).email.style.backgroundColor = color1;
			current_color = 1;
		} else {
			document.getElementById(id_form).email.style.backgroundColor = color2;
			current_color = 0;
		}
		current_i++;
		setTimeout("blink_from_element_core_new("+current_color+","+current_i+","+max_i+",'"+color1+"','"+color2+"','"+id_form+"')", 100);
	}
	else {
		document.getElementById(id_form).email.style.backgroundColor = color2;
	}
}

/* ----------------------- */

