$(document).ready(function(){
	$('.addToCartButton').click(function(){
		var $artId 		= $(this).parent().find('.artId').val();
		var $qty 		= $(this).parent().find('.itemCant').val();
		var $sizeFl 	= $(this).parent().find('.SizeFl').val();
		var $sizeId 	= $(this).parent().find('span.size.active').attr('sizeId');
		
		if ( $qty == undefined || $qty == "")
			$qty = 0;
		if ( $sizeId == undefined || $sizeId == "")
			$sizeId = 0;
			
			
		lightAddCartOn( $artId, $qty, $sizeFl, $sizeId );		
	});
	$('.addToCartButtonDetail').click(function(){
		var $artId 	= $('.artId').val();
		var $qty 	= $('.itemCant').val();
		var $sizeFl = $('.SizeFl').val();
		var $colorId = $('#ColorSelect').val();
		var $sizeId = $('#SizeSelect').val();
		if ( $qty == undefined || $qty == "")
			$qty = 0;
		if ( $sizeId == undefined || $sizeId == "")
			$sizeId = 0;
			
		lightAddCartOn( $artId, $qty, $sizeFl, $colorId, $sizeId );		
	});
});

function lightAddCartOn( artId, qty, colorSize_FL, colorId, sizeDetId ){
	//alert( artId + ' ' + qty + ' ' + colorSize_FL + ' ' + colorId + ' ' + sizeDetId );
	if( colorSize_FL == 1) {		

		if( !colorId || colorId == 0){
			alert('Por favor elegir color');
			return;
		}
		if( !sizeDetId || sizeDetId == 0){
			alert('Por favor elegir talle');
			return;
		}
	}
	
	if( qty < 1 )
	{
		alert('Por favor especifique una cantidad mayor o igual a 1 para agregar este producto');
		return;
	}
	
	$.ajax(
    {
		type: "post",
		url: $basePath+'pedido/LBAddConfirm',
		data: "ART_ID="+artId+"&ORDER_ART_QTY="+qty+"&COLOR_ID="+colorId+"&SIZE_DET_ID="+sizeDetId+"&COLORSIZE_FL="+colorSize_FL,
		success: function(data)
		{
			orderModuleLoad('', 'orderModuleCol');
			$('#LightAddCartContent').html(data);
			//$("#colorId").val('');
			$("#sizeDetId_"+artId).val('');
			//$('.productcolor > a').removeClass("activated");
			$('.productsize a').removeClass('activated')
		}
	});
	
	$("#LightAddCart").fadeIn();
	document.getElementById('LightBack').style.display 	   	= 	'block'; //no hacer fade del fondo, rompe en ie
	dropDownChange('hide');

}
	
function lightAddCartOff(){
	$("#LightAddCart").fadeOut();
	document.getElementById('LightBack').style.display 	   	= 	'none'; //no hacer fade del fondo, rompe en ie
	dropDownChange('show');
}

function bannerFlotadorOff(){
	document.getElementById('bannerFlotador').style.display 			= 	'none';
	dropDownChange('hide');
}
function LightGaleriaOff(){
	document.getElementById('LightGaleria').style.display = 'none';
	document.getElementById('LightBack').style.display = 'none';
	dropDownChange('hide');
}
