﻿
document.getElementsByClassName = function(tag, cl) {

    var retnode = [];
    var myclass = new RegExp('\\b' + cl + '\\b');
    var elem = this.getElementsByTagName(tag);
    for (var i = 0; i < elem.length; i++) {
        var classes = elem[i].className;
        if (myclass.test(classes)) {
            retnode.push(elem[i]);
        }
    }
    return retnode;
};

function CenterDivs(classname, zindex) {

    var e = document.getElementsByClassName("div", classname);

    for (var i = 0; i < e.length; i++) { CenterDiv(e[i].id, zindex); }

}

//center an object in a browser window
function CenterDiv(id, zindex) {

    var container = document.getElementById(id);
    var width = container.offsetWidth;
    var height = container.offsetHeight;

    container.style.position = "absolute";
    container.style.zIndex = zindex;
                       
   container.style.top = ((( getInnerWindowHeight() / 2 ) - ( height / 2 )) + getScrollY()) + "px";            
   container.style.left =((( getInnerWindowWidth() / 2 ) -( width / 2 )) + getScrollX()) + "px";            
}    

function refreshPage()
{
    alert("fiets");
    document.aspnetForm.ctl00_btnRefresh.click();
    alert("gefietst");
}   

        
function CenterDivWidth(id, zindex, width, height)
{  
    var container = document.getElementById(id);
    
    container.style.position = "absolute";
    container.style.zIndex = zindex;
                       
    container.style.top = ((( getInnerWindowHeight() / 2 ) - ( width / 2 )) + getScrollY()) + "px";            
    container.style.left =((( getInnerWindowWidth() / 2 ) -( height / 2 )) + getScrollX()) + "px";            
} 


//center an object in a browser window
function MoveTo(id, parent)
{  

    var _parent = document.getElementById(parent);
    var container = document.getElementById(id);
    var parentwidth = _parent.offsetWidth;
    var width = container.offsetWidth;
    var height = container.style.height.replace("px","");;
               
    container.style.marginLeft = ((parentwidth / 2) - (width / 2)) + "px";            
}    

//Get current innerbrowserheight of the browser
function getInnerWindowHeight() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }  
  return myHeight;  
}
//Get current innerbrowserwidth of the browser
function getInnerWindowWidth() {
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    
  } else if( document.documentElement && document.documentElement.clientWidth ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;    
  } else if( document.body && document.body.clientWidth) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;   
  }  
  return myWidth;  
}
   
//Get vertical scroll offset
function getScrollY() {
  var scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
  } else if( document.body && document.body.scrollTop) {
    //DOM compliant
    scrOfY = document.body.scrollTop;    
  } else if( document.documentElement && document.documentElement.scrollTop ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    
  }
  return scrOfY;
}

//Get horizontal scroll offset
function getScrollX() {
  var scrOfX = 0;
  if( typeof( window.pageXOffset ) == 'number' ) {
    //Netscape compliant
    scrOfX = window.pageXOffset;
  } else if( document.body && document.body.scrollLeft) {
    //DOM compliant
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft) ) {
    //IE6 standards compliant mode   
    scrOfX = document.documentElement.scrollLeft;
  }
  return scrOfX;
}

// Move an element directly on top of another element (and optionally
// make it the same size)
function Cover(bottom, top, ignoreSize) {
    var location = Sys.UI.DomElement.getLocation(bottom);
    top.style.position = 'absolute';
    top.style.top = location.y + 'px';
    top.style.left = location.x + 'px';
    if (!ignoreSize) {
        top.style.height = bottom.offsetHeight + 'px';
        top.style.width = bottom.offsetWidth + 'px';
    }
}

//Ok/Cancel - popup
function confirmPost(message)
{       
    var agree = confirm(message);
    if (agree)
        return true ;
    else
        return false ;
}

function toggleDisplay(Id) 
{
    var div = document.getElementById(Id);            
    div.style.display = ((div.style.display == "block" || div.style.display == '') ? "none" : "block");      
}

function setDisplay(Id, arg) {
    var div = document.getElementById(Id);
    div.style.display = arg;
}

function disableEnterKey(e)
{
     var key;

     if(window.event)
          key = window.event.keyCode;     //IE
     else
          key = e.which;     //firefox

     if(key == 13)
          return false;
     else
          return true;
}

// position of the tooltip relative to the mouse in pixel //
var offsetx = 12;
var offsety =  8;

function newelement(newid)
{ 
    if(document.createElement)
    { 
        var el = document.createElement('div'); 
        el.id = newid;     
        with(el.style)
        { 
            display = 'none';
            position = 'absolute';
        } 
        el.innerHTML = '&nbsp;'; 
        document.body.appendChild(el); 
    } 
} 
var ie5 = (document.getElementById && document.all); 
var ns6 = (document.getElementById && !document.all); 
var ua = navigator.userAgent.toLowerCase();
var isapple = (ua.indexOf('applewebkit') != -1 ? 1 : 0);
function getmouseposition(e)
{
    if(document.getElementById)
    {
        var iebody=(document.compatMode && 
        	document.compatMode != 'BackCompat') ? 
        		document.documentElement : document.body;
        pagex = (isapple == 1 ? 0:(ie5)?iebody.scrollLeft:window.pageXOffset);
        pagey = (isapple == 1 ? 0:(ie5)?iebody.scrollTop:window.pageYOffset);
        mousex = (ie5)?event.x:(ns6)?clientX = e.clientX:false;
        mousey = (ie5)?event.y:(ns6)?clientY = e.clientY:false;

        var lixlpixel_tooltip = document.getElementById('tooltip');
        lixlpixel_tooltip.style.left = (mousex+pagex+offsetx) + 'px';
        lixlpixel_tooltip.style.top = (mousey+pagey+offsety) + 'px';
    }
}
function tooltip(tip)
{
    if(!document.getElementById('tooltip')) newelement('tooltip');
    var lixlpixel_tooltip = document.getElementById('tooltip');
    lixlpixel_tooltip.innerHTML = tip;
    lixlpixel_tooltip.style.display = 'block';
    document.onmousemove = getmouseposition;
}
function exit()
{
    document.getElementById('tooltip').style.display = 'none';
}


function getStyle(el, style) {
   if(!document.getElementById) return;
   
     var value = el.style[toCamelCase(style)];
   
    if(!value)
        if(document.defaultView)
            value = document.defaultView.
                 getComputedStyle(el, "").getPropertyValue(style);
       
        else if(el.currentStyle)
            value = el.currentStyle[toCamelCase(style)];
     
     return value;
}

function setStyle(objId, style, value) {
    document.getElementById(objId).style[style] = value;
}

function openNewWindow(url) {
 popupWin = window.open(url,
 'open_window',
 'menubar, toolbar, location, directories, status, scrollbars, resizable, dependent, width=800, height=600, left=0, top=0')
}
			
function CallPrint()
{

        window.focus();

        window.print();

}

function CheckAll(obj, checked) {

    var list = document.getElementById(obj);
    var chklist = list.getElementsByTagName("input");

    for (var i = 0; i < chklist.length; i++) {
        if (chklist[i].type == "checkbox") {
            chklist[i].checked = checked;
        }
    }

}

  //------------------------------------------------------------
// suppress all error messages and do nothing with them:
//
function noErrorMessages () { return true; }
window.onerror = noErrorMessages;

//------------------------------------------------------------
// advanced: a full error handler
//
function handleError (err, url, line) {
    if (err.indexOf('is not defined') != -1) {
      alert('Oops, something is not defined.\\n' +
             err + '\n' + url + '\nline no: ' + line); 
      return true; // error is handled
    }
    else
      return false; // let the browser handle the error
  }

//window.defaultOnError = window.onerror; // store default handler
//window.onerror = handleError; // assign own handler

//.. executing my faulty code

//window.onerror = window.defaultOnError;  // restore default handler






