// JavaScript Document
$(function() {

$(".rollover").hover(
		 function(e)
		 {
		  this.src = this.src.replace("_off","_active");
		 },
		 function(e)
		 {
		  this.src = this.src.replace("_active","_off");
		 }
	);
	
	$(".casilla").click(
		 function()
		 {
		  this.src = this.src.replace("_off","_on");
		 });
	
	$(".menu_p").hover(
		 function(e)
		 {
		  $(this).fadeTo(0,0.6);
		 },
		 function(e)
		 {
		  $(this).fadeTo(0,1);
		 }
	);
	
	$('#nombre').focusin(function() {
        error=0;$('#nombre').css('background','url(/images/contacto_10.jpg) no-repeat');
    });
	
	$('#email').focusin(function() {
         error=0;$('#email').css('background','url(/images/contacto_10.jpg) no-repeat');
    });
	
	
	    $('#submit').click(function(){
			if($('#nombre').val()==''){ error=1;$('#nombre').css('background','url(/images/contacto_01.jpg) no-repeat');}
			if($('#email').val()==''){error=1;$('#email').css('background','url(/images/contacto_01.jpg) no-repeat');}
			if(error==0){
				$.ajax({
				type: "POST",
				data: ($('.campo').serialize()),
				url: "/envia_email.php",
				success: function(msg) {
						window.location = '/gracias.php'; 
					},
				error: function(xhr,msg,e){
					alert(msg);
				}
			});}
		});
	
});

$(document).ready(function(){
	url=window.location.pathname;
	busca=url.indexOf ( 'decoracion' );
	if(busca!=-1){$("#decoracion").css('display', 'block');}
	
	busca=url.indexOf ( 'tarjetas' );
	if(busca!=-1){$("#tarjetas").css('display', 'block');}
	
	busca=url.indexOf ( 'eventos' );
	if(busca!=-1){$("#eventos").css('display', 'block');}
	
/*$('.menucin').click(function(){
		$('.hide').css('display', 'none');
		$("#"+$(this).attr('title')).fadeIn('slow');
	});*/
	
	$('.show_ck').click(function(){
		$('.table_ckc').fadeIn('slow');
	});
	
	$('.hide_ck').click(function(){
		$('.table_ckc').fadeOut('slow');
	});
	
	
	$('#boton_carrito').click(function(){
		$("#carrito_items").toggle('slow');
		$("#mycarousel").css('height','500px');
	});

	 $('#mycarousel').jcarousel({
        vertical: true,
        scroll: 2,
    });
	
	$('.casilla').click (function(){
		
		$.ajax({
				type: "POST",
				url: "/carrito/carrito.php",
				data: ({id : $(this).attr('id'), nombre_producto: $(this).attr('alt')+' '+$(this).attr('id'), cantidad_producto:01}),
				success: function(msg) {
					
					$("#carrito_items").html(msg);
					$('#mycarousel').jcarousel({
        				vertical: true,
        				scroll: 2,
    				});
					$('#carrito_items').fadeIn('slow');
					$("#mycarousel").css('height','500px');		
					},
				error: function(xhr,msg,e){
					alert(msg);
				}
		});
		
				$.ajax({
				type: "POST",
				url: "/carrito/cuenta_items.php",
				success: function(msg) {
					$("#cuantos").html(msg);
					},
				error: function(xhr,msg,e){
					alert(msg);
				}
		});
	});
	
		/****************************** souvenirs ****************************/
	$('.souvenirs').click (function(){
		//alert( $("#"+$(this).attr('id')));
		this.src = this.src.replace("off","on");
		
				$.ajax({
				type: "POST",
				url: "/carrito/carrito.php",
				data: ({id : $(this).attr('id'), nombre_producto: $(this).attr('title')+' '+$(this).attr('id'), cantidad_producto:01}),
				success: function(msg) {
					
					$("#carrito_items").html(msg);
					$('#mycarousel').jcarousel({
        				vertical: true,
        				scroll: 2,
    				});
					$('#carrito_items').fadeIn('slow');
					$("#mycarousel").css('height','500px');		
					},
				error: function(xhr,msg,e){
					alert(msg);
				}
		});
		
				$.ajax({
				type: "POST",
				url: "/carrito/cuenta_items.php",
				success: function(msg) {
					$("#cuantos").html(msg);
					},
				error: function(xhr,msg,e){
					alert(msg);
				}
		});

		
	});
	
});


