function getDateNow() {
  var date =new Date();
  var d=date.getDate();

  if (parseInt(d)<10) {
    d="0"+d;
  }

  var m=date.getMonth()+1;
  if (parseInt(m)<10) {
    m="0"+m;
  }
  var y=date.getYear();
  return msg=d+"-"+m+"-"+y;
}

function trim(str) {
  return str.replace(/^\s*/, '').replace(/\s*$/, '');
}

function getArrElementPosition(arrayToSearch, value){
  for(var x=0;x<arrayToSearch.length;x++){
    if(arrayToSearch[x] == value)
      return x;
  }
  return -1;
}

function checkDateRange(from, to){
//alert("from '"  + from + "' to '" + to + "'");
  if (to=='' || from=='') return true; //nothing to check

  var re = /^([0-3][0-9])[\-\/]([0-1][0-9])[\-\/](\d{4})$/g;

  var re1 = new RegExp();
  re1.compile("([0-9]{2})[\-\/]([0-9]{2})[\-\/]([0-9]{4})","g");

  var matchArray = re.exec(from);
  if (matchArray ) {
    var dayFrom   = matchArray [1];
    var monthFrom = matchArray [2];
    var yearFrom  = matchArray [3];
  } else return false;
  var matchArrayTo = re1.exec(to);
  if (matchArrayTo) {
    var dayTo   = matchArrayTo [1];
    var monthTo = matchArrayTo [2];
    var yearTo  = matchArrayTo [3];
  } else return false;
  if (yearTo < yearFrom ) return false;
  else if  (yearTo > yearFrom ) return true;
    else if  (monthTo < monthFrom) return false;
      else if  (monthTo > monthFrom) return true;
        else if ( dayTo < dayFrom) return false;
          else return true;
}


function createRaquoButton(inputName, formName) {
  var buttonText = '<button class="button" style="width:20px;" onclick="insertRaquoCharacter(\''+inputName+'\',\''+formName+'\', this.innerHTML)">&raquo;</button>';
  //var buttonText = '&nbsp;<button style="width:20px; color:#000000; background-color:#f4e500; font-size:11px; text-align:center; font-weight:bold; border:1px solid #000000; border-top-color:#acaaaa; border-right-color:#000000; border-bottom-color:#000000; border-left-color:#acaaaa;" onclick="insertRaquoCharacter(\''+inputName+'\',\''+formName+'\', this.innerHTML)">&raquo;</button>';
  document.write(buttonText);
}

function insertRaquoCharacter(inputName, formName, raquo) {
  FormManager.getInput(inputName, formName).value += raquo;
}

function askDelete(){
  return (confirm("Weet u zeker dat u dit wilt verwijderen?"))
};

var openedDivs = Cookies.get("openedDivs");
if(openedDivs==null){
  openedDivs = "";
}

function toggleDIV(id){
  var idIndex = (","+openedDivs+",").indexOf(","+id+",");
  if( idIndex>-1 ){
    openedDivs=openedDivs.substring(0,idIndex)+openedDivs.substring(idIndex+((""+id).length)+1);
  }else{
    if(openedDivs.length>0){
      openedDivs += ",";
    }
    openedDivs += id;
  }  
  Cookies.set("openedDivs", openedDivs);

  var imgid = id + "img"
  var divid = id + "div";
  var div = Global.getObject(divid);
 // 
  var my_divIMGID=id+"imgdivimg";
  var my_divIMG=Global.getObject(my_divIMGID);
 //
  if (div) {
    if(div.style.display=='block'){
      div.style.display='none';
      my_divIMG.src="/images/pm_cl.gif";
    }else{
      div.style.display='block';
    my_divIMG.src="/images/pm_op.gif";
  }
  }
   
    var img = Global.getObject(imgid);
    if(img==null)
      return;
  if(hasSubChilds[id])
  {
    if(img.src.indexOf('dir_open.gif')>=0)
      img.src = '/images/dir.gif';
    else
      img.src = '/images/dir_open.gif';
   }
}
window.onerror=handleError;
function handleError(a,b,c){
  alert(a+" "+b+" "+c);
}
function toggleFiles(id){
  var divid = "files" + id;
  var div = Global.getObject(divid);
  // 
  var my_divIMGID=id+"imgdivimg";
  var my_divIMG=Global.getObject(my_divIMGID);
  //

  if (div) {
  if(div.style.display=='block'){
    div.style.display='none';
    my_divIMG.src="/images/pm_cl.gif";
  }else{
    div.style.display='block';
    my_divIMG.src="/images/pm_op.gif";
  }
  }
}

var openedDivsArr = openedDivs.split(",");
openedDivs="";
for(var i=0;i<openedDivsArr.length;i++){
  if(openedDivsArr[i]!=""){
    toggleDIV(openedDivsArr[i]);
    toggleFiles(openedDivsArr[i]);
  }
}

