	$(document).ready(function() {
		$('input').bind('focus', function() {
			if ($(this).val() == $(this).attr('title'))
				$(this).val('');
		});
		$('input').bind('blur', function() {
			if ($(this).val() == '')
				$(this).val($(this).attr('title'));
		});
	
		$('.questionpop').live('click', function() {
			$('#questionpop h2').html($(this).attr('rel').split('|')[0]);
			$('#questionpop span').html($(this).attr('rel').split('|')[1]);
			$('#questionpop').css('left', $(this).position().left).css('top', $(this).position().top).fadeIn();
		});
		$('.popclose a').live('click', function() {
			$(this).parent().parent().fadeOut();
		});
		
		$('.outlink').click(function(){
			window.open(this.href);
			return false;
		});
		
		$('#quick-start-form input[type=text]').focus(function(){
			if ($(this).val() == this.defaultValue)
			{
				$(this).val('');
			}
		}).blur(function(){
			if ($(this).val() == '')
			{
				$(this).val(this.defaultValue);
			}
		});
		
		$(".tooltip_div").draggable();
		$('#tooltip_dialog').dialog({
			autoOpen: false,
			bgiframe: true,
			buttons: {
			    'Close': function() {
				    $(this).dialog('close');
			    }
			},
			resizable: false,
			draggable: false,
			modal: true,
			width: 400
		});

	});
	
	function updateInbox() {
		
		if($(".count_new_msg").length)
		{
			$.ajax({
				type: "POST",
				url: 'app/common/countNewMessage',
				data: {},
				success: function(data){
				    //alert(data);
				    if(data > 0){
					var newCount = '('+data+')';
					if( newCount != $(".count_new_msg").html() ){
						$(".count_new_msg").html('('+data+')');
						if($('#inbox_grid').length)
						{
							$('#inbox_grid').flexReload();
						}
					}
				    }
				    else{
					$(".count_new_msg").html('');
				    }
				}
			});
		}
	}
	
	function hide_tooltip(div_id)
	{
	    $("#"+div_id).css('display', 'none');
	}
	function show_tooltip(div_id)
	{
	    // $("#"+div_id).css('display', 'block');
		$("#" + div_id).children('img.close_tooltip').remove();
		if ($("#" + div_id).attr('title') == '')
		{
			var tt = $("#" + div_id).children(':first').text()
			$("#" + div_id).attr('title', tt).children(':first').remove();
		}
		
		$("#" + div_id).dialog({
			bgiframe: true,
			resizable: false,
			draggable: false,
			modal: true,
			width: 400,
			overlay: {
				backgroundColor: '#000',
				opacity: 0.5
			},
			buttons: {
				Close: function() {
				$(this).dialog('destroy');
				}
			}
		});

	}
	
	function display_tool_tip(title, desc, serverData, ex, section)
	{
		$('#tooltip_dialog').dialog('option', 'title', title);
		$('#tooltip_dialog').html('Apologies but we experienced an error while uploading your file. Please try again. If the problem persists try logging out and back in again. If this doesn\'t work email us at <a href="mailto:info@theloop.com.au">info@theloop.com.au</a>  and we\'ll get the problem sorted ASAP. Sorry for the inconvenience, and thanks for your patience.');
		$('#tooltip_dialog').dialog('open');
		
		//console.log(typeof(ex) + ' - ' + ex + ' - ' + serverData);
		$.ajax({
			type: "POST",
			url: 'app/common/email_system_error_message',
			data: {'serverData':serverData, 'ex':ex , 'section':section},
			success: function(data){
			    
			}
		});
		
		
	}
