$(document).ready(function() {
	$('a.delete').click(function() {
		if (jQuery(this).attr('title').indexOf("el ") > -1)
			return confirm('\u00BFDesea borrar '+jQuery(this).attr('title')+' seleccionado?');
		else
			return confirm('\u00BFDesea borrar '+jQuery(this).attr('title')+' seleccionada?');
	}); 
	if($.fn.fancybox) {	
		$("a.fancybox").fancybox({ 'overlayShow': true, 'zoomSpeedIn': 300, 'zoomSpeedOut': 300 });
	}
	$('a[rel="external"], a.external').click( function() {
		this.target = "_blank";
	});
	
	$('#language-selector #lang, #language-selector #theme').hover(function() {
		$(this).css('height', '84px');		
	}, function() {
		$(this).css('height', '0');
	});
});

function showPreview(coords) {	
	if (parseInt(coords.w) > 0) {
		var rx = 470 / coords.w;
		var ry = 352 / coords.h;

		if ($("#collection_item_image").length) {
			$('#preview').css({
				width: Math.round(rx * $('#collection_item_image').width()) + 'px',
				height: Math.round(ry * $('#collection_item_image').height()) + 'px',
				marginLeft: '-' + Math.round(rx * coords.x) + 'px',
				marginTop: '-' + Math.round(ry * coords.y) + 'px'
			});
		}			
		jQuery('#x').val(coords.x);
		jQuery('#y').val(coords.y);
		jQuery('#w').val(coords.w);
		jQuery('#h').val(coords.h);		
	}
};