function eCheckSpecialChar(sn){
    var tofind='àâôèéêëçîïùûü';
    var n = tofind.length;
    for(var i=0;i<n;i++){ 
        var ch=tofind.charAt(i);
        var ind=sn.value.indexOf(ch);
        if(ind!=-1) return false;
    }
    return true;
}
//_____________________________________________________________________________
function CheckSpecialChar(theForm){
   for(var i=1; i<CheckSpecialChar.arguments.length; i++){
        elem="td_"+theForm.elements[arguments[i]].name;
        td=ToObj(elem);
        if (!eCheckSpecialChar(theForm.elements[CheckSpecialChar.arguments[i]])){
            td.color='red';
            alert("Field entry is not valid (Specials caraters)");
            theForm.elements[CheckSpecialChar.arguments[i]].focus();
            return false;
        }
        else td.color='#708FB6';
   }
   return true;
}
//_____________________________________________________________________________
function eCheckDate(sn) {
    y1=1900;
    y2=2100;
    m=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
    vdate= sn.value;
    yyyy=vdate.substring(0,4);
    mm=vdate.substring(5,7);
    dd=vdate.substring(8,10);
    sep1=vdate.substring(4,5);
    sep2=vdate.substring(7,8);
    if(yyyy%4==0) m[1]++;
    if((sep1==sep2) && (sep1=='-' || sep1=='/'))
        if(yyyy>y1 && yyyy<y2)
            if(mm>0 && mm<13)
                if(dd>0 && dd<=m[mm-1])
                    return true;
    return false;
}
//_____________________________________________________________________________
function CheckDate(theForm){
   for(var i=1; i<CheckDate.arguments.length; i++){
        elem="td_"+theForm.elements[arguments[i]].name;
        td=ToObj(elem);
        if (!eCheckDate(theForm.elements[CheckDate.arguments[i]])){
            td.color='red';
            alert("Field entry is not valid (Date)");
            theForm.elements[CheckDate.arguments[i]].focus();
            return false;
        }
        else td.color='#708FB6';
   }
   return true;
}
//_____________________________________________________________________________
function eCheckEMail(sn){
    pattern = /(.*){1,}@(.*){2,}\.(.*){2,}/;
    return (pattern.test(sn.value));
}
//_____________________________________________________________________________
function CheckEMail(theForm){
   for(var i=1; i<CheckEMail.arguments.length; i++){
        elem="td_"+theForm.elements[arguments[i]].name;
        td=ToObj(elem);
        if (!eCheckEMail(theForm.elements[CheckEMail.arguments[i]])){
            td.color='red';
            alert("Field entry is not valid (Mail)");
            theForm.elements[CheckEMail.arguments[i]].focus();
            return false;
        }
        else td.color='#708FB6';
   }
   return true;
}
//_____________________________________________________________________________
function eCheckAlphaNum(sn){
    pattern = /^[A-Za-z0-9_&nbsp;]/;
    return pattern.test(sn.value);
}
//_____________________________________________________________________________
function CheckAlphaNum(theForm){
   for(var i=1; i<CheckAlphaNum.arguments.length; i++){
        elem="td_"+theForm.elements[arguments[i]].name;
        td=ToObj(elem);
        if (!eCheckAlphaNum(theForm.elements[CheckAlphaNum.arguments[i]])){
            td.color='red';
            alert("Field entry is not valid (AN)");
            theForm.elements[CheckAlphaNum.arguments[i]].focus();
            return false;
        }
        else td.color='#708FB6';
   }
   return true;
}
//_____________________________________________________________________________
function eCheckAlpha(sn){
    pattern = /^[A-Za-z_]/;
    return pattern.test(sn.value);
}
//_____________________________________________________________________________
function CheckAlpha(theForm){
   for(var i=1; i<CheckAlpha.arguments.length; i++){
        elem="td_"+theForm.elements[arguments[i]].name;
        td=ToObj(elem);
        if (!eCheckAlpha(theForm.elements[CheckAlpha.arguments[i]])){
            td.color='red';
            alert("Field entry is not valid (A)");
            theForm.elements[CheckAlpha.arguments[i]].focus();
            return false;
        }
        else td.color='#708FB6';
   }
   return true;
}
//_____________________________________________________________________________
function eCheckNum(sn){
    pattern = /^[0-9]*$/;
    return pattern.test(sn.value);
}
//_____________________________________________________________________________
function _eCheckNum(sn){
    s= sn.value;
    for (var i = 0; i < s.length; i++) {
        ch = s.substring(i, i + 1)
        if (!(ch >= "0" && ch <= "9"))
             return false;
        }
   return true;
}
//_____________________________________________________________________________
function CheckNum(theForm){
   for(var i=1; i<CheckNum.arguments.length; i++){
        elem="td_"+theForm.elements[arguments[i]].name;
        td=ToObj(elem);
        if (!eCheckNum(theForm.elements[CheckNum.arguments[i]])){
            td.color='red';
            alert("Invalid number");
            theForm.elements[CheckNum.arguments[i]].focus();
            return false;
        }
        else td.color='#708FB6';
   }
   return true;
}
//_____________________________________________________________________________
function CheckRequiredFields(theForm){
   for(var i=1; i<arguments.length; i++){
        elem="td_"+theForm.elements[arguments[i]].name;
        td=ToObj(elem);
        if(theForm.elements[arguments[i]].value=="" || theForm.elements[arguments[i]].value=="1"){
            td.color='red';
            alert("This field is required");
            theForm.elements[arguments[i]].focus();
            theForm.elements[arguments[i]].select();
            return false;
        }
        else td.color='#708FB6';
   }
   return true;
}
//_____________________________________________________________________________
function CheckPasswords(theForm){
    if(theForm.elements[arguments[1]].value!=
            theForm.elements[arguments[2]].value){
        alert("Passwords don't matchs");
        theForm.elements[arguments[1]].value="";
        theForm.elements[arguments[2]].value="";
        theForm.elements[arguments[1]].focus();
        return false;
    }
    return true;
}
//_____________________________________________________________________________
function CheckChecked(theForm){
   for(var i=1; i<arguments.length; i++){
        if(!theForm.elements[arguments[i]]) continue;
        if(theForm.elements[arguments[i]].type != "checkbox") continue;
        elem="td_"+theForm.elements[arguments[i]].name;
        td=ToObj(elem);
        if(theForm.elements[arguments[i]].checked==false){
            td.color='red';
            alert("The Checkbox "+theForm.elements[arguments[i]].name+" must be checked.");
            return false;
        }
   }
   return true;
}
//_____________________________________________________________________________
function CheckForm_userstmp(theForm){
     if(CheckChecked(theForm, "policy"))
     if(CheckSpecialChar(theForm, "Login"))
     if(CheckRequiredFields(theForm, "First_Name","Last_Name","Country","City","SP","ZPC","Email","Niveau","Login","Experience"))
     if(CheckEMail(theForm, "Email"))
     if(CheckAlphaNum(theForm, "Login"))
     return true;
     return false;
}
//_____________________________________________________________________________
function CheckForm_acr(theForm){
     if(CheckRequiredFields(theForm, "type","title","keywords","users","lang"))
     return true;
     return false;
}
//_____________________________________________________________________________
function ClearForm(){
    for (var i = 0; i < document.menu.elements.length; i++) {
        if (document.menu.elements[i].type == "text" || document.menu.elements[i].type == "hidden"  || document.menu.elements[i].type == "textarea" || document.menu.elements[i].type == "password") {
            document.menu.elements[i].value = "";
        }
    }
}
//_____________________________________________________________________________
function CheckForm_(theForm){
     return true;
}
//_____________________________________________________________________________
function jQSch(){
    alert(document.frmqsch.quicksearch.value);
    jSubmit();
}
//_____________________________________________________________________________
function jSubmit(){
    document.menu.submit();
}
//_____________________________________________________________________________
function jFrmSubmit(frm){
     var forme="CheckForm_"+frm+"(document.forms[\"menu\"])";
     if(eval(forme)==true) document.menu.submit();
}
//_____________________________________________________________________________
function jSetId(_id){
 //   document.menu._id.value=_id;
}
//_____________________________________________________________________________
function jSetAcrId(_id){
//    document.menu.acr_id.value=_id;
}
//_____________________________________________________________________________
function jSetMode(_mode){
    document.menu.mode.value=_mode;
}
//_____________________________________________________________________________
function jSetPage(_page){
    document.menu.page.value=_page;
}
//_____________________________________________________________________________
function jSetQsch(_sch){
    document.menu.quicksearch.value=_sch;
}
//_____________________________________________________________________________
function jGotoURL(_url){
    window.location=_url;
}
//_____________________________________________________________________________
function jGoto(page){
    ClearForm();
    jSetPage(page);
    jSubmit();
}
//_____________________________________________________________________________
function jGotoID(page,id){
    ClearForm();
    jSetPage(page);
    jSetId(id);
    jSubmit();
}
//_____________________________________________________________________________
function jGotoID1(page,id){
    jSetPage(page);
    jSetId(id);
    jSubmit();
}
//_____________________________________________________________________________
function jGotoAcrID(page,id){
    ClearForm();
    jSetPage(page);
    jSetAcrId(id);
    jSubmit();
}
//_____________________________________________________________________________
function jGotoDomain(page,domain){
    jSetMode("");
    jSetId(domain);
    jSetPage(page);
    jSubmit();
}
//_____________________________________________________________________________
function jUpdate(_id){
    jSetMode("");
    jSetId(_id);
    jSubmit();
}
//_____________________________________________________________________________
function jDelete(_id){
    if (!confirm("Are you sure you want to delete this item?.")) return false;
    jSetMode("x");
    jSetId(_id);
    jSubmit();
}
//_____________________________________________________________________________
function jDeleteDoc(_id){
    if (!confirm("Are you sure you want to delete this item?.")) return false;
    window.location="acr.php?_id="+_id+"&mode=x";
}
//_____________________________________________________________________________
function jAddSel(){
    for(var i=0;i<document.menu.userslist1.length;i++){
        if(!document.menu.userslist1.options[i].selected) continue;
        var opt=document.menu.userslist1.options[i].value;
        var val=document.menu.userslist1.options[i].text;
        var len=document.menu.elements['userslist2[]'].options.length;
        for(var j=0;j<document.menu.elements['userslist2[]'].length;j++){
            var opt2=document.menu.elements['userslist2[]'].options[j].value;
            if(opt==opt2) return false;
        }
        document.menu.elements['userslist2[]'].options[len]=new Option(val,opt);
        document.menu.userslist1.options[i]=null;
        i--;
    }
}
//_____________________________________________________________________________
function jDelSel(list){
    for(var i=0;i<document.menu.elements[list].length;i++){
        if(!document.menu.elements[list].options[i].selected) continue;
        document.menu.elements[list].options[i]=null;
        i--;
    }
}
//_____________________________________________________________________________
function jSelAll(list,etat){
    for(var i=0;i<document.menu.elements[list].length;i++){
        document.menu.elements[list].options[i].selected=etat;
    }
}
//_____________________________________________________________________________
function jPreview(code){
    msg=window.open("");
    msg.document.write(code)
}
//_____________________________________________________________________________
function ejs_box2_go(){
    if(document.getElementById){
      ejs_box2_char = 1;
      ejs_box2_affich(ejs_box2_actual)
      ejs_box2_actual++;
      if(ejs_box2_actual >= ejs_box2_message.length) ejs_box2_actual = 0;
    }
}
//_____________________________________________________________________________
function ejs_box2_affich(lactual){
    var pix = ejs_box2_message[lactual].charAt(ejs_box2_char);
    if(pix == "<")
        ejs_box2_html_flag = 1;
    if(pix == ">")
        ejs_box2_html_flag = 0;
    var texte = ejs_box2_message[lactual].substring(0,ejs_box2_char);
    document.getElementById("ejs_box2_box").innerHTML = texte;
    if(ejs_box2_char < ejs_box2_message[lactual].length){
        ejs_box2_char++;
        if(ejs_box2_html_flag == 1)    
            ejs_box2_affich(lactual);
        else
            setTimeout("ejs_box2_affich("+lactual+")",50)
    }
    else setTimeout("ejs_box2_go()",3000)
}
//_____________________________________________________________________________
function jOpen(url, w, h) {
    var winl = (screen.width - w) / 2;
    var wint = (screen.height - h) / 2;
    popup = window.open(url, "PopupWnd", "height==" + h + ", width==" + w + ",left=" + winl + ", top=" + wint + ", " +    "location=no, menubar=no, resizable=no," + "scrollbars=no, titlebar=no, toolbar=no", true);
    if (parseInt(navigator.appVersion) >= 4) popup.window.focus();
    popup.resizeTo(w,h);
}
//_____________________________________________________________________________
function jOpen1(url, w, h) {
    var winl = (screen.width - w) / 2;
    var wint = (screen.height - h) / 2;
    popup = window.open(url, "PopupWnd", "height==" + h + ", width==" + w + ",left=" + winl + ", top=" + wint + ", " +    "location=no, menubar=no, resizable=no," + "scrollbars=yes, titlebar=no, toolbar=no", true);
    if (parseInt(navigator.appVersion) >= 4) popup.window.focus();
    popup.resizeTo(w,h);
}
//_____________________________________________________________________________
function ToObj(elem){
    if (nava) obj = eval("document."+elem)
        else if (dom)  obj = eval("document.getElementById('"+elem+"').style")
            else if (iex)  obj = eval(elem+".style");
    return obj;
}
//_____________________________________________________________________________
function jConfirmSendingMail(){
    if (!confirm("Are you sure you want to send this mail?.")) return false;
    menu.dometat.value='s';
    jSelAll('bcc[]',1);
    jSubmit();
}
//_____________________________________________________________________________
function jConfirmSendingMail1(){
    if (!confirm("Are you sure you want to send this message?.")) return false;
    document.menu.etat.value=1;
    document.menu.submit();
}
//_____________________________________________________________________________
function fullScreen(theURL) {
    if(iex) window.open(theURL, '', 'fullscreen=yes, scrollbars=auto');
    else window.open(theURL, '', 'scrollbars=yes,resizable=yes');
}
//_____________________________________________________________________________
function calIt(field){
    arg=field;
    var sel=showModalDialog("cal.html","Calendrier","dialogWidth:"+200+"px;dialogHeight:"+265+"px;resizable:no;help:no;status:Off;scroll:no;center:yes;");  
    if (window.navigator.appVersion.indexOf("MSIE")!=-1){
        if(sel != null) field.value=sel;
    }
}
//_____________________________________________________________________________
function treeIt(field){
    arg=field;
    var sel=showModalDialog("tree.php","Browse","dialogWidth:"+295+"px;dialogHeight:"+400+"px;resizable:no;help:no;status:Off;scroll:yes;center:yes;"); 
    if (window.navigator.appVersion.indexOf("MSIE")!=-1){
        if(sel != null) field.value+=sel+"\n";
    }
}
//_____________________________________________________________________________
