var widg = {
	WIDGET_CAPTION_CLASS :'widgetCaption',

	init : function() {
		var i;
		// check it's doable?
	if (!document.getElementById || !document.createTextNode) {
		return;
	}
	_log('widg.init');
	var divs = $$('div');
	for (i = 0; i < divs.length; i++) {
		var div = divs[i];
		if (div.hasClass(widg.WIDGET_CAPTION_CLASS)) {
			widg.addExpandJavascript(div);
		}
	}
},
addExpandJavascript : function(captionDiv) {
	var captionDivId = captionDiv.getAttribute('id');
	var extra = $(captionDivId + "extra");
	extra.setStyle("display","block");
	extra.normalHeight = extra.getScrollSize().y;
	_log("extra.normalHeight:"+extra.normalHeight);
	extra.setStyle('height',0);
	var inFunction = function() {
		widg.enlargeWidgetCaption(captionDivId, true);
	};
	
	captionDiv.onmousein = inFunction; 
	captionDiv.onmouseover = inFunction; 
	captionDiv.onmouseout = function() {
		widg.enlargeWidgetCaption(captionDivId, false);
	};
},

enlargeWidgetCaption : function(captionId, enlargeIt) {
	var extra = $(captionId + "extra");
	// Transitions the background color of the Element from black to red:
	if (enlargeIt) {
		if (extra.moving) {
			return;
		}
		//_log("E :" + extra.moving + ":"+captionId);
		extra.moving = true;
		var myFx = new Fx.Tween(extra, {duration: 100, onComplete: function(){extra.moving = false;}});
		myFx.start('height', 0, extra.normalHeight);
	} else {
		if (extra.moving) {
			return;
		}
		//_log("C :" + extra.moving + ":"+captionId);
		extra.moving = true;
		var myFx = new Fx.Tween(extra, {duration: 'long', onComplete: function(){extra.moving = false;}});
		myFx.start('height', extra.normalHeight, 0);
	}
},

addEvent : function(elm, evType, fn, useCapture) {
	if (elm.addEventListener) {
		elm.addEventListener(evType, fn, useCapture);
		return true;
	} else if (elm.attachEvent) {
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	} else {
		elm['on' + evType] = fn;
	}
}
}
widg.addEvent(window, 'load', widg.init, false);