/***********************************************************************************
Footer Date
***************************/
function customDateString() {
	currentDate = new Date()
	msie4 = ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 ));
	if (msie4) {
	    var theYear = currentDate.getYear()
	}
	else {
	     var theYear = currentDate.getYear() +1900
	}
	return theYear
}

/***********************************************************************************
Sneaky Email Script
***************************/
function codify (thisguy) {
	str = "";
	for (i=0; i<thisguy.length; i++) {
		str += "&#" + thisguy.charCodeAt(i) + ";";
	}	
	return str;
}
function buildaddress (one, two, three) {
	str = "";
	str += codify(three);
	str += "&#" + "064" + ";";
	str += codify(two);
	str += "&#" + "046" + ";";
	str += codify(one);
	return str;
}
// Our most popular function -- creates mailto link with email address as link text
function sneaky (one, two, three, four) {
	str = buildaddress(one, two, three);
	if (four != "") four = "class=" + four + " ";
	document.write("<a " + four + "hre" + "f=mai" + "lto:" + str +">" + str + "</" + "a>");
}
// Creates mailto link with fourth parameter as the link text
function sneaky2 (one, two, three, four, five) {
	str = buildaddress(one, two, three);
	if (four != "") five = "class=" + four + " ";
	document.write("<a " + five + "hre" + "f=mai" + "lto:" + str +">" + four + "</" + "a>");
}
// Simply prints the email address (great for forms!)
function sneaky3 (one, two, three) {
	document.write(buildaddress(one, two, three));
}

/***********************************************************************************
Form Validaator
***************************/
function isMailAddress(m) {
   if ((m == '') || (m == ' ')) { return false; }

    var a = 1;
    var ml = m.length;

    while ((ml>a) && (m.charAt(a) != "@")) { a++ }
    if ((a >= ml) || (m.charAt(a) != "@")) {
	return false;
    } else {
	a = a + 2;
    }
    while ((ml > a) && (m.charAt(a) != ".")) { a++ }
    if ((a >= ml - 1) || (m.charAt(a) != ".")) {
	return false;
    } else {
    return true;
    }
}
// For English Contact Form
function validate(obj) {
	var valid = true;
	var msg = "";
	if (obj.elements["name"].value == "") {
		msg += "Please enter your name.\n";
		valid = false;
		obj.elements["name"].focus();
	}
		// Check for white space
		reWhiteSpace = new RegExp(/^\s+$/);
		if (reWhiteSpace.test(obj.elements["name"].value)) {
			msg += "Please enter your name.\n";
			valid = false;
			obj.elements["name"].focus();
		}
	if (!isMailAddress(obj.elements["email"].value)) {
		msg += "Please enter a valid email address.\n";
		if (valid) {
			valid = false;
		    obj.elements["email"].focus();
		}
	}
	if (!valid) alert(msg);
	return valid;
}
// For French Contact Form
function validateFR(obj) {
	var valid = true;
	var msg = "";
	if (obj.elements["name"].value == "") {
		msg += "S'il vous plait entrer votre nom.\n";
		valid = false;
		obj.elements["name"].focus();
	}
		// Check for white space
		reWhiteSpace = new RegExp(/^\s+$/);
		if (reWhiteSpace.test(obj.elements["name"].value)) {
			msg += "S'il vous plait entrer votre nom.\n";
			valid = false;
			obj.elements["name"].focus();
		}
	if (!isMailAddress(obj.elements["email"].value)) {
		msg += "S'il vous plait entrer une adresse courriel valide.\n";
		if (valid) {
			valid = false;
		    obj.elements["email"].focus();
		}
	}
	if (!valid) alert(msg);
	return valid;
}
