// Function MM_preloadImages

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

// Function MM_findObj

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

// Function MM_swapImage

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// Function MM_swapImgRestore

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

// Function changeStyle

function changeStyle (what , how) {
  	what.className = how;
}

// Function changeStyle2

function changeStyle2 (what , how) {
  	document.getElementById(what).className = how;
}

// Function goto_top_timer

var goto_top_type = -1;
var goto_top_itv = 0;

function goto_top_timer()
{
	var y = goto_top_type == 1 ? document.documentElement.scrollTop : document.body.scrollTop;
	//alert(y);
	var moveby = 15; // set this to control scroll seed. minimum is fast
	y -= Math.ceil(y * moveby / 100);
	if (y < 0)
	y = 0;
	if (goto_top_type == 1)
	document.documentElement.scrollTop = y;
	else
	document.body.scrollTop = y;
	if (y == 0)
	{
		clearInterval(goto_top_itv);
		goto_top_itv = 0;
	}
}

// Function goto_top

function goto_top()
{
	if (goto_top_itv == 0)
	{
		if (document.documentElement && document.documentElement.scrollTop)
		goto_top_type = 1;
		else if (document.body && document.body.scrollTop)
		goto_top_type = 2;
		else
		goto_top_type = 0;
		if (goto_top_type > 0)
		goto_top_itv = setInterval('goto_top_timer()', 25);
	}
}

// Function MM_validateForm

function MM_validateForm() { //v4.0
//LET OP! .slice(14,100) is toegevoegd om page$ te verwijderen uit de ERROR meldingen
var aantalslice
aantalslice = 5
  var i,p,d,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { 
            //emailcheck
            p=val.indexOf('@');
            d=val.indexOf('.', p);

            if (p>=0 && d>=0 && val.length >= 3) { 
            } else {
                errors+='- '+nm.slice(aantalslice,100)+' moet een geldig emailadres bevatten.\n';
            }
      } else if (test.indexOf('RisSelected')!=-1) { 
            //dropdowncheck
            if (val == '0') { 
                errors+='- ' + nm.slice(aantalslice,100) + ' is niet geselecteerd.\n';
            } 
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm.slice(aantalslice,100)+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm.slice(aantalslice,100)+' is verplicht.\n'; }
  } if (errors) alert('De volgende velden zijn verplicht:\n'+errors);
  document.MM_returnValue = (errors == '');
}

// Function MM_validateFormSteps

function MM_validateFormSteps() { //v4.0
//LET OP! .slice(14,100) is toegevoegd om page$ te verwijderen uit de ERROR meldingen
var aantalslice
aantalslice = 0
var i,p,d,q,nm,test,num,min,max,errors='',args=MM_validateFormSteps.arguments;

for (i=0; i<(args.length-2); i+=3)
{
	test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="")
	{
		if (test.indexOf('isEmail')!=-1)
		{
			//emailcheck
			p=val.indexOf('@');
			d=val.indexOf('.', p);
			if (p>=0 && d>=0 && val.length >= 3)
			{
			} else {
				errors+='- '+nm.slice(aantalslice,100)+' moet een geldig emailadres bevatten.\n';
            }
		} else if (test.indexOf('RisSelected')!=-1) {
			//dropdowncheck
			if (val == '0')
			{
				errors+='- ' + nm.slice(aantalslice,100) + ' is niet geselecteerd.\n';
			}
      } else if (test!='R') { num = parseFloat(val);
	  	if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm.slice(aantalslice,100)+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm.slice(aantalslice,100)+' is verplicht.\n'; }
  } if (errors) alert('De volgende velden zijn verplicht:\n'+errors);
  document.MM_returnValue = (errors == '');
}

// Function ShowLayer

NumberofLayers1 = 4;
function ShowLayer1(a)
{
	for(i=1;i<=NumberofLayers1;i++)
	{
		document.getElementById('Layer'+i).style.display = 'none';
	}
	document.getElementById('Layer'+a).style.display = 'block';
}

NumberofLayers2 = 5;
function ShowLayer2(a)
{
	for(i=1;i<=NumberofLayers2;i++)
	{
		document.getElementById('Layer'+i).style.display = 'none';
	}
	document.getElementById('Layer'+a).style.display = 'block';
}

var Tooltip = {
    followMouse: true,
    offX: 8,
    offY: 12,
    tipID: "tipDiv",
    showDelay: 100,
    hideDelay: 200,
    
    ready:false, timer:null, tip:null, 
  
    init: function() {  
        if ( document.createElement && document.body && typeof document.body.appendChild != "undefined" ) {
            if ( !document.getElementById(this.tipID) ) {
                var el = document.createElement("DIV");
                el.id = this.tipID; document.body.appendChild(el);
            }
            this.ready = true;
        }
    },
    
    show: function(e, msg) {
        if (this.timer) { clearTimeout(this.timer);	this.timer = 0; }
        this.tip = document.getElementById( this.tipID );
        if (this.followMouse) // set up mousemove 
            dw_event.add( document, "mousemove", this.trackMouse, true );
        this.writeTip("");  // for mac ie
        this.writeTip(msg);
        viewport.getAll();
        this.positionTip(e);
        this.timer = setTimeout("Tooltip.toggleVis('" + this.tipID + "', 'visible')", this.showDelay);
    },
    
    writeTip: function(msg) {
        if ( this.tip && typeof this.tip.innerHTML != "undefined" ) this.tip.innerHTML = msg;
    },
    
    positionTip: function(e) {
        if ( this.tip && this.tip.style ) {
            // put e.pageX/Y first! (for Safari)
            var x = e.pageX? e.pageX: e.clientX + viewport.scrollX;
            var y = e.pageY? e.pageY: e.clientY + viewport.scrollY;
    
            if ( x + this.tip.offsetWidth + this.offX > viewport.width + viewport.scrollX ) {
                x = x - this.tip.offsetWidth - this.offX;
                if ( x < 0 ) x = 0;
            } else x = x + this.offX;
        
            if ( y + this.tip.offsetHeight + this.offY > viewport.height + viewport.scrollY ) {
                y = y - this.tip.offsetHeight - this.offY;
                if ( y < viewport.scrollY ) y = viewport.height + viewport.scrollY - this.tip.offsetHeight;
            } else y = y + this.offY;
            
            this.tip.style.left = x + "px"; this.tip.style.top = y + "px";
        }
    },
    
    hide: function() {
        if (this.timer) { clearTimeout(this.timer);	this.timer = 0; }
        this.timer = setTimeout("Tooltip.toggleVis('" + this.tipID + "', 'hidden')", this.hideDelay);
        if (this.followMouse) // release mousemove
            dw_event.remove( document, "mousemove", this.trackMouse, true );
        this.tip = null; 
    },

    toggleVis: function(id, vis) { // to check for el, prevent (rare) errors
        var el = document.getElementById(id);
        if (el) el.style.visibility = vis;
    },
    
    trackMouse: function(e) {
    	e = dw_event.DOMit(e);
     	Tooltip.positionTip(e);
    }
    
}
