function closeHeadLayer(elem)
{
	document.getElementById(elem).style.visibility='hidden';
	document.getElementById("idErrorMessageCodePostal").style.visibility='hidden';
	document.getElementById("idErrorMessageLogin").style.visibility='hidden';
	document.getElementById("idErrorMessageCodePostal").style.display='none';
	document.getElementById("idErrorMessageLogin").style.display='none';
}

function openLoginForm(){
	document.getElementById("layerMeConnecter").style.visibility ="visible";
	document.getElementById("layerMeConnecter").style.display ="block";
}

function openLayerMagasin(){
	document.getElementById("layerMonMagasin").style.visibility ="visible";
	document.getElementById("layerMonMagasin").style.display ="block";
}

function openLayerNewsLetter(){
	document.getElementById("layerInscriptionNewsletter").style.visibility ="visible";
	document.getElementById("layerInscriptionNewsletter").style.display ="block";
}

function clearText(elem)
{
	elem.value="";
}

function checkFormMagasin(){
    if(fcheckCodePostal(document.magasin.cp.value)){
       document.magasin.submit();
    }
}

function fcheckCodePostal(sValue){
    var strValidChars = "0123456789";
    var element = document.getElementById('idErrorMessageCodePostal');
    for (i=0;i < sValue.length;i++)
    {
            if(strValidChars.indexOf(sValue.charAt(i)) == -1)
            {
		
		    element.innerHTML = "seuls les caract&egrave;res 0123456789 sont autoris&eacute;s";
                    element.style.visibility='visible';
	   	    element.style.display='block';
                    return false;
            }
    }
    if(sValue.length != 5){
        element.innerHTML = "Le code postal indiqu&eacute; est erron&eacute;, veuillez le ressaisir";
        element.style.visibility='visible';
	element.style.display='block';
        return false;
    }

    //all is good
    return true;
 }

function showOverlay(layer)
{
$('#overlay').show();
		$('#overlay').css({'height':$(document).height()+'px','width':$(document).width()+'px'})
		$('#overlay').bind('click',function()
		{
			$('#overlay').hide();
			$(layer).hide();
		});
}



function findCodePostal(){	
	if(fcheckCodePostal(document.getElementById('codepostal').value)){
		window.location="/mpng2-front/pre?idLSPub=1090934336&zone=zonecatalogue&cp=" + document.getElementById('codepostal').value;
	}
}

function enterKeyCodePostal(e,codepostal) {
     var key;
     if(window.event)
	  key = window.event.keyCode;     //IE
     else
	  key = e.which;     //firefox
     if(key == 13){
          if(fcheckCodePostal(document.getElementById('codepostal').value)){
		  window.location="/mpng2-front/pre?idLSPub=1090934336&zone=zonecatalogue&cp=" + codepostal.value;
	}
     }
}

function sendNewsLetter(){
	window.location="/mpng2-front/pre?zone=zoneespaceperso&srvname=srveldataupdate&pageid=27&email=" + document.getElementById('mail').value;
}

function enterKey(e,mail) {
     var key;
     if(window.event) {
	  key = window.event.keyCode;     //IE
     } else {
	  key = e.which;     //firefox
     }
     if(key == 13){
	  window.location="/mpng2-front/pre?zone=zoneespaceperso&srvname=srveldataupdate&pageid=27&email=" + mail.value;
     }
}

