function goBack(){
	history.go(-1);
}

function showRea(id){
	if(document.getElementById('rea_'+id).style.display == ''){
		document.getElementById('rea_'+id).style.display = 'none';
		document.getElementById('hide_'+id).style.display = '';
	}
	else{
		document.getElementById('rea_'+id).style.display = '';
		document.getElementById('hide_'+id).style.display = 'none';
	}
}

function envoieDem(hndl, lang){
	if(validForm(hndl)){
		killAjax();
		ret = function(){
			if(ajaxOk()){
				document.getElementById('resultat').innerHTML = objAjax.responseText;
			}
		}
		callAjax('/script/addDemande.php?lang='+lang,ret,null,hndl);
	}
}

function validateMailing(lang){
	if(!validateEmail(document.getElementById('mailingEmail').value)){
		document.getElementById('mailingEmail').focus();
		alert(document.getElementById('mailingEmail').getAttribute('error'));
		return false;
	}
	else if(document.getElementById('mailingEmail').getAttribute('default') == document.getElementById('mailingEmail').value){
		document.getElementById('mailingEmail').focus();
		alert(document.getElementById('mailingEmail').getAttribute('errorS'));
		return false;
	}
	else{
		killAjax();
		ret = function(){
			if(ajaxOk()){
				document.getElementById('prout').innerHTML = objAjax.responseText;
			}
		}
		callAjax("/script/addMail.php?lang="+lang+"&em="+document.getElementById('mailingEmail').value,ret,null,null,null);
	}
}

function validateEmail(email) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   return reg.test(email);
}

function switchReplace(id){
	if($(id).value == ""){
		$(id).value = $(id).getAttribute('default');	
	}
	if($(id).value == $(id).getAttribute('default') && $(id).style.color != "#888"){
		$(id).style.color = "#888";								 
    }
}

function enleveMoiCa(id){
	if($(id).value == $(id).getAttribute('default')){
		$(id).value = "";	
		$(id).style.color = "#444";	
	}
}


sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);



function showStateDistributor(etat) {
  var f = document.getElementById('gmapframe');
  f.src = '/iframe-maps.php?etat='+etat;
  var url = '/ajax_data/showstatedistributor.php?etat='+etat;
  var myRandom = parseInt(Math.random()*99999999); // cache buster 
    new Ajax.Request(
	url+'&'+'rand=' + myRandom,
    {
        onSuccess: function(transport, json) {
		   document.getElementById('dealerlist').innerHTML = transport.responseText;
       } 
   } );
    location.href=location.href='#content';
	
}

function selSuccursale(id) {
  var f = document.getElementById('gmapframe');
  f.src = '/iframe-maps.php?succid='+id;
  location.href=location.href='#content';
}



