 $(document).ready(function() {
	$('area').each(function() {
	  var id = $(this).attr('id');
	  var coords = getCoords(id);
	  $(this).contextMenu(sectormenu,
	               { theme: 'osx',
	                 beforeShow: function() {
	                     $(this.menu).find('.context-menu-item:first').find('div').text("Sector " + coords + " orders");
	                     $(this.menu).find('.toggletransponders').toggleClass("context-menu-item-disabled", !canToggle(id));
	                     $(this.menu).find('.buildships').toggleClass("context-menu-item-disabled", !canBuild(id));
	                     $(this.menu).find('.createdesigns').toggleClass("context-menu-item-disabled", !canDesign(id));
	                     $(this.menu).find('.repairships').toggleClass("context-menu-item-disabled", !canRepair(id));
	                     $(this.menu).find('.transmitportals').toggleClass("context-menu-item-disabled", !canTransmit(id));
	                 }
	  });
	  $(this).click(function(event) {
	                  var data = getPopupData(id);
	                  event.preventDefault();
	                  $('#dialog').html(data);
	                  $('#dialog').dialog('option', 'title', getTitle(id));
	                  $('#dialog').dialog('open');
	                  return false;
	                }
	  );
	  $(this).qtip({ content: {
	                    text: getHoverData(id),
	                    title: getTitle(id)
	               },
	               position: { adjust: { screen: true } },
	               show: { delay: 0, effect: { type: 'fade', length:10 }},
	               hide: { effect: {length:0 } },
	               style: {
	                     name: 'dark',
	                     border: { width: 0, radius: 4 }
	               }
	   });
	});
	$('#dialog').dialog({
	  stack: true,
	  position: ['top', 'right' ],
	  width: 375,
	  autoOpen: false
	});
	$("#transponder-dialog").dialog({
		autoOpen: false,
		position: ['top', 'right' ],
		height: 200,
		width: 400,
		modal: false,
		stack: true
     });
	$("#build-dialog").dialog({
		autoOpen: false,
		position: ['top', 'right' ],
		height: 200,
		width: 400,
		modal: false,
		stack: true
     });
	$("#design-dialog").dialog({
		autoOpen: false,
		position: ['top', 'right' ],
		height: 200,
		width: 600,
		modal: false,
		stack: true
     });
	$("#repair-dialog").dialog({
		autoOpen: false,
		position: ['top', 'right' ],
		height: 200,
		width: 400,
		modal: false,
		stack: true
     });
	$("#transmit-dialog").dialog({
		autoOpen: false,
		position: ['top', 'right' ],
		height: 200,
		width: 400,
		modal: false,
		stack: true
     });
  });
