
// COMMON: Load page in a new window; use class="new_window" on <a> tags
$(document).ready(function(){
	$("a.new_window").click(function(){
		w = window.open(this.href, 'new_window');
		return false;
	});
});


// HOME: Select text from subscribe box when clicked
$(document).ready(function(){
	$("#subscribe").click(function(){
		$(this).select();
	});
});


// HOME: Popup window
// SimpleModal: http://www.ericmmartin.com/projects/simplemodal/
function showPopup(id){
	var url = http_base + '/' + language + '/ajax/popup/?id=' + id.substring(5);
	$.get(url, null, function(html){
		$(html).modal({
			overlayId: 'dialog-overlay',
			containerId: 'dialog-container',
			closeTitle: language == 'en' ? 'Close' : 'Fermer',
			onOpen: openPopup,
			onClose: closePopup
		});
	});
}

function openPopup(dialog){
	dialog.overlay.fadeIn(200, function(){
		dialog.container.fadeIn(200, function(){
			dialog.data.fadeIn(200);
		});
	});
}

function closePopup(dialog){
	dialog.data.fadeOut(200, function(){
		dialog.container.fadeOut(200, function(){
			dialog.overlay.fadeOut(200, function(){
				$.modal.close();
			});
		});
	});
}

$(document).ready(function(){
	$("a.popup").click(function(){
		showPopup($(this).attr("id"));
		return false;
	});
});
