/////////////////////////////
// Check for valid email  //
///////////////////////////
function emailCheck (emailStr) {
var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|bz|aero|name|coop|info|pro|museum)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);
if (matchArray==null) {
alert("Le courriel que vous avez fourni n'est pas valide. Veuillez vérifier le @ et le .");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("Le nom d’utilisateur contient des caractères non valides.");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("Le nom de domaine contient des caractères non valides.");
return false;
   }
}

if (user.match(userPat)==null) {
alert("Le nom d’utilisateur n’est pas valide.");
return false;
}

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {

for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("L’adresse IP de la destination n’est pas valide.");
return false;
   }
}
return true;
}

var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("Le nom de domaine n’est pas valide.");
return false;
   }
}
if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("Le courriel doit terminer avec une extension connue ou un code de pays connu.");
return false;
}
if (len<2) {
alert("Le courriel ne contient pas de hôte.");
return false;
}
return true;
}

////////////////////////////////////
// Copyright Year Auto Increment //
//////////////////////////////////
today=new Date();
year=today.getFullYear();
copyrightmessage="Copyright © "+year+" iMISonline™ Corporation. Tous droits réservés.";

////////////////////////////////////
// Popup Window Resizable        //
//////////////////////////////////
function adview (mylink,windowname) {
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 800, yMax=600;

    var xOffset = (xMax - 200)/2, yOffset = (yMax - 200)/2;
    if (! window.focus)return true;
    var href;
    if (typeof(mylink) == 'string')
       href=mylink;
    else
       href=mylink.href;
    window.open(href,'adview','width=640,height=600,scrollbars=yes');
return false;
}

////////////////////////////////////
// Popup Window Resizable        //
//////////////////////////////////
function adview1 (mylink,windowname) {
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 800, yMax=600;

    var xOffset = (xMax - 200)/2, yOffset = (yMax - 200)/2;
    if (! window.focus)return true;
    var href;
    if (typeof(mylink) == 'string')
       href=mylink;
    else
       href=mylink.href;
    window.open(href,'adview1','width=690,height=600,scrollbars=yes');
return false;
}