$.ProdutoDivopen = function (el) {
	
	var me = this;
	var $element = this.$element = $(el);
	var $containerFoto = $('#produto-foto');
	var indice = 0;
	
	this.geraCores = function() {
		var html = "";
		for(var i = 0; i < dadosProdutoDivopen.length; i++) {
			html += '<div style="background-color:#'+dadosProdutoDivopen[i].cor+'"><img src="img/px.gif" alt="" /></div>';
		}
		$("#produto-cores").html(html);
		
		me.bindclick();
	};

	this.loadFoto = function() {
		$containerFoto.find('img').bind("load", function (e) {
			$(this).fadeTo('fast', 1);
			me.bindclick();
		});
	};

	this.show = function() {
		me.unbindclick();
		$containerFoto.find('img')
			.fadeTo('fast', .01)
			.queue(function () {
				$(this)
				.dequeue()
				.attr('src', dadosProdutoDivopen[me.indice].foto);
			});
	};
	
	this.bindclick = function(){
		$element.find('a').bind("click", function() {
			me.indice = $("#produto-cores a").index(this);
			me.show();
		});
	};
	
	this.unbindclick = function(){
		$element.find('a').unbind("click");
	};
	
	this.loadFoto();
	this.geraCores();
	
};

var dadosProdutoDivopen = []; //array com os dados
var produtoDivopen_arr = [];