window.onload = heightRubBackgroundImage;

var userAgent = navigator.userAgent.toLowerCase();
var clickAddic = 0;
 
// Figure out what browser is being used
jQuery.browser = {
	version: (userAgent.match( /.+(?:rv|it|ra|ie|me)[\/: ]([\d.]+)/ ) || [])[1],
	chrome: /chrome/.test( userAgent ),
	safari: /webkit/.test( userAgent ) && !/chrome/.test( userAgent ),
	opera: /opera/.test( userAgent ),
	msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
	mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
};

var intervaloCatalogo = 100;
var top_n = 0;
var cntCatag = 0;
var alturaV = 0;
var contaSubidas = 0;


jQuery(document).ready(function(){
  
  clickTD();
  $(".seguinte").css("visibility", "hidden");
	$(".previous").css("visibility", "hidden");
	
  heightRubBackgroundImage();
  slideShowHome();
  jsonSlideShow();
  
  if(jQuery.browser.msie == true) {
    jQuery(".link_bannerTopProd1, .link_bannerTopProd2").css("margin-top", "10px")
  }
  
  if(jQuery.browser.mozilla == true) {
    jQuery("form input[type=text], form input[type=password]").css({"padding-top" : "5px", "padding-bottom" : "5px"})
  }
  
  
  var ipad = /ipad/.test(navigator.userAgent.toLowerCase())
	if(ipad) {
	 jQuery("body").width(jQuery(document).width());
	}
  
   
  jQuery(".elemt_menu").mouseenter(function(event){
    jQuery(this).css("z-index", "10");
    jQuery(".submenu_topo", this).fadeIn(200);
  }).mouseleave(function(event){
    jQuery(".submenu_topo", this).fadeOut(200);
    jQuery(this).css("z-index", "0");
  });
  
  //style selects
  
  jQuery('.rightselect span.selectvalue').each(function(){
    jQuery(this).text(jQuery('option:selected', jQuery(this).parent()).text());
  });
  
	jQuery('.rightselect select').change(function(){
		jQuery('span.selectvalue', this.parentNode).text(jQuery('option:selected', this).text());
	});
	
	
	//MINI-MENU
	
	var links_mini = jQuery(".mini_menu").children();
	
	jQuery(".mini_menu a").live('click', function(){
	  
	  var cnt_mini = jQuery(".line11 .cnt_selectt").children();
	  var rel = jQuery(this).attr("rel");
	  var that = jQuery(this);
    

    jQuery(cnt_mini[jQuery(".mini_menu a.sel").attr("rel")]).hide(200, function(){
      jQuery(".mini_menu a.sel").removeClass();
      that.addClass("sel");
      jQuery(cnt_mini[rel]).show(200);
    });
    
  });
  
  
  jQuery(".a_newsletter").click(function(){

  
    if(jQuery(".popPressCenter").css("display") == "block") {
      jQuery(".a_press").removeClass("sel");
      jQuery(".popPressCenter").fadeOut(500).animate({
        top : "-350px"
      }, 500);
    }
    
  
    jQuery(".popNews").fadeIn(500).animate({
      top : "-290px"
    }, 500);
    jQuery(this).addClass("sel");
    
  });
  
	jQuery(".close2").click(function(){
    jQuery(".popNews").fadeOut(500).animate({
      top : "-250px"
    }, 500);
    jQuery(".a_newsletter").removeClass("sel");
  });
  
  jQuery(".a_press").click(function(){
  
    if(jQuery(".popNews").css("display") == "block") {
      jQuery(".a_newsletter").removeClass("sel");
      jQuery(".popNews").fadeOut(500).animate({
        top : "-250px"
      }, 500);
    }
  
    jQuery(".popPressCenter").fadeIn(500).animate({
      top : "-365px"
    }, 500);
    jQuery(this).addClass("sel");
  });
  
	jQuery(".close3").click(function(){
    jQuery(".popPressCenter").fadeOut(100).animate({
      top : "-350px"
    }, 500);
    jQuery(".a_press").removeClass("sel");
  });
  
  
  /**** NOVO ****/
  
  
  heightRubBackgroundImage();
  
  jQuery(".uniradio_et").live("click", function(){
    jQuery(".uniradio_etsel").attr("class", "uniradio_et");
    jQuery(this).attr("class", "uniradio_etsel");
    var valor = jQuery(this).attr("value");
    jQuery("#hiddenInput_st").attr("value", valor);
    muda_lojas(); 
  });
  
  
  /*
  jQuery(".btAddic").click(function(){
    clickAddic = 1;
    var divOpen = ".adicionar"+addic;
    jQuery(divOpen).css("display", "block");
    addic++;
    if(addic == 3) {
      jQuery(".btAddic").css("display", "none");
    }
    
    novaAlturar = (jQuery(".rubrica").height() + jQuery(".adicionar1").height());
    jQuery(".rubrica").css("height", novaAlturar);
    
    
  });
  */
  jQuery(".btAddic").click(function(){
    var divOpen = ".adicionar"+addic;
    jQuery(".btRemov").css("display", "block");
    jQuery(divOpen).css("display", "block");
    addic++;
    jQuery(".btRemov").css("display", "block");
    if(addic == 3) {
      jQuery(".btAddic").css("display", "none");
    }
    
    novaAlturar = (jQuery(".rubrica").height() + jQuery(".adicionar1").height());
    jQuery(".rubrica").css("height", novaAlturar);
  });
  
  jQuery(".btRemov").click(function(){
    var divOpen1 = ".adicionar1";
    var divOpen2 = ".adicionar2";
    if(jQuery(divOpen2).css("display")=="block"){
      jQuery(divOpen2).css("display", "none");
      jQuery(".btAddic").css("display", "block");
    } else if(jQuery(divOpen1).css("display")=="block"){
      jQuery(divOpen1).css("display", "none");
      jQuery(".btRemov").css("display", "none");
    }
    addic--;
    
    novaAlturar = (jQuery(".rubrica").height() - jQuery(".adicionar1").height());
    jQuery(".rubrica").css("height", novaAlturar);
  });
  
  
  
  jQuery(".btAddiclg").click(function(){
    var divOpen = ".adicionarlg"+addic;
    jQuery(".btRemovlg").css("display", "block");
    jQuery(divOpen).css("display", "block");
    addic++;
    jQuery(".btRemovlg").css("display", "block");
    if(addic == 3) {
      jQuery(".btAddiclg").css("display", "none");
    }
    
    
    
    if(addic == 2) {
      //novaAlturar = (jQuery(".rubrica").height() + jQuery(".adicionarlg1").height());
      novaAlturar = 670;
    } else if(addic == 3) {
      novaAlturar = 768;
    }
    jQuery(".rubrica").css("height", novaAlturar);
    
  });
  
  jQuery(".btRemovlg").click(function(){
    var divOpen1 = ".adicionarlg1";
    var divOpen2 = ".adicionarlg2";
    if(jQuery(divOpen2).css("display")=="block"){
      jQuery(divOpen2).css("display", "none");
      jQuery(".btAddiclg").css("display", "block");
    } else if(jQuery(divOpen1).css("display")=="block"){
      jQuery(divOpen1).css("display", "none");
      jQuery(".btRemovlg").css("display", "none");
    }
    addic--;
    
    
    novaAlturar = (jQuery(".rubrica").height() - jQuery(".adicionarlg1").height());
    jQuery(".rubrica").css("height", novaAlturar);
    
  });
  
  
  jQuery(".guardaRoupa").click(function(){
    if(jQuery(".popGuarda").css("display") == "none") {
      jQuery(".popGuarda").show(500, function(){
        jQuery(".guardaRoupa").mouseleave(function(){
          jQuery(".popGuarda").hide(300);
        });
      });
    } else {
      jQuery(".popGuarda").hide(300);
    }
  });
  
  //animaNewhome();
  
  
  jQuery(".nw_lik").mouseenter(function(){
    jQuery(".init", this).show();
  }).mouseleave(function(){
    jQuery(".init", this).hide();
    filhos = jQuery(".resultsMenu");
    jQuery(filhos).css("display", "none");
  });
  
  jQuery(".nw_lik").mouseenter(function(){
    jQuery(".submenuNormal", this).show();
  }).mouseleave(function(){
    jQuery(".submenuNormal", this).hide();
  });  
  
  jQuery(".init p").click(function(){
    rel = jQuery(this).attr("rel");
    filhos = jQuery(".resultsMenu");
    jQuery(filhos).css("display", "none");
    jQuery(".init").css("display", "none");
    jQuery(filhos[rel]).css("display", "block");
  });
  
  jQuery(".resultsMenu p").click(function(){
    jQuery(filhos).css("display", "none");
    jQuery(".init").css("display", "block");
  });
  
  jQuery(".introLinguas span").click(function(){
    jQuery(".introLinguas").css("display", "none");
    jQuery(".introLinguas2").css("display", "block");
  });
   
  
  jQuery(".link_bannerTopProd1").mouseenter(function(event){
    event.stopImmediatePropagation(); 
    jQuery(".link_bannerTopProd1").css("color", "#333333");
    jQuery(".link_bannerTopProd1 table").show();
  }).mouseleave(function(event){
    event.stopImmediatePropagation(); 
    jQuery(".link_bannerTopProd1 table").hide();
    jQuery(".link_bannerTopProd1").css("color", "#B2B2B2");
  });
  
  
  jQuery(".elementRadio").click(function(){
    filhos = jQuery(".elementRadio");
    jQuery(".radioF", filhos).attr("class", "radioF");
    jQuery(".radioF", this).attr("class", "radioF selradiof");
    valor = jQuery(this).attr("value");
    jQuery("#valorRadiosF").attr("value", valor);
  });
  
  
  jQuery(".infoProduct").live('mouseenter', function(){
    jQuery(".detalheinfo").fadeIn(300);
  }).live('mouseleave', function(){
    jQuery(".detalheinfo").hide();
  });
  
});


/*** SLIDER HOME ****/


var tmpInterval = 30;
var intervalo = 0;
var intervalo2 = 0;
var widthTotal = 0;
var imgSel = 0;
var imagens = 0;
var imgNow = 0;

function slideShowHome() {
   imagens = jQuery(".imagens_home").children();
   intervalo = setInterval(progressBar, tmpInterval);
   
   
   jQuery(".bt1").click(function(){
    clearInterval(intervalo);
    clearTimeout(intervalo2);
    widthTotal = 215;
    jQuery(".barra_cinza").animate({ width: widthTotal + 1}, 300);
    trocaImagemClick(0);
    imgSel = 0;
    intervalo2 = setTimeout(tempoEspera, 7000);
   });
   
   
   jQuery(".bt2").click(function(){
    clearInterval(intervalo);
    clearTimeout(intervalo2);
    widthTotal = 389;
    jQuery(".barra_cinza").animate({ width: widthTotal + 1}, 300);
    trocaImagemClick(1);
    imgSel = 1;
    intervalo2 = setTimeout(tempoEspera, 7000);
   });
   
   jQuery(".bt3").click(function(){
    clearInterval(intervalo);
    clearTimeout(intervalo2);
    widthTotal = 569;
    jQuery(".barra_cinza").animate({ width: widthTotal + 1}, 300);
    trocaImagemClick(2);
    imgSel = 2;
    intervalo2 = setTimeout(tempoEspera, 7000);
   });
   
   jQuery(".bt4").click(function(){
    clearInterval(intervalo);
    clearTimeout(intervalo2);
    widthTotal = 759;
    jQuery(".barra_cinza").animate({ width: widthTotal + 1}, 300);
    trocaImagemClick(3);
    imgSel = 3;
    intervalo2 = setTimeout(tempoEspera, 7000);
   });
   
   jQuery(".bt5").click(function(){
    clearInterval(intervalo);
    clearTimeout(intervalo2);
    widthTotal = 951;
    jQuery(".barra_cinza").animate({ width: widthTotal + 1}, 300);
    trocaImagemClick(4);
    imgSel = 4;
    intervalo2 = setTimeout(tempoEspera, 7000);
   });
   
}

function tempoEspera() {
  clearTimeout(intervalo2);
  intervalo = setInterval(progressBar, tmpInterval);
}


function trocaImagem(imgSel) {

  
  if(imgSel == 0) {
    imgNow = 4;
  } else {
    imgNow = (imgSel - 1);
  }
  
  jQuery(imagens).css("z-index", "0");
  jQuery(imagens[imgSel]).css("z-index", "10");
  
  jQuery(imagens[imgSel]).stop().fadeIn(800, function(){
    jQuery(imagens[imgNow]).css("display", "none");
  });
  
}


function trocaImagemClick(imgSel) {
  
  jQuery(imagens).css("z-index", "0");
  jQuery(imagens[imgSel]).css("z-index", "10");
  
  jQuery(imagens[imgSel]).stop().fadeIn(800, function(){
    jQuery(imagens).css("display", "none");
    jQuery(imagens[imgSel]).css("display", "block");
  });
  
}

function progressBar() {
  widthTotal++;
  
  jQuery(".barra_cinza").css("width", widthTotal);

  if(widthTotal == 216) {
    imgSel++;
    trocaImagem(imgSel);
  }
  
  else if(widthTotal == 390) {
    imgSel++;
    trocaImagem(imgSel);
  }
  
  else if(widthTotal == 570) {
    imgSel++;
    trocaImagem(imgSel);
  }
  
  else if(widthTotal == 760) {
    imgSel++;
    trocaImagem(imgSel);
  }

  else if(widthTotal == 952) {
    imgSel = 0;
    trocaImagem(imgSel);
    widthTotal = 0;
  }
  
}

/*** SLIDER HOME ****/

//panel-container



jQuery(window).load(function(){
  clonarImagens("inicio");
  
      
  if(cntX == 1) {
    jQuery(".panel-container").css("margin-top", "-282px");
  } else {
    jQuery(".panel-container").css("margin-top", "-564px");
  }
});



var cntX = 0;

function animaLateral(val) {
  
  totalInit = jQuery(".panel-container").children();
  
  
  if(val == true) {
    jQuery(".lateral").animate({
      right : "0px"
    }, 500);
  } else {
    jQuery(".lateral").css("right", "0px");
  }
  
  
  var clickLateral = 0;
  
  jQuery(".lateral").mouseenter(function(){
      jQuery(this).animate({
        right : "0px"
      }, 1000);
  });
  
  jQuery(".lateral").mouseleave(function(){
    var posRight = jQuery(this).css("right");
    
    if(posRight == "1px" && clickLateral == 1) {
      jQuery(this).animate({
        right : "-180px"
      }, 1000);
    }
  });
  
  
  cntX++;
}

function imagemLateralSlider(){
  alturaimg = undefined;
  //filhos = jQuery(".panel").children();
  //jQuery("a", filhos).removeClass("sel");
  //jQuery(this).addClass("sel");
  clickLateral = 1;
  activoSlider = 0;
  contaPainelSel = navClicks;
}


/*************************************************                    ***********************************************/
/************************************************* ANIMAÇÃO COLECÇÕES ***********************************************/
/*************************************************                    ***********************************************/

testeGetTeste = 0;

if(testeGetTeste = 1) {

var navClicks = 1;
var carregaLateral = 0;
var animacaoFull
var fimanimacaoFull = 999999;
var contaPainelSel = 1;
var intervaloEspera101
var activoSlider = 0;
var new_inter_v;
var numeroElementPainel = 0;
var conta_1 = undefined;
var toralElementPanel = 1;
var numeroPainelSelected = 0;
var imageSelected;
var fimSlider;
var intervaloPanelSlider;
var tempoPanelSlider = 5000;
var apagarPainel = 0;
var autorixarAndamento = 1;
var intervAndamento;
var panelClone = 0;
var divClone = -1;
var panelClone_n = 0;
var divClone_n = -1;
var andamentoSlider = 0;
var cntClones = 0;
var ul_f = 0;
var ul_g = 0;
var furos = 0;
var hrefSelected;
var tempcntPainelsel;
var validaIntervalo;
var intervaloRotacao15;
var intervaloRotacao;

function iniciarIntervalo() {
  
  if(totalInit.length > 1) {
  
    intervaloRotacao = setInterval(function(){
      validaIntervalo = true;
      clearInterval(intervaloRotacao15);
      $('#coda-nav-right-1 a').click();
    }, 5000);
    
  }
    
}

//intervaloPanelSlider = setInterval(showPanelDow, tempoPanelSlider);

function animaImagemFull() {
  animaLateral(true);
  fimanimacaoFull = 999999;
  jQuery(".imagemPannel").css("top", "0px");
  alturaimg = Math.abs(jQuery(".imagemPannel img").height() - (jQuery(".panFullSize").height() + 20));

  tempo = "" + Math.round(alturaimg / 40) + "000";
  tempo++; tempo--;
  //tempo = 4000;
  
  autorixarAndamento = 1;
  
  $(".seguinte").css("visibility", "visible");
	$(".previous").css("visibility", "visible");
	
	jQuery(".imagemPannel").stop(true, false);
  jQuery(".imagemPannel").animate({"top" : -alturaimg+"px"}, tempo, 'linear', function(){
    fimanimacaoFull = -alturaimg;
    //intervaloEspera101 = setTimeout(selectNewImage, 2000);
    selectNewImage();
    //console.log("fim")
    clearInterval(int_sliderMargtpo);
  });
  
  new_inter_v = setTimeout(funcint, 400);
  
}

var int_sliderMargtpo;
function marginTopSlider() {
  int_sliderMargtpo = setInterval(functionMargintop, 100);
}

function functionMargintop() {
  jQuery(".panel-container").css("margin-top", "-282px");
}


function functionAndamento() {
  clearTimeout(intervAndamento);
  autorixarAndamento = 1;
}


function funcint() {
  clearTimeout(new_inter_v);
  activoSlider = 1;
}




function showPanelDow() {
  /*
  if(andamentoSlider == 0) {
    $('#coda-nav-right-1 a').click();
  }*/

}

var totalInit = 0;

function clonarImagens(aux){
  
  
  ul_a = jQuery(".panel-container").children();
  ul_b = jQuery(ul_a[ul_a.length-1]).children();
  ul_c = jQuery(ul_a[ul_a.length-1]);
  
  //alert(totalInit.length);
  
  if(ul_b.length < 3 && totalInit.length > 1) {//verificar se o ultimo pannel está incompleto
    
    for(m=ul_b.length; m<3; m++) {
      divClone_n++;
      ul_d = jQuery(ul_a[panelClone_n]).children();
      href = jQuery("a", ul_d[divClone_n]).attr("href");
      src = jQuery("a img", ul_d[divClone_n]).attr("src");
      desc = jQuery("a", ul_d[divClone_n]).attr("desc");
      rel = jQuery("a", ul_d[divClone_n]).attr("rel");
      imagem = jQuery("a", ul_d[divClone_n]).attr("imagem");
      grupo = jQuery("a", ul_d[divClone_n]).attr("grupo");
      //classClone = jQuery("a", ul_d[divClone_n]).attr("class");
      classClone = "imagemLateral";
      descinfo = jQuery("a", ul_d[divClone_n]).attr("descinfo");
      onclick_c = "changeGrandeImagem('"+imagem+"','"+desc+"', this,'"+descinfo+"', 'click', '"+grupo+"');";
      
      //alert("panelClone_n :: " + panelClone_n + "divClone_n :: " + divClone_n);
      
      
      furos++;
      
      if(href != "javascript:void(0);") {
        target = jQuery("a", ul_d[divClone_n]).attr("target");
        if(target == "_blank") {
          htmlTarget = "target='_blank'";
        } else {
          htmlTarget = "";
        }
        jQuery(ul_c).append('<div><a href="'+href+'" grupo="'+grupo+'" class="'+classClone+'" imagem="'+imagem+'" target="'+htmlTarget+'"><img src="'+src+'" style="width:171px; height:89px;" /></a></div>');
      } else {
        jQuery(ul_c).append('<div><a href="'+href+'" grupo="'+grupo+'" onclick="'+onclick_c+'" imagem="'+imagem+'" desc="'+desc+'" descinfo="" class="'+classClone+'" rel="'+rel+'"><img src="'+src+'" style="width:171px; height:89px;" /></a></div>');
      }
      
      
      //jQuery(ul_c).append('<div><a href="'+href+'" onClick="'+onclick+'" imagem="'+imagem+'" desc="'+desc+'" class="imagemLateral" rel="'+rel+'"><img src="'+src+'" style="width:171px; height:89px;" /></a></div>');
      
    }
    
    panelClone_n++;
    //panelClone_n++;
    
  }  
    
    
 
    
  if(aux == "inicio") {
    
    /****** PREVIOUS ******/
    
    jQuery(".panel-container").prepend("<div class='panel'></div>");
    ul_a = jQuery(".panel-container").children();
    ul_b = jQuery(ul_a[0]).children();
    ul_c = jQuery(ul_a[0]);
    
    if(divClone <= 0) {
      divClone = 3;
    }
    
    
    if(panelClone == 0) {
      panelClone = ul_a.length;
    }
    
    if(divClone == 0 || panelClone > totalInit.length) {
      panelClone--;
      if(panelClone > totalInit.length) {
        if(divClone > 0) {
          panelClone = 0;
          divClone++;
        } else {
          panelClone = totalInit.length;
          panelClone--;
        }
      }
    }
    
    ul_d = jQuery(ul_a[panelClone]).children();
    
    for(n=0; n<3; n++) {
      divClone--;
              
      imagem = jQuery("a", ul_d[divClone]).attr("imagem");
      
      if(imagem == undefined && divClone > 0) {
        divClone--;
      } else if(divClone < 0) {
        panelClone--;
        divClone = 2;
      }
      
      
      
      if(panelClone < 0) {
        panelClone = totalInit.length;
        panelClone--;
      }
      
      if(furos > 0) {
        furos--;
        divClone--;
      }
      
      if(divClone == -1) {
      divClone = 0;
      }
      
      ul_d = jQuery(ul_a[panelClone]).children();
      href = jQuery("a", ul_d[divClone]).attr("href");
      desc = jQuery("a", ul_d[divClone]).attr("desc");
      src = jQuery("a img", ul_d[divClone]).attr("src");
      rel = jQuery("a", ul_d[divClone]).attr("rel");
      imagem = jQuery("a", ul_d[divClone]).attr("imagem");
      descinfo = jQuery("a", ul_d[divClone_n]).attr("descinfo");
      grupo = jQuery("a", ul_d[divClone_n]).attr("grupo");
      onclick_c = "changeGrandeImagem('"+imagem+"','"+desc+"', this,'"+descinfo+"', 'click', '"+grupo+"');";
      //onclick_c = "changeGrandeImagem('"+imagem+"','"+desc+"', this);";
      //classClone = jQuery("a", ul_d[divClone]).attr("class");
      classClone = "imagemLateral";
      
      //alert("panelClone :: " + panelClone + "divClone :: " + divClone + " imagem :: " + imagem + " src :: " + src);
      
      //jQuery(ul_c).prepend('<div><a href="'+href+'" onclick="'+onclick+'" imagem="'+imagem+'" desc="'+desc+'" class="imagemLateral" rel="'+rel+'"><img src="'+src+'" style="width:171px; height:89px;" /></a></div>');
      
      
      if(href != "javascript:void(0);") {
        target = jQuery("a", ul_d[divClone_n]).attr("target");
        if(target == "_blank") {
          htmlTarget = "target='_blank'";
        } else {
          htmlTarget = "";
        }
        jQuery(ul_c).append('<div><a href="'+href+'" grupo="'+grupo+'" class="'+classClone+'" imagem="'+imagem+'" target="'+htmlTarget+'"><img src="'+src+'" style="width:171px; height:89px;" /></a></div>');
      } else {
        jQuery(ul_c).append('<div><a href="'+href+'" grupo="'+grupo+'" onclick="'+onclick_c+'" imagem="'+imagem+'" desc="'+desc+'" descinfo="" class="'+classClone+'" rel="'+rel+'"><img src="'+src+'" style="width:171px; height:89px;" /></a></div>');
      }
      
    }
    
    panelClone++;
    
    var ul_h = ""+jQuery(".panel-container").css("margin-top")+"";
    var ul_j = parseInt(ul_h.substring(0,ul_h.length-2));
    var ul_i = ul_j -282;
    
    jQuery(".panel-container").css("margin-top", ul_i+"px");
    
    if(window.offset != undefined) {
      var ul_k = window.offset;
      window.offset = (ul_k - 282);
			if(window.offset == ul_k){ window.offset = (ul_k - 282); }
    }
    
  } else {
    
    
    /****** NEXT ******/
    
    jQuery(".panel-container").append("<div class='panel'></div>");
    ul_a = jQuery(".panel-container").children();
    ul_b = jQuery(ul_a[ul_a.length-1]).children();
    ul_c = jQuery(ul_a[ul_a.length-1]);
    
  
    
    for(n=0; n<3; n++) {
      divClone_n++;
      
      if(divClone_n == 3) { //mudar de pannel e divClone
        panelClone_n++;
        divClone_n = 0;
      }
      
      
      //alert("panelClone_n :: " + panelClone_n + " divClone :: " + divClone);
      
      imagem = jQuery("a", ul_d[divClone_n]).attr("imagem");
      if(imagem == undefined) {
        panelClone_n = 0;
        divClone_n = 0;
      }
      
      
      ul_d = jQuery(ul_a[panelClone_n]).children();
      href = jQuery("a", ul_d[divClone_n]).attr("href");
      desc = jQuery("a", ul_d[divClone_n]).attr("desc");
      src = jQuery("a img", ul_d[divClone_n]).attr("src");
      rel = jQuery("a", ul_d[divClone_n]).attr("rel");
      imagem = jQuery("a", ul_d[divClone_n]).attr("imagem");
      //classClone = jQuery("a", ul_d[divClone_n]).attr("class");
      classClone = "imagemLateral";
      //onclick_c = "changeGrandeImagem('"+imagem+"','"+desc+"', this);";
      descinfo = jQuery("a", ul_d[divClone_n]).attr("descinfo");
      grupo = jQuery("a", ul_d[divClone_n]).attr("grupo");
      onclick_c = "changeGrandeImagem('"+imagem+"','"+desc+"', this,'"+descinfo+"', 'click', '"+grupo+"');";
      
      
      
      if(href != "javascript:void(0);") {
        target = jQuery("a", ul_d[divClone_n]).attr("target");
        if(target == "_blank") {
          htmlTarget = "target='_blank'";
        } else {
          htmlTarget = "";
        }
        jQuery(ul_c).append('<div><a href="'+href+'" grupo="'+grupo+'" class="'+classClone+'" imagem="'+imagem+'" target="'+htmlTarget+'"><img src="'+src+'" style="width:171px; height:89px;" /></a></div>');
      } else {
        jQuery(ul_c).append('<div><a href="'+href+'" grupo="'+grupo+'" onclick="'+onclick_c+'" imagem="'+imagem+'" desc="'+desc+'" descinfo="" class="'+classClone+'" rel="'+rel+'"><img src="'+src+'" style="width:171px; height:89px;" /></a></div>');
      }
      
      
      //jQuery(ul_c).append('<div><a href="'+href+'" onclick="'+onclick+'" imagem="'+imagem+'" desc="'+desc+'" class="imagemLateral" rel="'+rel+'"><img src="'+src+'" style="width:171px; height:89px;" /></a></div>');
      
      //alert("panelClone_n :: " + panelClone_n + " divClone_n :: " + divClone_n + " imagem :: " + imagem);
      
      
    }
    
    /*
    var ul_h = ""+jQuery(".panel-container").css("margin-top")+"";
    var ul_j = parseInt(ul_h.substring(0,ul_h.length-2));
    var ul_i = ul_j +282;
    
    jQuery(".panel-container").css("margin-top", ul_i+"px");*/
    
  }
    
  
  
  
  if(apagarPainel > 1 && aux != "inicio" && currentPanel > 1) {
    panelClone_n--;
    ul_a = jQuery(".panel-container").children();
    jQuery(ul_a[0]).remove();
    //alert(offset);
    jQuery(".panel-container").css("margin-top", "-564px");
    window.currentPanel = 3;
  }
  
  
  if(apagarPainel > 1 && aux == "inicio" && currentPanel > 1) {
    ul_a = jQuery(".panel-container").children();
    jQuery(ul_a[ul_a.length-1]).remove();
  }
  
  
  apagarPainel++;
  
}


var contafim = 0;

function selectNewImage() {
  //clearTimeout(intervaloEspera101);
  paneis = jQuery(".panel-container").children();
  
  //console.log("teste luis");
  
    for(i=0; i<paneis.length; i++) {
      elpanel = jQuery(paneis[i]).children();
      for(j=0; j<elpanel.length; j++) {
        elemt = jQuery("a", elpanel[j]).attr("class");
        if(elemt == "imagemLateral sel") {
            numeroPainelSelected = i;
            numeroElementPainel = j;
            toralElementPanel = elpanel.length;
            fimSlider = elpanel[j] + 1;
            //jQuery("a", elpanel[j]).attr("class", "imagemLateral");
        }
      }
    }
    
 
  
  //numeroPainelSelected
  //alert(numeroElementPainel)
  //alert(toralElementPanel)
  
  if(paneis.length + 1 > contaPainelSel) {
    
    //alert(numeroPainelSelected)
  
    tempcntPainelsel = contaPainelSel;
  
    if((toralElementPanel - numeroElementPainel) == 1) { // trocar de panel
      
      contaPainelSel++;
      
      for(i=0; i<paneis.length; i++) {
        elpanel = jQuery(paneis[i]).children();
        fim = elpanel.length;
        for(j=0; j<elpanel.length; j++) {
          elemt = jQuery("a", elpanel[j]).attr("class");
          if(elemt == "imagemLateral sel") {
              numeroPainelSelected = i;
              toralElementPanel = elpanel.length;
              //jQuery("a", elpanel[j]).attr("class", "imagemLateral");
          }
        }
      }
      
      //alert("numeroPainelSelected :: " + numeroPainelSelected + " numeroElementPainel :: " + numeroElementPainel + " toralElementPanel :: " + toralElementPanel);
      numeroPainelSelected++;
      numeroElementPainel = 0;
      
      elpanel = jQuery(paneis[numeroPainelSelected]).children();
      
      //alert(numeroPainelSelected);
      
      for(j=0; j<elpanel.length; j++) {
      
      
        if(numeroElementPainel == j) {
          hrefSelected = jQuery("a", elpanel[numeroElementPainel]).attr("href");
          
          //alert(numeroElementPainel);
          
          if(hrefSelected == "javascript:void(0);") {
            jQuery(".panel a").attr("class", "imagemLateral");
            jQuery("a", elpanel[numeroElementPainel]).attr("class", "imagemLateral sel");
          } else {
            numeroElementPainel--;
            encontrarProximaImagem();
          }
          
          imageSelected = jQuery("a", elpanel[numeroElementPainel]).attr("imagem");
          grupoSelected = jQuery("a", elpanel[numeroElementPainel]).attr("grupo");
          descSelected = jQuery("a", elpanel[numeroElementPainel]).attr("desc");
          descinfoSelected = jQuery("a", elpanel[numeroElementPainel]).attr("descinfo");
          jQuery("a", elpanel[numeroElementPainel]).attr("class", "imagemLateral sel");
        }
      }
      
      toralElementPanel = elpanel.length;
      numeroElementPainel++;
      
      //alert("teste :: " + imageSelected);
      
      if(imageSelected != undefined) {
        changeGrandeImagem(imageSelected,descSelected,'undefined',descinfoSelected,'',grupoSelected);
        //calcularMovimentos();
      }
      
      
      
      
    } else { // o painel e o mesmo
      
      elpanel = jQuery(paneis[numeroPainelSelected]).children();
      
      //alert(elpanel.length)
      
      for(j=0; j<elpanel.length; j++) {
        if(numeroElementPainel == j) {
          //alert(jQuery("a", elpanel[numeroElementPainel+1]).attr("imagem") + "\n" + imageSelected);
          hrefSelected = jQuery("a", elpanel[numeroElementPainel+1]).attr("href");
          
          if(hrefSelected == "javascript:void(0);") {
            jQuery(".panel a").attr("class", "imagemLateral");
            jQuery("a", elpanel[numeroElementPainel+1]).attr("class", "imagemLateral sel");
          } else {
            if(numeroElementPainel == 1) {
              encontrarProximaImagem2();
            } else {
              encontrarProximaImagem();
            }
          }
          
          imageSelected = jQuery("a", elpanel[numeroElementPainel+1]).attr("imagem");
          grupoSelected = jQuery("a", elpanel[numeroElementPainel+1]).attr("grupo");
          descSelected = jQuery("a", elpanel[numeroElementPainel+1]).attr("desc");
          descinfoSelected = jQuery("a", elpanel[numeroElementPainel+1]).attr("descinfo");
        }
      }
      
      toralElementPanel = elpanel.length;
      numeroElementPainel++;
      
      
      if(imageSelected != undefined) {
        changeGrandeImagem(imageSelected,descSelected,'undefined',descinfoSelected,'',grupoSelected);
      }
      
    }
    
  } else {
    
    jQuery("a", fimSlider).attr("class", "imagemLateral sel");
    
  }
  
  
}


function encontrarProximaImagem() {
  
  numeroElementPainel++;
  
  elpanel = jQuery(paneis[numeroPainelSelected]).children();

  for(j=0; j<elpanel.length; j++) {
    if(numeroElementPainel == j) {
      //alert(jQuery("a", elpanel[numeroElementPainel+1]).attr("imagem") + "\n" + imageSelected);
      hrefSelected = jQuery("a", elpanel[numeroElementPainel+1]).attr("href");
      
      if(hrefSelected == "javascript:void(0);") {
        jQuery(".panel a").attr("class", "imagemLateral");
        jQuery("a", elpanel[numeroElementPainel+1]).attr("class", "imagemLateral sel");
      } else {
        encontrarProximaImagem();
      }
      
      imageSelected = jQuery("a", elpanel[numeroElementPainel+1]).attr("imagem");
      grupoSelected = jQuery("a", elpanel[numeroElementPainel+1]).attr("grupo");
      descSelected = jQuery("a", elpanel[numeroElementPainel+1]).attr("desc");
      descinfoSelected = jQuery("a", elpanel[numeroElementPainel+1]).attr("descinfo");
    }
  }
  
  toralElementPanel = elpanel.length;
  numeroElementPainel++;
  
  
  if(imageSelected != undefined) {
    changeGrandeImagem(imageSelected,descSelected,'undefined',descinfoSelected,'',grupoSelected);
  }
  
}



function encontrarProximaImagem2() {
  
  
  
  contaPainelSel++;
      
  for(i=0; i<paneis.length; i++) {
    elpanel = jQuery(paneis[i]).children();
    fim = elpanel.length;
    for(j=0; j<elpanel.length; j++) {
      elemt = jQuery("a", elpanel[j]).attr("class");
      if(elemt == "imagemLateral sel") {
          numeroPainelSelected = i;
          toralElementPanel = elpanel.length;
          //jQuery("a", elpanel[j]).attr("class", "imagemLateral");
      }
    }
  }
  
  //alert("numeroPainelSelected :: " + numeroPainelSelected + " numeroElementPainel :: " + numeroElementPainel + " toralElementPanel :: " + toralElementPanel);
  numeroPainelSelected++;
  numeroElementPainel = 0;
  
  elpanel = jQuery(paneis[numeroPainelSelected]).children();
  for(j=0; j<elpanel.length; j++) {
    if(numeroElementPainel == j) {
      hrefSelected = jQuery("a", elpanel[numeroElementPainel]).attr("href");
      
      if(hrefSelected == "javascript:void(0);") {
        jQuery(".panel a").attr("class", "imagemLateral");
        jQuery("a", elpanel[numeroElementPainel]).attr("class", "imagemLateral sel");
      } else {
        encontrarProximaImagem();
      }
      
      imageSelected = jQuery("a", elpanel[numeroElementPainel]).attr("imagem");
      grupoSelected = jQuery("a", elpanel[numeroElementPainel]).attr("grupo");
      descSelected = jQuery("a", elpanel[numeroElementPainel]).attr("desc");
      descinfoSelected = jQuery("a", elpanel[numeroElementPainel]).attr("descinfo");
      jQuery("a", elpanel[numeroElementPainel]).attr("class", "imagemLateral sel");
    }
  }
  
  toralElementPanel = elpanel.length;
  //numeroElementPainel++;
  
  numeroElementPainel--;
  
  if(imageSelected != undefined) {
    changeGrandeImagem(imageSelected,descSelected,'undefined',descinfoSelected,'',grupoSelected);
    //calcularMovimentos();
  }
  
  
  
}




function calcularMovimentos() {
  //alert("ANDAR PAINEL :: " + navClicks + " TOCAR PAINEL PARA :: " + contaPainelSel);
 /*
 if(navClicks < contaPainelSel) {
  for(k=navClicks; k<contaPainelSel; k++) {
    $('#coda-nav-right-1 a').click();
  }
  navClicks = contaPainelSel;
 }
 
 if(navClicks > contaPainelSel) {
  for(k=contaPainelSel; k<navClicks; k++) {
    $('#coda-nav-left-1 a').click();
  }
  navClicks = contaPainelSel;
 }
  */
}

}

/*************************************************                    ***********************************************/
/************************************************* ANIMAÇÃO COLECÇÕES ***********************************************/
/*************************************************                    ***********************************************/





function animaPagina1() {
  
  jQuery(".posicao_where").show(500);
  
  jQuery(".mostraResultados").change(function(){
    if(jQuery(".resultados_selects").css("display") == "block") {
      jQuery(".resultados_selects").hide(500, function(){ 
        jQuery(".resultados_selects").show(500);  
      });
    } else {
      jQuery(".resultados_selects").show(500);
    }
    
  });
  
  jQuery(".close").live('click', function(){
    jQuery(".resultados_selects").hide(500);
  });
  
}

var intervalSets = setTimeout(funaaa, 3200);

function funaaa() {
  clearTimeout(intervalSets);
  $(".seguinte").css("visibility", "visible");
	$(".previous").css("visibility", "visible");
}

function heightRubBackgroundImage() {
  
  
  var alturaImagem = jQuery(".imBackground").height();
  var alturaRub = jQuery(".rub_img_fundo").height();
  
  if(alturaImagem > alturaRub) {
    jQuery(".rub_img_fundo").css("height", alturaImagem);
  }
  
}

/*************************/


/*************************/

function jsonSlideShow() {
  
  var objJSON = {
    "quinteto" : [
      {
        "de" : "1970",
        "ate" : "1975",
        "datas" : [
          {
            "ano" : "1973",
            "text" : "",
            "images" :[
              "images/1973.jpg"
            ]
          }
        ]
      }
    ],
    "quinteto" : [
      {
        "de" : "1975",
        "ate" : "1980",
        "datas" : [
          {
            "ano" : "1979",
            "text" : "",
            "images" :[
              "images/1979.jpg"
            ]
          }
        ]
      }
    ],
    "quinteto" : [
      {
        "de" : "1980",
        "ate" : "1985",
        "datas" : [
          {
            "ano" : "1983",
            "text" : "",
            "images" :[
              "images/1983.jpg"
            ]
          }
        ]
      }
    ],
    "quinteto" : [
      {
        "de" : "1990",
        "ate" : "1995",
        "datas" : [
          {
            "ano" : "1990",
            "text" : "",
            "images" :[
              "images/1990.jpg"
            ]
          },
          {
            "ano" : "1995",
            "text" : "",
            "images" :[
              "images/1995.jpg"
            ]
          }
        ]
      }
    ],
    "quinteto" : [
      {
        "de" : "1995",
        "ate" : "2000",
        "datas" : [
          {
            "ano" : "1997",
            "text" : "",
            "images" :[
              "images/1997.jpg"
            ]
          },
          {
            "ano" : "1999",
            "text" : "",
            "images" :[
              "images/1999.jpg"
            ]
          }
        ]
      }
    ],
    "quinteto" : [
      {
        "de" : "2000",
        "ate" : "2005",
        "datas" : [
          {
            "ano" : "2005",
            "text" : "",
            "images" :[
              "images/2005.jpg"
            ]
          }
        ]
      } 
    ]
  }
  

		
		var obj;
	
  	if(!(typeof objJSON == 'object')){
  		obj = jQuery.parseJSON(objJSON);
  	}
  	else{
  		obj = objJSON;
  	}
  	
  	var totalDados = obj.quinteto.length;
		
    //for(i in objJSON) { alert(i) }
		
		//alert(totalDados.length)
		
		//alert();
		/*
		valor = jQuery(".centro_timeline").width();
		
		jQuery(".tempos").animate({
      "margin-left" : "-100"
    }, 10000);
		*/
		
		
		//jQuery(document.createElement('div')).append(jQuery(document.createElement('a').attr().css()));
		
		
		
  
}

function getXmlHttpRequest() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
}

function getRegiao(pais) {
  
  var p = pais.value;
  
  var url ="_getregiao.php"; 	
  var post_data="p="+p;
  var cmsajaxhttp = getXmlHttpRequest();
 	cmsajaxhttp.open("GET", url+'?'+post_data, true);
  cmsajaxhttp.onreadystatechange = function(){
		if (cmsajaxhttp.readyState==4){
			var resultado = cmsajaxhttp.responseText;
			var rs = resultado.split('||');
			if (rs[1]=='OK'){
			 
        document.getElementById('loja_regs').innerHTML = rs[2];
        jQuery("#loja_regs .selectvalue").text(rs[3]);
        jQuery("#loja_regs select").css("width", "148px");
        if(jQuery('.rightselect span.selectvalue').text() == ''){
          jQuery('span.selectvalue').each(function(i){
              jQuery(this).text(jQuery('select option:selected', jQuery(this).parent()).text());
          });
        }
        
        jQuery('.rightselect select').change(function(){
          jQuery('span.selectvalue', this.parentNode).text(jQuery('option:selected', this).text());
        });
        
        jQuery(".resultados_selects").hide(500);

      }
		}
	}
 	cmsajaxhttp.send(null);
}

function getMoradas(regiao) {
  //var r = regiao.value;
  var r = regiao;
  var marca = jQuery("#hiddenInput_st").val();
  
  var url ="_getmoradas.php"; 	
  var post_data="r="+r;
  post_data = post_data+"&mrc="+marca;
  
  var cmsajaxhttp = getXmlHttpRequest();
 	cmsajaxhttp.open("GET", url+'?'+post_data, true);
  cmsajaxhttp.onreadystatechange = function(){
		if (cmsajaxhttp.readyState==4){
			var resultado = cmsajaxhttp.responseText;
			var rs = resultado.split('||');
			if (rs[1]=='OK'){
        document.getElementById('caixa_moradas').innerHTML = rs[2];
        jQuery(".resultados_selects").show(500, function(){
        var scroller = null;
    		var scrollbar = null;
    			
    		scroller = new jsScroller(document.getElementById("Scroller-1"), 607, 280);
    		scrollbar = new jsScrollbar (document.getElementById("Scrollbar-Container"), scroller, false);
      });
      } else {
        jQuery(".resultados_selects").hide(500);
      }
		}
	}
 	cmsajaxhttp.send(null);
}

function muda_lojas() {
  var pais = jQuery("#sel_pais").val();
  var regi = jQuery("#sel_regiao").val();
  
  if((pais>0) && (regi>0)){
    getMoradas(regi);
  } else {
    return false;
  }
  
}



var departamentoOpen = 0;
var addic = 1;

function preencherCandidatura(rel) {
  
  var departamentos = jQuery(".descDepartamento");
  var unidep = jQuery(".unidep");
  
  jQuery(".tp", unidep).css("background-color", "#FFFFFF");
  jQuery(".tp", unidep[rel]).css("background-color", "#F7F7F7");
  
  if(departamentoOpen == 0) {
    jQuery(".line24", unidep[rel]).show(500);
    jQuery(departamentos[rel]).show(500);
  } else {
    jQuery(".line24", unidep).hide(0);
    jQuery(departamentos).hide(0, function(){
      jQuery(".line24", unidep[rel]).show(0);
      jQuery(departamentos[rel]).show(0);
    });
  }
  
  departamentoOpen = 1;
  
}



function verify_number(field,lg){
  if (isNaN(field.value)) 
  {
    if(lg=='pt')
      alert("Só pode introduzir caracteres numéricos.");
    if(lg=='gb')
      alert("You can only enter numeric characters.");
    if(lg=='sp')
      alert("Sólo se pueden introducir caracteres numéricos.");
    if(lg=='fr')
      alert("Vous ne pouvez introduire des caractères numériques.");
      
    field.value='';
    field.focus();
  }
}



function posicionarFooter(valor) {

  if(clickAddic == 0) {
    
    jQuery(".rubrica").css({
      "height" : "0px"
    });
    
    
    if(!valor) {
      altura = jQuery(document).height() - (jQuery(".topo").outerHeight(true) + jQuery(".footer").outerHeight(true) + 55);
    } else if(valor == "1") {
      
      jQuery(".rubrica").css({
        "height" : "540px"
      });
      
      if(jQuery(".adicionarlg1").css("display")=="block") {
        jQuery(".rubrica").css({
          "height" : "670px"
        });
      } 
      
      if(jQuery(".adicionarlg2").css("display")=="block") {
        jQuery(".rubrica").css({
          "height" : "768px"
        });
      }
      
      
      
      altura = jQuery(document).height() - (jQuery(".topo").outerHeight(true) + jQuery(".footer").outerHeight(true) + 53);
    } else if(valor == "frm6") {
      
      jQuery(".rubrica").css({
        "height" : "588px"
      });
      
      if(jQuery(".adicionarlg1").css("display")=="block") {
        jQuery(".rubrica").css({
          "height" : "670px"
        });
      } 
      
      if(jQuery(".adicionarlg2").css("display")=="block") {
        jQuery(".rubrica").css({
          "height" : "768px"
        });
      }
      
      
      
      altura = jQuery(document).height() - (jQuery(".topo").outerHeight(true) + jQuery(".footer").outerHeight(true) + 53);
    } else if(valor == "rubrica") {
      altura = jQuery(document).height() - (jQuery(".topo").outerHeight(true) + jQuery(".footer").outerHeight(true) + 55);
    }
    
    
    if(altura <= 430 && valor == undefined) {
      jQuery(".rubrica").css({
        "height" : "430px"
      });
    } else {
      jQuery(".rubrica").css({
        "height" : altura + "px"
      });
    }
  }
}


  
/******** HOME *********/  
  
var cmp_site = jQuery(window).width();
var cmp_filhos = 0;
var cmp_imgsel = 1;
var cmp_anda = 0;
var activaBt = true;
var sequenciaHome = window.setInterval(IntervaloNewhome, 5000);
var t_sequenciaHome;
var contaClone = 1;

function animaNewhome(valor) {
  
  if(valor != "on") {
    cmp_site = jQuery(document).width();
    jQuery(".centerGaleria, .pannel").width(cmp_site);
  }
  
  /* redimencionar imagens */
  
  if(jQuery("div", cmp_filhos[cmp_imgsel]).attr("class") == "movie") {
    jQuery(".bannerTopProd").hide();
    jQuery(".bannerFooter").hide();
    alt1 = jQuery(".contentNewHome, .pannel").height();
    jQuery(".contentNewHome, .pannel, .movie").height(alt1);    
    cnt2 = (alt1 / 2) - (jQuery(".next").height() / 2);
    jQuery(".next, .previous").css({"top" : cnt2+"px"})
  } else {
    alt1 = jQuery(window).height() - (jQuery(".topo").outerHeight(true) + jQuery(".bannerFooter").outerHeight(true) + jQuery(".footer").outerHeight(true) + jQuery(".bannerTopProd").outerHeight(true) + 3);
    if(alt1 <= 411) {
      alt1 = 411;
    }
    jQuery(".contentNewHome, .pannel").height(alt1);
    cnt2 = (alt1 / 2) - (jQuery(".next").height() / 2);
    jQuery(".next, .previous").css({"top" : cnt2+"px"});
  }
  
  
  if(valor != "on") {
    cmp_filhos = jQuery(".pannel");
    for(i=0; i<cmp_filhos.length; i++) {
      jQuery("img", cmp_filhos[i]).attr("altura", jQuery("img", cmp_filhos[i]).height());
      perc = (Math.abs(jQuery("img", cmp_filhos[i]).attr("posy")) * 100) / parseInt(jQuery("img", cmp_filhos[i]).attr("altura"));
      jQuery("img", cmp_filhos[i]).width(cmp_site);
      posY = -((jQuery("img", cmp_filhos[i]).height() * perc) / 100);
      jQuery("img", cmp_filhos[i]).css("top", posY);
    }
    for(i=0; i<cmp_filhos.length; i++) {
      jQuery("img", cmp_filhos[i]).attr("altura", jQuery("img", cmp_filhos[i]).height());
      perc = (Math.abs(jQuery("img", cmp_filhos[i]).attr("posy")) * 100) / parseInt(jQuery("img", cmp_filhos[i]).attr("altura"));
      jQuery("img", cmp_filhos[i]).width(cmp_site);
      posY = -((jQuery("img", cmp_filhos[i]).height() * perc) / 100);
      jQuery("img", cmp_filhos[i]).css("top", posY);
    }
  }
  
  cmp_site = jQuery(document).width(); 
  negativo = -(cmp_site * cmp_imgsel);
  if(valor != "on") {
     jQuery(".contentNewHome").css({"left" : negativo});
  }
  
  /* redimencionar imagens */
  
}


function IntervaloNewhome() {
  cmp_filhos = jQuery(".pannel");
  animaNewhome();
  
    if(activaBt == true) {
      
      activaBt = false;
            
      cmp_imgsel++;
      contaClone++;
      
      if(contaClone == images.length) {
        contaClone = 0;
      }
      
      stylePanel = jQuery(".pannel").attr("style");
      jQuery(".contentNewHome").append("<div class='pannel' style='"+stylePanel+"'><img src='"+images[contaClone]+"' posy='-10'/></div>");
      jQuery(".pannel img").css("width", jQuery(document).width()+"px");
      cmp_filhos = jQuery(".pannel");
      cmp_anda = -(jQuery(document).width() * cmp_imgsel);
      
      
      if(jQuery("div", cmp_filhos[cmp_imgsel]).attr("class") == "movie") {
        jQuery(".bannerTopProd").hide();
        jQuery(".bannerFooter").hide();
        alt1 = jQuery(".contentNewHome, .pannel").height() + jQuery(".bannerFooter").height() + 27;
        jQuery(".contentNewHome, .pannel, .movie").height(alt1);    
        cnt2 = (alt1 / 2) - (jQuery(".next").height() / 2);
        jQuery(".next, .previous").css({"top" : cnt2+"px"})
      } else {
        jQuery(".bannerTopProd").show();
        jQuery(".bannerFooter").show();
        animaNewhome("on");
      }
      
      jQuery(".contentNewHome:not(:animated)").animate({"left" : cmp_anda}, 600, function(){
        jQuery(cmp_filhos[0]).remove();
        cmp_imgsel--;
        cmp_anda = -(jQuery(document).width() * cmp_imgsel);
        jQuery(".contentNewHome").css("left", cmp_anda+ "px");
        activaBt = true;
      });
      
    }
}

function tempoEsperaNewHome() {
  clearTimeout(t_sequenciaHome);
  sequenciaHome = window.setInterval(IntervaloNewhome, 5000);
}


var images = new Array();

function buttonsNewhome(myString) {
  
  images = myString.split('||'); 
  
  cmp_anda = -(jQuery(document).width() * cmp_imgsel);
  jQuery(".contentNewHome").css("left", cmp_anda+"px");
  jQuery(".contentNewHome").append("<div class='pannel'><img src='"+images[images.length-1]+"' posy='-10'/></div>");
  for(i=0; i<2; i++) {
    jQuery(".contentNewHome").append("<div class='pannel'><img src='"+images[i]+"'/></div>");
  }
  jQuery(".newGaleriaHome .previous").css("display", "block");
  
  animaNewhome();
  
  jQuery(".newGaleriaHome .next").click(function(){
    if(activaBt == true) {
      activaBt = false;
      clearInterval(sequenciaHome);
      clearTimeout(t_sequenciaHome);
      t_sequenciaHome = window.setTimeout(tempoEsperaNewHome, 10000);
      
      cmp_imgsel++;
      contaClone++;
      
      if(contaClone == images.length) {
        contaClone = 0;
      }
      
      stylePanel = jQuery(".pannel").attr("style");
      jQuery(".contentNewHome").append("<div class='pannel' style='"+stylePanel+"'><img src='"+images[contaClone]+"' posy='-10'/></div>");
      jQuery(".pannel img").css("width", jQuery(document).width()+"px");
      cmp_filhos = jQuery(".pannel");
      cmp_anda = -(jQuery(document).width() * cmp_imgsel);
      
      
      if(jQuery("div", cmp_filhos[cmp_imgsel]).attr("class") == "movie") {
        jQuery(".bannerTopProd").hide();
        jQuery(".bannerFooter").hide();
        alt1 = jQuery(".contentNewHome, .pannel").height() + jQuery(".bannerFooter").height() + 27;
        jQuery(".contentNewHome, .pannel, .movie").height(alt1);    
        cnt2 = (alt1 / 2) - (jQuery(".next").height() / 2);
        jQuery(".next, .previous").css({"top" : cnt2+"px"})
      } else {
        jQuery(".bannerTopProd").show();
        jQuery(".bannerFooter").show();
        animaNewhome("on");
      }
      
      jQuery(".contentNewHome:not(:animated)").animate({"left" : cmp_anda}, 600, function(){
        jQuery(cmp_filhos[0]).remove();
        cmp_imgsel--;
        cmp_anda = -(jQuery(document).width() * cmp_imgsel);
        jQuery(".contentNewHome").css("left", cmp_anda+ "px");
        activaBt = true;
      });
        
    }
  });
  
  
  jQuery(".newGaleriaHome .previous").click(function(){
    if(activaBt == true) {
      activaBt = false;
      clearInterval(sequenciaHome);
      clearTimeout(t_sequenciaHome);
      t_sequenciaHome = window.setTimeout(tempoEsperaNewHome, 10000);
      
      cmp_imgsel++;
      
      if(contaClone == 0) {
        contaClone = images.length-1;
      }
      
      stylePanel = jQuery(".pannel").attr("style");
      jQuery(".contentNewHome").prepend("<div class='pannel' style='"+stylePanel+"'><img src='"+images[contaClone]+"' posy='-10'/></div>");
      jQuery(".pannel img").css("width", jQuery(document).width()+"px");
      prev_cmp_anda = -(jQuery(document).width() * cmp_imgsel);
      jQuery(".contentNewHome").css("left", prev_cmp_anda + "px");
      
      cmp_imgsel--;
      cmp_filhos = jQuery(".pannel");
      cmp_anda = -(jQuery(document).width() * cmp_imgsel);
      
      
      if(jQuery("div", cmp_filhos[cmp_imgsel]).attr("class") == "movie") {
        jQuery(".bannerTopProd").hide();
        jQuery(".bannerFooter").hide();
        alt1 = jQuery(".contentNewHome, .pannel").height() + jQuery(".bannerFooter").height() + 27;
        jQuery(".contentNewHome, .pannel, .movie").height(alt1);    
        cnt2 = (alt1 / 2) - (jQuery(".next").height() / 2);
        jQuery(".next, .previous").css({"top" : cnt2+"px"})
      } else {
        jQuery(".bannerTopProd").show();
        jQuery(".bannerFooter").show();
        animaNewhome("on");
      }
      
      jQuery(".contentNewHome:not(:animated)").animate({"left" : cmp_anda}, 600, function(){
        jQuery(cmp_filhos[cmp_filhos.length-1]).remove();
        activaBt = true;
      });
      
      
      contaClone--;
        
    }
  });

}


/************* INTRO ***********/

var intr_imagemSel = 0;
var intr_imagens;
var intr_total;
var intr_animacao;
var intr_intervalo1;
var intr_intervalo2;
var intr_top = 0;
var intr_left = 0;
var max_top = 0;
var posY = 0;
var posleft = 0;
var tmpduracao = 0;
var intduracao = 0;
var comprWidth = 0;
var str;
var strWidth;
var stageWidth = jQuery("body").width();
var stageHeight = 688;
var alturaImg = 0;
var perc = 0;
var percTop = 0;
var imgIntro;
var prevImage
var parImage = 1;
var prev_imgIntro = 99;
var cntEntradas = 0;


function init_animaIntro() {
  intr_total = myJSONObject.length; 
  jQuery(".bg").css("z-index", "0");
  
  imgIntro = jQuery(document.createElement('img')).attr({
    "class" : "bg",
    "src" : myJSONObject[intr_imagemSel].src
  }).css({"z-index" : "100", "display" : "none", "height" : "auto"});
  
  jQuery(".imagemsIntro").append(jQuery(document.createElement('a')).attr("href", "index.php?id=74").append(imgIntro));
  jQuery(imgIntro).load(animaIntro);
}


function animaIntro() {
  
  
  clearTimeout(intr_intervalo1);
  
  alturaImg = jQuery(imgIntro).height();
  stageWidth = jQuery("body").width();
  if(stageWidth < 1024) {
    stageWidth = 1024;
  }
  
  
  
  if(cntEntradas > 1) {
    filhos = jQuery(".imagemsIntro").children();
    jQuery(filhos[0]).remove();
  }
  
  intr_animacao = myJSONObject[intr_imagemSel].animacao;
  tmpduracao = parseInt(myJSONObject[intr_imagemSel].tempoAnimacao);
  intduracao = parseInt(myJSONObject[intr_imagemSel].intervalo);
  

  jQuery(imgIntro).stop().width(stageWidth).css({"opacity" : 100, "filter" : "alpha(opacity=100)"});
  

  animacoesIntro();
  
  jQuery(window).bind('resize', function() {
    clearTimeout(intr_intervalo1);
    stageWidth = jQuery("body").width();
    if(stageWidth < 1024) {
      stageWidth = 1024;
    }
    jQuery(imgIntro).width(stageWidth).stop().css({"opacity" : 100, "filter" : "alpha(opacity=100)"});
    
    
    animacoesIntro();
    
  });
  
  
  intr_imagemSel++;
  
  if(intr_imagemSel == intr_total) {
    intr_imagemSel = 0;
  }
  
  imgIntro = jQuery(document.createElement('img')).attr({
    "class" : "bg",
    "src" : myJSONObject[intr_imagemSel].src
  }).css({"z-index" : "100", "display" : "none", "height" : "auto"});
  
  jQuery(".imagemsIntro").append(jQuery(document.createElement('a')).attr("href", "index.php?id=74").append(imgIntro));
  
  cntEntradas++;

}

function animacoesIntro(){
  
  if(intr_animacao == "Vertical") {
  
    perc = (Math.abs(myJSONObject[intr_imagemSel].posy) * 100) / alturaImg;
    posY = -((jQuery(imgIntro).height() * perc) / 100);
    percTop = (Math.abs(myJSONObject[intr_imagemSel].maxtop) * 100) / alturaImg;
    max_top = -((myJSONObject[intr_imagemSel].posy * percTop) / 100);
    jQuery(imgIntro).css({"top" : posY+"px"});
    jQuery(imgIntro).fadeIn({ queue: false, duration: 3000 });
    jQuery(imgIntro).animate({ "top" : max_top+"px" }, { queue: false, duration: tmpduracao });
    intr_intervalo1 = setTimeout(animaIntro, (tmpduracao + intduracao) - 4000);
    
    
  } else if(intr_animacao == "Horizontal") {
  
    posleft = myJSONObject[intr_imagemSel].left;
    posY = (stageWidth * (myJSONObject[intr_imagemSel].posy) / 1280);
        
    comprWidth = jQuery(imgIntro).width();
    strWidth = parseInt(posleft.substring(1,(posleft.length)));
    jQuery(imgIntro).width(comprWidth + strWidth);
    jQuery(imgIntro).css({"left" : posleft+"px", "top" : posY+"px"});
    jQuery(imgIntro).fadeIn({ queue: false, duration: 3000 });
    jQuery(imgIntro).animate({ "left" : "0px", "width" : comprWidth+"px" }, { queue: false, duration: tmpduracao });
    intr_intervalo1 = setTimeout(animaIntro, (tmpduracao + intduracao) - 4000);
  
  } else if(intr_animacao == "Fade In") {
   
    perc = (Math.abs(myJSONObject[intr_imagemSel].posy) * 100) / alturaImg;
    posY = -((jQuery(imgIntro).height() * perc) / 100);
    jQuery(imgIntro).css({"top" : posY+"px"});
    jQuery(imgIntro).fadeIn(3000);
    intr_intervalo1 = setTimeout(animaIntro, (tmpduracao + intduracao) - 4000);
    
  }
  
}

function resizeIntro() {
  /*stageWidth = jQuery("body").width();
  if(stageWidth < 1024) {
    stageWidth = 1024;
  }*/
  
  jQuery(imgIntro).removeData();
  
  //console.log(imgIntro);
  
  //animaIntro();
}



function verif_form_newsletter(frm,erro1){
  var check1 = document.getElementById('N4').checked;
  var check2 = document.getElementById('N5').checked;
  
  if(check1==false && check2==false){
    alert(erro1);
    return false;
  }
  
  return verify_form_data(frm,'THISFORMNL');
}

function monta_menu_groupa(idp){
  var params = {id:idp};
  var str = jQuery.param(params);
  var aux = 0;
  
  jQuery.ajax({
    url: '_get_menu_groupa.php',
    data:str,
    success: function(data) {
      if(data!='||NOK||') {
        if(document.getElementById("groupa_html2")) {
          document.getElementById("groupa_html2").style.display = "none";
        }
        
        if(document.getElementById("groupa_html").style.display == "none") {
          
          document.getElementById("groupa_html").style.display = "block";
        }
  			$('#groupa_html').html(data);
  		}
      //alert(data);
      //$('#detalhe_aniv').html(data);
      //location = 'index.php?id='+rub;
    }
  })
  
  return aux;
}

function addgroupa() {
  var idp = document.getElementById("id").value;
  var fam = document.getElementById("fam").value;
  var sfm = document.getElementById("sfam").value;
  var grp = document.getElementById("grp").value;
  var tkn = document.getElementById("token").value;
  
  var params = {id:idp,f:fam,sf:sfm,gp:grp,tk:tkn};
  var str = jQuery.param(params);
  var aux = 0;
  
  jQuery.ajax({
    url: 'actions_wardrobe_ajax.php',
    data:str,
    success: function(data) {
      var rs = data.split('||');
			if (rs[1]=='OK') {
        monta_menu_groupa(idp);
        alert(rs[2]);
			}
      //alert(data);
     //$('#detalhe_aniv').html(data);
     //location = 'index.php?id='+rub;
    }
  })
  
  return aux;
}

function addgroupa2(idp,fam,sfm,grp,tkn) {
  
  //window.mousedown = false;
  
  var params = {id:idp,f:fam,sf:sfm,gp:grp,tk:tkn};
  var str = jQuery.param(params);
  var aux = 0;
  
  jQuery.ajax({
    url: 'actions_wardrobe_ajax.php',
    data:str,
    success: function(data) {
      var rs = data.split('||');
			if (rs[1]=='OK') {
        monta_menu_groupa(idp);
        alert(rs[2]);
			}
      //alert(data);
     //$('#detalhe_aniv').html(data);
     //location = 'index.php?id='+rub;
    }
  })
  
  return aux;
}

function clickTD(){
  $('.tabela_inc td').click(function(){
    $('input',this).attr('checked','checked');
  })
}
function viewChecked(str){
  var radios = $('.tabela_inc input[type=radio]');
  var cont = 0;
  var contador = 0;
  for(i = 0; i<radios.length; i++){
    cont++;
    checked = $(radios[i]).attr('checked');
    
    if(checked == true){
      contador = 1;
    }
    
    if(contador == 0){
      
      pai = $(radios[i]).parents("tr");
      $(pai).css('background-color','#FFE5E5');
      $('td:first-child + td',pai).css('background-color','#FFFFFF');
    } else {
      pai = $(radios[i]).parents("tr");
      $(pai).css('background-color','transparent');
    } 
    
    
    if(cont==6)
    {
       cont = 0;
       contador =0;
    } 
  }  
  
  
  
  var tamanho = $('.tabela_inc input:checked').length;
  if(tamanho == 19){
    return true;
  } else {
    alert(str)
  }
  return false;
}


