timerLoop = 0;

//Added 2010-08-17
var d = new Date();
chatAvailable = 0;

//Added 2010-08-17
if ( d.getUTCHours() >= 14 && d.getUTCHours() < 21 )
	chatAvailable = 1;

jQuery(document).ready(function() {
	
	$("#liveChatImage").fancybox({
		'padding'           : 0,
		'margin'			: 0,
		'width'				: 466,
		'height'			: 380,
        'autoScale'     	: false,
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'type'				: 'iframe',
		'scrolling'			: 'no',
		onStart		:	function() {
			timerLoop = 1;
		}
	});
	
});

//idle user function
(function($){
	
	// idleTimer() takes an optional argument that defines the idle timeout
	// timeout is in milliseconds; defaults to 30000
	
	//Changed 2010-08-17
	//if (timerLoop != 1)
	if (timerLoop != 1 && chatAvailable == 1)
		$.idleTimer(20000);
	else
		$.idleTimer('destroy');
	 
	// user is idle
	$(document).bind("idle.idleTimer", function(){
	
		if (timerLoop != 1){
	
		timerLoop = 1;
	 
		$.fancybox(
			'http://www.itconvergence.com/pls/portal/docs/PAGE/PUBLICTRAINING/FILES/load.html',
			{
	        	'padding'           : 0,
				'margin'			: 0,
				'width'				: 466,
				'height'			: 380,
				'autoScale'     	: false,
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'type'				: 'iframe',
				'scrolling'			: 'no'
			}
		);
		
		}else
			$.idleTimer('destroy');
	 
	});
		 
	//user is active again
	//$(document).bind("active.idleTimer", function(){
	
	//});
		
})(jQuery);
