
var Tooltips 	= {} ;
Tooltips.opened = new Array() ;
Tooltips.index = 10000 ;


function Calendar()
{
	this.init();
};

Calendar.prototype.init = function()
{
	this._rpc = '/rpc.php';
	this._init = false;
	
	this._command = "calendar";

	this._busyclass = "ajaxprogress";
	this._loading = false;

	
	// load initial list
	this.load('','');
	
	this._init = true;
	
	return true;
};

 

Calendar.prototype.load = function( iMonth, iYear )
{
	this._loading = true;
	
	var oXML = new klib3.xml();
	oXML._parent = this;
	
	oVariable = new Object();
	oVariable.command = this._command;
	oVariable._format = "xml";
	oVariable.month = iMonth;
	oVariable.year = iYear;

	oXML.onload  = function()
	{
		this._parent._onLoad( this );
	}	
	oXML.post( this._rpc, true, oVariable );
	
	return false;
};

Calendar.prototype._onLoad = function( oXML )
{
	var oStatus = new Status( oXML );	
	var oDiv = document.getElementById("calendar");
	
	if ( oStatus.status != "ERROR"){
		oDiv.innerHTML = oStatus.content["data"];		
	}
	this._loading = false;
};


function showCaltip( iCalid )
{
	var oToolTip = document.getElementById('caltip_'+iCalid);
	
	
	hideAllCaltips( iCalid ) ;
	Tooltips.opened[Tooltips.opened.length] = iCalid ;
	
	if (oToolTip.style.display == 'block')
	{
		oToolTip.style.display = 'none';
	}
	else
	{
		oToolTip.parentNode.style.zIndex = ++Tooltips.index;
		oToolTip.style.display = 'block';
	}	
	oToolTip._id = iCalid;
	oToolTip._timer = null;
	
	oToolTip.onmouseover = function()
	{
		 clearTimeout(this._timer);
	};

	return false;
};

 

function hideAllCaltips( iCalid )
{
	if( !iCalid )
		iCalid = 9999999999999 ;

	if( Tooltips.opened.length )
	{
		var oTooltip = null ;
		for( var t=0 ; t<Tooltips.opened.length ; t++ )
		{
			if( Tooltips.opened[t] != iCalid )
			{
				oTooltip = document.getElementById('caltip_' + Tooltips.opened[t] );
				
				//alert(oToolTip.parentNode);
				
				if( oTooltip )
					oTooltip.style.display = 'none' ;
			}
		}
		Tooltips.opened = new Array() ;
	}
}
