function checkpassword(){
	if(document.getElementById('pass1').value ==""){
	    alert("you can not leave the password empty");	
	 }else
	if(document.getElementById('pass1').value==document.getElementById('pass2').value ){
	 return true;
	}
	 else{
	 	alert("The Password does not match with the confirmation");
	 		document.getElementById('pass2').focus();
	 	return false;
	 } 
}function validateall(){
if (validate(1,'Name',0,32,4,4,1,0)){
	alert('hiiii');
    validate(2,'Prenom',0,32,4,4,1,0);
  }else return false;
if (checkpassword()){
	validate(3,'Email',0,32,0,4,1,0);
 		return true;
 		}
	else 
		return false;	
}


function validate(id,desc,min,max,valid_char1,valid_char2,required,return_f){

var valid_spec_char= new Array(
		"-",
		".",
		"_",
		"@",
		" ",
		"/",
		"\\",
		"~",
		"!",
		"$",
		"%",
		"^",
		"&",
		"*",
		"(",
		")",
		"+",
		"|",
		"}",
		"{",
		":",
		"?",
		">",
		"<",
		",",
		";",
		"]",
		"[",
		"=",
		"#",
		"'");
var text=document.getElementById(id).value;
var text_len=text.length;
var chk_text;
var div_id_msg=id+'_msg'
var div_id_tip=id+'_tip'
var allowed_spec_char;
chk_text="";
allowed_spec_char="";

if(required==1 && text_len==0){
	alert('You Cant Leave The '+desc+' Field Empty')
	document.getElementById(div_id_tip).innerHTML='<font title="You Cant Leave The '+desc+' Field Empty" color=red>#</font>'
	//document.getElementById(div_id_msg).innerHTML='<font color=red>You Cant Leave The '+desc+' Field Empty </font>'
	document.getElementById(id).focus();
	return false;
	}


for(j=valid_char1;j<=valid_char2;j++){
allowed_spec_char=valid_spec_char[j]+' '+allowed_spec_char;
}


	if(text_len>=min && text_len <=max){

		for(i=0;i<max;i++){



			if((text.charAt(i)>=0 && text.charAt(i)<=9) || (text.charAt(i).toLowerCase()>="a" && text.charAt(i).toLowerCase()<="z")){// || ){
				chk_text = chk_text+text.charAt(i);
				//alert(text.charAt(i))
				document.getElementById(div_id_tip).innerHTML='<font color=Green>OK</font>'
				//document.getElementById(div_id_msg).innerHTML=''
			}
			else{

					flag1=0;
					for(k=valid_char1;k<=valid_char2;k++){

						if(valid_spec_char[k]==text.charAt(i)){
							chk_text = chk_text+text.charAt(i);
							//alert(text.charAt(i)+''+valid_spec_char[k])
							//document.getElementById(div_id_tip).innerHTML='<font color=Green>OK</font>'
							//document.getElementById(div_id_msg).innerHTML=''
							flag1=1;
						}
					}
						if(flag1==0 && required==1){

//alert('The Char '+text.charAt(i)+' Is Not Allowed In The '+desc+' Field..You Are Allowed To Enter Numbers 1 to 9 and characters a z A Z In Addtion To The Following Special Characters '+allowed_spec_char)
document.getElementById(div_id_tip).innerHTML='<font title="The Char '+text.charAt(i)+' Is Not Allowed In The '+desc+' Field..You Are Allowed To Enter Numbers 1 to 9 and characters a z A Z In Addtion To The Following Special Characters '+allowed_spec_char+'" color=red>#</font>'
//document.getElementById(div_id_msg).innerHTML='<font color=red>The Char '+text.charAt(i)+' Is Not Allowed In The '+desc+' Field..<br>You Are Allowed To Enter Numbers 1 to 9 and characters a z A Z In Addtion To The Following Special Characters '+allowed_spec_char+'</font>'
//document.getElementById(div_id_msg).innerHTML='<font color=red>'+unvalidcharacters+'</font>';
						document.getElementById(id).focus();
						//document.getElementById("divMessage").innerHTML = '';
						return false;


						}


			}


		}

document.getElementById(id).value=chk_text
if(return_f==1){
return true;
}
else{
return false;
}

	}
	else{
	//alert('The '+desc+' Field Must Be Not Less Than '+min+' And Not More Than '+max+' Digits Long')
	document.getElementById(div_id_tip).innerHTML='<font title="The '+desc+' Field Must Be Not Less Than '+min+' And Not More Than '+max+' Digits Long" color=red>#</font>'
	//document.getElementById(div_id_msg).innerHTML='<font color=red>The '+desc+' Field Must Be Not Less Than '+min+' And Not More Than '+max+' Digits Long</font>'
	//document.getElementById(div_id_msg).innerHTML='<font color=red>'+unvalidlength1+'</font>';
	//document.getElementById("divMessage").innerHTML = '';
	document.getElementById(id).focus();
	return false;
	}


//return false;
}

