function checkForm(oForm, sLanguage) 
{
       var bError = false;
       var sOutput_NL = 'Gelieve volgende problemen op te lossen:\n';
       var sOutput_FR = 'Veuillez résoudre les problèmes suivants :\n';
       var aElem = oForm.elements;
    
           for(var i=0; i<aElem.length; i++) {
           var aNamePrefix = aElem[i].name.split('_');
           if(aElem[i].getAttribute('haserror') == '1')
           {
               sOutput_NL +=  '- ' + aElem[i].getAttribute('desc') + ' is niet geldig\n';
               sOutput_FR +=  '- ' + aElem[i].getAttribute('desc') + ' n\'est pas valide\n';
               bError = true;
           };
           if((aNamePrefix[0] == "textreq") && (aElem[i].value.length == 0)) {
               sOutput_NL +=  '- ' + aElem[i].getAttribute('desc') + ' is een verplicht veld\n';
               sOutput_FR +=  '- ' + aElem[i].getAttribute('desc') + ' est un champ obligatoire\n';
               bError = true;
           }
     if((aNamePrefix[0] == "textreqemail") && (aElem[i].value.length == 0)) {
               sOutput_NL +=  '- ' + aElem[i].getAttribute('desc') + ' is een verplicht veld\n';
               sOutput_FR +=  '- ' + aElem[i].getAttribute('desc') + ' est un champ obligatoire\n';
               bError = true;
           }
           if((aNamePrefix[0] == "textreqemail") && (!checkEmail(aElem[i].value))) {
               sOutput_NL +=  '- ' + aElem[i].getAttribute('desc') + ' is niet geldig\n';
               sOutput_NL +=  '- ' + aElem[i].getAttribute('desc') + ' n\'est pas valable\n';
               bError = true;
           }
           if((aNamePrefix[0] == "selectreq") && (aElem[i].value.length == 0)) {
               sOutput_NL +=  '- ' + aElem[i].getAttribute('desc') + ' is een verplichte keuze\n';
               sOutput_FR +=  '- ' + aElem[i].getAttribute('desc') + ' est obligatoire\n';
               bError = true;
           }
           if((aNamePrefix[0] == "intreq") && (aElem[i].value.length == 0 || !parseInt(aElem[i].value) || parseInt(aElem[i].value) != aElem[i].value)) {
               sOutput_NL +=  '- ' + aElem[i].getAttribute('desc') + ' is een verplicht veld en moet numeriek zijn\n';
               sOutput_FR +=  '- ' + aElem[i].getAttribute('desc') + 'doit être rempli avec un numéro\n';
               bError = true;
           }
           if((aNamePrefix[0] == "textreq500max") && (aElem[i].value.length == 0)) {
               sOutput_NL +=  '- ' + aElem[i].getAttribute('desc') + ' is een verplicht veld\n';
               sOutput_FR +=  '- ' + aElem[i].getAttribute('desc') + ' est un champ obligatoire\n';
               bError = true;
           }
           if((aNamePrefix[0] == "textreq500max") && (aElem[i].value.length > 500)) {
               sOutput_NL +=  '- ' + aElem[i].getAttribute('desc') + ' mag maximaal 500 karakters bevatten (je input: ' + aElem[i].value.length + ' karakters)\n';
               sOutput_FR +=  '- ' + aElem[i].getAttribute('desc') + ' ne peut pas dépasser 500 caractères (votre texte: ' + aElem[i].value.length + ' caractères)\n';
               bError = true;
           }
           if((aNamePrefix[0] == "textreq2000max") && (aElem[i].value.length == 0)) {
               sOutput_NL +=  '- ' + aElem[i].getAttribute('desc') + ' is een verplicht veld\n';
               sOutput_FR +=  '- ' + aElem[i].getAttribute('desc') + ' est un champ obligatoire\n';               bError = true;
           }
           if((aNamePrefix[0] == "textreq2000max") && (aElem[i].value.length > 2000)) {
               sOutput_NL +=  '- ' + aElem[i].getAttribute('desc') + ' mag maximaal 2000 karakters bevatten (je input: ' + aElem[i].value.length + ' karakters)\n';
               sOutput_FR +=  '- ' + aElem[i].getAttribute('desc') + ' ne peut pas dépasser 2000 caractères (votre texte: ' + aElem[i].value.length + ' caractères)\n';
               bError = true;
           }
           if((aNamePrefix[0] == "textreq6min") && (aElem[i].value.length == 0)) {
               sOutput_NL +=  '- ' + aElem[i].getAttribute('desc') + ' is een verplicht veld\n';
               sOutput_FR +=  '- ' + aElem[i].getAttribute('desc') + ' est un champ obligatoire\n';               bError = true;
           }
           if((aNamePrefix[0] == "textreq6min") && (aNamePrefix[2] != "oldpassword") && (aElem[i].value.length < 6)) {
               sOutput_NL +=  '- ' + aElem[i].getAttribute('desc') + ' moet ten minste 6 karakters bevatten (je input: ' + aElem[i].value.length + ' karakters)\n';
               sOutput_FR +=  '- ' + aElem[i].getAttribute('desc') + ' doit avoir 6 caractères au minimum (votre texte: ' + aElem[i].value.length + ' caractères)\n';
               bError = true;
           }
           if(aElem[i].name.value == "textreq_usr_password2") {
              if(oForm.textreq_usr_password.value != oForm.textreq_usr_password2.value) {
                sOutput_NL += 'Paswoorden zijn niet gelijk\n';
                sOutput_FR += 'Veuillez vous assurer que les deux mots de passe tapés sont identiques\n';
                bError = true;
        }
           }
       }
       if(bError){
          if(sLanguage == "NL")
              alert(sOutput_NL);
          else
              alert(sOutput_FR);
          return false;
       } else {
           return true;
       }
    
}
function checkEmail(sEmail) 
{
    if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(sEmail)){return true;}
    return false;
}
 
function stripHTML( strSrc ) {return strSrc.replace( /<[^<|>]+?>/gi,'' );}
 
function getObjectByID(sName) 
{
    var oObject;
    if (document.all){oObject = document.all.item(sName);}
    else if (document.getElementById) {oObject = document.getElementById(sName);}
    return oObject;
}
function getCookie(NameOfCookie)
{
    if (document.cookie.length > 0) 
    {  
        begin = document.cookie.indexOf(NameOfCookie+" = ");
        if (begin != -1) 
        {
            begin += NameOfCookie.length+1;    
            end = document.cookie.indexOf(";", begin); 
            if (end == -1) end = document.cookie.length;
            return unescape(document.cookie.substring(begin, end));
        } 
    }
    return null; 
}
function setCookie(NameOfCookie, value, expiredays) 
{
    var ExpireDate = new Date ();
    ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
    document.cookie = NameOfCookie + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString()); 
}
function viewDiv(idDiv) 
{
    if (document.getElementById(idDiv) != null)
    {
        var div = document.getElementById(idDiv);
        div.style.visibility = 'visible';
        div.style.display = 'block';  
    }    
}
function hiddenDiv(idDiv) 
{
    if (document.getElementById(idDiv) != null)
    {
        var div = document.getElementById(idDiv);
        div.style.visibility = 'hidden';
        div.style.display = 'none';
    }
}

function checkCommentForm(oForm) {
        oForm.comments.value = stripHTML(oForm.comments.value);
        oForm.comments.value = oForm.comments.value.replace(/\r\n/g,'<br/>');
        if(oForm.comments.value.length == 0) {
            alert('Gelieve een reactie in te vullen.');
            return false;
        }
        return true;
    };
function checkTextareaLength(obj,i) {
    if(obj.value.length > i) {
        obj.value = obj.value.substr(0,i);
        alert('U mag maximum ' + i.toString() + ' karakters ingeven.');
    }
}

 
function escamotableListener(div) {div.style.display = (div.style.display == 'none') ? 'block' : 'none';};
 
function callStoredProcedure( content_object_id, content_item_id, classified_id, comment_id, user_id, user_email, description  ) 
{ 
    jQuery.post('/asp/wrap_StoredProc.asp', {'spname':'Zappy_Reporting_Message','content_object_id':content_object_id, 'content_item_id':content_item_id,'classified_id':classified_id, 'comment_id':comment_id, 'user_id':user_id, 'user_email':user_email, 'description':description}, callStoredProcedure_Callback);
};
  
function callStoredProcedure_Callback(res) 
{
    //alert('The response: ' + res);
    if(res == 1)
    {
        if(currentForm != null)
        {
            currentForm.comment_ongepast.value = '';
            currentForm.email_ongepast.value = '';
        }
        if(currentDiv != null)
        {
            currentDiv.innerHTML = 'Message send.'
        }  
    } 
    else 
    {
        if(currentDiv != null){currentDiv.innerHTML = 'Sorry... Message not send...'} 
    }
  
    currentForm = null;
    currentDiv = null;
};
 



function open_new_window(page) {
    OpenWin = this.open(page, "Xquis", "toolbar=yes,menubar=yes,location=yes,scrollbars=yes,resizable=yes");
}



function ShowBIMPopup() 
{
    var Freq = 3;
    var ShowOrNot = Math.floor(Freq * Math.random()+1);
    if (ShowOrNot == 1)
    {
        visited=getCookie('BIMvisited');
        if (visited==null)
        {
            setCookie('BIMvisited','yes',45)
            document.write("<"+"script type=\"text/javascript\" src=\"http://bimonline.insites.be/nl/start.asp?SiteID=598&amp;TagID=1\"></scr"+"ipt>"); 
        } 
    } 
}
function popUpPage(URL, width, height, screenX, screenY) 
{
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "','toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=1,width=" + width + ",height=" + height + ",screenX="+ screenX + ",screenY=" + screenY + "');");
}

   var currentForm = null;
   var currentDiv = null;
   function onSendMailToFriend(oForm, oDiv) {
    currentForm = oForm;
    currentDiv = oDiv;
    oForm.message.value = stripHTML(oForm.message.value);
    if(oForm.sender_name.value.length == 0) {
  if(oForm.sender_name.value.length == 0)
      alert('Gelieve je naam in te vullen.');
     return false;
    } else {
     if((oForm.friend_name.value.length == 0) || (!checkEmail(oForm.friend_email.value))) {
      alert('Gelieve je e-mail en de naam van je vriend(in) in te vullen.');
      return false;
     } else {  
      //alert('oForm.url_content.value : '+oForm.url_content.value);
      //alert('oForm.title_content.value : '+oForm.title_content.value);
  
      callMailFriend(oForm.sender_name.value, oForm.friend_email.value, oForm.friend_name.value, oForm.message.value, oForm.url_content.value, oForm.title_content.value); 
     }
    }
   };
   
   function callMailFriend(sender_name, friend_email, friend_name, message, url_content, title_content ) { 
    jQuery.post('/asp/Wrap_Mail.asp', {template:'nl_mail_to_friend.html', subject:'Een vriend stuurt u deze link door', sender_name:currentForm.sender_name.value, to:currentForm.friend_email.value, friend_name:currentForm.friend_name.value, message:currentForm.message.value, url_content:currentForm.url_content.value, title_content:currentForm.title_content.value}, callMailFriend_Callback);
   };
   function callMailFriend_Callback(res) {
    //alert('The response: ' + res);
    if(res == 1){
     if(currentForm != null){
       //alert('sender_name:'+currentForm.sender_email.value);
jQuery.post('/asp/Wrap_Mail.asp', {template:'nl_confirm_sending_mail_to_friend.html', subject:'Mail Doorgestuurd', sender_name:currentForm.sender_name.value, to:currentForm.sender_email.value, friend_email:currentForm.friend_email.value, friend_name:currentForm.friend_name.value, title_content:currentForm.title_content.value }, callMailFriend_CallbackSecond);
      
      currentForm.friend_name.value = '';
      currentForm.friend_email.value = '';
      currentForm.message.value = '';
     }
     if(currentDiv != null){
      currentDiv.innerHTML = 'Message send.'
     }  
    } else {
      
      currentForm.friend_name.value = '';
      currentForm.friend_email.value = '';
      currentForm.message.value = '';
     
      if(currentDiv != null){
        currentDiv.innerHTML = 'Sorry... Message not send...'
      } 
    } 
    currentForm = null;
    currentDiv = null;
    escamotableListener(document.getElementById('post_mail_to_friend'));
   };
   function callMailFriend_CallbackSecond(res) {};

   var currentForm = null;
   var currentDiv = null;
   function onSendMailToFriendFR(oForm, oDiv) {
    currentForm = oForm;
    currentDiv = oDiv;
    oForm.message.value = stripHTML(oForm.message.value);
    if(oForm.sender_name.value.length == 0) {
     alert('Veuillez remplir votre nom.');
     return false;
    } else {
     if((oForm.friend_name.value.length == 0) || (!checkEmail(oForm.friend_email.value))) {
      alert('Veuillez indiquer l\'e-mail et le nom de votre ami(e).');
      return false;
     } else {  
      //alert('oForm.url_content.value : '+oForm.url_content.value);
      //alert('oForm.title_content.value : '+oForm.title_content.value);
           callMailFriendFR(oForm.sender_name.value, oForm.friend_email.value, oForm.friend_name.value, oForm.message.value, oForm.url_content.value, oForm.title_content.value);
     }
    }
   };

   function callMailFriendFR(sender_name, friend_email, friend_name, message, url_content, title_content ) { 
    jQuery.post('/asp/Wrap_Mail.asp', {template:'fr_mail_to_friend.html', subject:'Un ami vous envoi ce lien', sender_name:sender_name, to:friend_email, friend_name:friend_name, message:message, url_content:url_content, title_content:title_content}, callMailFriend_CallbackFR);
   };

   function callMailFriend_CallbackFR(res) {
    //alert('The response: ' + res);
    if(res == 1){
     if(currentForm != null){
       //alert('sender_name:'+currentForm.sender_email.value);
jQuery.post('/asp/Wrap_Mail.asp', {template:'fr_confirm_sending_mail_to_friend.html', subject:'Mail transmis', sender_name:currentForm.sender_name.value, to:currentForm.sender_email.value, friend_email:currentForm.friend_email.value, friend_name:currentForm.friend_name.value, title_content:currentForm.title_content.value }, callMailFriend_CallbackSecond);
      
      currentForm.friend_name.value = '';
      currentForm.friend_email.value = '';
      currentForm.message.value = '';
     }
     if(currentDiv != null){
      currentDiv.innerHTML = 'Message envoyé.'
     }  
    } else {
      
      currentForm.friend_name.value = '';
      currentForm.friend_email.value = '';
      currentForm.message.value = '';
     
      if(currentDiv != null){
        currentDiv.innerHTML = 'Désolé... Le message n\'a pas pu être envoyé...'
      } 
    } 
    currentForm = null;
    currentDiv = null;
    escamotableListener(document.getElementById('post_mail_to_friend'));
   };

function viewLexicon(sFileId, sLanguage){

  var sTitle_NL = 'Lexicon';
  var sTitle_FR = 'Lexique';

  var sTitle;
  if(sLanguage == "NL")
    sTitle = sTitle_NL;
  else
    sTitle = sTitle_FR;

  
  var sUrl = 'http://www.xquis.com/xquis/popup_lexicon.html?lang_code=' + sLanguage + '&file_id=' + sFileId;
  Modalbox.show(sUrl , {title: sTitle });

};


function checkFavoritesForm(oForm){
 var length = 1;
 if(oForm.chkElt.length > 1) length = oForm.chkElt.length;
 //alert(length);
 var sListchk='';
 var oCheck;
 for (i=0; i<length; i++) {
  if(length == 1) oCheck = oForm.chkElt;
  if(length > 1) oCheck = oForm.chkElt[i];
        if (oCheck.checked){
          // cochée
          if ((sListchk.length) != 0){
           sListchk += ','; 
          }
          sListchk +=  oCheck.getAttribute('value') 
        }
 }
 //alert('sListchk : '+sListchk);
 oForm.listElt.value = sListchk;
};