/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

var newscalendar = {}


newscalendar.tipSetup = function(
	width,
	backgroundColor,
	borderColor,
	borderWidth,
	radius,
	padding,
	spikeLength,
	spikeGirth,
	shadow,
	shadowBlur,
	shadowOffsetX,
	shadowOffsetY,
	positions,
	fadeSpeed) {
	
	newscalendar.tip = {

		width : width,
		backgroundColor : backgroundColor,
		borderColor : borderColor,
		borderWidth : borderWidth,
		radius : radius,
		padding : padding,
		spikeLength : spikeLength,
		spikeGirth : spikeGirth,
		shadow: shadow,
		shadowBlur: shadowBlur,
		shadowOffsetX: shadowOffsetX,
		shadowOffsetY: shadowOffsetY,
		positions: positions,
		fadeSpeed : fadeSpeed
	}
	
}

newscalendar.processToolTip = function( toolTipID ) {

	try {
	
			newscalendar.tip.positions = 'bottom';

		
		jQuery( '#idMenu' + toolTipID ).bt({
				centerPointX: 0,
				centerPointY: 1,
				cornerRadius: 10,
				clickAnywhereToClose: true,
			    shadow: true,
			    shadowBlur: newscalendar.tip.shadowBlur,
			    shadowOffsetX: newscalendar.tip.shadowOffsetX,
			    shadowOffsetY: newscalendar.tip.shadowOffsetY,
				positions: newscalendar.tip.positions,
				cssClass: 'newscalendar-tip newscalendar-tip-id-' + toolTipID ,
				trigger : 'none',
				contentSelector : 'jQuery( "#toolTipIdMenu' + toolTipID + '").html()',
				padding: newscalendar.tip.padding,
				width: newscalendar.tip.width,
				spikeLength: 5,
				spikeGirth: 5,
				cornerRadius: newscalendar.tip.radius,
				fill: newscalendar.tip.backgroundColor,
				strokeWidth: 2,
				strokeStyle: newscalendar.tip.borderColor,
				showTip: function(box){
					jQuery(box).fadeIn(newscalendar.tip.fadeSpeed);
				},
				hideTip: function(box, callback){
					callback();
				},
				shrinkToFit: true,
				hoverIntentOpts: {
					interval: 300,
					timeout: 500
				}

		});

		jQuery( '#idMenu' + toolTipID ).mousedown( function( event ) {

			var calendar = document.getElementById('calendar');
			var elements = calendar.getElementsByTagName('div');
			for (var i = 0; i < elements.length; i++) {
				var e = elements[i];
				if (e.className == 'newscalendarTooltip')
					var menuId = e.id.substring(13); /* 'toolTipIdMenu'.length */
					jQuery( '#idMenu' + menuId ).btOff();
			}

			jQuery( '#idMenu' + toolTipID ).btOn({positions: 'bottom'});

			/*
			jQuery( '.newscalendar-tip-id-' + toolTipID ).bind( 'mouseleave', function( event ) {

				jQuery( '#idMenu' + toolTipID ).btOff();

			});

			/**/
			/*
			jQuery( '.newscalendar-tip-id-' + toolTipID + ' canvas' ).bind( 'mousedown', function( event ) {
				if (event.target.nodeName != 'A')
					jQuery( '#idMenu' + toolTipID ).btOff();

			});
			jQuery( '.bt-content' ).bind( 'mousedown', function( event ) {
				if (event.target.nodeName != 'A')
					jQuery( '#idMenu' + toolTipID ).btOff();

			});
			*/
			jQuery( 'canvas, .bt-content' ).bind( 'mousedown', function( event ) {
				if (event.target.nodeName != 'A')
					jQuery( '#idMenu' + toolTipID ).btOff();
			});
			/**/
			/*
			jQuery( '#idMenu' + toolTipID ).mouseout( function( event ) {

				try {
				if ( event.relatedTarget.localName !== 'CANVAS' ) {

					jQuery( '#idMenu' + toolTipID ).btOff();

				}
				} catch(e) {}

			} );
			/**/
			

		} );

	} catch( e ) {}
}

