function filtrer(obj)  { obj_str = obj.value;  if(obj_str == '') return obj_str; 	 remplace0 = /[^0-9a-z]+$/i; if(obj_str != '') obj_str = obj_str.replace(remplace0, ''); remplace1 = /^[^0-9a-z]+/i; if(obj_str != '') obj_str = obj_str.replace(remplace1, ''); remplace2 = /\;/g; if(obj_str != '') obj_str = obj_str.replace(remplace2, ','); remplace22 = / or /ig; if(obj_str != '') obj_str = obj_str.replace(remplace22, ','); remplace3 = / /g; if(obj_str != '') obj_str = obj_str.replace(remplace3, ''); remplace4 = /,,+/g; if(obj_str != '') obj_str = obj_str.replace(remplace4, ','); remplace44 = /\.\.+/g; if(obj_str != '') obj_str = obj_str.replace(remplace44, '.'); remplace5 = /@@+/g; if(obj_str != '') obj_str = obj_str.replace(remplace5, '@'); remplace6 = /([\._]|-)*@([\._]|-)*/g; if(obj_str != '') obj_str = obj_str.replace(remplace6, '@'); remplace7 = /[^0-9a-zA-Z\._@\-,]/g; if(obj_str != '') obj_str = obj_str.replace(remplace7, ''); 
obj.value = obj_str;
return obj_str;
} 

function filtrer_email(obj)  { obj_str = obj.value;  if(obj_str == '') return obj_str; 	 remplace0 = /[^0-9a-z]+$/i; if(obj_str != '') obj_str = obj_str.replace(remplace0, ''); remplace1 = /^[^0-9a-z]+/i; if(obj_str != '') obj_str = obj_str.replace(remplace1, ''); remplace2 = /\;/g; if(obj_str != '') obj_str = obj_str.replace(remplace2, ','); remplace22 = / or /ig; if(obj_str != '') obj_str = obj_str.replace(remplace22, ','); remplace3 = / /g; if(obj_str != '') obj_str = obj_str.replace(remplace3, ''); remplace4 = /,,+/g; if(obj_str != '') obj_str = obj_str.replace(remplace4, ','); remplace44 = /\.\.+/g; if(obj_str != '') obj_str = obj_str.replace(remplace44, '.'); remplace5 = /@@+/g; if(obj_str != '') obj_str = obj_str.replace(remplace5, '@'); remplace6 = /([\._]|-)*@([\._]|-)*/g; if(obj_str != '') obj_str = obj_str.replace(remplace6, '@'); remplace7 = /[^0-9a-zA-Z\._@\-,]/g; if(obj_str != '') obj_str = obj_str.replace(remplace7, ''); 
if((obj_str.indexOf("@") == -1)||(obj_str.indexOf(".") == -1))
	{ 	alert('email invalid.');
		obj_str	="";
	}
obj.value = obj_str;
return obj_str;
} 

function spacecontrol(str,msge,minich)
{	nosp=0;
	control=0;
	for(i = 0; i < str.length; i++)
	{ 	ch = str.charAt(i);
		if(ch!=' ')
		nosp++;
	}
	if(nosp<minich)
	{	alert(msge);
		control++;//return false;
	}
	return control;
}

function nospace(str,msge)
{	control=0;
	for(i = 0; i < str.length; i++)
	{ 	ch = str.charAt(i);
		if((ch==' ')&&(str!=''))
		{	alert(msge);
			control++;
		}
	}
	return control;
}

function valide_email(email)
{	if((email.value.indexOf("@") == -1)||(email.value.indexOf(".") == -1))
		{ 	//alert('Votre email invalide. Veuillez le corriger.');
			//formcontrol++;
				return false;
		}
	return true
}

function regsubmit()
{	formcontrol=0;
	with(document.regform)
	{
		if((spacecontrol(last_name.value,'Please enter your name.',1))!=0)
		{	//formcontrol++;
			last_name.focus();
			return false;
		}

		if((spacecontrol(first_name.value,'Please enter your first name.',1))!=0)
		{	//formcontrol++;
			first_name.focus();
			return false;
		}

	/*	if((spacecontrol(user_name.value,'Please enter your login.',1))!=0)
		{	//formcontrol++;
			user_name.focus();
			return false;
		}
		
		if((spacecontrol(user_name.value,'The password should contain more than  3 characters',4))!=0)
		{	//formcontrol++;
			user_name.focus();
			return false;
		}
*/
        if((spacecontrol(password1.value,'Please enter a password.',1))!=0)
		{	//formcontrol++;
			return false;
		}

		if((spacecontrol(password1.value,'The password should contain more than  6 characters',5))!=0)
		{	//formcontrol++;
			return false;
		}

		if((spacecontrol(password2.value,'Please enter a confirm a password.',1))!=0)
		{	//formcontrol++;
			return false;
		}

		if(password1.value!=password2.value)
		{ 	alert('The password and the confirm password are not the same.');
			password2.value="";
			password1.value="";
			//formcontrol++;
			return false;
		}

		if((spacecontrol(email.value,'Please Enter your email.',1))!=0)
		{	//formcontrol++;
			return false;
		}

		if((email.value.indexOf("@") == -1)||(email.value.indexOf(".") == -1))
		{ 	alert('Your email invalide.');
			//formcontrol++;
				return false;
		}
		
		//if(formcontrol==0)
		//	submit();
	}
	
document.regform.submit();
	return (true);
}

function do_upload(val)
{	alert('tttt');
	
	/*document.up_form.up_load.value=val;
	document.up_form.submit();
	return (true);
	*/
}

function new_window(lesH,filnameH,nameH)
{ 
window.open(lesH+'?filename='+filnameH, '', 'toolbar=no,width=800,height=700,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes');
//window.open(lesH+'?filename='+filnameH+'&lg='+lgH+'&headref='+refH, '', 'toolbar=yes,width=800,height=700,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes');
}

function new_window2(lesH,filnameH,m_id)
{ 
window.open(lesH+'?m_id='+filnameH, '', 'toolbar=no,width=800,height=700,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes');
}

function new_window4(lesH,namevalH,nameH)
{ 
window.open(lesH+'&'+nameH+'='+namevalH, '', 'toolbar=no,width=800,height=700,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes');
}

function new_window3(lesH,namevalH,nameH)
{ 
window.open(lesH+nameH+'='+namevalH, '', 'toolbar=no,width=600,height=500,menubar=no,scrollbars=yes,resizable=yes,alwaysRaised=yes');
}

function open_window(lesH,namevalH,nameH,msgH)
{ if(msgH!="")
	{	if(confirm(msgH))
		window.open(lesH+nameH+'='+namevalH, '', 'toolbar=no,menubar=yes,scrollbars=yes,resizable=yes,alwaysRaised=yes');
	}
	else 
		window.open(lesH+nameH+'='+namevalH, '', 'toolbar=no,menubar=yes,scrollbars=yes,resizable=yes,alwaysRaised=yes');
//width=800,height=700,	
}

function window_open5(lesH,msgH)
{ if(msgH!="")
	{	if(confirm(msgH))
		window.open(lesH, '', 'toolbar=no,menubar=yes,scrollbars=yes,resizable=yes,alwaysRaised=yes');
	}
	else 
		window.open(lesH, '', 'toolbar=no,menubar=yes,scrollbars=yes,resizable=yes,alwaysRaised=yes');
//width=800,height=700,	
}

function edition(url)
    {//'toolbar=no,menubar=yes,scrollbars=yes,resizable=yes,alwaysRaised=yes'
    options = 'toolbar=no,menubar=yes,scrollbars=yes,resizable=yes,alwaysRaised=yes' ;
    window.open(url, "edition", options ) ;
    }

function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}