curHeight = 500;
curRow = 0;
curOptionBox = null;
curActionOptionBox = 0;
visibleCat = 0;
visibleDevCat = 0;
t = 0;
ta = 0;
browser = navigator.appName;
included = new Array();
actionoptionsBoxes = new Array();

function mousePos(e){
	mouse = new Array();
	boxLeft = boxTop = 0;
	headerHeight = 210;
	addLeft = 90;
	
	if(e.pageX || e.pageY){
		mouse[1] = e.pageX - addLeft;
		mouse[2] = e.pageY - headerHeight;
	} else {
		mouse[1] = e.clientX - addLeft + document.body.scrollLeft;// + document.documentElement.scrollLeft;
		mouse[2] = e.clientY - headerHeight + document.body.scrollTop;//  + document.documentElement.scrollTop;
	}
	
	return mouse;
}

function getWindowSize() {
  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;
  }
  
  var dims = new Array( myWidth, myHeight );
  return dims;
}

function getPosition( el ) {
	
	x = y = 0;
	DivParent = el;
	
	while( DivParent.offsetParent ) {
		DivParent = DivParent.offsetParent;
		x += DivParent.offsetLeft;
		y += DivParent.offsetTop;
	}
	
	pos = new Array( x, y );
	
	return pos;
}

function getDivPosition() {
	
	// breedte window
	dims = getWindowSize();
	windowwidth = dims[0];
	
	// breedte tabel in scherm
	workwidth = 982;
	
	// dus links is
	if( windowwidth > workwidth )
		addLeft = ( windowwidth - workwidth ) / 2;
	else
		addLeft = 50;
	
	return addLeft;
}

function includeSub( id, row, isLast, framed ) {
	
	if( row == 'cat' )
		script_filename = 'user.planpad.cat.js.php?id=' + id + '&' + Math.random(0, 1000) + '=' + Math.random(0, 1000);
	else {
		script_filename = 'user.planpad.js.php?id=' + id + '&row=' + row + '&islast='+isLast;
		
		if( typeof( frame ) != 'undefined' )
			script_filename += '&extframe=' + frame;
			
		if( typeof( framed ) != 'undefined' )
			script_filename += '&framed=' + framed;
			
		script_filename += '&' + Math.random(0, 1000) + '=' + Math.random(0, 1000);
	}
	
	var html_doc = document.getElementsByTagName('head').item(0);
	var js = document.createElement('script');
	js.setAttribute('language', 'javascript');
	js.setAttribute('type', 'text/javascript');
	js.setAttribute('src', script_filename);
	html_doc.appendChild(js);
	return false;
}

function rolloutCategory( row, id, isLast, framed ) {
	
	// sluit vorige
	if( visibleCat ) {
		document.getElementById( 'sub'+visibleCat ).style.display = 'none';
		newHeight = curHeight - included[visibleCat];
		resizeMainDiv( newHeight, 1 );
	}
		
	if( visibleCat != id ) {
	
		document.getElementById( 'sub'+id ).style.display = 'block';
		
		if( typeof( included[id] ) == 'undefined' ) {
			includeSub( id, row, isLast, framed );
		} else {
			newHeight = curHeight + included[id];
			addHeight = included[id];
			resizeDiv( addHeight, row );
			
			if( document.getElementById( 'turn'+row ) != null ) {
				document.getElementById( 'turn'+row ).style.height = turnHeight+included[id];
			}
	
		}
	
		// vorige uitgeplapte turn herstellen, indien aanwezig en ongelijk aan nieuwe
		if( curRow != row && document.getElementById( 'turn'+curRow ) != null )
			document.getElementById( 'turn'+curRow ).style.height = turnHeight;
			
		visibleCat = id;
		
	} else if( visibleCat ) {
			
		resizeDiv( 0, row );
		visibleCat = 0;
		
		// vorige uitgeplapte turn herstellen, indien aanwezig
		if( document.getElementById( 'turn'+curRow ) != null )
			document.getElementById( 'turn'+curRow ).style.height = turnHeight;
	}
	

	curRow = row;
		
}

function showCatActions( catId ) {
	
	if( visibleDevCat != catId ) {
		
		// sluit vorige
		if( visibleDevCat ) {
			document.getElementById( 'catsub'+visibleDevCat ).style.display = 'none';
			// niet meer bold
			document.getElementById( 'catName'+visibleDevCat ).style.fontWeight = 'normal';
			
		}
		includeSub( catId, 'cat', 0, 0 );
		document.getElementById( 'catsub'+catId ).style.display = 'block';
		// bold maken
		document.getElementById( 'catName'+catId ).style.fontWeight = 900;
			
		visibleDevCat = catId;
	}
}

function resizeMainDiv( newHeight, moveEnddiv ) {
	
	document.getElementById( 'maindiv' ).style.height = newHeight+'px';
	
	if( moveEnddiv )
		document.getElementById( 'enddiv' ).style.top = (newHeight-10)+'px';
	
	curHeight = newHeight;
}

function resizeDiv( addHeight, row ) {
	
	// posities divs herstellen (in vorige en huidige rij)
	
		for( i=1; i<=row; i++ ) {
			
			if( typeof( divsInRow[i] ) != 'undefined' ) {
				
				// aantal divs op deze rij
				thisRow = divsInRow[i];
				nrDivs = thisRow.length;
				for( j=0; j<nrDivs; j++ ) {
					id = divsInRow[i][j];
					
					// terugschuiven
					newHeight = divsPositions[id];
					document.getElementById( 'div'+id ).style.top = newHeight+'px';
					document.getElementById( 'options'+id ).style.top = (newHeight-optionBoxTop)+'px';
				}
					
				// 'turn'-div, bestaat pas als aan volgende rij is begonnen
				if( i>1 ) {
					turni = i;
					newHeight = turnPositions[turni];
					if( document.getElementById( 'turn'+turni ))
						document.getElementById( 'turn'+turni ).style.top = newHeight+'px';
				}
			}
		}
		
	// alle divs in verdere rijen opschuiven
		
		// aantal rijen
		nrRows = divsInRow.length;
		for( i=row+1; i<=nrRows; i++ ) {
			
			if( typeof( divsInRow[i] ) != 'undefined' ) {
				
				// aantal divs op deze rij
				thisRow = divsInRow[i];
				nrDivs = thisRow.length;
				for( j=0; j<nrDivs; j++ ) {
					id = divsInRow[i][j];
					
					// opschuiven
					newHeight = divsPositions[id]+addHeight;
					document.getElementById( 'div'+id ).style.top = newHeight+'px';
					document.getElementById( 'options'+id ).style.top = (newHeight-optionBoxTop)+'px';
				}
					
				// 'turn'-div, bestaat pas als aan volgende rij is begonnen, en mag pas een rij verder aangepast worden
				if( i>row && i<nrRows ) {
					turni = i;
					newHeight = turnPositions[turni]+addHeight;
					if( document.getElementById( 'turn'+turni ))
						document.getElementById( 'turn'+turni ).style.top = newHeight+'px';
					//document.getElementById( 'turn'+turni ).style.height = turnHeight+'px';
				}
			}
		}
	
	
	newHeight = curHeight + addHeight;
	
	if( row == nrRows-1 )
		resizeMainDiv( newHeight, 0 );
	else
		resizeMainDiv( newHeight, 1 );
		
}

function positionDivs() {
	
	//addLeft = getDivPosition();
	addLeft = 70;
	
	// alle divs links goed uitlijnen
		
		// aantal rijen
		nrRows = divsInRow.length;
		for( i=1; i<=nrRows; i++ ) {
			
			if( typeof( divsInRow[i] ) != 'undefined' ) {
				
				// aantal divs op deze rij
				thisRow = divsInRow[i];
				nrDivs = thisRow.length;
				for( j=0; j<nrDivs; j++ ) {
					id = divsInRow[i][j];
					
					// opschuiven
					newLeft = divsPositionsX[id]+addLeft;
					document.getElementById( 'div'+id ).style.left = newLeft+'px';
					document.getElementById( 'sub'+id ).style.left = newLeft+'px';
				}
			
				// 'turn'-div, bestaat pas als aan volgende rij is begonnen
				if( i>1 ) {
					turni = i-1;
					newLeft = turnPositionsX[turni]+addLeft;
					document.getElementById( 'turn'+turni ).style.left = newLeft+'px';
				}
			}
		}
	
}

function checkDateFormat( day, month, year ) {

	// Some basic date validation //
	// did they enter number?  
	if (isNaN(day) || isNaN(month) || isNaN(year)) { 
	   //alert("Invalid number. Please ensure the day, month and    year are valid numbers.");  
	   return false;  
	} 

	// check month range 
	if (month < 1 || month > 12) {  
	   //alert("Invalid Month. Please ensure that the month is    between 1 and 12 inclusive.");  
	   return false;  
	} 

	// check day range 
	if (day < 1 || day > 31) {  
	   //alert("Invalid Day. Please ensure that the day is between    1 and 31 inclusive.");  
	   return false;  
	} 

	// check day/month combination 
	if ((month==4 || month==6 || month==9 || month==11) && day==31) { 
	   //alert("Invalid Day/Month combination. Please ensure that    you have a valid day/month combination."); 
	   return false; 
	} 

	// check for february 29th 
	if (month == 2) {  
	   var isleap = (year % 4 == 0 && (year % 100 != 0 || year %    400 == 0)); 
	   if (day>29 || (day==29 && !isleap)) {  
	      //alert("Invalid Day. This year is not a leap year.       Please enter a value less than 29 for the day."); 
	      return false 
	   } 
	}
	
	return true;
}

function compareDates( start_date, end_date, color ) {
	
	start_date = start_date.split("-")
	syear = start_date[2];  
	smonth = start_date[1]; 
	sday = start_date[0];  

	end_date = end_date.split("-")
	eyear = end_date[2];  
	emonth = end_date[1]; 
	eday = end_date[0];  

	if( !checkDateFormat( sday, smonth, syear )) {
		document.getElementById( 'planeditError' ).innerHTML = 'Ongeldige invoer startdatum!';
		document.getElementById( 'planeditError' ).style.visibility = 'visible';
		document.planedit.startdate.className = color;
		return false;
	}
	if( !checkDateFormat( eday, emonth, eyear )) {
		document.getElementById( 'planeditError' ).innerHTML = 'Ongeldige invoer einddatum!';
		document.getElementById( 'planeditError' ).style.visibility = 'visible';
		document.planedit.enddate.className = color;
		return false;
	}
	
	// Set the start date using the Date object and pass it our date parameters. 
	// NOTE: when passing the month as a number, remember that the array starts at 0. // So Jan = 0, Feb = 1 ... Dec = 11 
	var start = new Date(syear,smonth-1,sday);  
	var end = new Date(eyear,emonth-1,eday);  
	
	if( end < start ) {
		
		document.getElementById( 'planeditError' ).innerHTML = 'Einddatum kan niet voor startdatum liggen!';
		document.getElementById( 'planeditError' ).style.visibility = 'visible';
		return false;
	} else
		return true;
}

function validateEdit(color) {
	
	returnval = true;
	
	if ( document.planedit.category.value == -1 ) {
		document.planedit.category.className = color;
		//alert( 'category mist' );
		returnval = false;
	}
	if ( document.planedit.titel.value == '' ) {
		document.planedit.titel.className = color;
		//alert( 'naam mist' );
		returnval = false;
	}
	if ( document.planedit.startdate.value == '' ) {
		document.planedit.startdate.className = color;
		//alert( 'start mist' );
		returnval = false;
	}
	if ( document.planedit.enddate.value == '' ) {
		document.planedit.enddate.className = color;
		//alert( 'eind mist' );
		returnval = false;
	}
	if ( document.planedit.owner.value == '' ) {
		document.planedit.owner.className = color;
		//alert( 'owner mist' );
		returnval = false;
	}
	
	if( !returnval )
		document.getElementById( 'planeditError' ).style.visibility = 'visible';
	else
		return compareDates( document.planedit.startdate.value, document.planedit.enddate.value, color );
	
	return returnval;
}

function validateAddCat(color) {
	
	returnval = true;
	
	if ( document.planaddcat.cattitel.value == '' ) {
		document.planaddcat.cattitel.className = color;
		//alert( 'naam mist' );
		returnval = false;
	}
	
	if( !returnval ) {
		document.getElementById( 'planAddCatError' ).innerHtml = 'Niet alle gegevens zijn ingevuld!';
		document.getElementById( 'planAddCatError' ).style.visibility = 'visible';
	}
	
	return returnval;
}

function validateStartDate() {
		
		returnval = true;
		
		if ( document.planDatum.TrouwDatum.value == '' ) {
			returnval = false;
		} else {
		
			sdate = document.planDatum.TrouwDatum.value;
			sdate = sdate.split("-")
			syear = sdate[2];  
			smonth = sdate[1]; 
			sday = sdate[0];
		
			if( !checkDateFormat( sday, smonth, syear )) {
				document.planDatum.TrouwDatum.className = 'planPadNoInput';
				document.getElementById( 'planEditDateError' ).innerHTML = 'Ongeldige invoer trouwdatum!';
				document.getElementById( 'planEditDateError' ).style.visibility = 'visible';
				return false;
			}
		}
		
		if( !returnval ){
			document.planDatum.TrouwDatum.className = 'planPadNoInput';
			document.getElementById( 'planEditDateError' ).innerHTML = 'Er is geen datum ingevoerd!';
			document.getElementById( 'planEditDateError' ).style.visibility = 'visible';
		}
		
		return returnval;
}
	
function returnStyle(el) {
	el.className = 'planPadInput';
}

function openAddCategory() {
	
	document.planaddcat.catid.value = '';
	document.planaddcat.cattitel.value = '';
	document.planaddcat.cattitel.className = 'planPadInput';
	
	document.getElementById( 'planAddCatError' ).style.visibility = 'hidden';
	document.getElementById( 'planAddCatPopDiv' ).style.display = 'block';
	stretchDiv( 'planAddCatPopDiv', 'popAddCatVenster', false );
}
function openEditCategory( id, titel ) {
	
	document.planaddcat.catid.value = id;
	document.planaddcat.cattitel.value = titel;
	document.planaddcat.cattitel.className = 'planPadInput';
	
	document.getElementById( 'planAddCatError' ).style.visibility = 'hidden';
	document.getElementById( 'planAddCatPopDiv' ).style.display = 'block';
	stretchDiv( 'planAddCatPopDiv', 'popAddCatVenster', false );
}

function openEditDate() {
	
	//document.planaddcat.cattitel.value = curdate;
	document.planaddcat.cattitel.className = 'planPadInput';
	
	document.getElementById( 'planAddCatError' ).style.visibility = 'hidden';
	document.getElementById( 'planStartPopDiv' ).style.display = 'block';
	stretchDiv( 'planStartPopDiv', 'popPlanstartVenster', false );
}

function openAddAction( id ) {
	
	// reset defaults
	document.planedit.startdate.value = '';
	document.planedit.starttime.value = '';
	document.planedit.enddate.value = '';
	document.planedit.endtime.value = '';
	document.planedit.owner.value = '';
	
	// herstel standaardkleuren
	document.planedit.titel.className = 'planPadInput';
	document.planedit.startdate.className = 'planPadInput';
	document.planedit.enddate.className = 'planPadInput';
	document.planedit.owner.className = 'planPadInput';
	
	document.getElementById( 'planeditError' ).style.visibility = 'hidden';
	document.getElementById( 'planeditPopDiv' ).style.display = 'block';
	// kalender verbergen
	getObj('fc').style.display='block';
	
	stretchDiv( 'planeditPopDiv', 'popEditVenster', false );
	
	script_filename = 'user.planpad.edit.js.php?id=' + id + '&add=1&' + Math.random(0, 1000) + '=' + Math.random(0, 1000);
	var html_doc = document.getElementsByTagName('head').item(0);
	var js = document.createElement('script');
	js.setAttribute('language', 'javascript');
	js.setAttribute('type', 'text/javascript');
	js.setAttribute('src', script_filename);
	html_doc.appendChild(js);
}

function openNewAction( catID ) {
	document.planedit.titel.value = '';
	document.planedit.titel.className = 'planPadInput';

	document.planedit.category.value = catID;
	document.planedit.id.value = '';
	document.planedit.baseID.value = '';

	document.getElementById( 'planeditError' ).style.visibility = 'hidden';
	document.getElementById( 'planeditPopDiv' ).style.display = 'block';
	// kalender verbergen
	getObj('fc').style.display='block';
	
	stretchDiv( 'planeditPopDiv', 'popEditVenster', false );
	
	script_filename = 'user.planpad.edit.js.php?catID=' + catID + '&add=1&' + Math.random(0, 1000) + '=' + Math.random(0, 1000);
	var html_doc = document.getElementsByTagName('head').item(0);
	var js = document.createElement('script');
	js.setAttribute('language', 'javascript');
	js.setAttribute('type', 'text/javascript');
	js.setAttribute('src', script_filename);
	html_doc.appendChild(js);

}

function openNewAction2( catID ) { // is vervangen voor de phpversie door Chris, ivm het automatisch invullen van velden (datum enz)

	// reset defaults
	document.planedit.titel.value = '';
	document.planedit.titel.className = 'planPadInput';
	document.planedit.startdate.value = '';
	document.planedit.startdate.className = 'planPadInput';
	document.planedit.starttime.value = '';
	document.planedit.enddate.value = '';
	document.planedit.enddate.className = 'planPadInput';
	document.planedit.endtime.value = '';
	document.planedit.owner.value = '';
	document.planedit.owner.className = 'planPadInput';
	document.planedit.comment.value = '';
	document.planedit.category.value = catID;
	document.planedit.id.value = '';
	document.planedit.baseID.value = '';

	document.getElementById( 'planeditError' ).style.visibility = 'hidden';
	document.getElementById( 'planeditPopDiv' ).style.display = 'block';
	// kalender verbergen
	getObj('fc').style.display='block';
	
	stretchDiv( 'planeditPopDiv', 'popEditVenster', false );
	
}

function openEdit( id ) {
	
	// herstel standaardkleuren
	document.planedit.titel.className = 'planPadInput';
	document.planedit.startdate.className = 'planPadInput';
	document.planedit.enddate.className = 'planPadInput';
	document.planedit.owner.className = 'planPadInput';
	
	document.planedit.baseID.value = '';
	
	document.getElementById( 'planeditError' ).style.visibility = 'hidden';
	document.getElementById( 'planeditPopDiv' ).style.display = 'block';
	// kalender verbergen
	getObj('fc').style.display='block';
	
	stretchDiv( 'planeditPopDiv', 'popEditVenster', false );
	
	script_filename = 'user.planpad.edit.js.php?id=' + id + '&' + Math.random(0, 1000) + '=' + Math.random(0, 1000);
	var html_doc = document.getElementsByTagName('head').item(0);
	var js = document.createElement('script');
	js.setAttribute('language', 'javascript');
	js.setAttribute('type', 'text/javascript');
	js.setAttribute('src', script_filename);
	html_doc.appendChild(js);
}

function openBudgetwizard() {
	document.getElementById( 'planBudgetWizard1' ).style.display = 'block';
	stretchDiv( 'planBudgetWizard1', 'planBudgetWizard1Venster', false );
}

function openOfferte( url, divIDmain, divIDsub, frameID ) {
	var myWidth = 0, myHeight = 0;
	
	if( typeof( divIDmain ) == 'undefined' )
		divIDmain = 'planOfferte';
	if( typeof( divIDsub ) == 'undefined' )
		divIDsub = 'planOfferteVenster';
	if( typeof( frameID ) == 'undefined' )
		frameID = 'offerteframe';
	
	document.getElementById( frameID ).src = url;
	document.getElementById( divIDmain ).style.display = 'block';
	
	//stretchDiv( 'planOfferte', 'planOfferteVenster', true );
	  
	  //holdScroll = true;
	  popupDiv = document.getElementById( divIDmain );
	  
	  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;
	  }
	  
	  // hoogte gaat niet goed, dus neem groot getal
		alternativeHeight = 1500;
		
	  	//document.body.style.overflow = 'hidden';
	  	popupDiv.style.width = myWidth + 30;
		popupDiv.style.height = alternativeHeight + 350;
		document.getElementById( divIDsub ).style.top = 60;
		
		
	//document.getElementById( 'offerteframe' ).width = myWidth - 450;
	if( typeof( frame ) != 'undefined' && frame == 'woon' ) {
		document.body.style.overflow = 'hidden';
		document.getElementById( frameID ).height = myHeight - 180;
		document.getElementById( divIDsub ).style.height = myHeight - 148;
	} else if( frameID == 'planBudgetWizard2Frame' ) {
		// niet aanpassen
	} else {
		document.getElementById( frameID ).height = myHeight - 140;
		document.getElementById( divIDsub ).style.height = myHeight - 108;
	}
	
	closeActionOptionBox();
}

function removeGuestDiv( divID ) {
		document.body.style.overflow = 'auto';
		document.getElementById( divID ).style.display = 'none';
		holdScroll = false;
}

function stretchDiv( divIDmain, divIDsub, scrollable ) {
	  var myWidth = 0, myHeight = 0;
	  addScroll = 0;
	  
	  if( !scrollable ) {
		//holdScroll = true;
		addScroll = document.body.scrollTop;
	  }
	  
	  popupDiv = document.getElementById( divIDmain );
	  
	  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;
	  }
	  
	  // hoogte gaat niet goed, dus neem groot getal
		myHeight = 1500;
		
	  	//document.body.style.overflow = 'hidden';
	  	popupDiv.style.width = myWidth + 30;
		popupDiv.style.height = myHeight + addScroll;
		document.getElementById( divIDsub ).style.top = 60 + addScroll;

	closeActionOptionBox();
}

function closeActionOptionBox() {
	// sluit oude actionOptionbox, als die niet al gesloten is
	if( document.getElementById('actionoptionsBox') != null ) {
		document.getElementById('actionoptionsBox').style.display='none';
	}
	if( curActionOptionBox ) {
		document.getElementById('actionoptions'+curActionOptionBox).style.display='none';
		curActionOptionBox = 0;
	}
}

function showOptionsBox( catID, e ) {
	//mouse = mousePos(e);
	
	// sluit oude optionbox, als die niet al gesloten is
	if( curOptionBox != null && curOptionBox != catID )
		document.getElementById('options'+curOptionBox).style.display='none';
	
	closeActionOptionBox();
	
	// stop voorgaande sluit timer
	if( t ) clearTimeout(t);
	
	divID = document.getElementById('options'+catID);
	
	//divID.style.left = mouse[1] + 2;
	//divID.style.top = mouse[2] + 2;
	divID.style.display = 'block';
	
	curOptionBox = catID;
	//t=setTimeout( "divID.style.display='none'", 3000 );
}

function closeOptionsBox( catID ) {
	
	divID = document.getElementById('options'+catID);
	t=setTimeout( "divID.style.display='none'", 1000 );
}

function closeActionOptionsBox2() {
	
	divID = document.getElementById('actionoptionsBox');
	ta=setTimeout( "divID.style.display='none'", 1000 );
}

function stopTimer() {
	if( t ) clearTimeout(t);
	if( ta ) clearTimeout(ta);
}

function showActionOptionsBox( ID ) {
	// buiten gebruik, gebruik showActionOptionsBox2( ID, parentID, e )
	
	// sluit oude actionoptionbox, als die niet al gesloten is
	if( curActionOptionBox && curActionOptionBox != ID )
		document.getElementById('actionoptions'+curActionOptionBox).style.display='none';
	
	// sluit oude optionbox, als die niet al gesloten is
	if( curOptionBox != null ) {
		document.getElementById('options'+curOptionBox).style.display='none';
		curOptionBox = 0;
	}
	
	// stop voorgaande sluit timer
	if( ta ) clearTimeout(ta);
	
	ActiondivID = document.getElementById('actionoptions'+ID);
	
	ActiondivID.style.display = 'block';
	
	curActionOptionBox = ID;
	//ta=setTimeout( "ActiondivID.style.display='none'", 3000 );
}

function showActionOptionsBox2( ID, parentID, e, el ) {
	
	mouse = mousePos(e);
	pos = getPosition( el );
	//addLeft = getDivPosition();
	addLeft = pos[0];
	
	// sluit oude optionbox, als die niet al gesloten is
	if( curOptionBox != null ) {
		document.getElementById('options'+curOptionBox).style.display='none';
		curOptionBox = 0;
	}
	
	// stop voorgaande sluit timer
	if( ta ) clearTimeout(ta);
	
	ActiondivID = document.getElementById('actionoptionsBox');
	
	//alert( addLeft+' '+actionoptionsBoxes[ID][1] );
	ActiondivID.style.left = addLeft+actionoptionsBoxes[ID][1];
	//ActiondivID.style.left = divsPositionsX[parentID]+actionoptionsBoxes[ID][1];
	//ActiondivID.style.top = divsPositions[parentID]+actionoptionsBoxes[ID][2];
	//ActiondivID.style.left = mouse[1] + actionoptionsBoxes[ID][1];
	ActiondivID.style.top = mouse[2] + actionoptionsBoxes[ID][2];
	ActiondivID.innerHTML = actionoptionsBoxes[ID][3];
	ActiondivID.className = actionoptionsBoxes[ID][4];
	ActiondivID.style.display = 'block';
	
	//curActionOptionBox = ID;
	//ta=setTimeout( "ActiondivID.style.display='none'", 3000 );
}

function closeActionOptionsBox( ID ) {
	
	actiondivID = document.getElementById('actionoptions'+ID);
	ta=setTimeout( "actiondivID.style.display='none'", 1000 );
}

function closeActionOptionsBox2( ID ) {
	
	actiondivID = document.getElementById('actionoptionsBox');
	ta=setTimeout( "actiondivID.style.display='none'", 1300 );
}

function deleteCategory( id, title ) {
	bevestig( "Weet u zeker dat u '"+title+"', en alle acties erin, wilt verwijderen?", "user.planpad.php?deletecat="+id );
}
function deleteEdit( id, title ) {
	bevestig( "Weet u zeker dat u '"+title+"' wilt verwijderen?", "user.planpad.php?deleteaction="+id );
}

