
// Al Cargar el Doom
$(document).ready(function () {
	liquidColumns();
	$('#mycarousel').jcarousel();
	
	
	$("#closeBox").click(function(){ 
								  
		$("#facebox").fadeOut("fast");
		var miSize = $("#BoxSize").val("");
		var miCount = $("#BoxCount").val("");
	
	});
		
	
	$("#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("added to shopping cart");
			$.post("model/transaction.php",{ accion :'addCarr', session : _session, id : _id, coleccion : _coleccion, descripcion : _name, imagen : _img, size : miSize, count : miCount },
				function(){
					//alert('added to shopping cart');
					$("#mensaje").html("<div id='mensaje'><a>add to shopping cart</a></div>");
					$("#BoxCount").val("");
					$("#BoxSize").val("FALSE"); 
					$('#facebox').fadeOut('fast');
					//setTimeout("$('#facebox').fadeOut('fast');",1000);//despues de un segundo de procesar, se vuelve invisible
					
			});//ajax
			$('#facebox').fadeOut('fast');
			
		}//else
		
		return false;
		
	});//Clic
	
	
});

//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");
	});			
};

/**********************************************/
var _id;
var _name;
var _img;
var _precio;
var _session;
var _coleccion;

function showBoxBuy(id,name,img,precio,session,coleccion){
	$("#mensaje").html("<div id='mensaje'></div>");
	$("#facebox").fadeIn("fast");
	$("#BoxImagen").html("<img  src='"+img+"' />");
	$("#BoxDesc").html("<a>"+name+"<a/>");
	$("#BoxPrice").html("<a> $ "+precio+"<a/>");
	
		_id=id;
		_name=name;
		_img=img;
		_precio=precio;
		_session=session;
		_coleccion=coleccion;
	
}

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


function showBoxEdit(id,name,cantidad,talla,precio,img){
	$("#mensaje").html("<div id='mensaje'></div>");
	$("#facebox").fadeIn("slow");
	$("#BoxImagen").html("<img src='"+img+"' />");
	$("#BoxDesc").html("<a>"+name+"<a/>");
	$("#BoxPrice").html("<a> $ "+precio+"<a/>");
	
	$("#BoxSize").val(talla);
	$("#BoxCount").val(cantidad);
	
	
	
	
}

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

