function bindModalEvents(hash) {
	hash.w.jqmAddClose($('.jqmClose',hash.w));
	
	$('#miniMap').draggable({
		containment: 'document',
		zIndex: 3000,
		handle: '#dragHandle'
	});
	
	$('#miniMap a').css('opacity', 0).not('#dragHandle').click(function() {
		$('#loading').show();
		$('#miniMap a').not('#dragHandle').css('opacity', 0).hover(
			function() { $(this).css('opacity', 0.3) }, 
			function() { $(this).css('opacity', 0) }
		);		
		$(this).css('opacity', 0.3).hover(
			function() { $(this).css('opacity', 0.3) }, 
			function() { $(this).css('opacity', 0.3) }
		);
		$('#detailPlan').load(function() {
			$('#loading').hide();																																 
		}).attr('src', $(this).attr('href'));
		return false;
	}).not('#startMap').hover(
		function() { $(this).css('opacity', 0.3) }, 
		function() { $(this).css('opacity', 0) }
	);
	$('#miniMap a#startMap').css('opacity', 0.3);
	$('#dragHandle').click(function() { return false });
}

$(function() {
	$('body').prepend('<div class="jqmWindow" id="modal"></div>');
	
	$('#modal').jqm({
		modal: false,
		trigger: '#plan',
		ajax: 'plan.ajx.php',
		onLoad: function(hash) {
			$('#loading').hide();
			bindModalEvents(hash);
		}
	});
});