// Add the default callBack-handler:
Widget.addCallBack("VisitorInfo", function(params) {
	// Retrieve the used widget ID's:
	widgets = params.widgets.split("_");
	
	// Add the correct datepicker handlers:
	Widget.addCallBack("DatePicker", new function(params) {
		// When the datepicker is loaded, add the widget handler to the datepicker:
		Widget.getClass("DatePicker").addHandler(params.widgets[3], function(date) {
			new Widget($(params.widgetId).$().parentNode).refresh("widgetId=" + params.widgetId + "&date=" + date);
		});
	});
});

/**
 * The visitor info static class.
 * 
 * @version 24-11-2009
 * @author <a href="mailto:r.tennapel@griponservice.nl?SUBJECT=VisitorInfo script.js">R. ten Napel, ing.</a>
 **/
function VisitorInfo() {}

VisitorInfo.minHeight 		= 0;
VisitorInfo.maxHeight 		= 350;
VisitorInfo.duration 		= 750;
VisitorInfo.tweenType 		= Tween.ease;
VisitorInfo.fps 			= 30;
VisitorInfo.suffix 		= "px";
VisitorInfo.selectedBlock 	= null;

/**
 * Open an element, collapse the old one.
 * 
 * @param id			The ID of the element to open.
 **/
VisitorInfo.selectBlock = function(id) {
	var block = $(id);
	
	// If there is no old element:
	if (this.selectedBlock != null) {
		// If the given block is already open, close it:
		if (this.selectedBlock.$().id == id) {
			block.resizeHeight(this.maxHeight, this.minHeight, this.duration, this.tweenType, this.fps, this.suffix);
			
			this.selectedBlock = null
			
			return;
		}
		
		// Collapse the old block:
		this.selectedBlock.resizeHeight(this.maxHeight, this.minHeight, this.duration, this.tweenType, this.fps, this.suffix);
	}
	
	// Open the given block:
	block.resizeHeight(this.minHeight, this.maxHeight, this.duration, this.tweenType, this.fps, this.suffix);
	
	// Store the given block:
	this.selectedBlock = block;
};

//Store the VisitorInfo static JS class:
Widget.addClass("VisitorInfo", VisitorInfo);
