$(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});
	}
	if($.fn.fancybox) {	
		$("a.inline").fancybox({'hideOnContentClick': false,'overlayShow':true,'zoomSpeedIn':300,'zoomSpeedOut':300});
	}

	$('a[rel=external]').click(function(e){ 
		open(this.href); 
		e.preventDefault();
    });

	$('a.back').click(function(e){ 
		history.back(-1);
		e.preventDefault();
    });
    
	if ($('ul.slide-marcas li').length > 0) {
		i = 1;
		size = $("ul.slide-marcas li").length;
/* 		alert(size); */
		path = new Array();
		for (x=0;x<size;x++) {
			path.push(x);
		}
		for (x=size;x<0;x++) {
			path.push(x);
		}
		$(document).everyTime('3s',function() {
			incremental = path[i];		
	
			$("ul.slide-marcas").animate({
				opacity: 0.3,
				top: -(incremental*112)
			}, 1500, "swing", function() {
				$(this).animate({ opacity: 1}, 300);
			});
			i++;
			if (i == path.length) {
				i = 0;
			}		
	
		});
    } 
    
});

function showPreview(coords) {	
	if (parseInt(coords.w) > 0) {
		var rx = 470 / coords.w;
		var ry = 352 / coords.h;

		if ($("#notice_image").length) {
			$('#preview').css({
				width: Math.round(rx * $('#notice_image').width()) + 'px',
				height: Math.round(ry * $('#notice_image').height()) + 'px',
				marginLeft: '-' + Math.round(rx * coords.x) + 'px',
				marginTop: '-' + Math.round(ry * coords.y) + 'px'
			});
		}
		if ($("#offer_image").length) {
			$('#preview').css({
				width: Math.round(rx * $('#offer_image').width()) + 'px',
				height: Math.round(ry * $('#offer_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);		
	}
};