var Utils={
	
	ouvrirAidePbMinitel:function(page){
		window.open('/index/aideMinitel','','width=500,height=480,left=10,top=10,resizable=yes,scrollbars=yes');
	},
	
	
	ouvrirAideAudio:function(partner){
	    if(partner==undefined)
	        partner='0';
	   window.open('page/p_comment_ca_marche.php?partner='+partner,'','width=320,height=300,left=10,top=10,resizable=yes,status,location=no');
	},
	
	ouvrirAideMulti:function(idc, partner) {
	 if(window.urchinTracker)
	        alert("1");
	    else
	        alert("0");
	    if(partner==undefined)
	        partner='0';
	    window.open('page/p_comment_ca_marche_multi.php?idc='+idc+'&partner='+partner,'','width=590,height=470,left=10,top=10,resizable=yes,scrollbars=yes');
	},
	
	affNotifyMsg:function(dst, msg, style){
		if(style=="ok")
		msg = "<div style=\"color:#009900;\">"+msg+"</div>";
		else
			msg = "<div style=\"color:#ff0000;font-weight:bold;\">"+msg+"</div>";	
		
        if( $(dst) ==undefined )
            return; 
            
        document.getElementById(dst).innerHTML = msg;		
		window.setTimeout(function(){ document.getElementById(dst).innerHTML = ""},6000);
	},
	
	verifierEmail:function(email) {
            var modele = /^[a-z0-9\-_\.]+@[a-z0-9\-_\.]+\.[a-z]{2,}$/i;
            if (modele.test(email))
				return true;
            else return false;
	},

	getMessageStr:function(val){
		if(val=="OK")
			return "ok";
		else if(val=="KO")
			return "ko";
		else if(val=="MAIL_EMPTY")
			return "Mail vide";
		else if(val=="PASS_EMPTY")
			return "pass vide";	
		else if(val=="PARAMS_EMPTY")
			return "parametres vides";
		else if(val=="BAD_MAIL")
			return "mauvais mail";
		else if(val=="MAIL_EXISTS")
			return "Mail deja existant";
		else if(val=="SHORT_PARAM")
			return "Parametre trop court";
			
		return val;
	},
	
	ouvrirAideCB:function(idc, partner){
	    if(partner==undefined)
	        partner='0';
	    window.open('page/p_comment_ca_marche_cb.php?idc='+idc+'&partner='+partner,'','width=590, height=470,left=10,top=10,resizable=yes,scrollbars=yes');
	}
	
};



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,location=0,status=0,resizable=0');
		},
			    
	    aideWHA:function(){		
			window.open(baseUrl+'/images/online/aide-wha.gif','_blank', 'width=590,height=270,top='+((screen.height-270)/2)+',left='+((screen.width-590)/2)+',scrollbars=0,location=0,status=0,resizable=0');				
		},
		
		aideCB:function(){				
			window.open(baseUrl+'/images/online/aide-cb.gif','_blank', 'width=590,height=350,top='+((screen.height-350)/2)+',left='+((screen.width-590)/2)+',scrollbars=0,location=0,status=0,resizable=0');				
		},
	    
	    infosIntegrale:function(){
	        window.open(baseUrl+"/concours/infosintegrale", '_blank', 'width=550,height=420,top='+((screen.height-500)/2)+',left='+((screen.width-500)/2)+',scrollbars=0,location=0,status=0,resizable=0');
	    },
	    
	    infosQcm:function(){
	        window.open(baseUrl+"/QCM-concours-atsem/infospack", '_blank', 'width=550,height=422,top='+((screen.height-550)/2)+',left='+((screen.width-422)/2)+',scrollbars=0,location=0,status=0,resizable=0');
	    },
	    infostroisfois:function(){
	        window.open("http://www.atsem.fr/se-preparer-au-concours-gardien-de-la-paix/paiement3x", '_blank', 'width=550,height=470,top='+((screen.height-470)/2)+',left='+((screen.width-550)/2)+',scrollbars=0,location=0,status=0,resizable=0');
	    },

	    infos:function(type, pid){
	        var url="";
	        var pidParam="";
	        if(pid != undefined)
	            pidParam = "/pid/"+pid;
	        if(type=="wha")
	            url=baseUrl+"/concours/whainfos";
	        else if(type=="cb")
	            url=baseUrl+"/concours/cbinfos";
	        else if(type=="tkt")
	            url=baseUrl+"/concours/smsinfos";
		else if(type=="tkt2")
	        url=baseUrl+"/concours/smsinfos2";
		
	            
	            
	        url+=pidParam;
	        window.open(url,'','width=500,height=400,left=10,top=10,resizable=yes,status,location=no');
	    },
		
		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
		}
	};