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 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) {

	jQuery("#BBGallery_list li").each( function(i) {
		jQuery(this).removeClass().css("position", "relative");
		(i==itemID) ? jQuery(this).addClass("BBTool_galMainImg").css("position", "absolute") : jQuery(this).addClass("BBTool_galImg");
	});

}

function BBTool_menu(menuID, action) {

	switch(action) {
		case "show":
			/*if(BBSettings.defaultEffect=="fade") jQuery("#"+menuID).BBFadeIn(BBSettings.defaultEffectSpeed).css("display","block");
			else jQuery("#"+menuID).show("normal").css("display","block");*/
			jQuery("#"+menuID).show();
			jQuery("#top_menu_btn_01").css("background-position","0 -42px");
			break;
		case "hide":
			/*if(BBSettings.defaultEffect=="fade") jQuery("#"+menuID).BBFadeOut(BBSettings.defaultEffectSpeed).css("display","none");
			else jQuery("#"+menuID).hide("normal").css("display","none");*/
			jQuery("#top_menu_btn_01").css("background-position","0 0");
			jQuery("#"+menuID).hide();
			break;
		case "init":
			break;
		default:
			break;
	
	}
	
}

function BBTool_flash() {
	jQuery(".flashLayer").each( function() {
		var flashID			 	= (jQuery(this).attr("flashID")==undefined) ? "flash" : jQuery(this).attr("flashID");
		var flashSrc			= (jQuery(this).attr("flashSrc")==undefined) ? false : jQuery(this).attr("flashSrc");
		var flashWMode			= (jQuery(this).attr("flashWMode")==undefined) ? "transparent" : jQuery(this).attr("flashWMode");
		var flashBG				= (jQuery(this).attr("flashBG")==undefined) ? "transparent" : jQuery(this).attr("flashBG");
		var flashScriptAccess	= (jQuery(this).attr("flashScriptAccess")==undefined) ? "always" : jQuery(this).attr("flashScriptAccess");
		var flashParams			= (jQuery(this).attr("flashParams")==undefined) ? "" : eval("({"+jQuery(this).attr("flashParams")+"})");
		var flashBase			= (jQuery(this).attr("flashParams")==undefined) ? "" : jQuery(this).attr("flashBase");
		if(jQuery(this).attr("flashWidth")==undefined) {
			var flashWidth = (jQuery(this).width()>0) ? jQuery(this).width() : "auto";
		} else var flashWidth = jQuery(this).attr("flashWidth");
		if(jQuery(this).attr("flashHeight")==undefined) {
			var flashHeight = (jQuery(this).height()>0) ? jQuery(this).height() : "auto";
		} else var flashHeight = jQuery(this).attr("flashHeight");
		
		if(flashSrc) 
			jQuery(this).flash({
				id:					flashID,
				src:				flashSrc,
				width:				flashWidth,
				height:				flashHeight,
				wmode:				flashWMode,
				allowScriptAccess:	flashScriptAccess,
				flashvars:			flashParams,
				base:				flashBase
			});
	});
}

function BBSendMail( action, objID ) {

	switch(action) {
		case "send":
			var data = "";
			if (BBVars.dataSendContentID != "") 
				data = jQuery("#"+BBVars.dataSendContentID).html();
			else if(jQuery(".dataSend:last").length == 1)
				data = jQuery(".dataSend:last").html();
			jQuery("#msgData").attr("value", data);
			BBTool_formPost(objID, true);
			break;
		case "msg":
			jQuery.get(
				BBVars.pagesURL + "ajax/envoyer.cfm"
				+ "?formAction=prompt"
				+ "&msgDataType=msg",
				function(data) {BBTool_openMsgBox(data, true);}
			);
			break;
		case "data":
			jQuery.get(
				BBVars.pagesURL + "ajax/envoyer.cfm"
				+ "?formAction=prompt"
				+ "&msgDataType=data",
				function(data) {BBTool_openMsgBox(data, true);}
			);
			break;
		case "url":
			jQuery.get(
				BBVars.pagesURL + "ajax/envoyer.cfm"
				+ "?formAction=prompt"
				+ "&msgDataType=url",
				function(data) {BBTool_openMsgBox(data, true);}
			);
			break;
		case "prod":
			jQuery.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:
			jQuery.get(
				BBVars.pagesURL + "ajax/envoyer.cfm?formAction=prompt",
				function(data) {BBTool_openMsgBox(data, true);}
			);
			break;		
	}
	

}

function viewDefil(videoSrc) {
	
	var dsp = (jQuery("#view_defil").css("display")=="none"||jQuery("#view_defil").css("display")==undefined) ? "block" : "none";
	jQuery("#view_defil").css("display",dsp);
	var dsp = (jQuery("#view_sil").css("display")=="none"||jQuery("#view_sil").css("display")==undefined) ? "block" : "none";
	jQuery("#view_sil").css("display", dsp);
		
	jQuery('#video').html("");
	jQuery('#video').flash({
		src: BBVars.pagesURL + 'ximg/flash/video.swf',
		width: 180,
		height: 320,
		wmode: 'transparent',
		allowScriptAccess: 'always',
		flashvars: {
			flvwidth: 180,
			flvheight: 320,
			flvname: videoSrc
		}
	});
}


(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);

// TOOLTIPS
(function(jQuery) {
    function tooltip(el, fn, options) {
        el.hover(function (e) {
		
		    this.anchor_title = this.title;
            this.title = '';
			
           	jQuery('#' + options.tooltipID).html(fn(this)+"&nbsp");
	
			var scrollPos = BBTool_getPageScroll();
			
			if(options.tTipWidth==0) options.tTipWidth = jQuery("#"+options.tooltipID).width();
			if(options.tTipHeight==0) options.tTipHeight = jQuery("#"+options.tooltipID).height();
			
			var xPos 	= (options.tTipWidth+e.pageX+options.xOffset<BBVars.windowWidth+scrollPos[0])
						? e.pageX + options.xOffset
						: e.pageX - options.xOffset - options.tTipWidth;
						
			var yPos 	= (options.tTipHeight+e.pageY+options.yOffset<BBVars.windowHeight+scrollPos[1])
						? e.pageY + options.yOffset
						: BBVars.windowHeight + scrollPos[1] - options.tTipHeight;

            jQuery('#' + options.tooltipID)
                .css("top", yPos + "px")
                .css("left", xPos + "px")
                .fadeIn("fast");
	                
	         
        }, function () {
            this.title = this.anchor_title;
            jQuery('#' + options.tooltipID).css("display","none");
        });
        
        el.mousemove(function (e) {
		
			var scrollPos = BBTool_getPageScroll();
			
			var xPos 	= (options.tTipWidth+e.pageX+options.xOffset<BBVars.windowWidth+scrollPos[0])
						? e.pageX + options.xOffset
						: e.pageX - options.xOffset - options.tTipWidth;
						
			var yPos 	= (options.tTipHeight+e.pageY+options.yOffset<BBVars.windowHeight+scrollPos[1])
						? e.pageY + options.yOffset
						: BBVars.windowHeight + scrollPos[1] - options.tTipHeight;
						
			jQuery('#' + options.tooltipID)
				.css("top", yPos + "px")
				.css("left", xPos + "px");
			
		});
    }

    jQuery.fn.tooltip = function(fn, options) {
        options = options || {};
        var defaults = {
            xOffset: 		20,
            yOffset: 		-10,
            tooltipID: 		'BBTTip',
			tTipHeight:		0,
			tTipWidth:		0
        };
        
		jQuery('body').append('<div id="' + options.tooltipID + '">' + fn(this) + '&nbsp;</div>');
		jQuery('#' + options.tooltipID)
				.css("z-index", 10000)
				.css("position", "absolute");
		
        return this.each(function() {
            tooltip(jQuery(this), fn, jQuery.extend(defaults, options));
        });
    }
    
})(jQuery);

function BBTool_toolTip() {
	
	jQuery("a."+BBSettings.defaultTTipClassName).tooltip(function (el) {
			var c = (el.anchor_title != "") ? "<p>" + el.anchor_title + "</p>" : "";
			return c ;
		}, {
			'tooltipID': BBSettings.defaultTTipName,
			'tTipHeight': 60,
			'tTipWidth': 60
	});
	
}
