function addToCart(products_uvc,quantity,autoreload){
	if (autoreload==undefined){
		autoreload=false;
	}
	
	jQuery.ajax({
		url: 'ajax_getBoxContent.php?page=addToCart&products_uvc='+products_uvc+'&quantity='+quantity,
		context : document.body,
		success: function(data){
			if (autoreload){
				window.location.reload();
			}else {
				addModalBg();
				disableSelectsAndFlashs();
				jQuery('#modal_popup').html(data);
				displayModalBg();
			}
		}
	});
}
function removeToCart(products_uvc,quantity){
	jQuery.ajax({
		url: 'ajax_getBoxContent.php?page=removeToCart&products_uvc='+products_uvc+'&quantity='+quantity,
		context : document.body,
		success: function(data){
			window.location.reload();
		}
	});
}

function addModalBg(){
	if (jQuery('#modal_bg').length==0){
		jQuery('body').append('<div id="modal_bg" class="modal_bg"></div><div id="modal_popup" class="modal_popup"></div>');
	}
}
function displayModalBg(){
	jQuery('#modal_bg').css('opacity','0');
	jQuery('#modal_bg').css('display','block');
	jQuery('#modal_bg').animate({width : Math.max(jQuery(window).width(),jQuery(document).width()),
									height : Math.max(jQuery(window).height(),jQuery(document).height()),
									opacity : 0.6},500,'linear',function(){
																jQuery('#modal_popup').css('opacity','0');
																jQuery('#modal_popup').css('display','block');
																var left = (jQuery(window).width()-jQuery('#modal_popup').width())/2;
																var top = (jQuery(window).height()-jQuery('#modal_popup').height())/2+jQuery("body").scrollTop();
																jQuery('#modal_popup').css('left',left+'px');
																jQuery('#modal_popup').css('top',top+'px');
																jQuery('#modal_popup').animate({opacity : 600},500);
																}
	);
}

function refreshShoppingCartBox(){
	jQuery(".shoppingCartBox").each(function(){
		var currentShippingCartBox=jQuery(this);
		jQuery.ajax({
			url: 'ajax_getBoxContent.php?page=shoppingCart&src='+jQuery(this).attr('src'),
			context : document.body,
			success: function(data){
				currentShippingCartBox.fadeOut(300,'linear',function(){
					jQuery(this).html(data);
					jQuery(this).fadeIn();
				});
			}
		});
	});
	hideShoppingCartLightbox();
}
function hideShoppingCartLightbox(){
	jQuery('#modal_popup').fadeOut(300,'linear',function(){
		jQuery('#modal_bg').fadeOut(300,'linear',function(){
			enableSelectsAndFlashs();
		});
	});
}
function disableSelectsAndFlashs(){
	jQuery("object").css('visibility','hidden');
	if (jQuery.browser.msie && parseFloat(jQuery.browser.version)<=6){
		jQuery("select").css('visibility','hidden');
	}
}
function enableSelectsAndFlashs(){
	jQuery("object").css('visibility','visible');
	if (jQuery.browser.msie && parseFloat(jQuery.browser.version)<=6){
		jQuery("select").css('visibility','visible');
	}
}
function getValueFromMultipleFormField(name){
	if(jQuery(':input[name$="'+name+'"] option').length==0){
		return jQuery(':input[name$="'+name+'"]').attr('value');
	}else {
		return jQuery(':input[name$="'+name+'"] option:selected').attr('value');
	}
	
}

function regroupementAppear(){
	if (jQuery('#regroupement option:selected').attr('value')!=""){
		jQuery.ajax({
			url: 'ajax_getBoxContent.php?page=gamme&type=1&products_id='+jQuery('#regroupement option:selected').attr('value'),
			context : document.body,
			success: function(data){
				jQuery('#gamme1').css('display','none');
				jQuery('#gamme1').html(data);
				jQuery('#gamme1').fadeIn(300);
			}
		});
	}
	else {
		jQuery('#gamme1').fadeOut(300,function(){
			jQuery(this).html('');
		});
		jQuery('#gamme2').fadeOut(300,function(){
			jQuery(this).html('');
		});
		jQuery('#addToCart').fadeOut(300,function(){
			jQuery(this).html('');
		});
	}
}

function gamme1Appear(products_id){
	if (jQuery('#gammeSelect1 option:selected').attr('value')!=""){
		jQuery.ajax({
			url: 'ajax_getBoxContent.php?page=gamme&type=2&products_id='+products_id+'&id1='+jQuery('#gammeSelect1 option:selected').attr('value'),
			context : document.body,
			success: function(data){
				jQuery('#gamme2').css('display','none');
				jQuery('#gamme2').html(data);
				jQuery('#gamme2').fadeIn(300);
			}
		});
	}
	else {
		jQuery('#gamme2').fadeOut(300,function(){
			jQuery(this).html('');
		});
		jQuery('#addToCart').fadeOut(300,function(){
			jQuery(this).html('');
		});
	}
}
function gamme2Appear(products_id,id1){
	if (jQuery('#gammeSelect2 option:selected').attr('value')!=""){
		jQuery.ajax({
			url: 'ajax_getBoxContent.php?page=gamme&type=3&products_id='+products_id+'&id1='+id1+'&id2='+jQuery('#gammeSelect2 option:selected').attr('value'),
			context : document.body,
			success: function(data){
				jQuery('#addToCart').css('display','none');
				jQuery('#addToCart').html(data);
				jQuery('#addToCart').fadeIn(300);
			}
		});
	}
}
