var numbr=1;
var numbr2=1;
var tipo="Appear";
var randprodDest;
var randprodDest2;
var randprodDest2;
var blcImgs1=new Array();
var blcImgs2=new Array();
function randomProd(){

randprodDest = self.setInterval(function (){

if(numbr!=blcImgs1.length-1){
  numbr++;
}else{
  numbr=1;
}
if(numbr!=blcImgs2.length-1){
  numbr2++;
}else{
  numbr2=1;
}

Effect.Appear("imgBLC1", { duration: 5.0,from:1,to:1,afterFinishInternal:function (){Effect.Fade("imgBLC1", { duration: 5.0,from:1,to:1});}});
Effect.Appear("imgBLC2", { duration: 5.0,from:1,to:1,afterFinishInternal:function (){Effect.Fade("imgBLC2", { duration: 5.0,from:1,to:1});}});


muda_img(blcImgs1[numbr],blcImgs2[numbr2],numbr);
},"10000");
}





function muda_img(id,id2,pos){

window.clearInterval(randprodDest);
numbr=pos;

var obj1 = document.getElementById('imgBLC1');
var obj2 = document.getElementById('imgBLC2');

var serverPage ="destaque1.php";
var params = "id="+id+"&id2="+id2+"&pos="+pos;


xmlhttp.open("GET",serverPage+"?"+params);
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState == 1) {
  //obj.innerHTML="<div style='width:477px;height:277px;' align='center' valign='middle'><img src='./sysimages/ajax-loader.gif' border='0' style='margin-top:100px;'></div>";
}else if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
  
  var resultado = xmlhttp.responseText;
  var res = resultado.split("|*|");
  
  obj1.innerHTML = res[0];
  obj2.innerHTML = res[1];
  document.getElementById('titProd1').innerHTML = res[2];
  document.getElementById('subtitProd1').innerHTML = res[3];
  document.getElementById('titProd2').innerHTML = res[4];
  document.getElementById('subtitProd2').innerHTML = res[5];    
  randomProd();
}
}
xmlhttp.send(null);
}

// JavaScript Document

function showSub(id)
{
  document.getElementById(id).style.display = "block";
}

function hideSub(id)
{
  document.getElementById(id).style.display = "none";
}


function loadScript() {
  var script = document.createElement("script");
  script.setAttribute('id', 'gscript');
  script.type = "text/javascript";
  script.src = "http://maps.google.com/maps?file=api&v=2.x&key=ABQIAAAAzvLh3KbZlhobsg5AgoKdmxQbdHbScjNT1Y8uuvzT2qysa7vNpRSGGft8K0d93GDsoE0QRE7mFuHyxA&async=2";
  if(document.getElementById("gscript")==null){
  document.body.appendChild(script);
  }
  
}


// SUBMENU
function showMap(id,id2,cord0,cord1)
{  
  for(i = 1; i < mapas.length; i++){
    //alert(i);
    document.getElementById('mapa' + i).style.display = "none";
    //document.getElementById('BtnMais' + i).src = "sysimages/btnmais.jpg";
    //document.getElementById('MouseLnk_' + i).onclick = mapasOnclick1[i];
    
    //alert(mapasOnclick1[i]);
    
  }
  //var id3=id2.split("mapa");
  //document.getElementById('MouseLnk_' + id3[1]).onclick = function () {hideSub("mapa" + id3[1]);}
  //document.getElementById('BtnMais' + id3[1]).src = "sysimages/btnmenos.jpg";
  document.getElementById(id2).style.display = "";
  if(cord0!="" && cord1!=""){
    loadScript();
    Effect.Appear(id, { duration: 5.0,from:0,to:1,afterFinishInternal:function (){loadMap(id,cord0,cord1);}});
  }
  
  
}

function verifica_pesq(form) {

var formulario = document.getElementById(form)
var txt=formulario.pesq;
var texto = txt.value;
var error;

  if((txt.value=="") || (txt.value==unescape(json[63]))){
      alert(unescape(json[64]));
      error=1;
  }else if(txt.value!="" &&  texto.length<3){
      alert(unescape(json[65]));
      error=2;
      
  }

  if((txt.value!=unescape(json[63])) && (texto.value!="") && (texto.length>=3)){
     error=0;
  }
  
  if(error>0){
    return false;
  }else {
    return document.getElementById(form).submit();
  }
  
  
}


function RenderTTFH(){
  
   DATAFUNCS.RenderFonts('tituloH1Geral',{ 
       fontSize         : '15',
       backgroundColor  : 'F0F0F0',
       color            : '333333',
       fontFile         : 'fonts/MM215600.TTF',
       transparent      : '1'
    }); 
    
}

function mostraSubCat(id){



var obj1 = document.getElementById('subcat');
var cat = document.getElementById('cat').value;


var serverPage ="subcategorias.php";
var params = "id="+id+"&cat="+cat;


xmlhttp.open("GET",serverPage+"?"+params);
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState == 1) {
  //obj.innerHTML="<div style='width:477px;height:277px;' align='center' valign='middle'><img src='./sysimages/ajax-loader.gif' border='0' style='margin-top:100px;'></div>";
}else if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
  
  var resultado = xmlhttp.responseText;
  
  obj1.innerHTML = resultado;
  document.getElementById("frm_filtro").submit();
    
  
}
}
xmlhttp.send(null);
}


var not=0;
function changeNotDest(){
  
  not++;  
  if (not>2){
    not = 0;
  }    
      
  document.getElementById('titNotDest').innerHTML = _obj[not]['nomept'];
  document.getElementById('txtNotDest').innerHTML = _obj[not]['descpt'];
  document.getElementById('dataNotDest').innerHTML = _obj[not]['data'];
  document.getElementById('picNotDest').innerHTML = _obj[not]['imagem'];
  
  setTimeout(changeNotDest,10000);
            
}

var contaDest = 0;
function changeHomeDest1(){
  
  contaDest++;
  if (contaDest>4){
    contaDest=0;
  }
  
  document.getElementById('imgBLC1').innerHTML = _dest1[contaDest]['imagem'];
  document.getElementById('titProd1').innerHTML = _dest1[contaDest]['tit'];
  document.getElementById('subtitProd1').innerHTML = _dest1[contaDest]['subtit'];    
  
  setTimeout(changeHomeDest1,7500);
  
  //setInterval(changeHomeDest1, 5000);      
  
}

var contaDest2 = 0;
function changeHomeDest2(){
  
  contaDest2++;
  if (contaDest2>4){
    contaDest2=0;
  }
  
  document.getElementById('imgBLC2').innerHTML = _dest2[contaDest2]['imagem'];
  document.getElementById('titProd2').innerHTML = _dest2[contaDest2]['tit'];
  document.getElementById('subtitProd2').innerHTML = _dest2[contaDest2]['subtit'];    
  
  setTimeout(changeHomeDest2,7500);
  //setInterval(changeHomeDest2, 5000);      
  
}

