// JavaScript Document

function showMe(el,loader) {
		el.style.display = "block";
		el.className= "";
		document.getElementById(loader).style.backgroundImage = "none";
}

var _afficsOpened = false;
var _afficSizeOpened = false;
var _afficModelOpened = false;
var _numbersOpened = false;

var _colorsOpened = false;
var _colorSelected = false;
var _oldColorName = "";
var _oldColorValue = "";

var _sizesOpened = false;
var _sizeSelected = false;
var _oldSizeName = "";

//var _colorNameAll = "Toutes";
//var _sizeNameAll = "Toutes";
if (!_colorNameAll) var _colorNameAll = "Toutes";
if (!_sizeNameAll) var _sizeNameAll = "Toutes";

var toolbar = new function()
{

	/**
	*       Miniatures
	*/
	this.showAffics = function() {
		if (_afficSizeOpened) this.hideAfficSize();
		if (_afficModelOpened) this.hideAfficModel();
		if (_numbersOpened) this.hideNumbers();
		if (_colorsOpened) this.hideColors();
		if (_sizesOpened) this.hideSizes();
		if ($("#zItemsAffic").is(":hidden")) {
			$("#zItemsAffic").slideDown("fast");
			_afficsOpened = true;
		} else this.hideAffics();
	}

	this.hideAffics = function()
	{
			if (!_afficsOpened) return false;
			if (_afficsOpened) $("#zItemsAffic").slideUp("fast");
			_afficsOpened = false;
	}

	/**
	*       Taille des Miniatures
	*/
	this.showAfficSize = function() {
		if (_afficsOpened) this.hideAffics();
		if (_afficModelOpened) this.hideAfficModel();
		if (_numbersOpened) this.hideNumbers();
		if (_colorsOpened) this.hideColors();
		if (_sizesOpened) this.hideSizes();
		if ($("#zItemsAfficSize").is(":hidden")) {
			$("#zItemsAfficSize").slideDown("fast");
			_afficSizeOpened = true;
		} else this.hideAfficSize();
	}

	this.hideAfficSize = function()
	{
			if (!_afficSizeOpened) return false;
			if (_afficSizeOpened) $("#zItemsAfficSize").slideUp("fast");
			_afficSizeOpened = false;
	}


	/**
	*       Modèles
	*/
	this.showAfficModel = function() {
		if (_afficsOpened) this.hideAffics();
		if (_afficSizeOpened) this.hideAfficSize();
		if (_numbersOpened) this.hideNumbers();
		if (_colorsOpened) this.hideColors();
		if (_sizesOpened) this.hideSizes();
		if ($("#zItemsAfficModel").is(":hidden")) {
			$("#zItemsAfficModel").slideDown("fast");
			_afficModelOpened = true;
		} else this.hideAfficModel();
	}

	this.hideAfficModel = function()
	{
			if (!_afficModelOpened) return false;
			if (_afficModelOpened) $("#zItemsAfficModel").slideUp("fast");
			_afficModelOpened = false;
	}

	/**
	*       Nombre
	*/
	this.showNumbers = function() {
		if (_afficsOpened) this.hideAffics();
		if (_afficSizeOpened) this.hideAfficSize();
		if (_afficModelOpened) this.hideAfficModel();
		if (_colorsOpened) this.hideColors();
		if (_sizesOpened) this.hideSizes();
		if ($("#zItemsNumbers").is(":hidden")) {
			$("#zItemsNumbers").slideDown("fast");
			_numbersOpened = true;
		} else this.hideNumbers();
	}

	this.hideNumbers = function()
	{
			if (!_numbersOpened) return false;
			if (_numbersOpened) $("#zItemsNumbers").slideUp("fast");
			_numbersOpened = false;
	}

	/**
	* 		Couleurs
	*/
	this.showColors = function()
	{
			if (_afficSizeOpened) this.hideAfficSize();
			if (_afficModelOpened) this.hideAfficModel();
			if (_numbersOpened) this.hideNumbers();
			if (_afficsOpened) this.hideAffics();
			if ($("#zItemColors").is(":hidden")) {
					this.hideSizes();
					_oldColorName = $$("zColorName").innerHTML;
					_oldColorValue = $$("items_toolbar_color").style.backgroundColor;
					$("#zItemColors").slideDown("fast");
					_colorsOpened = true;
			}
			else this.hideColors();
	}
	this.hideColors = function()
	{
			if (!_colorsOpened) return false;
			if (_colorsOpened) $("#zItemColors").slideUp("fast");
			$$("zColorName").innerHTML = _oldColorName;
			$$("items_toolbar_color").style.backgroundColor = _oldColorValue;
			_colorsOpened = false;
	}
	this.overColor = function(color, color_name)
	{
			//if (_colorSelected) return false;
			$$('zColorName').innerHTML = color_name;
			$$("items_toolbar_color").style.backgroundColor = color;
	}

	this.outColor = function()
	{
			//if (_colorSelected) return false;
			$$('zColorName').innerHTML = _colorNameAll;
			$$("items_toolbar_color").style.backgroundColor = "transparent";
	}

	this.selectColor = function(color, color_name, color_url)
	{
			if (!_colorsOpened) return false;
			_colorSelected = color_name;
			$("#zItemColors").slideUp("fast", this.showColorItems(color, color_name) );
	}
	this.showColorItems = function(color, color_name)
	{
			this.updateColorName(color, color_name);
	}
	this.updateColorName = function(color, color_name)
	{
			$$("zColorName").innerHTML = color_name;
			$$("items_toolbar_color").style.backgroundColor = color;
			_colorSelected = color_name;
			_colorsOpened = false;
			changeUrl();
	}



	/**
	* 		Tailles
	*/


	this.showSizes = function()
	{
			if (_afficSizeOpened) this.hideAfficSize();
			if (_afficModelOpened) this.hideAfficModel();
			if (_numbersOpened) this.hideNumbers();
			if (_afficsOpened) this.hideAffics();
			if ($("#zItemSizes").is(":hidden")) {
					this.hideColors();
					_oldSizeName = $$("zSizeName").innerHTML;
					$("#zItemSizes").slideDown("fast");
					_sizesOpened = true;
			}
			else this.hideSizes();
	}
	this.hideSizes = function()
	{
			if (!_sizesOpened) return;
			if (_sizesOpened) $("#zItemSizes").slideUp("fast");
			$$("zSizeName").innerHTML = _oldSizeName;
			_sizesOpened = false;
	}
	this.overSize = function(size_name)
	{
			//if (_sizeSelected) return;
			$$('zSizeName').innerHTML = size_name;
	}

	this.outSize = function()
	{
			//if (_sizeSelected) return;
			$$('zSizeName').innerHTML = _sizeNameAll;
	}

	this.selectSize = function(size_name)
	{
			if (!_sizesOpened) return false;
			_sizeSelected = size_name;
			$("#zItemSizes").slideUp("fast", this.showSizeItems(size_name) );
	}
	this.showSizeItems = function(size_name)
	{
			this.updateSizeName(size_name);
	}
	this.updateSizeName = function(size_name)
	{
			$$("zSizeName").innerHTML = size_name;
			_sizeSelected = size_name;
			_sizesOpened = false;
			changeUrl();
	}
	this.getSelectedSize = function()
	{
			return _sizeSelected;
	}




	/**
	* 		Reset
	*/
	this.resetColors = function()
	{
			_oldColorName = _colorNameAll;
			$$("zColorName").innerHTML = _colorNameAll;
			$$("items_toolbar_color").style.backgroundColor = "transparent";
			_colorSelected = false;
			this.hideColors();
			changeUrl();
	}

	this.resetSizes = function()
	{
			_oldSizeName = _sizeNameAll;
			$$("zSizeName").innerHTML = _sizeNameAll;
			_sizeSelected = false;
			this.hideSizes();
			changeUrl();
	}


}