$(function() {        
  $.browser.msie6 =
        $.browser.msie
        && /MSIE 6\.0/i.test(window.navigator.userAgent)
        && !/MSIE 7\.0/i.test(window.navigator.userAgent); 
    
	if($.browser.msie6) {
	$('a.help').cluetip({
      local: true,
      arrows: true,
      width: 300,
      cluetipClass: 'jtip'}
    );	
    $('#cluetip').bgiframe();
    } else {	
	$('a.help').cluetip({
      local: true,
      arrows: true,
      width: 300,
      cluetipClass: 'jtip'}
    );
  }
   	 $('#question').bind("keyup", function(e){
 	 	  if ($('#question').val().length < 130) {
 	 	  	$('#divQuestionLenghtAlert').slideDown();
 	 	  } else {
 	 	  	$('#divQuestionLenghtAlert').slideUp();
 	 	  }		
    });
    
    $('#question').cluetip({
      local: true,
      arrows: true,
      width: 300,
      cluetipClass: 'jtip'}
    );
	
    $('#linkLogin').click(function(){
    	 $('#divRegisterUser').slideUp('slow');
       $('#divLoginUser').slideDown('slow');
       $('#type').val('1');
    });	
    $('#linkRegister').click(function(){
    	 $('#divRegisterUser').slideDown('slow');
       $('#divLoginUser').slideUp('slow');
       $('#type').val('0');
    });	    
	
	  if ($('#type').val() == '1') {
	  	$('#divRegisterUser').slideUp('slow');
       $('#divLoginUser').slideDown('slow');
	  }	
 	 	  if ($('#question').val().length < 130) {
 	 	  	$('#divQuestionLenghtAlert').show();
 	 	  } else {
 	 	  	$('#divQuestionLenghtAlert').hide();
 	 	  }			
	
});




		// Calendar callback. When a date is clicked on the calendar
		// this function is called so you can do as you want with it
		function calendarDeadlineCallback(day, month, year)
		{
		  month = month.toString();
      day = day.toString();
      year = year.toString();
      
		  if(month.length == 1)
		    month = "0" + month;

		  if(day.length == 1)
		    day = "0" + day;      
      
  // set the value in form		    		
      document.forms['fquestion'].deadlineDay.selectedIndex = day;
      document.forms['fquestion'].deadlineMonth.selectedIndex = month;
      
      for(i=0;i<document.forms['fquestion'].deadlineYear.length;++i)
        if(document.forms['fquestion'].deadlineYear.options[i].text == year)
          document.forms['fquestion'].deadlineYear.options[i].selected = true;

				DisplayMoreInfos('{/literal}{$display_missing_enduser_info}{literal}');
		}

		function calendarBirthdateCallback(day, month, year)
		{
		  month = month.toString();
      day = day.toString();
      year = year.toString();
      
		  if(month.length == 1)
		    month = "0" + month;

		  if(day.length == 1)
		    day = "0" + day;      
      
  // set the value in form		    		
      document.forms['fquestion'].birthdateDay.selectedIndex = day;
      document.forms['fquestion'].birthdateMonth.selectedIndex = month;
      
      for(i=0;i<document.forms['fquestion'].birthdateYear.length;++i)
        if(document.forms['fquestion'].birthdateYear.options[i].text == year)
          document.forms['fquestion'].birthdateYear.options[i].selected = true;
		}

function DisplayMoreInfos(todisp) {
 if (todisp == 'YES') {
 	document.getElementById('enduser_infos').style.display = 'block';
 document.getElementById('enduserinfosshowed').value = "1";
 } else {
 //document.getElementById('enduser_infos').style.display = 'none';
 //document.getElementById('enduserinfosshowed').value = "0";
 }

}	

			function check()
				{
					var Nbr_Erreur = 0;
					var Obj = null;
					var Reg;
					var Tab_ID = new Array("cp",  "sponsor"); 
	
					for( var i=0; i < Tab_ID.length; i++)
					{
						Obj = document.getElementById( Tab_ID[i]);
						Reg = new RegExp('[^0-9]+', 'g'); // Ici initialisation de Reg
	
						if( Reg.test( Obj.value))
						{
							Nbr_Erreur++;
							Obj.value = Obj.value.replace(/[^0-9]+/, '');
						}
					}
					return( Nbr_Erreur);
				}
				
			function evalPwd(s)
			{
				var cmpx = 0;
				
				if (s.length >= 4)
				{
					cmpx++;
					
					if (s.search("[A-Z]") != -1)
					{
						cmpx++;
					}
					
					if (s.search("[0-9]") != -1)
					{
						cmpx++;
					}
					
					if (s.length >= 8 || s.search("[\x20-\x2F\x3A-\x40\x5B-\x60\x7B-\x7E]") != -1)
					{
						cmpx++;
					}
				}
				
				if (cmpx == 0)
				{
					document.getElementById("weak").className = "nrm";
					document.getElementById("medium").className = "nrm";
					document.getElementById("strong").className = "nrm";
				}
				else if (cmpx == 1)
				{
					document.getElementById("weak").className = "red";
					document.getElementById("medium").className = "nrm";
					document.getElementById("strong").className = "nrm";
				}
				else if (cmpx == 2)
				{
					document.getElementById("weak").className = "yellow";
					document.getElementById("medium").className = "yellow";
					document.getElementById("strong").className = "nrm";
				}
				else
				{
					document.getElementById("weak").className = "green";
					document.getElementById("medium").className = "green";
					document.getElementById("strong").className = "green";
				}
			}
	var SubCounter=0;
	function SubmitSubscription()
		{

			if (SubCounter == 0) {
				document.fsubscribe.submit();
				SubCounter++;
			}

		}					

		function writediv(texte) {
		  document.getElementById('pseudobox').innerHTML = texte;
		}
		
    function veriflogin(login) {
	  	param = 'login='+login;
	  	$.ajax({
	      data: param,
	      url: '/AJAX_Veriflogin.php',
	      dataType: 'text',
	   		type: "GET",
	      error: function(req,str,e){
	          errmsg = 'Error veriflogin' + str;
	      },
	      success: function(msg){
	          // do something 
	       	   handleveriflogin(msg,login);
	  //     	   selRegion = "";
	      }
	  	});     	
    }	
    
    
    function handleveriflogin(msg,login) {

         
            Obj1 = document.getElementById("login");
            Reg1 = new RegExp('[^a-z0-9.-_]+', 'gi'); // Ici initialisation de Reg
            
            if( Reg1.test( Obj1.value)) {
              Obj1.value = Obj1.value.replace(/[^a-z0-9.-_]+/, '');
            }
            // -----------------------------------------------------------------
                  		
            if(msg == 1) {
               writediv('<span style="color:#cc0000; font-face:verdana; font-size:10px"><b>'+login+' :</b>Pseudo déjà pris, veuillez en choisir un autre</span>');
            //document.formulaire.Submit.disabled = true;
            }
            else if(msg == 2) {
               writediv('<span style="color:#1A7917; font-face:verdana; font-size:10px"><b>'+login+' :</b>Pseudo libre</span>');
            // document.formulaire.Submit.disabled = false;
            }
            else if(msg == 3) {
               writediv('<span style="color:#cc0000; font-face:verdana; font-size:10px">Le pseudo ne doit être composé que de caractères alphanumériques et aucun espace</span>');
            // document.formulaire.Submit.disabled = false;
            }
            else if(msg == 4) {
               writediv('<span style="color:#cc0000; font-face:verdana; font-size:10px">Pseudo trop court</span>');
            // document.formulaire.Submit.disabled = false;
            }
            else if(msg == 5) {
               writediv('<span style="color:#cc0000; font-face:verdana; font-size:10px">Pseudo trop long</span>');
            // document.formulaire.Submit.disabled = false;
            
            } else {
               writediv(msg);
             //document.formulaire.Submit.disabled = false;
            }

      
    } // end function				
    
    
function CheckForm() {
	
	
}	    