/**
Peewa-js, <http://sourceforge.net/projects/peewa-js/>, Super Light-Weight Javascript Framework Copyright (c) 2010 Viard Julien, <http://blog.peewa.org>, GNU v3 License.
**/

Peewa.M_Modules.notifications = function(strHTML,intTimer,fct){
	if(!intTimer) intTimer = 3500;
	if(!fct) fct = function(d){var intTimer = _heightDown(d);_fadeOut(d);_setTimeout(d,function(d){_remove(d);},intTimer,d);};
	var d = _create('div');
	d._class('peewa-notifications')._opac(0)._style('display','none');
	d._function('onmouseover',function(){_resetTimeout(this);});
	d._function('onmouseout',function(){_setTimeout(this,fct,intTimer,this);});
	d._function('onclick',function(){_setTimeout(this,fct,0,this);});
	_append(_create('div')._class('peewa-notifications-content')._innerHTML(strHTML),d);
	_append(_create('div')._style('clear','both'),d);
	_setTimeout(d,fct,intTimer,d);
	_append(d);
	_fadeIn(d);
	_heightUp(d);
};
		
Peewa.M_Modules.tips = function(node){
	if(_multiple(_tips,arguments)) return;
	var d = _create('div')._class('peewa-tips')._style({'display':'none','position':'absolute'})._innerHTML(node._get('title'))._opac(0);
	node._set({'title':'','tips':d._get('id')});
	_append(d);
	node._function('onmouseover',function(e){
		var d = _(this._get('tips'));
		var pos = _getMouse(e);
		if(d._isHidden()) d._style({'top':(pos[1]-30)+'px','left':(pos[0]+10)+'px'});
		_fadeIn(d);});
	node._function('onmouseout',function(){
		var d = _(this._get('tips'));
		_setTimeout(d,function(d){_fadeOut(d);},600,d);});
};

Peewa.M_Modules.toggleBG = function(strColor,maxOpac){
	if(!strColor) strColor = '#222222';
	if(!maxOpac) maxOpac = 80;
	var s = _getWinSize();
	var d = _('bg-toggler');
	if(!d){
		d = _create('div')._style({'top':0,'left':0,'width':s[0]+'px','height':s[1]+'px'})._set('id','bg-toggler')._opac(0);
		d._style({'position':'absolute','cursor':'pointer','padding':'0','margin':'0','outline':'0','border':'0','backgroundColor':strColor});
		d._function('onclick',function(){_fadeOut(this);});
		_append(d);
		_fadeIn(d,{maxOpac:maxOpac});}
	else if(d._isHidden()) _fadeIn(d,{maxOpac:maxOpac});
	else _fadeOut(d);
}; 

/**Modules**/
function _notifications(){
	return _M.notifications.apply(null,arguments);
}
 
function _tips(){
	return _M.tips.apply(null,arguments);
}

function _toggleBG(){
	return _M.toggleBG.apply(null,arguments);
}
