function BBTool_getPageSize() {
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else {
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {
		if(document.documentElement.clientWidth) windowWidth = document.documentElement.clientWidth; 
		else  windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) {
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	if(yScroll < windowHeight) pageHeight = windowHeight;
	else pageHeight = yScroll;
	if(xScroll < windowWidth) pageWidth = xScroll;		
	else pageWidth = windowWidth;
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	return arrayPageSize;
};

function BBTool_getPageScroll() {
	var xScroll, yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	} else if (document.documentElement && document.documentElement.scrollTop) {
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	} else if (document.body) {
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}
	arrayPageScroll = new Array(xScroll,yScroll);
	return arrayPageScroll;
};

function BBGallery_swapItem(itemID) {

	$("#BBGallery_list li").each( function(i) {
		$(this).removeClass().css("position", "relative");
		(i==itemID) ? $(this).addClass("BBTool_galMainImg").css("position", "absolute") : $(this).addClass("BBTool_galImg");
	});

}

function BBTool_menu(menuID, action) {

	switch(action) {
		case "show":
			/*if(BBSettings.defaultEffect=="fade") $("#"+menuID).fadeIn(BBSettings.defaultEffectSpeed).css("display","block");
			else $("#"+menuID).show("normal").css("display","block");*/
			$("#"+menuID).show();
			$("#top_menu_btn_01").css("background-position","0 -42px");
			break;
		case "hide":
			/*if(BBSettings.defaultEffect=="fade") $("#"+menuID).fadeOut(BBSettings.defaultEffectSpeed).css("display","none");
			else $("#"+menuID).hide("normal").css("display","none");*/
			$("#top_menu_btn_01").css("background-position","0 0");
			$("#"+menuID).hide();
			break;
		case "init":
			break;
		default:
			break;
	
	}
	
}

function BBTool_flash() {
	$(".flashLayer").each( function() {
		var flashID			 	= ($(this).attr("flashID")==undefined) ? "flash" : $(this).attr("flashID");
		var flashSrc			= ($(this).attr("flashSrc")==undefined) ? false : $(this).attr("flashSrc");
		var flashWMode			= ($(this).attr("flashWMode")==undefined) ? "transparent" : $(this).attr("flashWMode");
		var flashBG				= ($(this).attr("flashBG")==undefined) ? "transparent" : $(this).attr("flashBG");
		var flashScriptAccess	= ($(this).attr("flashScriptAccess")==undefined) ? "always" : $(this).attr("flashScriptAccess");
		var flashParams			= ($(this).attr("flashParams")==undefined) ? "" : eval("({"+$(this).attr("flashParams")+"})");
		if($(this).attr("flashWidth")==undefined) {
			var flashWidth = ($(this).width()>0) ? $(this).width() : "auto";
		} else var flashWidth = $(this).attr("flashWidth");
		if($(this).attr("flashHeight")==undefined) {
			var flashHeight = ($(this).height()>0) ? $(this).height() : "auto";
		} else var flashHeight = $(this).attr("flashHeight");
		if(flashSrc) 
			$(this).flash({
				id:					flashID,
				src:				flashSrc,
				width:				flashWidth,
				height:				flashHeight,
				wmode:				flashWMode,
				allowScriptAccess:	flashScriptAccess,
				flashvars:			flashParams
			});
	});
}

function BBSendMail( action, objID ) {

	switch(action) {
		case "send":
			var data = "";
			if (BBVars.dataSendContentID != "") 
				data = $("#"+BBVars.dataSendContentID).html();
			else if($(".dataSend:last").length == 1)
				data = $(".dataSend:last").html();
			$("#msgData").attr("value", data);
			BBTool_formPost(objID, true);
			break;
		case "msg":
			$.get(
				BBVars.pagesURL + "ajax/envoyer.cfm"
				+ "?formAction=prompt"
				+ "&msgDataType=msg",
				function(data) {BBTool_openMsgBox(data, true);}
			);
			break;
		case "data":
			$.get(
				BBVars.pagesURL + "ajax/envoyer.cfm"
				+ "?formAction=prompt"
				+ "&msgDataType=data",
				function(data) {BBTool_openMsgBox(data, true);}
			);
			break;
		case "url":
			$.get(
				BBVars.pagesURL + "ajax/envoyer.cfm"
				+ "?formAction=prompt"
				+ "&msgDataType=url",
				function(data) {BBTool_openMsgBox(data, true);}
			);
			break;
		case "prod":
			$.get(
				BBVars.pagesURL + "ajax/envoyer.cfm"
				+ "?formAction=prompt"
				+ "&msgDataType=prod"
				+ "&msgShowData=true"
				+ "&msgDataProdID=" + BBVars.currentProdID
				+ "&msgDataColorID=" + BBVars.currentColorID,
				function(data) {BBTool_openMsgBox(data, true);}
			);
			break;
		default:
			$.get(
				BBVars.pagesURL + "ajax/envoyer.cfm?formAction=prompt",
				function(data) {BBTool_openMsgBox(data, true);}
			);
			break;		
	}
	

}

function viewDefil(videoSrc) {
	
	var dsp = ($("#view_defil").css("display")=="none"||$("#view_defil").css("display")==undefined) ? "block" : "none";
	$("#view_defil").css("display",dsp);
	var dsp = ($("#view_sil").css("display")=="none"||$("#view_sil").css("display")==undefined) ? "block" : "none";
	$("#view_sil").css("display", dsp);
		
	$('#video').html("");
	$('#video').flash({
		src: BBVars.pagesURL + 'ximg/flash/video.swf',
		width: 180,
		height: 320,
		wmode: 'transparent',
		allowScriptAccess: 'always',
		flashvars: {
			flvwidth: 180,
			flvheight: 320,
			flvname: videoSrc
		}
	});
}

// onload de plusieurs images

(function($) {
$.fn.batchImageLoad = function(options) {
	var images = $(this);
	var originalTotalImagesCount = images.size();
	var totalImagesCount = originalTotalImagesCount;
	var elementsLoaded = 0;

	// Init
	$.fn.batchImageLoad.defaults = {
		loadingCompleteCallback: null, 
		imageLoadedCallback: null
	}
    var opts = $.extend({}, $.fn.batchImageLoad.defaults, options);
		
	// Start
	images.each(function() {
		// The image has already been loaded (cached)
		if ($(this)[0].complete) {
			totalImagesCount--;
			if (opts.imageLoadedCallback) opts.imageLoadedCallback(elementsLoaded, originalTotalImagesCount);
		// The image is loading, so attach the listener
		} else {
			$(this).load(function() {
				elementsLoaded++;
				
				if (opts.imageLoadedCallback) opts.imageLoadedCallback(elementsLoaded, originalTotalImagesCount);

				// An image has been loaded
				if (elementsLoaded >= totalImagesCount)
					if (opts.loadingCompleteCallback) opts.loadingCompleteCallback();
			});
			$(this).error(function() {
				elementsLoaded++;
				
				if (opts.imageLoadedCallback) opts.imageLoadedCallback(elementsLoaded, originalTotalImagesCount);
					
				// The image has errored
				if (elementsLoaded >= totalImagesCount)
					if (opts.loadingCompleteCallback) opts.loadingCompleteCallback();
			});
		}
	});

	// There are no unloaded images
	if (totalImagesCount <= 0)
		if (opts.loadingCompleteCallback) opts.loadingCompleteCallback();
};
})(jQuery);
function delTR( lineID, lineHeight ) {
	
	jQuery(lineID).css({overflow: "hidden", height: lineHeight});
	jQuery(lineID+" td").css({height: lineHeight, overflow: "hidden"});
	jQuery(lineID+" td")
			.animate(
				{opacity:0},
				function() {
					jQuery(this)
						.css("height", 0)
						.remove();
					jQuery(lineID).animate({height: 0}, function() { jQuery(this).remove(); });
				});
				
}
