
// Al Cargar el Doom
$(document).ready(function () {
	liquidColumns();
	$('#mycarousel').jcarousel();
	
});

//funcion que se utiliza al redimencionar la pantalla
$(window).resize(function () {
	liquidColumns();
});

function loadPage(boton,web){
	 	$(boton).click(function(){
			//$("#contenedor").fadeOut("slow");
			if(!$("#contenedor").is(":visible")){
				$("#contenedor").load(web,{},function(){$("#contenedor").fadeIn("slow");})	
			}else{
				$("#contenedor").fadeOut("slow");
			}
	});	
}

function liquidColumns() { 
	var ancho_columna=112;
	var ancho_total="95%"
        
	$("ul.column").css({ 'width' : ancho_total});
	var colWrap = $("ul.column").width(); 
	var colNum = Math.floor(colWrap / ancho_columna); 
	var colFixed = Math.floor(colWrap / colNum); 
	$("ul.column").css({ 'width' : colWrap}); 
	$("ul.column li").css({ 'width' : colFixed}); 

}	


/*PREVIEW*/
this.imagePreview = function(){	
		
		xOffset = 10;
		yOffset = 30;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.preview").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='preview'><img src='"+ this.name +"' alt='Image preview' />"+ c +"</p>");								 
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	$("a.preview").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};


function showBoxEdit(id,name,cantidad,talla,precio,img){
	$("#mensaje").html("<div id='mensaje'></div>");
	$("#facebox").fadeIn("fast");
	$("#BoxImagen").html("<img src='"+img+"' />");
	$("#BoxDesc").html("<a>"+name+"<a/>");
	$("#BoxPrice").html("<a> $ "+precio+"<a/>");
	
	$("#BoxSize").val(talla);
	$("#BoxCount").val(cantidad);
	
	
	$("#cancelBox").click(function(){ $("#facebox").fadeOut("fast");  });
	
	$("#confirmBox").click(function(){						
									
		var miSize = $("#BoxSize option:selected").val();
		var miCount = $("#BoxCount option:selected").val();
		
		if(miSize == "FALSE" || miCount=="FALSE"){
			$("#mensaje").html("<div id='mensaje'><a>Please select quantity and size to continue</a></div>");
		}else{
			alert("save change");
			$.post("model/transaction.php",{ accion :'edit', id : id, cantidad : miCount, talla : miSize },
				function(){
					$("#mensaje").html("<div id='mensaje'><a>sucess</a></div>");
					$("#BoxCount").val("");
					$("#BoxSize").val("FALSE"); 
					$('#facebox').fadeOut('fast');	
				//	setTimeout("$('#facebox').fadeOut('slow');",1000);
					setTimeout("location.reload()",1000);
			});//ajax
			
			
			
		}//else
		
	});//Clic
	
}

/**********************************************/

