var Util = {
    base_url: function() {
        return base_url;
    },

    site_url: function(uri) {
        var url = Util.base_url() + index_page;

        if (index_page != '')
            url += '/';

        return url + uri;
    },

    configCalendar: function(fields) {
        fields.each(function(field, i) {
            var bt = new Element('img');

            bt.setStyle('width', '20px');
            bt.setStyle('height', '20px');
            bt.setStyle('cursor', 'pointer');

            bt.set('src', Util.base_url() + 'img/calendar/bt.png');

            bt.inject($(field.parentNode));

            bt.addEvent('click', function() {
                displayCalendar(field, 'dd/mm/yyyy hh:ii', this, true);
            });

            field.set('readonly', 'true');

            field.addEvent('focus', function(e) {
                this.value = '';
            });
        });
    },
    mostrarSub: function(sub) {


    },

    mouseOverTrainee: function(elem) {
        var children = elem.childNodes;
        var div = children[0].childNodes;
        div[0].className = 'img_over';
        div[2].className = 'modaSubTituloTrainee modaSelecionado';
        div[3].className = 'modaSubTextoTrainee modaSelecionado';
    },
    mouseOutTrainee: function(elem) {
        var children = elem.childNodes;
        var div = children[0].childNodes;
        div[0].className = '';
        div[2].className = 'modaSubTituloTrainee';
        div[3].className = 'modaSubTextoTrainee';
    },

    mouseOver: function(elem) {
        var children = elem.childNodes;
        var div = children[0].childNodes;
        div[0].className = 'img_over';
        div[2].className = 'modaSubTitulo modaSelecionado';
        div[3].className = 'modaSubTexto modaSelecionado';

        //alert(div[2].getElementsByTagName('span'));
        if (div[2].getElementsByTagName('span')) {
            var span = div[2].getElementsByTagName('span');
            for (var i = 0; span.length > i; i++)
                alert(span[i].className)
            //span[j].style.color = '#ffffff';
        }


        if (elem.childNodes[0].childNodes[3].getElementsByTagName('span')) {
            var spans = elem.childNodes[0].childNodes[3].getElementsByTagName('span');
            for (var j = 0; spans.length > j; j++)
                spans[j].style.color = '#ffffff';
        }
    },
    mouseOut: function(elem) {
        var children = elem.childNodes;
        var div = children[0].childNodes;
        div[0].className = '';
        div[2].className = 'modaSubTitulo';
        div[3].className = 'modaSubTexto';

        if (elem.childNodes[0].childNodes[3].getElementsByTagName('span')) {

            var spans = elem.childNodes[0].childNodes[3].getElementsByTagName('span');
            for (var j = 0; spans.length > j; j++)
                spans[j].style.color = '#333333';
        }
    },
    mouseOverFoto: function(elem) {
        //var children = elem.childNodes[0];
        elem.childNodes[0].className = 'img_over';
        /*var div = children[0].childNodes;		
        div[0].className='img_over';*/

    },
    mouseOutFoto: function(elem) {
        elem.childNodes[0].className = '';
    },
    fotoAdd: function(path, img) {
        $(img).src = path;
    },


    showPreview: function(imagePath) {
        $('img_orig').removeEvents();

        $('img_orig').addEvent('load', function() {
            
           
            
            var ori_width_img = $(this).width;
            var ori_height_img = $(this).height;

            width_img = ori_width_img;
            height_img = ori_height_img;

            if (ori_width_img > ori_height_img) {
                width_img = Init.getWidth();
                height_img = width_img * ori_height_img / ori_width_img;

                if (height_img > Init.getHeight()) {
                    height_img = Init.getHeight();
                    width_img = height_img * ori_width_img / ori_height_img;
                }
            }
            else {
                height_img = Init.getHeight();
                width_img = height_img * ori_width_img / height_img;

                if (width_img > Init.getWidth()) {
                    width_img = Init.getWidth();
                    height_img = width_img * ori_height_img / ori_width_img;
                }
            }

            $('background_2').src = imagePath;
            $('background_2').style.width = width_img + 'px';
            $('background_2').style.height = height_img + 'px';

            var left = (Init.getWidth() / 1 - width_img) / 2;
            var top = (Init.getHeight() / 1 - height_img) / 2;
            $('background_2').style.left = left + 'px';
            $('background_2').style.top = top + 'px';

        });


        $('img_orig').src = imagePath;
        
       
        


    },
    showPreview_: function(imagePath, item, preco) {

        $('img_orig').removeEvents();

        $('img_orig').addEvent('load', function() {

            var ori_width_img = $(this).width;
            var ori_height_img = $(this).height;

            width_img = ori_width_img;
            height_img = ori_height_img;

            if (ori_width_img > ori_height_img) {
                width_img = Init.getWidth();
                height_img = width_img * ori_height_img / ori_width_img;

                if (height_img > Init.getHeight()) {
                    height_img = Init.getHeight();
                    width_img = height_img * ori_width_img / ori_height_img;
                }
            }
            else {
                height_img = Init.getHeight();
                width_img = height_img * ori_width_img / height_img;

                if (width_img > Init.getWidth()) {
                    width_img = Init.getWidth();
                    height_img = width_img * ori_height_img / ori_width_img;
                }
            }

            $('background_2').src = imagePath;
            $('background_2').style.width = width_img + 'px';
            $('background_2').style.height = height_img + 'px';

            var left = (Init.getWidth() / 1 - width_img) / 2;
            var top = (Init.getHeight() / 1 - height_img) / 2;
            $('background_2').style.left = left + 'px';
            $('background_2').style.top = top + 'px';


        });


        $('img_orig').src = imagePath;
        

        //	$('item').innerHTML = item;
		//	var valor =  preco.split(",");
			
		//	$('preco').innerHTML = valor[0] + ',';
		//	$('cent').innerHTML = valor[1];         


    },

    showPreviewCatalogo: function(imagePath, item, preco,item2,preco2,item3,preco3,item4,preco4) {
        $('img_orig').removeEvents();

        $('img_orig').addEvent('load', function() {

            var ori_width_img = $(this).width;
            var ori_height_img = $(this).height;

            width_img = ori_width_img;
            height_img = ori_height_img;

            if (ori_width_img > ori_height_img) {
                width_img = Init.getWidth();
                height_img = width_img * ori_height_img / ori_width_img;

                if (height_img > Init.getHeight()) {
                    height_img = Init.getHeight();
                    width_img = height_img * ori_width_img / ori_height_img;
                }
            }
            else {
                height_img = Init.getHeight();
                width_img = height_img * ori_width_img / height_img;

                if (width_img > Init.getWidth()) {
                    width_img = Init.getWidth();
                    height_img = width_img * ori_height_img / ori_width_img;
                }
            }

            $('background_2').src = imagePath;
            $('background_2').style.width = width_img + 'px';
            $('background_2').style.height = height_img + 'px';

            var left = (Init.getWidth() / 1 - width_img) / 2;
            var top = (Init.getHeight() / 1 - height_img) / 2;
            $('background_2').style.left = left + 'px';
            $('background_2').style.top = top + 'px';

        });


        $('img_orig').src = imagePath;
        
	


		$('item').innerHTML = item;
		$('real').innerHTML ='';
		$('cent').innerHTML = '';		
		if(item == "") { $('desc').innerHTML = '&nbsp;';} //
		else    
		    {
		    		var valor =  preco.split(",");
	                $('real').innerHTML = valor[0] + ',';
		            $('cent').innerHTML = valor[1];
            		$('desc').innerHTML = '  R$ ';
		    
		    }		

        //vet=$('todos').getChildren();
	  
		$('item2').innerHTML = item2;
		$('real2').innerHTML ='';
		$('cent2').innerHTML = '';		
		if(item2 == "") { $('desc2').innerHTML = '&nbsp;';} //
		else    
		    {
		    		var valor =  preco2.split(",");
	                $('real2').innerHTML = valor[0] + ',';
		            $('cent2').innerHTML = valor[1];
            		$('desc2').innerHTML = '  R$ ';
		    
		    }		
		
		    
		
		
		$('real3').innerHTML ='';
		$('cent3').innerHTML = '';
//        $('desc3').innerHTML = ' a partir de R$';
		
		
		$('item3').innerHTML = item3;
		if(item3 == "") { $('desc3').innerHTML = '&nbsp;';} //
		else    
		    {
		    		var valor =  preco3.split(",");
	                $('real3').innerHTML = valor[0] + ',';
		            $('cent3').innerHTML = valor[1];
            		$('desc3').innerHTML = '  R$ ';
		    
		    }
		//alert(item3); 
		//$('desc3').innerHTML = ' a partir de R$';

		$('real4').innerHTML ='';
		$('cent4').innerHTML = '';
//        $('desc3').innerHTML = ' a partir de R$';
		
		
		if (item4 != null)
		    {
		            $('item4').innerHTML = item4;
		            if(item4 == "") { $('desc4').innerHTML = '&nbsp;';} //
		            else    
		                {
		    		            var valor =  preco4.split(",");
	                            $('real4').innerHTML = valor[0] + ',';
		                        $('cent4').innerHTML = valor[1];
            		            $('desc4').innerHTML = '  R$ ';
            		    
		                }
            }

		
		
		
		
		
	//	alert(valor[1]+ ' cada');      		
        
        


    },
    showPreviewCatalogo_: function(imagePath, item, preco,item2,preco2,item3,preco3) {

        $('img_orig').removeEvents();

        $('img_orig').addEvent('load', function() {

            var ori_width_img = $(this).width;
            var ori_height_img = $(this).height;

            width_img = ori_width_img;
            height_img = ori_height_img;

            if (ori_width_img > ori_height_img) {
                width_img = Init.getWidth();
                height_img = width_img * ori_height_img / ori_width_img;

                if (height_img > Init.getHeight()) {
                    height_img = Init.getHeight();
                    width_img = height_img * ori_width_img / ori_height_img;
                }
            }
            else {
                height_img = Init.getHeight();
                width_img = height_img * ori_width_img / height_img;

                if (width_img > Init.getWidth()) {
                    width_img = Init.getWidth();
                    height_img = width_img * ori_height_img / ori_width_img;
                }
            }

            $('background_2').src = imagePath;
            $('background_2').style.width = width_img + 'px';
            $('background_2').style.height = height_img + 'px';

            var left = (Init.getWidth() / 1 - width_img) / 2;
            var top = (Init.getHeight() / 1 - height_img) / 2;
            $('background_2').style.left = left + 'px';
            $('background_2').style.top = top + 'px';


        });


        $('img_orig').src = imagePath;
        
        
         // alert(item);
       

        
			
	   


    },    
    
    
    
    filtroCatalago: function(sexo, elem) {
        $('galeriaFundoBranco').style.marginLeft = '0px';
        $("num1").innerHTML = 1;

        var listSexo = $('sexo').getElementsByTagName('DIV');
        for (var j = 0; listSexo.length > j; j++)
            listSexo[j].className = 'cor';

        elem.childNodes[0].className = "flu";


        var links = $('galeriaFundoBranco').getElementsByTagName('a');
        var qtd = 0;

        for (var i = links.length - 1; i >= 0; i--) {
            if (sexo != links[i].className) {
                links[i].style.display = 'none';
            }
            else {
                qtd++;
                links[i].style.display = '';
            }
        }
        $("num2").innerHTML = Math.round(qtd / 4);

    },
    addFoto: function(path_img, elem) {

        var a = $('containerFashionInternaDireita').getElementsByTagName('A');

        for (var j = 0; a.length > j; j++) {
            if (a[j].childNodes[0].className == 'posicionaGaleriaThumb')
                a[j].childNodes[0].childNodes[0].childNodes[0].className = '';
        }

        $('foto_fashion').src = path_img;
        elem.childNodes[0].className = 'img_over';
    },
    addFotoV: function(path_img, amplia) {
        $('foto_fashion').src = path_img;


        if (!amplia) {
            var menu = $$('.amplia');
            menu.each(function(item, index) {
                item.style.display = 'none';
            });
        } else {
            var menu = $$('.amplia');
            menu.each(function(item, index) {
                item.style.display = 'block';
            });

        }


    },

    ativaFotoV: function(elem) {
        var a = $('galeriaFundoBrancoV').getElementsByTagName('A');

        for (var j = 0; a.length > j; j++) {

            if (a[j].childNodes[0].childNodes[0].childNodes[0].className == 'mascarabrancaFixa') {
                a[j].childNodes[0].childNodes[0].childNodes[0].className = '';
                a[j].childNodes[0].childNodes[0].childNodes[0].className = 'mascarabranca';
            }
        }


        elem.childNodes[0].childNodes[0].childNodes[0].className = 'mascarabrancaFixa';


    },

    maximiliza: function(el) {
        if ($('galeria')) {
            $('galeria').destroy();
            el.childNodes[0].src = 'img/collection/ico-ampliar.gif';
        } else {
            var pai = el.parentNode;
            var urll = $('foto_fashion').src;
            var pos1 = urll.lastIndexOf("/");
            var pos2 = urll.indexOf(".jpg");
            ur = urll.substring(0, pos2);
            str = urll.substring(pos1 + 1, pos2);

            div = new Element('div', { id: 'galeria' });
            img = new Element('img', { src: ur + '_G.jpg' });

            el.childNodes[0].src = 'img/collection/ico-minimizar.gif';

            div.inject(pai);
            img.inject(div);
        }

    },



    mascara: function(elem) {

        var a = $('containerFashionInternaDireita').getElements('div');


        for (var j = 0; a.length > j; j++) {
            a[j].removeClass('img_over');
        }

        elem.childNodes[0].addClass('img_over');
    },
    addFotoTexto: function(path_img, elem, title, sub_title, text, lista) {

        var a = $('containerFashionInternaDireita').getElementsByTagName('A');

        for (var j = 0; a.length > j; j++) {
            if (a[j].childNodes[0].className == 'posicionaGaleriaThumb')
                a[j].childNodes[0].childNodes[0].childNodes[0].className = '';
        }

        $('foto_fashion').src = path_img;
        elem.childNodes[0].className = 'img_over';



        $('title_dica').empty;
        $('title_dica').innerHTML = title;

        $('sub_title_dica').empty;
        $('sub_title_dica').innerHTML = sub_title;


        $('text_dica').empty;
        $('text_dica').innerHTML = text;

        $('list_dica').empty;
        $('list_dica').innerHTML = lista;



    },

    ativaAba: function(el) {

        var menu = $$('.itemmenu');


        menu.each(function(item, index) {
            item.style.backgroundColor = "#fff";
        });


        el.style.backgroundColor = "#cccccc";

    },

    loadGaleriaPreVenda: function(src, galeria, subpasta, destino, qtd, amplia) {
        zoom = amplia ? true : false;
        $('num1').innerHTML = 0;
        $('num2').innerHTML = 0;
        $('containerProdutos').setStyle('display','block');
      
         if($defined($('vdo'))==true){
           $('vdo').destroy();
        
           $('foto_fashion').setStyle('display','block');
           $('vertical_slide').setStyle('display','block');
           
           $('teste').setStyle('border','0px');
        }
        var diretorio = 'img/collection/' + galeria + '/' + subpasta;

        dest = $(destino);

        dest.empty();

        var t = this;
        var feed = src;

        var currentEntry;
        var entries;
        var timer;

        id = new Array();
        tipo = new Array();
        preco = new Array();
        cores = new Array();
        quantidade = new Array();



        var request = new Request.JSON({
            url: feed,
            onComplete: function(jsonObj) {

                jsonObj.itens.each(function(item, index) {
                    
                    zoom = item.zoom;

                    var a = new Element('a', {
                        'class': 'menuhover',
                        'href': 'javascript:Util.addFotoV(\'img/collection/' + galeria + '/' + subpasta + '/M/' + item.id + '.jpg\',' + zoom + ');',
                        events: {
                            click: function() {
                                Util.ativaFotoV(this);
                                Util.loadProdutos(item.mercadorias, diretorio);
                            }
                        }
                    });


                    var div1 = new Element('div', { 'class': 'containerModaCinza' });
                    var div2 = new Element('div', { 'styles': { 'background-image': 'url(img/collection/' + galeria + '/' + subpasta + '/thumb/' + item.id + '.jpg)'} });
                    var div3 = new Element('div', { 'class': 'mascarabranca' });

                    a.inject(dest);
                    div1.inject(a);
                    div2.inject(div1);
                    div3.inject(div2);
                    if (galeria == 'reinaldo' || galeria == 'amir') 
                    {
                        if(index==0){                        
                            Util.loadProdutos(item.mercadorias, diretorio);
                            Util.addFotoV('img/collection/' + galeria + '/' + subpasta + '/M/' + item.id + '.jpg', zoom);
                        }
                    
                    }
                });
            }
        }).get();


        setTimeout("Util.loadScrollGaleriaV()", 5000);
    },

    loadGaleriaColecao: function(src, galeria, subpasta, destino, qtd, amplia) {
        zoom = amplia ? true : false;
        $('num1').innerHTML = 0;
        $('num2').innerHTML = 0;
        $('containerProdutos').setStyle('display','none');
      
         if($defined($('vdo'))==true){
           $('vdo').destroy();
        
           $('foto_fashion').setStyle('display','block');
           $('vertical_slide').setStyle('display','block');
           
           $('teste').setStyle('border','0px');
        }
        var diretorio = 'img/collection/' + galeria + '/' + subpasta;

        dest = $(destino);

        dest.empty();

        var t = this;
        var feed = src;

        var currentEntry;
        var entries;
        var timer;

        id = new Array();
        tipo = new Array();
        preco = new Array();
        cores = new Array();
        quantidade = new Array();



        var request = new Request.JSON({
            url: feed,
            onComplete: function(jsonObj) {

                jsonObj.itens.each(function(item, index) {
                    
                    zoom = item.zoom;

                    var a = new Element('a', {
                        'class': 'menuhover',
                        'href': 'javascript:Util.addFotoV(\'img/collection/' + galeria + '/' + subpasta + '/M/' + item.id + '.jpg\',' + zoom + ');',
                        events: {
                            click: function() {
                                Util.ativaFotoV(this);
                                Util.loadProdutos(item.mercadorias, diretorio);
                            }
                        }
                    });


                    var div1 = new Element('div', { 'class': 'containerModaCinza' });
                    var div2 = new Element('div', { 'styles': { 'background-image': 'url(img/collection/' + galeria + '/' + subpasta + '/thumb/' + item.id + '.jpg)'} });
                    var div3 = new Element('div', { 'class': 'mascarabranca' });

                    a.inject(dest);
                    div1.inject(a);
                    div2.inject(div1);
                    div3.inject(div2);
                    
                    
                    // se for igual a reinaldo, tem que carregar a lista de vendas de imediato
                    //{
                    //    if(index==0){                        
                    //        Util.loadProdutos(item.mercadorias, diretorio);
                     //       Util.addFotoV('img/collection/' + galeria + '/' + subpasta + '/M/' + item.id + '.jpg', zoom);
                     //   }
                    
                    //}                    
                });
            }
        }).get();


        setTimeout("Util.loadScrollGaleriaV()", 5000);
    },


    envia: function(formulario) {

        var sel = formulario.getElements('select');
        envia = true;



        sel.each(function(item, index) {
            if (item.value == "") {
                envia = false;
            }
        });


        if (envia) {
            formulario.submit();
        }
        else {
            alert("Por favor escolha um tamanho e quantidade!");
        }

    },

    loadProdutos: function(produtos, diretorio) {
    
        //alert(diretorio);
    
         if($(document.body).getElementById('esgotado')){
                        $(document.body).getElementById('esgotado').destroy();                
                    }

        i = 1;



        container = $('containerProdutos');

        container.empty();

        produtos.each(function(item, index) {
            if (i % 2 == 0) {
                right = "right";
            } else {
                right = "left";
            }

            var div1 = new Element('div', { 'class': 'prevendaDescritivo', 'styles': { 'float': right} });

            var div1a = new Element('div', { 'styles': { 'width': '143px', 'height': '19px', 'padding-left': '10px', 'border': '1px solid #fff', 'border-top': '0px', 'border-left': '0px'} });
            var div1b = new Element('a', { 'href': 'javascript:Util.envia($(\'formulario' + index + '\'))' });

            var div1compra = new Element('div', { 'styles': { 'width': '78px'} });

            var div1cores = new Element('div', { 'styles': { 'width': '137px', 'padding-left': '6px', 'background-color': '#CCCCCC', 'margin-left': '6px'} });

            var div1c = new Element('div', { 'class': 'imgprevenda' });
            var div1d = new Element('div', { 'class': 'textoprevenda' });


            var div1a1 = new Element('div', { 'styles': { 'font-size': '12px', 'top': '0px', 'margin-right': '4px'} });
            div1a1.innerHTML = item.tipo;
            var div1a2 = new Element('div', { 'styles': { 'font-size': '9px', 'top': '0px', 'margin-right': '4px'} });
            div1a2.innerHTML = "R$";
            var div1a3 = new Element('div', { 'styles': { 'font-size': '15px'} });
            div1a3.innerHTML = item.preco;
            var div1a4 = new Element('div', { 'styles': { 'font-size': '9px', 'margin-top': '0px'} });
            div1a4.innerHTML = ',' + item.centavos + ' ' + item.unidade;

            var div1b1 = new Element('div', { 'class': 'botaoPadrao', 'styles': { 'border': '1px solid #fff', 'border-top': '0px', 'border-left': '0px', 'border-right': '0px'} });

            div1b1.innerHTML = 'COMPRAR';   

            if (diretorio=='img/collection/reinaldo/prevenda')
               {
                        var div1compra1 = new Element('form', { 'id': 'formulario' + index, 'action': 'http://www.dshop.com.br/cea/reinaldolourenco_cart.php' });
                }
                
            if (diretorio=='img/collection/amir/prevenda')
                {
                        var div1compra1 = new Element('form', { 'id': 'formulario' + index, 'action': 'http://www.dshop.com.br/cea/amirslama_cart.php' });
                
                }
            
            var div1compra11 = new Element('select', { 'name': 'tamanho', 'id': 'tamanho' });


            var div1compra12 = new Element('select', { 'name': 'qtd' });
            var div1compra122 = new Element('input', { 'name': 'id', 'type': 'hidden' });
            var div1compra123 = new Element('input', { 'name': 'codigo_produto', 'type': 'hidden' });

            var div1cores1 = new Element('div');
            div1cores1.innerHTML = "Cores:";


            var div1c1 = new Element('img', { 'src': '' });

            var div1d1 = new Element('div', { 'class': 'prevendaCabecalho' });
            div1d1.innerHTML = "";
            var div1d2 = new Element('div', { 'styles': { 'width': '210px', 'height': '200px', 'overflow': 'auto'} });
            div1d2.innerHTML = item.descricao;

            div1.inject(container);

            div1a.inject(div1);
            div1a1.inject(div1a);
            div1a2.inject(div1a);
            div1a3.inject(div1a);
            div1a4.inject(div1a);

           div1b.inject(div1);
            div1b1.inject(div1b);

            div1compra.inject(div1);
            div1compra1.inject(div1compra);
            div1compra11.inject(div1compra1);
            div1compra12.inject(div1compra1);
            div1compra122.inject(div1compra1);
            div1compra123.inject(div1compra1);

            div1cores.inject(div1);
            div1cores1.inject(div1cores);


            div1c.inject(div1);
            div1c1.inject(div1c);

            div1d.inject(div1);
            div1d1.inject(div1d);
            div1d2.inject(div1d);

            Util.montaVariantes(div1compra122, div1compra123, div1compra11, div1compra12, div1cores, div1c1, item.variantes, diretorio);

            Util.alteraCombos(div1compra122, div1compra123, div1compra11, div1compra12, div1c1, item.variantes[0].tamanhos, diretorio);


            i++;

        });
    },

    alteraQtd: function(id, id_prod, el, quantidade, valores, diretorio) {
        quantidade.empty();
        quantidade.disabled = false;
        //numero = valores[el.options[el.selectedIndex].value].qtd;
        id.value = valores[el.options[el.selectedIndex].value].id;
        id_prod.value = valores[el.options[el.selectedIndex].value].id_prod;

        opt = new Element('option', {'value': ''});
        opt.innerHTML = 'Quantidade';
        opt.inject(quantidade);

        
        // json quantidade

        urlQtd = "verificaQuantidadePrevenda.aspx?codigo="+id_prod.value+"&colecao="+diretorio;
        
        var request = new Request.JSON({
            url: urlQtd,
            onComplete: function(jsonObj) {                
                numero = jsonObj;
                
                
                for (j = 1; j <= numero; j++) {

                    opt = new Element('option', { 'value': j });
                    opt.innerHTML = j;
                    
                     if($(document.body).getElementById('esgotado')){
                        $(document.body).getElementById('esgotado').destroy();                
                    }
                    
                    opt.inject(quantidade);

                }
                if (numero == 0) {
                    opt = new Element('option', { 'value': 0 });
                    img = $(document.body).getElementById('foto_fashion');
                    
                    if($(document.body).getElementById('esgotado')){
                        $(document.body).getElementById('esgotado').destroy();                
                    }
                   
                    ddd = new Element('div', {'id': 'esgotado','styles':{'position':'absolute','zindex':'10','top':'0px','left':'0px','background-image':'url(img/collection/aviso_esgotado.gif)','width':'119px','height':'118px'}});
                    ddd.inject(img,'before');           
                   
                    opt.innerHTML = "0";

                    opt.inject(quantidade);
                    quantidade.disabled = true;
                }
                
                
            }
        }).get();

        


    },

    montaVariantes: function(id, id_prod, tamanho, quantidade, cores, foto, valores, diretorio) {
        valores.each(function(item, index) {

            div = new Element('div', { 'class': 'opcor', 'styles': { 'background-color': item.cor },
                events: {
                    click: function() {

                        Util.alteraCombos(id, id_prod, tamanho, quantidade, foto, item.tamanhos, diretorio);
                    }
                }
            });

            div.inject(cores);

        });
    },

    alteraCombos: function(id, id_prod, tamanho, quantidade, foto, valores, diretorio) {
        quantidade.empty();
        tamanho.empty();
        tamanho.removeEvents('change');


        tamanho.addEvent('change', function() {
            Util.alteraQtd(id, id_prod, tamanho, quantidade, valores, diretorio);
        });


        opt = new Element('option', { 'name': 'tamanho', 'value': '' });
        opt.innerHTML = 'Tamanho';
        opt.inject(tamanho);
      
        // adiciona quantde no box que estava vazio, epdido denis  
        opt = new Element('option', {'value': ''});
        opt.innerHTML = 'Quantidade';
        opt.inject(quantidade);



        foto.width = 142;
        foto.height = 85;
        foto.src = diretorio + '/thumb/' + valores[0].id + '.jpg';
        $('foto_fashion').src = diretorio + '/M/' + valores[0].id + '.jpg';

        valores.each(function(item, index) {

            opt = new Element('option', { 'name': 'tamanho', 'value': index });
            opt.innerHTML = item.tamanho;

            opt.inject(tamanho);

        });



    },

    loadGaleriaVertical: function(galeria, subpasta, destino, qtd, amplia) {
        zoom = amplia ? true : false;
        $('num1').innerHTML = 0;
        $('num2').innerHTML = 0;
          $('containerProdutos').setStyle('display','none');

        if($defined($('vdo'))==true){
           $('vdo').destroy();
           $('foto_fashion').setStyle('display','block');
           $('vertical_slide').setStyle('display','block');

           $('teste').setStyle('border','0px');
        }
        dest = $(destino);

        dest.empty();

        for (i = 1; i < qtd; i++) {
            
            ii = i < 10 ? '0' + i : i;



            var a = new Element('a', {
                'class': 'menuhover',
                'href': 'javascript:Util.addFotoV(\'img/collection/' + galeria + '/' + subpasta + '/' + galeria + ii + '.jpg\',' + zoom + ');',
                events: {
                    click: function() {
                        Util.ativaFotoV(this);
                    }
                }
            });


            var div1 = new Element('div', { 'class': 'containerModaCinza' });
            var div2 = new Element('div', { 'styles': { 'background-image': 'url(img/collection/' + galeria + '/' + subpasta + '/' + galeria + ii + '_thumb.jpg)'} });
            var div3 = new Element('div', { 'class': 'mascarabranca' });

            a.inject(dest);
            div1.inject(a);
            div2.inject(div1);
            div3.inject(div2);
        }


        this.loadScrollGaleriaV();
 

    },

    loadScrollGaleriaV: function() {
    
    

        if ($('galeriaFundoBrancoV')) {
            var links = $('galeriaFundoBrancoV').getElements('a');
             
            links = links.length;        
                   
                
            var totalPag = Math.ceil(links / 5);
           

            var pag = 1;
            $('num1').innerHTML = '1';
            $('num2').innerHTML = totalPag;
            var totIncrement = 0;
            var increment = 473;



            $('galeriaFundoBrancoV').setStyle('margin-top', '0px');
            // "anterior"
            /*$('MenuTop').addEvents({
                'click': function(event) {

                   

                    pag = parseInt($('num1').innerHTML);                    
                    totalPag = parseInt($('num2').innerHTML);
                    

                    if (totIncrement < 0) {
                        //alert('a = '+totIncrement);
                        $('num1').innerHTML = parseInt($('num1').innerHTML);
                        totIncrement = totIncrement + increment;
                        $('galeriaFundoBrancoV').setStyle('margin-top', totIncrement);                        
                    }

                    Init.verificaBotoesNavegacao();
                }
            });

            // "proximo"
            $('MenuBottom').addEvents({
                'click': function(event) {

                    pag = parseInt($('num1').innerHTML);

                    if (pag == 1) {
                        totIncrement = 0
                    }
                    totalPag = parseInt($('num2').innerHTML);

                    if (totalPag > pag) {
                        $('num1').innerHTML = parseInt($('num1').innerHTML);
                        totIncrement = totIncrement - increment;
                        $('galeriaFundoBrancoV').setStyle('margin-top', totIncrement);
                    }

                    Init.verificaBotoesNavegacao();
                }
            });*/
            Init.verificaBotoesNavegacao();
        }
    },

    addPromocao: function(elem, text, texto1) {

        elemento = elem.parentNode.parentNode.parentNode;

        if ($(elem.parentNode).getElement('div.PA_btPromocaoActive')) {
            $(elem.parentNode).getElement('div.PA_btPromocaoActive').addClass('PA_btPromocao');
            $(elem.parentNode).getElement('div.PA_btPromocaoActive').removeClass('PA_btPromocaoActive');
        }        
        if($(elemento).getElement('div.PA_prmocoesTextoDescricao')){
            $(elem).addClass('PA_btPromocaoActive');
            $(elemento).getElement('div.PA_prmocoesTextoDescricao').empty;
            $(elemento).getElement('div.PA_prmocoesTextoDescricao').innerHTML = text;
        }




        //$(elem).empty;
        //$(elem).innerHTML = text;

    },




    mouseOverHome: function(div) {
        $(div).style.display = '';
    },
    mouseOutHome: function(div) {
        $(div).style.display = 'none';
    },
     loadGaleriaVideo:function(nome) {
     
       //$('foto_fashion').destroy();
       $('foto_fashion').setStyle('display','none');
       $('vertical_slide').setStyle('display','none');
       $('containerProdutos').setStyle('display','none');
       //wide -> "475", "290"
		//normal -> "475, "377"
        
        /* 
        
        var flashvars = {video:	nome, tipo: "normal"};
        var params = { allowFullScreen: true, wmode: "transparent"};
        swfobject.embedSWF("swf/playercea.swf", "teste", "475", "377", "9.0.0", "expressInstall.swf",flashvars,params);
        
        */
        
       var  videoflash=new Element('div', {id: 'flashDiv'});
       var  vdo=new Element('div', {id: 'vdo'});
       videoflash.inject(vdo);
      
       vdo.inject('teste');
       var AdobePlayer= new Element('a', {href:'href="http://www.adobe.com/go/getflashplayer"'});
       var imgPlayer  = new Element('img', {src:'http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player'});
       AdobePlayer.inject('flashDiv');
       imgPlayer.inject(AdobePlayer);

        var flashvars = {video:	nome, tipo: "wide"};
        var params = { allowFullScreen: true, wmode: "transparent"};
        swfobject.embedSWF("swf/playercea.swf", "flashDiv", "475", "290", "9.0.0", "expressInstall.swf",flashvars,params);

       /*
       var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
       var MMredirectURL = window.location;
       document.title = document.title.slice(0, 47); 
       var MMdoctitle = document.title;
       var flashvars = { MMredirectURL: MMredirectURL, MMplayerType: MMPlayerType, MMdoctitle: MMdoctitle, urlVIDEO: nome };
       var params = {};
       params.menu = "false";
       params.scale = "noscale"; 
       var attributes = {};
       swfobject.embedSWF("swf/playercea.swf", "flashDiv", "477", "355", "9.0.0", "swf/expressInstall.swf", flashvars, params, attributes); */
       
     },
    // função que seleciona os videos
        
       selecionaVideo: function(nome) {
      
        var flashvars = {video:	nome, tipo: "normal" };
        var params = { allowFullScreen: true, wmode: "transparent"};
        swfobject.embedSWF("swf/playercea.swf", "flashDiv", "475", "377", "9.0.0", "expressInstall.swf",flashvars,params);
       },
       selecionaVideoWide: function(nome) {
      
        var flashvars = {video:	nome, tipo: "wide" };
        var params = { allowFullScreen: true, wmode: "transparent"};
        swfobject.embedSWF("swf/playercea.swf", "flashDiv", "475", "290", "9.0.0", "expressInstall.swf",flashvars,params);
       }

    

};