try
{
$(document).ready(
	function ()
	{
		//$('.live_chat_body').hide();
		//$('.live_chat').css('top','100px');
		//$('.live_chat_tab').show();
		$('.live_chat_tab_off').show();
		//$('.live_chat').hide();
		$('.live_chat').css('z-index','1000');
		setFormPosition();
		$('.live_chat').css('height',"60px");
		$('.live_chat').css('width',$('.live_chat').parent().innerWidth() + "px");
		//$('.live_chat_online').css('height',$('.live_chat').outerHeight() + "px");
		$('.live_chat_online').css('width',$('.live_chat').parent().innerWidth() + "px");		
		//$('.live_chat_online').css('height',$('.live_chat').outerHeight() + "px");
		$('.live_chat_offline').css('width',$('.live_chat').parent().innerWidth() + "px");
		if($('.live_chat_button').find('img').width() > 10)
		{
			$('.live_chat_tab').show();
			$('.live_chat_tab_off').hide();
		}

		findChatStatus();
		/*$(window).scroll(function() {
    		$(".live_chat").css("top", ($(window).scrollTop() + 100) + "px");
			$('.live_chat').css('left',($(window).width() - $('.live_chat').innerWidth() + $(window).scrollLeft()) + "px");
		});*/
		$(window).resize(function() {
			setFormPosition();
		});
		$('.live_chat_tab').click(
			function (e)
			{
				var main = $(this).parent().find('.live_chat');
				if(main.size() < 1)
				{
					main = $(this).parents('.live_chat');
				}
				if(main.is(':visible'))
				{
					main.hide(300);
				}
				else
				{
					main.show(300);
				}
				//e.stopImmediatePropagation();
			}
		);
		$('.live_chat_tab_open').click(
			function(e)
			{
				//var main = $(this).parents('.live_chat');
				//main.find('.live_chat_body').hide("slide",{'direction':'right'},300,function(){main.find('.live_chat_tab').show();});
			}
		)
		$(document).click(
			function(e)
			{
				
				if($(e.target).parents('.live_chat').size() || $(e.target).hasClass('live_chat') || $(e.target).hasClass('live_chat_tab'))
				{
				}
				else
				{
					$('.live_chat').hide(300);
				}
			}
		);
		$('.live_chat_submit').click(
			function(e)
			{
				if(getLiveChatUsername() == "")
				{
					alert('You must enter a name for yourself');
				}
				else
				{
					//$('.live_chat_button').find('a').trigger('click');
					launchWin('framemain','http://jive.lynch.ca:8888/webchat/start.jsp?test=test&workgroup=lynchchat@workgroup.jive.lynch.ca&noUI=true&email=&username=' + escape(getLiveChatUsername()) + '&location=http://lynch.ca/index2.php',500, 400);
					
				}
			}
		);
		$('.live_chat_user').keypress(
			function(e)
			{
				if(e.which == 13)
				{
					if(getLiveChatUsername() == "")
					{
						alert('You must enter a name for yourself');
					}
					else
					{
						//$('.live_chat_button').find('a').trigger('click');
						launchWin('framemain','http://jive.lynch.ca:8888/webchat/start.jsp?test=test&workgroup=lynchchat@workgroup.jive.lynch.ca&noUI=true&email=&username=' + escape(getLiveChatUsername()) + '&location=http://lynch.ca/index2.php',500, 400);
						
					}
				}
			}
		);
		$('.live_chat_user').click(
			function(e)
			{
				$(this).val('');
				$(this).css('color','#000000');
			}
		);
	}
);
}
catch(e)
{
}
function setFormPosition()
{
	$('.live_chat').css('left',$('.live_chat').parent().position().left + "px");
	$('.live_chat').css('top',($('.live_chat').parent().position().top + 115) + "px");
}
function findChatStatus()
{
	//alert($('.live_chat_button').find('img').innerWidth());
	if($('.live_chat_button').find('img').innerWidth() < 2)
	{
		setTimeout('findChatStatus()',200);
	}
	else if($('.live_chat_button').find('img').innerWidth() > 10)
	{
		$('.live_chat_online').show();
		$('.live_chat_tab').show();
		$('.live_chat_tab_off').hide();
	}
	else
	{
		$('.live_chat_online').hide();
		$('.live_chat_tab').hide();
		$('.live_chat_tab_off').show();
	}
}

function getLiveChatUsername()
{
	return $('#live_chat_user').val();
}

function getCSSValue(value)
{
	var ans = value;
	if(value.indexOf('px') < 0)
	{
		ans = parseInt(value.substring(0,value.indexOf('px')));
	}
	return ans;
}

