function $(element) {
   element = document.getElementById(element);
  return element;
}

var Helpers = {

	pop:function(url){
		window.open(url, '_blank', 'width=500,height=500,top='+((screen.height-500)/2)+',left='+((screen.width-500)/2)+',scrollbars=0,toolbar=yes,location=0,status=0,resizable=0');
	},

    aideWHA:function(){
		window.open('/images/online/aide-wha.gif','_blank', 'width=590,height=270,top='+((screen.height-270)/2)+',left='+((screen.width-590)/2)+',scrollbars=0,toolbar=yes,location=0,status=0,resizable=0');
	},

	aideCB:function(){
		window.open('/images/online/aide-cb.gif','_blank', 'width=590,height=350,top='+((screen.height-350)/2)+',left='+((screen.width-590)/2)+',scrollbars=0,toolbar=yes,location=0,status=0,resizable=0');
	},

	checkform:function(theForm,checkpass){
    	var message='';
        var retour=false;
        // email
        if((theForm.email.value == '')||(theForm.confirm_email.value == '') ||(theForm.email.value != theForm.confirm_email.value))  message += "- Vous devez indiquer votre email de facon identique dans les deux zones de saisie.\n";
        else if(checkMail(theForm.email.value) == false){
        	message += "- L'email que vous avez saisi n'est pas valide\n";
        }
        if( (checkpass) && (theForm.password.value == '')){
        	message += "- Vous devez fournir un mot de passe\n";
        }
        if(message != ""){
        	retour = ('Erreur(s) :\n' + message)
        } else retour=true;
    	return(retour);
	},

	/**
	* DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
	*/
	checkMail:function(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) return false
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) return false
		if (str.indexOf(at,(lat+1))!=-1) return false
		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) return false
		if (str.indexOf(dot,(lat+2))==-1) return false
		if (str.indexOf(" ")!=-1) return false
		tld = str.substr(str.lastIndexOf(dot) + 1)
		if(tld != 'com'
		    && tld != 'net'
		    && tld != 'org'
			&& tld != 'fr'
			&& tld != 'info'
			&& tld != 'int'
			&& tld != 'name'
			&& tld != 'be'
			&& tld != 'it'
		) return false
		return true
	}
};


function focus() {
   // if (document.getElementById("telephone").value == "")
    //    document.getElementById("telephone").focus();
}
function ppRetreivePass(){
    window.open("http://www.annuaire-inverse.net/retrievepass/", '_blank', 'width=450,height=220,top='+((screen.height-500)/2)+',left='+((screen.width-500)/2)+',scrollbars=0,toolbar=yes,location=0,status=0,resizable=0');
}
function showLoginConf(){
//    document.getElementById('divLoginConf').style.display="";
//    window.setTimeout(function(){document.getElementById('divLoginConf').style.display="none"}, 2000);
}
function clean_fields(){
    var log = document.getElementById('email');
    var pass = document.getElementById('pass');
    if (log.value == 'Email' || log.value == 'Identifiants incorrects !') log.value = '';
    if (pass.value == 'Mot de passe') pass.value = '';
}
