$(function(){
	/*$('.content_bg').corner('cc:#f0f0f0');
	if($('#productos ul li').length){ 
		$('#productos ul').corner('cc:#F0F0F0');
		$('#productos ul li').corner();
	}*/

	if($('#banner-contenido').length){
		//$('#banner-img').corner('10px').parent().corner('12px cc:#F0F0F0');
		//$('#banner-borde').dropShadow({left:2, top:2, blur:4});
		$('#banner-contenido').innerfade({
			speed: 'slow',
			timeout: 4000,
			type: 'sequence',
			containerheight: '300px'
		});
	}

	if($('#newsletter').length){
		$('#newsletter').overlay();
	}

	if($('.amigo').length){
		$('.amigo').overlay();
	}
	
	if($('#calendario').length){
		$('#calendario').load('ajax-calendario.php');
	}

	if($('a.lightbox').length){
		$('a.lightbox').lightBox();
	}

	if($('.agregar').length){
		$('.agregar').click(function(){
			var $id = $(this).attr('rel');
			var d = new Date();
			var $t = d.getTime();
			
			/* Mensaje de espera "Agregando" */
			$.blockUI.defaults.growlCSS.opacity = '0.8';
			$.blockUI.defaults.growlCSS.background = '#000 url(images/cargando.gif) no-repeat 20px 15px';
			$.growlUI('Agregando producto', '&nbsp;', 10000);	
			
			$.get('add-carrito.php', {id: $id, t: $t},
						function(datos){
							//alert(datos);
							$.blockUI.defaults.growlCSS.opacity = '0.8';
							if(datos['producto'] == '0'){
								$.blockUI.defaults.growlCSS.background = '#000 url(images/alert48.png) no-repeat 10px 10px';
								$.growlUI('No disponible', 'Esta acción no está disponible para paquetes especiales', 5000);
							}
							else{
								$('#info_carrito').html('(' + datos['total'] + ') Producto' + (datos['total'] == 1 ? '' : 's'));
								$.blockUI.defaults.growlCSS.background = '#000 url(images/check48.png) no-repeat 10px 10px';
								$.growlUI('Producto agregado', 'El producto: '+datos['producto']+', fu&eacute; agregado al carrito<br /><br /><a href="mi-carrito">&raquo; Ver carrito ('+datos['total']+' productos)</a>', 5000);
							}
						}, 'json');
			return false;
		});
	}
});

