overlay = {
	init: function() {
		$('#overlay').remove();
		$('#dimmer').remove();
		$('body').append('<div id="overlay"></div><div id="dimmer"></div>');
		$('#dimmer').click(function() {
			overlay.hide();
			});
	},
	hide: function() {
		$('#overlay').html('').hide();
		$('#dimmer').hide();
		$('#editMetaInformation').stop().animate({'top': '-'+$('#editMetaInformation').height()+'px'}, 250, 'swing', function() {
			$(this).hide();
		});
	},
	show: function() {
		$('#overlay').show();
		$('#dimmer').show();
		window.scrollTo(0, 50);
	},
	set: function(data) {
		$('#overlay').html(data);
		$('#overlay span.close').click(function() {
			overlay.hide();
			});
	}
}

$(document).ready(function() {
	$('a.targetBlank').each(function() {
		$(this).data('target', $(this).attr('href')).attr('href', 'javascript:;');
	});
	$('a.targetBlank').click(function() {
		window.open($(this).data('target'));
	});
	
	$('table.machines tr:has(td)').hover(function() {
		$(this).addClass('hover');
		},
		function() {
		$(this).removeClass('hover');
		});
	
	$('table.machines td').css('cursor', 'pointer').click(function() {
		var id=$(this).parent().attr('id').substr(12);
	
		$.ajax({
			cache: false,
			type: "GET",
			url: BaseURL+'machines/overlay/'+id,
			success: function(qdata) {
				overlay.init();
				overlay.set(qdata);
				overlay.show();
			}
		});
	});
});
