<!-- JavaScripts  -->

window.onload = setHeight;
window.onresize = setHeight;

function setHeight() {
    var browserName=navigator.appName;
    var bdv = document.getElementById('bodyDiv');
    var td = document.getElementById('topDiv');
    var mc = document.getElementById('mainContent');
    var ld = document.getElementById('leftDiv');
    var rd = document.getElementById('rightDiv');
    var bd = document.getElementById('bottomDiv');
    var ch = document.getElementById('checker');
    var rdch = document.getElementById('rd_checker');
    var h;
    var height;
    var maxHeight = 0;

    if (browserName == "Microsoft Internet Explorer") {
      h = document.documentElement.clientHeight;
    } else {
      h = window.innerHeight;
    }
    height = h - td.clientHeight;
    /*alert("rightDiv= "+findPos(rdch));*/

    /* var ss komt van ingestelde stylesheet vanuit template Algemeen*/
    if (style_choice == "Stylesheet type7") {
        if(findPos(ch) > 410) {
            mc.style.height = findPos(ch)+"px";   
        }
        if(findPos(rdch) > findPos(ch)) {
            mc.style.height = findPos(rdch)+"px";   
        }
    } else {
        if (mc.clientHeight > maxHeight) maxHeight = mc.clientHeight;
        if (ld.clientHeight > maxHeight) maxHeight = ld.clientHeight;
        if (rd.clientHeight > maxHeight) maxHeight = rd.clientHeight;
        if (h > maxHeight) maxHeight = h;
         mc.style.height = maxHeight+"px"; 
         ld.style.height = maxHeight+"px";
         rd.style.height = maxHeight+"px";
//         bdv.style.height = maxHeight+"px";
         bd.style.top = (td.clientHeight + height) + "px";
      }

}

function findPos(obj) {
  var curtop = 0;	
  if (obj.offsetParent) {
    curtop = obj.offsetTop
    while (obj = obj.offsetParent) {
       curtop += obj.offsetTop
    }
  }
  return curtop;
}

function MoveObj(e) {
  var e=(!e)?window.event:e;//IE:Moz
  var tmpX = 0;
  var tmpY = 0;

  if(e.pageX) {
    tmpX = e.pageX + window.pageXOffset;
    tmpY = e.pageY + window.pageYOffset;
    alert('pageX');
  } else if(e.clientX) {
    if(document.documentElement){//IE 6+ strict mode
    	tmpX = e.clientX + document.documentElement.scrollLeft;
    	tmpY = e.clientY + document.documentElement.scrollTop;
    alert('IE 6+ strict mode');
    }else if(document.body) {//Other IE
    	tmpX = e.clientX + document.body.scrollLeft;
    	tmpY = e.clientY + document.body.scrollTop;
    alert(' NOT IE 6+ strict mode');
    }
  } else {
    return false;
  }
    document.getElementById(rd).style.left = (tmpX)+'px';
    document.getElementById(rd).style.top = (tmpY)+'px';
}


function emailcheck(emailStr) {
  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) {
    return false;
  }
  var user=matchArray[1];
  var domain=matchArray[2];
  if (user.match(userPat)==null) {
    return false;
  }
  var IPArray=domain.match(ipDomainPat);
  if (IPArray!=null) {
    for (var i=1;i<=4;i++) {
      if (IPArray[i]>255) {
        return false;
      }
    }
    return true;
  }
  var domainArray=domain.match(domainPat);
  if (domainArray==null) {
    return false;
  }
  var atomPat=new RegExp(atom,"g")
  var domArr=domain.match(atomPat)
  var len=domArr.length
  if (domArr[domArr.length-1].length<2 ||
    domArr[domArr.length-1].length>4) {
    return false;
  }
  if (len<2) {
    return false;
  }

  return true;
}

