var site = $('meta[name=root]').attr('content');
var page = $('meta[name=page]').attr('content');
var lang = $('meta[name=lang]').attr('content');
var jornal = $('meta[name=jornal]').attr('content');
var url = $('meta[name=url]').attr('content');
var cords = $('meta[name=cords]').attr('content');
var qdt = $('meta[name=qdt]').attr('content');

var instance;
var instance2;

function getFlashMovieObject(movieName)
{
  if (window.document[movieName]) 
  {
      return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}

function setVideo(codigo)
{
  var flashMovie = getFlashMovieObject("flashVideo");
  flashVideo.setVideo(codigo);
}

$(document).ready(function(){

	//Fecha PopUP
	$('.popup2 img').click(function(){
		$('#backblack1').addClass('visiblecaixa');
	});
	$('#backblack3').click(function(){
		$('#backblack1').removeClass('visiblecaixa');
	});
	


    
    setHorizontalMoveCategorias();
  
    changeLinguas();
    
    if(page == "contato" || page == "chamado" || page == "rastreamento" || page == "downloads" || page == "licitacoes" || page == "trabalhe" || page == "dmp-download" || page == "ocorrencia-form" || page == "unidades")
    {
      $(".jqtransform").jqTransform();
    }
    
    callHorizontalMove();
    
    mouseHold();
    
    callSubMenu();
    
    destaquesSelected();
    
    imprimeFicha();
    
    if(page == "faq" || page == "faq-geral")
    {
      faq_suporte();
    } 
    
    if(page == "releases")
    {
      faq_suporte();
    } 
    
    if(page == "produtos-faq")
    {
      faq();   
    }
    
    if(page == "contato")
    {
      newsletter();
      envia_contato();
      addGoogleMaps();
    }
    
    if(page == "chamado")
    {
       envia_chamado();
    }
    
    if(page == "licitacoes")
    {
       envia_licitacoes();
    }
    
    if(page == "produtos-indique")
    {
       envia_indique();
    }
    
    $('#close-popup').click(function() {
       $('#pop-download').css('display', 'none');
    });
    
    $('.lightbox').lightBox();
    
    /**
     * Unidades
     * */
    if(page == "unidades")
    {
      envia_unidade();  
      addMapUnidades();
    }
    
    if(page == "passeio")
    {
       envia_passeio();
    }
    
    if(page == "produtos-videos")
    {
      setVideoSWF(); 
      
      //setVideo(jornal);
    }
    
    addMenuPadrao();
    
    novoMenu();
    
    setCategoriaHover();

    timeline();
    
    setItemProdutos();

    setItemGalery();
    
    setFlash();
    
    setHomeNovidades();
    
    setRodapeLinks();
    
    setPasseio();
    
    setJornal();
    
    setMenuInicial();
    
    anexar();
    
    envia_trabalhe();
    
    envia_download();
    
    envia_ocorrencia();
    
    if (page == 'chatter') {
    	chatterBot();
    }
});


function envia_ocorrencia(){
  $("#form-ocorrencia").submit(function(){
   return false;    
 });
 
 var options = 
 {   
   beforeSubmit:  showRequest,  
   success:       showResponse 
 }; 

 function showRequest(formData, jqForm, options) 
 { 
   
 }

 function showResponse(data)
 {
   if($.trim(data) == "true")
   {
     $("#erro-work").html(__('instrucoes_sucesso'));
     
     $("#form-ocorrencia").clearForm();
     
     setTimeout(function(){
       $("#erro-work").html("");
     },5000);
           
   }else{
     
     $("#erro-work").html(__('erro')); 
     
     setTimeout(function(){
       $("#erro-work").html("");
     },5000);
   }
 }
  
  $("#form-ocorrencia").validate({
     rules: {
       'contato':{required:true},
       'departamento':{required:true}, 
       'endereco':{required:true},
       'cidade':{required:true},
       'estado':{required:true},
       'ddd':{required:true},
       'telefone':{required:true},
       'defeito':{required:true},
       'comentario':{required:true}
     },
     messages: {
       contato:{required:__('contato')},
       departamento:{required:__('departamento')},       
       endereco:{required:__('endereco')},
       cidade:{required:__('cidade')},
       estado:{required:__('estado')},
       ddd:{required:__('ddd')},
       telefone:{required:__('telefone')},
       defeito:{required:__('defeito')},
       comentario:{required:__('comentario')}
     },
     submitHandler:function(){ 
       $("#erro-work").html(__('aguarde')); 
       $("#form-ocorrencia").ajaxSubmit(options);
     },
     errorLabelContainer: $("#erro-trabalhe")
 }); 
}

function downloadFile(codigo)
{
  var files=[codigo];if(codigo){var tempIFrame=document.createElement('iframe');tempIFrame.setAttribute('name','IFrameDownload');tempIFrame.style.border='0px';tempIFrame.style.width='0px';tempIFrame.style.height='0px';var iptCodigo=document.createElement('input');iptCodigo.type="hidden";iptCodigo.name="codigo";iptCodigo.value=codigo;var form=document.createElement('form'); form.action= site + '/download';form.method='POST';form.appendChild(iptCodigo);form.target='IFrameDownload';document.body.appendChild(tempIFrame);document.body.appendChild(form); form.submit();}
}

function envia_download(){
 
  $("#form-download-dmp").submit(function(){
   return false;    
 });
 
 var options = 
 {   
   beforeSubmit:  showRequest,  
   success:       showResponse 
 }; 

 function showRequest(formData, jqForm, options) 
 { 
   
 }

 function showResponse(data)
 {
   if($.trim(data) == "true")
   {
     $("#erro-work").html(__('instrucoes_sucesso'));
     
     $("#form-download-dmp").clearForm();
     
     setTimeout(function(){
       $("#erro-work").html("");
     },5000);
           
   }else{
     
     $("#erro-work").html(__('erro')); 
     
     setTimeout(function(){
       $("#erro-work").html("");
     },5000);
   }
 }
  
  $("#form-download-dmp").validate({
     rules: {
       'contato':{required:true},
       'nome-da-empresa':{required:true},       
       'ddd':{required:true},
       'telefone':{required:true},
       'cnpj':{required:true},
       'empresa':{required:true},
       'endereco':{required:true},
       'cidade':{required:true},
       'estado':{required:true},
       'cep':{required:true},
       'nfuncionarios':{required:true},
       'email':{required:true, email:true}
     },
     messages: {
       contato:{required:__('contato')},
       'nome-da-empresa':{required:__('nome-da-empresa')},       
       ddd:{required:__('ddd')},
       telefone:{required:__('telefone')},
       cnpj:{required:__('cnpj')},
       endereco:{required:__('endereco')},
       cidade:{required:__('cidade')},
       estado:{required:__('estado')},
       cep:{required:__('cep')},       
       nfuncionarios:{required:__('n_fun')},
       email:{required:__('email'), email:__('email_invalido')}
     },
     submitHandler:function(){ 
       $("#erro-work").html(__('aguarde')); 
       $("#form-download-dmp").ajaxSubmit(options);
     },
     errorLabelContainer: $("#erro-trabalhe")
 }); 
}

function envia_trabalhe(){
  $("#trabalhe-conosco").submit(function(){
   return false;    
 });
 
 var options = 
 {   
   beforeSubmit:  showRequest,  
   success:       showResponse 
 }; 

 function showRequest(formData, jqForm, options) 
 { 
   
 } 

 function showResponse(data)  
 {
   if($.trim(data) == "true")
   {
     $("#erro-work").html(__('enviado'));
     
     $("#trabalhe-conosco").clearForm();
     
     setTimeout(function(){
       $("#erro-work").html("");
     },2000);
           
   }else{
     
     $("#erro-work").html(__('erro')); 
     
     setTimeout(function(){
       $("#erro-work").html("");
     },2000);
   }
 }
  
  $("#trabalhe-conosco").validate({
     rules: {
       'nome':{required:true},
       'email':{required:true, email:true},
       'ddd':{required:true},
       'telefone':{required:true},
       'endereco':{required:true},
       'bairro':{required:true},
       'cidade':{required:true},
       'cep1':{required:true},
       'cep2':{required:true},
       'estado':{required:true},
       'curriculo':{required:true}
     },
     messages: {
       nome:{required:__('nome')},
       email:{required:__('email'), email:__('email_invalido')},
       ddd:{required:__('ddd')},
       telefone:{required:__('telefone')},
       endereco:{required:__('endereco')},
       cidade:{required:__('cidade')},
       bairro:{required:__('bairro')},
       cidade:{required:__('cidade')},
       cep1:{required:__('cep1')},
       cep2:{required:__('cep2')},
       estado:{required:__('estado')},
       curriculo:{required:__('curriculo')}
     },
     submitHandler:function(){ 
       $("#erro-work").html(__('aguarde')); 
       $("#trabalhe-conosco").ajaxSubmit(options);
     },
     errorLabelContainer: $("#erro-trabalhe")
 }); 
}

function anexar()
{
  $("#curriculo").change(function(){
    var valor = $(this).val();    
    
    $("#file-upload").val(valor);
  });
}

function setMenuInicial()
{
  $('.opening-pages li').hover(
      function()
      {
        $(this).find('p').css({'text-decoration':'underline'});
        $(this).find('a').css({'color':'#999999'});
        $(this).find('h1').css({'color':'#999999'});  
      },
      
      function()
      {
        $(this).find('p').css({'text-decoration':'none'});
        $(this).find('a').css({'color':'#64676c'});
        $(this).find('h1').css({'color':'#64676c'});
      }
  );
  
  $('.opening-pages li').click(
      function(){
        var link = $(this).find("a").attr("href");
        
        window.location = link;
        
      }
  );
}

function setRodapeLinks()
{
  $("#rodape li").hover(
      function()
      {
        $(this).find('p').css({'text-decoration':'underline'});
      },
      
      function()
      {
        $(this).find('p').css({'text-decoration':'none'});        
      }
  );
  
  $("#rodape li").click(
      function()
      {
        var link = $(this).find("a").attr("href");
        
        window.location = link;
        
        return false;
      }
  );
  
}

function setCategoriaHover()
{
  $('#categorias-lista li').hover( 
      function() 
      {
        $(this).css('border','#025529 solid 5px');
        $(this).find('.categoria-lista-texto').css('color','#909193');
      },
      
      function() 
      {
        $(this).css('border','#eaeaea solid 5px');
        $(this).find('.categoria-lista-texto').css('color','#4c4f52');
      }
  );    
}

function setHomeNovidades()
{
  $("#novidades li").hover(
    function()
    {
      $(this).find('p').css({'color':'#929292'});
      $(this).find('span').css({'background-color':'#767676'});
      $(this).find('h1').css({'color':'#767676'});
    },
    
    function()
    {
      $(this).find('p').css({'color':'#696969'});  
      $(this).find('span').css({'background-color':'#016939'});
      $(this).find('h1').css({'color':'#017745'});
    }
  );
  
  $("#novidades li").click(
      function(){
        var link = $(this).find("a").attr('href');
        
        window.location = link;
        
        return false;
      }
  );
}


function setFlash()
{
  addFlash(site + "/site/files/bin/banner.swf", "980", "392", "flashContent", "transparent", "10",{});
}

function setPasseio()
{
  addFlash(site + "/site/files/bin/main.swf", "697", "338", "passeio", "transparent", "10",{});
}

function setVideoSWF()
{
  addFlash(site + "/site/files/bin/videos.swf", "510", "326", "flashVideo", "opaque", "10",{});
}

function setJornal()
{
  addFlash(site + "/site/files/bin/jornal.swf", "986", "700", "folhar-jornal", "transparent", "10",{});
}

function addFlash(file, width, height, id, wmode, version,flashvars)
{
    var params = {
        'wmode':wmode,
        'allowscriptaccess': "always"
    };
    
    var attributes = {'id':id};
    swfobject.embedSWF(file, id, width, height, version,"js/expressInstall.swf", flashvars, params, attributes);
}

function setItemGalery()
{
  $(".galeria-touch").click(function(){    
    var link = $(this).find(".galeria-content").find('a').attr('href');    
    window.location = site + '/' + link;
  });
  
  $(".galeria-content a").click(function(){    
    var link = $(this).attr('href');    
    window.location = site + '/' + link;    
    return false;
  });
  
  $(".galeria-touch").hover(
      function(){
        $(this).find(".galeria-content").find('p').css({"color": '#7e858d'});
        
        if(jQuery.browser.msie)
        {
          if(jQuery.browser.version >= 9)
          {
            $(this).find(".galeria-content").find('a').stop().animate({opacity: '0.7'},500,'easeOutExpo'); 
          }
        }else{
          $(this).find(".galeria-content").find('a').stop().animate({opacity: '0.7'},500,'easeOutExpo');           
        }
        
      },
      function(){
        $(this).find(".galeria-content").find('p').css({"color": '#4c4f52'});
        
        if(jQuery.browser.msie)
        {
          if(jQuery.browser.version >= 9)
          {
            $(this).find(".galeria-content").find('a').stop().animate({opacity: '1'},500,'easeOutExpo');
          }
        }else{
          $(this).find(".galeria-content").find('a').stop().animate({opacity: '1'},500,'easeOutExpo');
        }
      }
  );
}

function setHorizontalMoveCategorias()
{
  $('#galeria-categorias').horizontalmove({
    main:'.galeria-categorias-main',
    mask:'.galeria-categorias-mask',
    left:'#galeria-categorias-left',
    right:'#galeria-categorias-right',
    item:'.galeria-categorias-item'
  });
}

function setItemProdutos()
{
  $("#produtos-interna a").hover(
      function(){
        $(this).css({"border": '6px solid #025429'});
        $(this).find(".produtos-interna-titulo").stop().animate({'top':'0px'},500,'easeOutExpo');
      },
      function(){
        $(this).css({"border": '6px solid #eaeaea'});
        $(this).find(".produtos-interna-titulo").stop().animate({'top':'-47px'},500,'easeOutExpo');
      }
  );
}

function timeline()
{
  $('.timeline-bloco').each(
      function(){
          var span = $(this).find("span").width();
          var width = $(this).find("a").width();        
          var position = (width / 2) - (span / 2) + 14;
          
          $(this).find("span").css({"margin-left": position + "px"});
      }
  );
  
  $('.timeline-bloco a').click(function(){return false;});
  
  $('.timeline-bloco a').hover(
      function()
      {
        var codigo = $(this).attr('href');        
        var position = $('#pop_' + codigo).css('top');        
        var height = $('#pop_' + codigo).height();
        
        $('#pop_' + codigo).css({'top':'-10px'});        
        $('#pop_' + codigo).show();
        
        if(jQuery.browser.msie)
        {
          if(jQuery.browser.version >= 9)
          {
            $('#pop_' + codigo).animate({'top':'-' + (height + 10) + 'px',opacity: '1'},500,'easeOutExpo');
          }
        }else{
          $('#pop_' + codigo).animate({'top':'-' + (height + 10) + 'px',opacity: '1'},500,'easeOutExpo');          
        }
      },
      
      function()
      {   
        var codigo = $(this).attr('href');
        
        $('#pop_' + codigo).stop(true,true).css({'top':'-10px'});        
        $('#pop_' + codigo).stop(true, true).hide();
      }
  );
  
  $('.timeline-popup').each(
      function(){
        var height = $(this).height();
        
        $(this).css({"top": "-" + (height + 10) + "px"});
      }
  );
}

function changeLinguas(){
  
  var id;
  
  $("#idiomas form").each(
      function(){
        
        var $this = $(this);
        
        $(this).find("a").click(
            function(){
              $this.submit();              
            }
        );
      }
  );
  
  $("#idiomas li").each(function(){
        var temp = $(this).attr("class");
    
        if(lang == temp)
        {
          $(this).addClass(temp + "-selecionado");
        }    
      }
  );
  
  $("#idiomas li").hover(
      function()
      { 
        if(lang + "-selecionado" != $(this).attr("class"))
        {
          id = $(this).attr("class");          
          $(this).removeClass(id);          
          $(this).addClass(id + "-selecionado");
        }
      },
      
      function()
      {        
        if(lang + "-selecionado" != $(this).attr("class"))
        {
          $(this).removeClass(id + "-selecionado");          
          $(this).addClass(id);
        }
      }
  );
  
}

function addMenuPadrao(){
  
  var selected = page;
  
  $('.menu-padrao-nao-selecionado').each(
      function(){
          var span = $(this).find("span").width();
          var width = $(this).find("a").width();        
          var position = (width / 2) - (span / 2) + 12;
          
          $(this).find("span").css({"left": position + "px"});
          
          if(selected == $(this).find("p").html())
          {
            $(this).find("a").css({"background-color": '#3f3f3f','color':'#838383'});
            
            $(this).find("span").show();
          }   
      }
  );
  
  $('.menu-padrao-nao-selecionado').hover(
      function(){
        $(this).find("a").css({"background-color": '#3f3f3f','color':'#838383'});
        
        $(this).find("span").show();        
      },
      function(){
        
        if(selected == $(this).find("p").html())
        {
          return;
        }
        
        $(this).find("span").hide();
                
        $(this).find("a").css({"background-color": '','color':'#cbcbcb'});
      }
  );
  
  if(page == "unidades")
  {    
    $('#menu-submenu li a').click(
        function(){
          var link = $(this).attr('href');
          
          loadData(link);
          
          return false;
        }
    );
  }
}

function envia_unidade(){
  
  $("#form-unidades").submit(function(){
    return false;    
  });
  
  var options = 
  {   
    beforeSubmit:  showRequest,  
    success:       showResponse 
  }; 

  function showRequest(formData, jqForm, options) 
  { 
    
  } 

  function showResponse(data)  
  {
    if($.trim(data) == "true")
    {
      $("#erro").html(__('enviado'));
      
      $("#form-unidades").clearForm();
      
      setTimeout(function(){
        $("#erro").html("");
      },2000);
            
    }else{
      
      $("#erro").html(__('erro')); 
      
      setTimeout(function(){
        $("#erro").html("");
      },2000);
    }
  }
  
  $("#form-unidades").validate({
      rules: {
        'email':{required:true, email:true},
        'telefone':{required:true},
        'assunto':{required:true}
      },
      messages: {
        email:{required:__("email"), email:__("email_invalido")},
        assunto:{required:__("assunto")},
        telefone:{required:__("telefone")}
      },
      submitHandler:function(){ 
        $("#erro").html(__('aguarde')); 
        $("#form-unidades").ajaxSubmit(options);
      },
      errorLabelContainer: $("#erro-form-unidades")
  });
}

var map;
var data;
var clusters;
var markers;
var geocoder;

function addMapUnidades(){
	
  /*$("#busca-unidades div.jqTransformSelectWrapper ul li a").click(function(){
  	 var index= $(this).attr('index');
    var coordenada = $('select.jqTransformHidden option:eq('+index+')').attr('value');
    var coords = coordenada.split(','); 
    var darwin = new google.maps.LatLng(coords[0], coords[1]);
    map.setCenter(darwin);
    map.setZoom(10);
  });*/
	
  $("#buscaUnidadeSelect").change(function() {
  		var coordenada = $(this).val();
  		var coords = coordenada.split(','); 
  		var darwin = new google.maps.LatLng(coords[0], coords[1]);
		map.setCenter(darwin);
  		map.setZoom(15);
  });	
  
  $("#busca-unidades").submit(function(){
    
    searchMaps($("#busca-field").val());
    
    return false;
  });
  
  geocoder = new google.maps.Geocoder();
  
  var center = new google.maps.LatLng(-6.315299, 3.691406);
  
  var options = {
    'zoom': 2,
    'center': center,
    'mapTypeId': google.maps.MapTypeId.ROADMAP
  };
  
  map = new google.maps.Map(document.getElementById("map_canvas"), options);
  
  $("#janela-google-maps").hide();
  
  loadData();
}

function loadData(codigo)
{
  try
  {
    if(codigo)
    {
      this.clusters.removeMarkers(markers);
      
      clearOverlays(markers);
    }
  }catch(e){    
    
  }
  
  $.ajax({
    url: url + '/data',
    dataType: 'json',
    type: "POST",
    global: false,
    data: {'codigo' : codigo},
    success: function(dados){
      data = dados;
      loadMarkers();
    },
    error: function(data){}
  });
}

function searchMaps(address) 
{
  geocoder.geocode( { 'address': address}, function(results, status) {
    
    if (status == google.maps.GeocoderStatus.OK) {
      
      map.setCenter(results[0].geometry.location);
      
      map.setZoom(10);
      
    } else {}
  });
}

function clearOverlays(markersArray) 
{
  if (markersArray) 
  {
    for (i in markersArray) 
    {
      markersArray[i].setMap(null);
    }
  }
}

function loadMarkers()
{
  var infoWindow = null;
    
  infoWindow = new google.maps.InfoWindow();
  
  markers = [];
  
  for (var i = 0; i < data.count; i++)
  {
    var latLng = new google.maps.LatLng(data.data[i].latitude,data.data[i].longitude);
    
    var marker = new google.maps.Marker({
      'position': latLng,
      map: map,
      icon:"site/images/gmaps/icon-gmap.png",
      title: "Dimep"
    });
    
    var html = '<div class="ggmaps-titulo">' + data.data[i].title + "</div>" + data.data[i].description;
    
    var email = data.data[i].email + "";
    
    addMarker(marker,html,latLng,email);
    
    markers.push(marker);
  }
  
  var styles = [{
    url: url + '/site/images/gmaps/' + data.unidades,
    height: 20,
    width: 72,
    anchor: [5, 4],
    textColor: '#85b905',
    textSize: 9
  }];
  
  var optMarkerCluster = {
      'imagePath':url + '/site/images/gmaps/m',
      'styles':styles
  }
  
  this.clusters = new MarkerClusterer(map, markers,optMarkerCluster);
  
  var ib;
  
  function addMarker(marker,content,latLng,email)
  {
    google.maps.event.addListener(marker, 'click', function() {
       
       $('#email-show').html(__('Para') + ': <a href="mailTo:' + email + '" >' + email + '</a>');       
       $('#email-input').val(email);
       
       map.panTo(latLng);
       
       var boxText = '<div class="ggmaps">' + 
                       '<div class="ggmaps-main">'+
                         '<div class="ggmaps-logo"><img src="' + site +'/site/images/gmaps/logo.png" /></div>' +
                           '<div class="ggmaps-content">'+
                             content +
                           '</div>'+
                           '<div class="ggmaps-enviar"><a href="javascript:void(0);" onclick="showWindow(\'email@hotmail.com\');"><img src="' + site +'/site/images/gmaps/' + __('enviar.png') + '" /></a></div>' +
                       '</div>' + 
                     '</div>';
       
       var position_box = "10px 2px 2px 2px";
       
       if(jQuery.browser.msie)
       {
         if(jQuery.browser.version <= 7)
         {
           position_box = "0px 0px 0px 250px";
         }
       }
       
       var myOptions = {
          content: boxText
         ,disableAutoPan: true
         ,maxWidth: 0
         ,pixelOffset: new google.maps.Size(-140, 0)
         ,closeBoxMargin: position_box 
         ,closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif"
         ,infoBoxClearance: new google.maps.Size(1, 1)
         ,isHidden: false
         ,pane: "floatPane"
         ,enableEventPropagation: false
       };
       
       if(ib)
       {
         ib.close();
       }
       
       ib = new InfoBox(myOptions);
       ib.open(map, marker);
       
       setTimeout(function(){
         
         var bt_fechar;
         
         $(".infoBox img").each(function(){
             if($(this).attr('align') == "right")
             {
               bt_fechar = $(this);
             }
         });
         
         if(jQuery.browser.msie)
         {
           if(jQuery.browser.version >= 9)
           {         
             bt_fechar.css({opacity:'0'});         
             $(".ggmaps-content").css({opacity: '0'});
             $(".ggmaps-enviar").css({opacity: '0'});
             $(".ggmaps").css({marginTop:'30px'});    
             $(".ggmaps").animate({marginTop:'0px'},500,'easeOutExpo',function(){ 
               bt_fechar.animate({opacity: '1'},500);
               $(".ggmaps-content").animate({opacity: '1'},500);
               $(".ggmaps-enviar").animate({opacity: '1'},500);           
             });
           }else{
             bt_fechar.css({'top':'25px'});      
           }
         }else{
           bt_fechar.css({opacity:'0'});         
           $(".ggmaps-content").css({opacity: '0'});
           $(".ggmaps-enviar").css({opacity: '0'});
           $(".ggmaps").css({marginTop:'30px'});    
           $(".ggmaps").animate({marginTop:'0px'},500,'easeOutExpo',function(){ 
             bt_fechar.animate({opacity: '1'},500);
             $(".ggmaps-content").animate({opacity: '1'},500);
             $(".ggmaps-enviar").animate({opacity: '1'},500);           
           });           
         }
                  
       },1);       
     });
  }
  
  $("#janela-fechar").click(function(){
    $("#janela-google-maps").stop().animate({right: '-300px',opacity: '1'},1000,'easeOutExpo');
  });
}

function showWindow(content)
{
  $("#janela-unidades").html(content);
  $("#janela-google-maps").show();    
  if(jQuery.browser.msie)
  {
    if(jQuery.browser.version >= 9)
    {
      $("#janela-google-maps").css({opacity: '0',right:'-300px'});    
      $("#janela-google-maps").stop().animate({right: '0px',opacity: '1'},1000,'easeOutExpo',function(){
        $('#emaildimap').focus();    
      });
    }else{
      $("#janela-google-maps").css({right:'-300px'});
      $("#janela-google-maps").stop().animate({right: '0px'},1000,'easeOutExpo',function(){
        $('#emaildimap').focus();    
      });
    }
  }else{
    $("#janela-google-maps").css({opacity: '0',right:'-300px'});    
    $("#janela-google-maps").stop().animate({right: '0px',opacity: '1'},1000,'easeOutExpo',function(){
      $('#emaildimap').focus();    
    });    
  }
}

function addGoogleMaps(){
  
  if (document.getElementById('gmaps')) 
  {
    if (typeof google == 'undefined') return;
    
    var latlng = cords.split(',');    
    
    latlng = new google.maps.LatLng(latlng[0],latlng[1]);

    var mapDiv = document.getElementById('gmaps');
    
    var map = new google.maps.Map(mapDiv, {
        center: latlng,
        zoom: 14,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        disableDefaultUI: true,
        navigationControl: true,
        navigationControlOptions: {
            position: google.maps.ControlPosition.LEFT,
            style: google.maps.NavigationControlStyle.SMALL
        }
    });
    
    var marker = new google.maps.Marker({
        position: latlng,
        map: map,
        icon:"site/images/gmaps/logo_dimep.png",
        title: "Dimep"
    });
  }
}

function callHorizontalMove(){
  
  instance = $('#galeria-cinza').horizontalmove({
    width:940,
    //itemMargin:10,
    callBack:function(page,percent){
      //currentPage(page);
      //instance2.setBar(percent);
    }
  });
}

function mouseHold(){

  try{
    instance2 = $("#slider").moveobject({callBack:function(percent,type){
        instance.setPercentege(percent,type);
      }
    });
  }catch(e){

  }
}

function slideMenus(){

  //Slide Menu Produtos
  $('.listagem-produtos li a').click(function(e) {
    e.preventDefault();

    var pagina = ["ficha","downloads","relacionados","recomendar","imprimir","faq"];
    var selecionado = $(this).attr('href');

    if (selecionado == 4) {

      window.open('produtos_detalhes/imprimir', "Dimep - Imprimir", "location=0,status=0,scrollbars=1, width=520,height=600");

    } else {

      $('#caixa-produto-detalhes').addClass('content-loading');
      $('.listagem-produtos .selecionado').removeClass('selecionado').trigger('mouseleave');
      $(this).addClass('selecionado');

      $.ajax({
        url: "produtos_detalhes/" + pagina[selecionado],

        success: function(html) {
          $('#caixa-produto-detalhes').html(html);
          $(document).trigger('content-loaded');
        },

        complete: function(){
          $('#caixa-produto-detalhes').removeClass('content-loading');
        }
      });

    }

  });

  //Slide Menu Serviï¿½os/Suporte
  $('.listagem-suporte li a').click(function(e) {
    e.preventDefault();

    var pagina2 = ["chamado","faq","downloads","ocorrencia"];
    var selecionado2 = $(this).attr('href');
   
    $('#suporte-body').addClass('content-loading');
    $('.listagem-suporte .selecionado').removeClass('selecionado').trigger('mouseleave');
    $(this).addClass('selecionado');

    $.ajax({
      url: "suporte/" + pagina2[selecionado2],

      success: function(html) {
        $('#suporte-body').html(html);
        $(document).trigger('content-loaded');
      },

      complete: function(){
        $('#suporte-body').removeClass('content-loading');
      }
    });

  });

  //Slide Menu Institucional
  $('.listagem-institucional li a').click(function(e) {
    e.preventDefault();

    var pagina3 = ["historia", "clientes", "cases", "", "destaques", "trabalhe"];
    var selecionado3 = $(this).attr('href');

    $('#institucional-body').addClass('content-loading');
    $('.listagem-institucional .selecionado').removeClass('selecionado').trigger('mouseleave');
    $(this).addClass('selecionado');

    $.ajax({
      url: "institucional/" + pagina3[selecionado3],

      success: function(html) {
        $('#institucional-body').html(html);
        $(document).trigger('content-loaded');
      },

      complete: function(){
        $('#institucional-body').removeClass('content-loading');
      }
    });

  });
  
  //Slide Menu Midia
  $('.listagem-midia li a').click(function(e) {
    e.preventDefault();

    var pagina4 = ["acessoria", "eventos", "noticias", "jornal", "releses"];
    var selecionado4 = $(this).attr('href');

    $('#midia-body').addClass('content-loading');
    $('.listagem-midia .selecionado').removeClass('selecionado').trigger('mouseleave');
    $(this).addClass('selecionado');

    $.ajax({
      url: "midia/" + pagina4[selecionado4],

      success: function(html) {
        $('#midia-body').html(html);
        $(document).trigger('content-loaded');
      },

      complete: function(){
        $('#midia-body').removeClass('content-loading');
      }
    });

  });

  //Animaï¿½ï¿½o Slide Menus
  $('.listagem-produtos a, .listagem-institucional a, .listagem-suporte a, .listagem-midia a').css({
    backgroundPosition:"-194px 0"
  }).hover(
    function(){
      $(this).stop(true).removeClass('stoped').animate(
      {
        color:'white',
        backgroundPosition:"0 0"
      },700,'easeOutExpo', function(){
        $(this).addClass('stoped');
      })
    },
    function(){
      if ($(this).hasClass('selecionado')) return;
      $(this).stop(true).removeClass('stoped').animate(
      {
        color:'#535252',
        backgroundPosition:"-194px 0"
      },700,'easeOutExpo', function(){
        $(this).addClass('stoped');
      })
    }
  );
}

function currentPage(page){

  $('#horizontal-pagination a').each(function(){

    if(parseInt($(this).attr('href')) == page) {

      $(this).css({'background-position':'0px 0px'});

    } else {

      $(this).css({'background-position':'-23px 0px'});

    }
  });


  $('#pagina-atual').html((parseInt(page) + 1) + "");

}

function destaquesSelected()
{
  $('#home-destaque div').hover(
      function(){
        if($(this).attr("id") != "")
        {
          $(this).find('span').find('a').stop().css({marginTop: '-18px'});
          $(this).find('p').stop().css({'text-decoration': 'underline'});
        }
      },
      function(){
        if($(this).attr("id") != "")
        {
          $(this).find('span').find('a').stop().css({marginTop: '0px'});
          $(this).find('p').stop().css({'text-decoration': 'none'});
        }
      }
  );
  
  $('#home-destaque div').click(function(){
    if($(this).attr("id") != "")
    {
      var link = $(this).find('a').attr('href');
      
      if($(this).find('a').attr('target') == "_blank")
      {
        window.open(link, '_blank');
        
        return;
        
      }else{
        window.location = link;
        
        return;
      }
    }
  });
  
  $('#home-destaque a').click(function(){
    
    var link = $(this).attr('href');
    
    if($(this).attr('target') == "_blank")
    {
      window.open(link, '_blank');
      
      return false;
      
    }else{
      window.location = link;
      
      return false;
    }
    
    return false;
  });
}

function callSubMenu()
{
  var fast = true;
  
  if(jQuery.browser.msie)
  {
    if(jQuery.browser.version <= 7)
    {
      fast = false;
    }
  }
  
  var id = "";
  
  $('#menu li').hover(
      function(){
        if(fast)
        {
          $(this).find('ul').show("fast");
        }else{
            $(this).find('ul').show();
        }
        
        if($(this).attr('id'))
        {
          id = $(this).attr('id');

          $(this).attr('id','');
        }

        $(this).addClass('menu-hover');
      },
      function(){
        $(this).find('ul').stop(true, true).hide();
        $(this).find('a').removeClass('menu-hover');

        if(id != "")
        {
          $(this).attr('id',id);
        }
      }
  );
}

function menuAction()
{
  if(jQuery.browser.msie)
  {
    if(jQuery.browser.version < 9)
    {
       return;
    }
  }


  $('#menu li').hover(
      function(){
        $(this).find('a').stop().animate({paddingRight: '30px'},600,'easeOutExpo');
      },
      function(){
        $(this).find('a').stop().animate({paddingRight: '10px'},600,'easeOutExpo');
      }
  );
}
function get_url()
{
  return site;
}

function get_url_revista()
{
  return url + '/xml/megazine/' + jornal;
}

function get_qdt()
{ 
  return qdt;
}
function faq(){
  $('#faq dd').each(function(){
    $(this).css('height', $(this).height());
  }).hide();
  $('#faq dt').click(function(){
    $(this).next('dd').stop(false,true).slideToggle();
  });

  if (window.location.hash) {
    try {
      $(window.location.hash).next('dd').show();
    }catch(e){}
  }
}

function faq_suporte(){
  $('#faq-suporte dd').each(function(){
    $(this).css('height', $(this).height());
  }).hide();
  $('#faq-suporte dt').click(function(){
    $(this).next('dd').stop(false,true).slideToggle();
  });

  if (window.location.hash) {
    try {
      $(window.location.hash).next('dd').show();
    }catch(e){}
  }
}

/* Menu Produtos */
function novoMenu() {
   //Menu
   $('#novo-menu li').each( function() {
      var posX = ($(this).width() - ($(this).find('span').width()/2) ) / 2;
      $(this).find('span').css('left',posX);
      $(this).find('span').css('display','none');
   }); 
   $('#novo-menu li').each( function() {
      var posX = ($(this).width() - ($(this).find('img').width()/2) ) / 2;
      $(this).find('img').css({
         'left': posX,
         'display': 'none'
      });
   });
     
  $('#novo-menu li').hover( function() {
      if (!$(this).hasClass('novo-menu-selected')) {
         $(this).css('background','#3F3F3F');
         $(this).find('img').css('display','block');
      }
   }, function() {
      if (!$(this).hasClass('novo-menu-selected')) {
         $(this).css('background','none');
         $(this).find('img').css('display','none');
      }
   });
   
   //Submenu
   $('#submenu li').each( function() {
      var posX = ($(this).width() - ($(this).find('span').width()/2) ) / 2;
      $(this).find('span').css({
         'left': posX,
         'display': 'none'
      });
   });
   
   //Selecionados
   $('.novo-menu-selected').find('span').css('display','block');

   $('.submenu-selected').find('a').css('color', '#016832');
   $('.submenu-selected').find('span').css('display', 'block');
}

function imprimeFicha() {
   $('#print').click(function(){
      codigo = $(this).attr('href');
      window.open(site + '/imprimir/' + codigo, "Dimep - Imprimir", "location=0,status=0,scrollbars=1, width=520,height=600");  
      
      return false;
   });   
}

function __(field)
{
  var msg = 
      {'nome' : {        
                  "br":"Campo Nome :: Obrigatório<br />",
                  "en":"Field Name :: Invalid<br />",
                  "sp":"Campo Nombre :: Requerido<br />",
                  "pt":"Campo Nome :: Obrigatório<br />"
                },
       'email' : {        
                  "br":"Campo E-mail :: Obrigatório<br />",
                  "en":"Field E-mail :: Invalid<br />",
                  "sp":"Campo E-mail :: Requerido<br />",
                  "pt":"Campo E-mail :: Obrigatório<br />"
                 },
       'email_invalido' : {
                            "br":"Campo E-mail :: Inválido<br />",
                            "en":"Field E-mail :: Invalid<br />",
                            "sp":"Campo E-mail ::Inválido<br />",
                            "pt":"Campo E-mail :: Inválido<br />"
                          },                 
       'telefone' : {
                      "br":"Campo Telefone :: Obrigatório<br />",
                      "en":"Field Telefone :: Invalid<br />",
                      "sp":"Campo Telï¿½fono :: Requerido<br />",
                      "pt":"Campo Telefone :: Obrigatório<br />"
                    },
      'nome-da-empresa' : {
                      "br":"Campo Nome da Empresa :: Obrigatório<br />",
                      "en":"Field Company's name :: Invalid<br />",
                      "sp":"Campo Nombre da Empresa :: Requerido<br />",
                      "pt":"Campo Nome da Empresa :: Obrigatório<br />"
                    },
       'contato' : {
                      "br":"Campo Contato :: Obrigatório<br />",
                      "en":"Field Contact :: Invalid<br />",
                      "sp":"Campo Contacto :: Requerido<br />",
                      "pt":"Campo Contato :: Obrigatório<br />"
                    },
       'empresa' : {
                      "br":"Campo Empresa :: Obrigatório<br />",
                      "en":"Field Company :: Invalid<br />",
                      "sp":"Campo Empresa :: Requerido<br />",
                      "pt":"Campo Empresa :: Obrigatório<br />"
                    },
        'cnpj' : {
                   "br":"Campo CNPJ :: Obrigatório<br />",
                   "en":"Field CNPJ :: Invalid<br />",
                   "sp":"Campo CNPJ :: Requerido<br />",
                   "pt":"Campo CNPJ :: Obrigatório<br />"
                 },
        'endereco' : {
                   "br":"Campo Endereço :: Obrigatório<br />",
                   "en":"Field Address :: Invalid<br />",
                   "sp":"Campo Direccion :: Requerido<br />",
                   "pt":"Campo Endereço :: Obrigatório<br />"
                 },         
        'numero' : {
                   "br":"Campo Número :: Obrigatório<br />",
                   "en":"Field Number :: Invalid<br />",
                   "sp":"Campo Número :: Requerido<br />",
                   "pt":"Campo Número :: Obrigatório<br />"
                 },                  
        'bairro' : {
                   "br":"Campo Bairro :: Obrigatï¿½rio<br />",
                   "en":"Field District :: Invalid<br />",
                   "sp":"Campo Barrio :: Requerido<br />",
                   "pt":"Campo Bairro :: Obrigatório<br />"
                 }, 
        'cidade' : {
                   "br":"Campo Cidade :: Obrigatório<br />",
                   "en":"Field City :: Invalid<br />",
                   "sp":"Campo Ciudad :: Requerido<br />",
                   "pt":"Campo Cidade :: Obrigatório<br />"
                 },                  
        'cep' : {
                   "br":"Campo CEP :: Obrigatório<br />",
                   "en":"Field CEP :: Invalid<br />",
                   "sp":"Campo CEP :: Requerido<br />",
                   "pt":"Campo CEP :: Obrigatório<br />"
                 },
        'cep1' : {
                   "br":"Campo CEP :: Obrigatório<br />",
                   "en":"Field CEP :: Invalid<br />",
                   "sp":"Campo CEP :: Requerido<br />",
                   "pt":"Campo CEP :: Obrigatório<br />"
                 },
        'cep2' : {
                   "br":"Campo CEP :: Obrigatório<br />",
                   "en":"Field CEP :: Invalid<br />",
                   "sp":"Campo CEP :: Requerido<br />",
                   "pt":"Campo CEP :: Obrigatório<br />"
                 },
        'ddd' : {
                   "br":"Campo DDD :: Obrigatório<br />",
                   "en":"Field DDD :: Invalid<br />",
                   "sp":"Campo DDD :: Requerido<br />",
                   "pt":"Campo DDD :: Obrigatório<br />"
                 },
        'curriculo' : {
                   "br":"Campo Currículo :: Obrigatório<br />",
                   "en":"Field Curriculum :: Invalid<br />",
                   "sp":"Campo Curriculum :: Requerido<br />",
                   "pt":"Campo Currículo :: Obrigatório<br />"
                 },
        'como_soube' : {
                   "br":"Campo Como Soube :: Obrigatório<br />",
                   "en":"Field How did you get to us? :: Invalid<br />",
                   "sp":"Campo Como supe? :: Requerido<br />",
                   "pt":"Campo Como Soube :: Obrigatório<br />"
                 },                    
        'produto' : {
                   "br":"Campo Produto :: Obrigatório<br />",
                   "en":"Field Product :: Invalid<br />",
                   "sp":"Campo Producto :: Requerido<br />",
                   "pt":"Campo Produto :: Obrigatório<br />"
                 },                          
        'departamento' : {
                   "br":"Campo Departamento :: Obrigatório<br />",
                   "en":"Field Department :: Invalid<br />",
                   "sp":"Campo Departamento :: Requerido<br />",
                   "pt":"Campo Departamento :: Obrigatório<br />"
                 },                                   
        'comentario' : {
                   "br":"Campo Comentário :: Obrigatório<br />",
                   "en":"Field Comments :: Invalid<br />",
                   "sp":"Campo Comentario :: Requerido<br />",
                   "pt":"Campo Comentário :: Obrigatório<br />"
                 },         
        'aguarde' : {
                   "br":"Aguarde um momento...",
                   "en":"Wait...",
                   "sp":"Espere un momento...",
                   "pt":"Aguarde um momento..."
                 },         
        'enviado' : {
                   "br":"Enviado com sucesso.",
                   "en":"Sent.",
                   "sp":"Enviado.",
                   "pt":"Enviado com sucesso."
                 },
        'erro' : {
                   "br":"Erro desconhecido.",
                   "en":"Error.",
                   "sp":"Error desconocido.",
                   "pt":"Erro desconhecido."
                 },           
        'n_fun' : {
                   "br":"Campo Nº Funcionários :: Obrigatório<br />",
                   "en":"Field Nº Employees :: Invalid<br />",
                   "sp":"Campo Nº Empleados :: Requerido<br />",
                   "pt":"Campo Nº Funcionários :: Obrigatório<br />"
                 },
        'assunto' : {
                   "br":"Campo Assunto :: Obrigatório<br />",
                   "en":"Field Subject :: Invalid<br />",
                   "sp":"Campo Tema :: Requerido<br />",
                   "pt":"Campo Assunto :: Obrigatório<br />"
                 },
        'Para' : {
                   "br":"Para",
                   "en":"To",
                   "sp":"Para",
                   "pt":"Para"
                 },
        'estado' : {
                   "br":"Campo Estado :: Obrigatório<br />",
                   "en":"Field State :: Invalid<br />",
                   "sp":"Campo Provincia :: Requerido<br />",
                   "pt":"Campo Estado :: Obrigatório<br />"
                 },
        'depoimentos' : {
                   "br":"Campo Depoimento :: Obrigatório<br />",
                   "en":"Field Testimony :: Invalid<br />",
                   "sp":"Campo Testimonio :: Requerido<br />",
                   "pt":"Campo Depoimento :: Obrigatório<br />"
                 },
       'instrucoes_sucesso' : {
                   "br":"Instruções enviadas com sucesso<br />",
                   "en":"Instruções enviadas com sucesso<br />",
                   "sp":"Instruções enviadas com sucesso<br />",
                   "pt":"Instruções enviadas com sucesso<br />"
                 },
       'defeito' : {
                   "br":"Defeito enviadas com sucesso<br />",
                   "en":"Defeito enviadas com sucesso<br />",
                   "sp":"Defeito enviadas com sucesso<br />",
                   "pt":"Defeito enviadas com sucesso<br />"
                 },
        'enviar.png' : {
                 "br":"enviar.png",
                 "en":"send_.png",
                 "sp":"enviar.png",
                 "pt":"enviar.png"
               }
                                 
      };
  
  
  return msg[field][lang];
}

function newsletter(){
   $("#contato-news").submit(function(){
    return false;    
  });
  
  var options = 
  {   
    beforeSubmit:  showRequest,  
    success:       showResponse 
  }; 

  function showRequest(formData, jqForm, options) 
  { 
    
  } 

  function showResponse(data)  
  {
    if($.trim(data) == "true")
    {
      $("#erro-news").html(__('enviado'));
      
      $("#contato-news").clearForm();
      
      setTimeout(function(){
        $("#erro-news").html("");
      },2000);
            
    }else{
      
      $("#erro-news").html(__('erro')); 
      
      setTimeout(function(){
        $("#erro-news").html("");
      },2000);
    }
  }
   
   $("#contato-news").validate({
      rules: {
        'nome_news':{required:true},
        'email_news':{required:true, email:true}
      },
      messages: {
        nome_news:{required:__('nome')},
        email_news:{required:__('email'), email:__('email_invalido')}
      },
      submitHandler:function(){ 
        $("#erro-news").html(__('aguarde')); 
        $("#contato-news").ajaxSubmit(options);
      },
      errorLabelContainer: $("#erro-contato-news")
  }); 
}

function envia_contato(){

  $("#form-contato").submit(function(){
    return false;    
  });
  
  var options = 
  {   
    beforeSubmit:  showRequest,  
    success:       showResponse 
  }; 

  function showRequest(formData, jqForm, options) 
  { 
    
  } 

  function showResponse(data)  
  {
    if($.trim(data) == "true")
    {
      $("#erro-form").html(__('enviado'));
      
      $("#form-contato").clearForm();
      
      setTimeout(function(){
        $("#erro-form").html("");
      },2000);
            
    }else{
      
      $("#erro-form").html(__('erro')); 
      
      setTimeout(function(){
        $("#erro-form").html("");
      },2000);
    }
  }
   
   
  
   $("#form-contato").validate({
      rules: {
        'nome_completo':{required:true},
        'e_mail':{required:true, email:true},
        'telefone':{required:true},
        'empresa':{required:true},
        'cnpj':{required:true},
        'endereco':{required:true},
        'numero':{required:true},
        'bairro':{required:true},        
        'cidade':{required:true},
        'cep':{required:true},
        'comosoube':{required:true},
        'produto':{required:true},
        'departamento':{required:true},
        'comentario':{required:true}
      },
      messages: {
        nome_completo:{required:__('nome')},
        e_mail:{required:__('email'), email:__('email_invalido')},
        telefone:{required:__('telefone')},
        empresa:{required:__('empresa')},
        cnpj:{required:__('cnpj')},
        endereco:{required:__('endereco')},
        numero:{required:__('numero')},
        bairro:{required:__('bairro')},        
        cidade:{required:__('cidade')},
        cep:{required:__('cep')},
        comosoube:{required:__('como_soube')},
        produto:{required:__('produto')},
        departamento:{required:__('departamento')},
        comentario:{required:__('comentario')}        
      },
      submitHandler:function(){ 
        $("#erro-form").html(__('aguarde')); 
        $("#form-contato").ajaxSubmit(options);
      },
      errorLabelContainer: $("#erro-contato-form")
  }); 
}


function envia_chamado(){
   $("#form-back-white").submit(function(){
    return false;    
  });
  
  var options = 
  {   
    beforeSubmit:  showRequest,  
    success:       showResponse 
  }; 

  function showRequest(formData, jqForm, options) 
  { 
    
  } 

  function showResponse(data)  
  {
    if($.trim(data) == "true")
    {
      $("#erro-chamado").html(__('enviado'));
      
      $("#form-back-white").clearForm();
      
      setTimeout(function(){
        $("#erro-chamado").html("");
      },2000);
            
    }else{
      
      $("#erro-chamado").html(__('erro')); 
      
      setTimeout(function(){
        $("#erro-chamado").html("");
      },2000);
    }
  }
   
   $("#form-back-white").validate({
      rules: {
        'nome':{required:true},
        'email':{required:true, email:true},
        'telefone':{required:true},
        'empresa':{required:true},
        'cnpj':{required:true},
        'nfuncionarios':{required:true},
        'endereco':{required:true},
        'cidade':{required:true},
        'produto':{required:true},
        'comentario':{required:true}
      },
      messages: {
        nome:{required:__('nome')},
        email:{required:__('email'), email:__('email_invalido')},
        telefone:{required:__('telefone')},
        empresa:{required:__('empresa')},
        cnpj:{required:__('cnpj')},
        nfuncionarios:{required:__('n_fun')},
        endereco:{required:__('endereco')},
        cidade:{required:__('cidade')},
        produto:{required:__('produto')},
        comentario:{required:__('comentario')}        
      },
      submitHandler:function(){ 
        $("#erro-chamado").html(__('aguarde')); 
        $("#form-back-white").ajaxSubmit(options);
      },
      errorLabelContainer: $("#erro-chamado-form")
  }); 
}

function envia_licitacoes(){
   $("#form-back-white").submit(function(){
    return false;    
  });
  
  var options = 
  {   
    beforeSubmit:  showRequest,  
    success:       showResponse 
  }; 

  function showRequest(formData, jqForm, options) 
  { 
    
  } 

  function showResponse(data)  
  {
    if($.trim(data) == "true")
    {
      $("#erro-chamado").html(__('enviado'));
      
      $("#form-back-white").clearForm();
      
      setTimeout(function(){
        $("#erro-chamado").html("");
      },2000);
            
    }else{
      
      $("#erro-chamado").html(__('erro')); 
      
      setTimeout(function(){
        $("#erro-chamado").html("");
      },2000);
    }
  }
   
   $("#form-back-white").validate({
      rules: {
        'interessada':{required:true},
        'estado':{required:true},
        'responsavel':{required:true},
        'telefone':{required:true},
        'email':{required:true, email:true},
        'comentario':{required:true}
      },
      messages: {
        interessada:{required:"Campo ï¿½rgï¿½o/Empresa :: Obrigatï¿½rio<br />"},
        estado:{required:__('estado')},
        responsavel:{required:"Campo Responsï¿½vel :: Obrigatï¿½rio<br />"},
        telefone:{required:__('telefone')},        
        email:{required:__('email'), email:__('email_invalido')},
        comentario:{required:__('comentario')}        
      },
      submitHandler:function(){ 
        $("#erro-chamado").html("Aguarde um momento..."); 
        $("#form-back-white").ajaxSubmit(options);
      },
      errorLabelContainer: $("#erro-chamado-form")
  }); 
}

function envia_indique(){
   $("#form-produtos").submit(function(){
    return false;    
  });
  
  var options = 
  {   
    beforeSubmit:  showRequest,  
    success:       showResponse 
  }; 

  function showRequest(formData, jqForm, options) 
  { 
    
  } 

  function showResponse(data)  
  {
    if($.trim(data) == "true")
    {
      $("#erro-indique").html("Enviado com sucesso.");
      
      $("#form-produtos").clearForm();
      
      setTimeout(function(){
        $("#erro-indique").html("");
      },2000);
            
    }else{
      
      $("#erro-indique").html("Erro desconhecido."); 
      
      setTimeout(function(){
        $("#erro-indique").html("");
      },2000);
    }
  }
   
   $("#form-produtos").validate({
      rules: {
        'nome':{required:true},
        'email':{required:true, email:true},
        'indicado':{required:true},
        'indicado_email':{required:true, email:true},
        'msg':{required:true}
      },
      messages: {
        nome:{required:"Campo Nome :: Obrigatï¿½rio<br />"},
        email:{required:"Campo E-mail :: Obrigatï¿½rio<br />", email:"Campo e-mail invï¿½lido<br />"},
        indicado:{required:"Campo Nome Indicado :: Obrigatï¿½rio<br />"},
        indicado_email:{required:"Campo E-mail Indicado :: Obrigatï¿½rio<br />", email:"Campo e-mail invï¿½lido<br />"},
        msg:{required:"Campo Mensagem :: Obrigatï¿½rio<br />"}        
      },
      submitHandler:function(){ 
        $("#erro-indique").html("Aguarde um momento..."); 
        $("#form-produtos").ajaxSubmit(options);
      },
      errorLabelContainer: $("#erro-indique-form")
  });
}

function envia_passeio(){
   $("#form-passeio").submit(function(){
    return false;    
  });
  
  var options = 
  {   
    beforeSubmit:  showRequest,  
    success:       showResponse 
  }; 

  function showRequest(formData, jqForm, options) 
  { 
    
  } 

  function showResponse(data)  
  {
    if($.trim(data) == "true")
    {
      $("#erro-passeio").html(__("enviado"));
      
      $("#form-passeio").clearForm();
      
      setTimeout(function(){
        $("#erro-passeio").html("");
      },2000);
            
    }else{
      
      $("#erro-passeio").html(__("erro")); 
      
      setTimeout(function(){
        $("#erro-passeio").html("");
      },2000);
    }
  }
   
   $("#form-passeio").validate({
      rules: {
        'nome':{required:true},
        'email':{required:true, email:true},
        'depoimento':{required:true}
      },
      messages: {
        nome:{required:__("nome")},
        email:{required:__("email"), email:__("email_invalido")},
        depoimento:{required:__("depoimentos")}
      },
      submitHandler:function(){ 
        $("#erro-passeio").html(__("aguarde")); 
        $("#form-passeio").ajaxSubmit(options);
      },
      errorLabelContainer: $("#erro-passeio-form")
  });
}

/* CHATTER BOT Animation */

function chatterBot() {	
	$('.chat-type').focus();

	$('#chat').submit(function(e){
		e.preventDefault();
		if ($('.chat-type').val().length > 0) {
			
			$.ajax({
				url: site + '/chatter.ajax',
				type: 'POST',
				data: $('#chat').serialize(),
				success: function(data) {
					$("#chatter-body-text").html(data);
				},
				error: function(){
					alert("ERRO");
				}
			});
			return false;
			
		}
	});
	
	setInterval(function() {    
      $('#chat-image').animate({
			backgroundPosition: "-158px -78px"
		},700,'easeInOutSine',function(){
			$('#chat-image').animate({
				backgroundPosition: "-147px -81px"
			},700,'easeInOutSine',function(){
				$('#chat-image').animate({
					backgroundPosition: "-155px -75px"
				},700,'easeInOutSine',function(){
					$('#chat-image').animate({
						backgroundPosition: "-154px -84px"
					})
				})
				})
			})	
   }, 1000);   
	
}

function rastreamento(){

}
