// JavaScript Document
// validates that the field value string has one or more characters in it
function isEmpty(elem) {
    var str = elem.value;
    var re = /.+/;
    if(!str.match(re)) {
        //alert("Please fill in the required field.");
        return false;
    } else {
        return true;
    }
}

// function for redirect the page to submit the research form by specifying the url
function goToURL(form, url){
	if (isEmpty(form.keyword)){
		//alert(form.motrecherche.value);
		window.location = url;
	}
}

// function check the telephone number
function checkPhone(strng){
	var stripped = strng.replace(/[\(\)\.\-\ ]/g, '');
	var error = "";
	//strip out acceptable non-numeric characters
	if ((strng != "") && isNaN(parseInt(stripped))) {
	   //error = "The phone number contains illegal characters.";
	   error = "Le numéro de téléphone contient les caractères illégaux.\n";
	}
	return error;
}

// function check the name (first, last), id and password of user
function checkNIP(strng, strnom){
	var error = "";
	var illegalChars = /\W/;
	
	if (strng == "")
		error = "Vous n'avez pas saisi votre "+strnom+".\n";
	else
	if ((strng.length < 6)) {
    	//error = "The username is the wrong length.\n";
		if ((strnom == "mot de passe") || (strnom == "login ID"))
			error += "Le "+strnom+" est trop court (>6).\n";
	}
    // allow only letters, numbers, and underscores
	if (strnom == "mot de passe"){
    	illegalChars = /[\W_]/; // allow only letters and numbers
    	if (illegalChars.test(strng)) {
       		//error = "The username contains illegal characters.\n";
	   		error = "Le "+strnom+" contient les caractères illégaux.\n";
		}
    }
	return error;
}

//function check the identity of password
function checkIPass(pass1, pass2)
{
	var error = "";
	if ((pass1 != "") && (pass2 == ""))
		error = "Le mot de passe n'est pas confirmé.\n";
	else
	if (pass1 != pass2)
		error = "Le mot de passe confirmé n'est pas identitique.\n";
	return error;
}
//function check mail
function checkMail(strng){
	var error = "";
	var emailFilter= /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/;/// ^.+@.+\..{2,3,4,6}$/;
	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/;
	if (strng != ""){
		if (!(emailFilter.test(strng))) { 
		   //error = "Please enter a valid email address.\n";
		   error = "Entrez un adresse de courrier valide.\n";
		}
	
		if (strng.match(illegalChars)) {
			error += "L'adresse de courrier contient les caractères illégaux.\n";
		}
	}
	return error;
}

//function check the whole form of register
function checkRegForm(form)
{
	var error = "";
	error += checkNIP(form.lginid.value, "connexion ID");
	error += checkNIP(form.pwd.value, "mot de passe");
	error += checkIPass(form.pwd.value, form.mdpcon.value);
	error += checkNIP(form.fname.value, "nom");
	error += checkNIP(form.lname.value, "prénom");
	error += (form.mail.value == "")? "Vous n'avez pas saisi votre adresse courrier.\n" : checkMail(form.mail.value);
	error += (form.phone.value == "")? "Vous n'avez pas saisi votre numéro de téléphone." : checkPhone(form.phone.value);
	
	if (error != "")
	{
		alert(error);
		return false;
	}
	return true;
}
//function check the whole form of account demand
function checkAccountForm(form){
	var error = "";
	error += checkNIP(form.fname.value, "nom");
	error += checkNIP(form.lname.value, "prénom");
	error += (form.job.value == "")? "Vous n'avez pas saisi votre occupation.\n" : "";
	error += (form.adr.value == "")? "Vous n'avez pas saisi votre adresse.\n" : "";
	error += (form.mail.value == "")? "Vous n'avez pas saisi votre adresse courrier.\n" : checkMail(form.mail.value);
	error += (form.phone.value == "")? "Vous n'avez pas saisi votre numéro de téléphone.\n" : checkPhone(form.phone.value);
	error += (form.reason.value == "")? "Vous n'avez pas saisi votre raison d'avoir un compte." : "";
	
	if (error != "")
	{
		alert(error);
		return false;
	}else if (!form.agree.checked){
		alert("Il faut que vous accordiez aux termes d'utilisation.");
		return false;
	}
	return true;
}

<!-- Script courtesy of http://www.web-source.net - Your Guide to Professional Web Site Design and Development
var message="Copyright Year by Your Site. WARNING ! All content contained within this site is protected by copyright laws. Unauthorized use of our material is strictly prohibited.";
function click(e) {
	if (document.all) {
		if (event.button==2||event.button==3) {
			alert(message);
			return false;
		}
	}
	if (document.layers) {
		if (e.which == 3) {
			alert(message);
			return false;
		}
	}
}
/*if (document.layers) {
	document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
*/

//function for redirecting to other web page
function redirect(url){
	window.location.href = url;
}
//function for changeing the class name of tag tr of list of found sites
function changeClass(){
	var obj = document.getElementById('tagtr');
	var obj_ = document.getElementById('btnchg');
	obj.className = (obj.className == 'restable')? 'restable_ext' : 'restable';
	obj_ .value = (obj_ .value == "Afficher comme précédent" )? "Afficher en une seule ligne" : "Afficher comme précédent";
}

//funciton that verify the forme of a word to match a model
//word, word
function validatewordform(form)
{
	var word = form.motrechercheenmode.value;
	var arrayword = Array();
	if (word == ""){
		return false;
	}
	arrayword = word.split(",");
	if (arrayword.length != 2){
		alert("Le mot donné n'est pas en forme correcte!\nModèle: [ Nom du site + , + Location ]");
		return false;
	}
	return true;
}
function validpasschange(form){
	pwdcurrent = form.passcourant;
	pwdnew = form.nouveaupass;
	pwdconfirm = form.confirmation;
	
	if (!isEmpty(pwdcurrent) || !isEmpty(pwdnew) || !isEmpty(pwdconfirm))
		return false;
	if (pwdnew.value.length < 6){
		alert("Votre nouveau mot de passe est trop court (>6) !");
		return false;
	}
	if (pwdnew.value != pwdconfirm.value){
		alert("Votre nouveau mot de passe non vérifié !");
		return false;
	}

	return true;
}

function validchamp(champ, nom){
	if ((champ != "") && isNaN(champ.value)){
		alert("Le "+nom+" doit être le numéro valide !");
		return false;
	}
	return true;
}
/*function validatemodform(form, lang)
{
	if (validchamp(form.noik, "N° Ik"))
		if (validchamp(form.nomh, "N° MH 1"))
			if (validchamp(form.nolm, "N° LM")){
				if (lang == "fr")
					if (validchamp(form.utme, "UTM EASTING"))
						if (validchamp(form.utmn, "UTM NORTHING"))
							if (validchamp(form.long, "Longitude"))
								if (validchamp(form.lat, "Latitude"))
									return true;
				return true;
			}
	return false;
}*/

//function to submit a form of modification of site
//applied to a link text so that to foward other
//form of modification(next)
function submitFormBylnk(formid, action){
	var form = document.getElementById(formid);
	form.action = action;
	if (validatemodform(form)) form.submit();
}

//function test for number that may contain all digit, . and ,
function IsNumeric(sText)

{
   var ValidChars = "0123456789., ;";
   var IsNumber=true;
   var Char;
   
   for (i = 0; i < sText.length && IsNumber == true; i++) 
   { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
      {
         IsNumber = false;
      }
   }
   return IsNumber; 
}
function IsPureNumeric(sText){
   var ValidChars = "0123456789.,";
   var IsNumber=true;
   var Char;
   
   for (i = 0; i < sText.length && IsNumber == true; i++) 
   { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
      {
         IsNumber = false;
      }
   }
   return IsNumber; 
}

//function to check the contact form
function chkcontactform(form){
	for (i=0; i<form.length; i++)
		if (!isEmpty(form.elements[i]))
			{ alert("Bien remplissez le formulaire, SVP"); return false; }
	if (isEmpty(form.mail))
		if (checkMail(form.mail.value) != ""){
			alert(checkMail(form.mail.value));
			return false;
		}

	return true;
}

//function to confirm for some action
function usr_confirm(txt_confirm){
	return window.confirm(txt_confirm);
}