
var elementoAtual = -1;

function leftProduto(){
    var selecionado = $('.select');
    
    if(!selecionado.parent('a').parent('div').hasClass('first')){
      
      $('.select').removeClass('select');
      geraProdutos(selecionado.parent('a').parent('div').prev('div').find('img').data('codigo'));
      selecionado.parent('a').parent('div').prev('div').find('img').addClass('select');
    
    }
}

function rightProduto(){
    var selecionado = $('.select');
    
    if(!selecionado.parent('a').parent('div').hasClass('last')){
      
      $('.select').removeClass('select');
      geraProdutos(selecionado.parent('a').parent('div').next('div').find('img').data('codigo'));
      selecionado.parent('a').parent('div').next('div').find('img').addClass('select');
    
    }
}


function geraProdutos(codigo){
     $('#texto-produto').html('').addClass('loader'); 
     $('#content-interna-texto-produtos').load(SITE+'/gera_produtos',{codigo:codigo},function(data){
            $(this).removeClass('loader');
     });
}

function marca(e){
  $('a.select').removeClass('select');
  $(e).addClass('select');
}

function geraHistorico(codigo){
  if(elementoAtual == codigo)
    return;
  elementoAtual = codigo;
  $.ajax({
      url: SITE + '/gera_historico',
      global: false,
      type: "POST",
      data: {codigo:codigo},
      dataType: "html",
      async:false,
      success: function(data){
        $('#content-interna-1').html('');
        $('#content-interna-1').append(data);
      }
   });
}

/*Produtos abrir e fechar*/
function fechasub(){ $('.subfaixa').hide(); }
function abresub(){ $('.subfaixa').show(); }

/* funcao value field para validate */
function valueField (event, obj) {
  e = event.type;
  var obj = get(obj);
  if(!obj.save){
    obj.save = obj.value;   
  }
  if(e == "blur"){
    if(obj.value == ""){
      obj.value = obj.save;
    }   
  }
  else if(e == "focus"){
    if(obj.value == ""){
      obj.value = obj.save;
    }
    else if(obj.value == obj.save){
      obj.value = "";
    }
  }
}

/* Funcao validate para o validate */
function validate(label, id, mensage){
  jQuery.validator.addMethod(id, function(value, element){
    if(value == label){
      return false;
    }
    return true;
  }, mensage);
}

/* funcao download file */
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();}
}

$(document).ready(function(){
    
    validaReclamacao();
    
    $('.horizontalmove7-item a img').each(function(){
      var elem = $(this).attr('name');
      $(this).data('codigo',elem);
    }); 
     
    $(".horizontalmove7-item img").click(function(){
        if($(this).hasClass('select'))
          return;
        
        $('.select').removeClass('select');
        $(this).addClass('select');  
    });
      
    /*Bloco de subcategorias*/
    $('.bloco-categorias').hide();
    
    $('.titulo-subfaixa').each(function(){
      var $this = $(this);
      $(this).hover(function(){
        if(!$this.find('.bloco-categorias').hasClass('selecionado')){
          var aux = $('.titulo-subfaixa').find('.selecionado');
          aux.removeClass('selecionado');
          aux.hide();
        }
        $this.find('.bloco-categorias').stop(false,true).toggle('fast');
        $this.find('.bloco-categorias').toggleClass('selecionado');
      },function(){
        if(!$this.find('.bloco-categorias').hasClass('selecionado')){
          var aux = $('.titulo-subfaixa').find('.selecionado');
          aux.removeClass('selecionado');
          aux.hide();
        }
        $this.find('.bloco-categorias').stop(false,true).hide();
        $this.find('.bloco-categorias').toggleClass('selecionado');
      });
    });
    
    /* faixa preta na pagina estrutura */
    if(jQuery.browser.msie && jQuery.browser.version<8){
      $('.bloco-img-estrutura').find('.faixa-estrutura').stop().css({top: '270px'});
    }else{
    $('.bloco-img-estrutura').each(function(){$(this).hover(function(){
      $(this).find('.faixa-estrutura').stop().animate({top: '270px'},300,'easeOutSine');
    },
    function(){
      $(this).find('.faixa-estrutura').stop().animate({top: '305px'},300,'easeOutSine');
    });});
    }
    
    /* menu */
    $('header ul li').css({backgroundPosition:"0 -68px"}).hover(
      function(){
        if(!$(this).hasClass(page)){
          $(this).stop(true,true).animate({backgroundPosition:"0 0"},600,'easeOutExpo');
        }
      },
      function(){
        if(!$(this).hasClass(page)){
          $(this).stop(true,true).animate({backgroundPosition:"0 -68px"},600,'easeOutExpo');
        }  
      })
      
    $('.' + page).css({backgroundPosition:"0 0"});
    
    /*-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
       Horizontal move
     *-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_*/
    $('#my-gallery').horizontalmove({});
    
    var instance2; $(function(){
    instance2 = $('#my-gallery2').horizontalmove({
    page:0,
    time:400,
    ease:'easeOutSine',
    main:'.horizontalmove2-main:first',
    mask:'.horizontalmove2-mask:first',
    left:'.horizontalmove2-left',
    right:'.horizontalmove2-right',
    item:'.horizontalmove2-item',
    onComplete:function(data){
    //data = true
    },
    callBack:function(page){
    currentPage(page);
    }
    });
    
    $('.botao-data').click(function(e){
    	instance2.setPage($(this).attr('name'));
    	$('.select').removeClass('select');
    	$(e.target).addClass('select');
    });
    
    $('.horizontalmove2-right,.horizontalmove2-left').click(function(){
    	$('.select').removeClass('select');
    	$('.botao-data[name='+instance2.cp()+']').addClass('select');
    });
    
   }); 
    var instance; $(function(){
    instance = $('#my-gallery3').horizontalmove({
    page:0,
    time:400,
    ease:'easeOutSine',
    main:'.horizontalmove3-main:first',
    mask:'.horizontalmove3-mask:first',
    left:'.horizontalmove3-left',
    right:'.horizontalmove3-right',
    item:'.horizontalmove3-item',
    onComplete:function(data){
    //data = true
    },
    callBack:function(page){
    currentPage(page);
    }
    });
  });
  var instance; $(function(){
    instance = $('#my-gallery7').horizontalmove({
    page:0,
    time:1500,
    ease:'easeOutSine',
    main:'.horizontalmove7-main:first',
    mask:'.horizontalmove7-mask:first',
    left:'.horizontalmove7-left',
    right:'.horizontalmove7-right',
    item:'.horizontalmove7-item',
    onComplete:function(data){
    //data = true
    },
    callBack:function(page){
    currentPage(page);
    }
    });
  });
  var instance; $(function(){
    instance = $('#my-gallery4').horizontalmove({
    page:0,
    time:1,
    ease:'easeOutSine',
    main:'.horizontalmove4-main:first',
    mask:'.horizontalmove4-mask:first',
    left:'.horizontalmove4-left',
    right:'.horizontalmove4-right',
    item:'.horizontalmove4-item',
    onComplete:function(data){
    //data = true
    },
    callBack:function(page){
    currentPage(page);
    }
    });
  });
  var instance; $(function(){
    instance = $('#my-gallery5').horizontalmove({
    page:0,
    time:500,
    ease:'easeOutSine',
    main:'.horizontalmove5-main:first',
    mask:'.horizontalmove5-mask:first',
    left:'.horizontalmove5-left',
    right:'.horizontalmove5-right',
    item:'.horizontalmove5-item',
    onComplete:function(data){
    //data = true
    },
    callBack:function(page){
    currentPage(page);
    }
    });
    
    /*
     * BANNER
     */
    
    /* Variavel da funcao setInterval */ 
    var intervalo = null;
    var intervalo2 = null;

    /* Funcao de intervalo */
    move();
    
    $('#pagination-move li').each(function(){
      var value = $(this).find('a').attr('href');
      $(this).val(value);
    });
    
    $('#pagination-move li a').click(function(){
      $('#flechas').stop().animate({left:positions[$(this).attr('href')]-10+"px"},1000,'easeOutExpo');
      var page = $(this).attr('href');
    
      instance.setPage(page);

      clearInterval(intervalo);
      move();
      return false;
      
    });
    
    function currentPage(page){
      $('#pagina-atual').html((parseInt(page) + 1) + "");
      $('#pagina-atual').val(parseInt(page) + 1);
      $('#flechas').stop().animate({left:positions[page]-5+"px"},1000,'easeOutExpo');
    }
    
    function move(){
      intervalo = setInterval(function(){
        if($('#pagina-atual').val()== numBanners){
          setTimeout(function(){instance.setPage(0);},100)
        }
        $('.horizontalmove5-right').trigger('click');
      },5000);
    }
    
    $('.horizontalmove5-right, .horizontalmove5-left').click(function(){
      clearInterval(intervalo);
      move();
    });
    
  });/*Fecha o my-gallery 5*/
  
if(page!='home'){ 
  var instance; $(function(){
    instance = $('#my-gallery6').horizontalmove({
    page:0,
    time:1500,
    ease:'easeOutExpo',
    main:'.horizontalmove6-main:first',
    mask:'.horizontalmove6-mask:first',
    left:'.horizontalmove6-left',
    right:'.horizontalmove6-right',
    item:'.horizontalmove6-item',
    onComplete:function(data){
    //data = true
    },
    callBack:function(page){
    currentPage(page);
    }
    });

    /* Funcao de intervalo */
    move2();
    
    $('#pagination-move2 li').each(function(){
      var value = $(this).find('a').attr('href');
      $(this).val(value);
    });
    
    $('#pagination-move2 li a').click(function(){
      $('#flechas2').stop().animate({left:positions2[$(this).attr('href')]-10+"px"},1000,'easeOutExpo');
      var page = $(this).attr('href');
    
      instance.setPage(page);

      clearInterval(intervalo2);
      move2();
      return false;
      
    });
    
    function currentPage(page){
      $('#pagina-atual2').html((parseInt(page) + 1) + "");
      $('#pagina-atual2').val(parseInt(page) + 1);
      $('#flechas2').stop().animate({left:positions2[page]-5+"px"},1000,'easeOutExpo');
    }
    
    function move2(){
      intervalo2 = setInterval(function(){
        if($('#pagina-atual2').val()== numBanners2){
          setTimeout(function(){instance.setPage(0);},100)
        }
        $('.horizontalmove6-right').trigger('click');
      },5000);
    }
    
    $('.horizontalmove6-right, .horizontalmove6-left').click(function(){
      clearInterval(intervalo2);
      move2();
    });
    
    $('.item-banner a').hover(function(){
      $(this).prev('div').css({textDecoration:'underline'});
    },function(){
      $(this).prev('div').css({textDecoration:'none'});
    });
    
  });/*Fecha o my-gallery 6*/
}/*fecha if home */    
    
    /*
     * Footer
     */
    $('#twitter,#facebook,#blog,#linkedin,#youtube').tipsy({gravity: 'n', fade: true});
    /*
     * Representantes
     */
    $('.representante-endereco').hide();
    
    $('#content-representantes h2').click(function(){
      $(this).next('ul').stop().toggle();
      if(!$(this).hasClass('selected')){
        $('.selected').next('ul').hide();
      }
      $('.selected').removeClass('selected');
      $(this).addClass('selected');
    })
    
    /*
     * jq transform
     */
     try {
        $("#form-contato").jqTransform();
        $("#trabalhe-form").jqTransform();
        $("#form-reclamacao").jqTransform();
        if(page == 'trabalhe')
         $(".jqTransformSelectWrapper").css({'float': 'none',marginLeft: '5px',marginBottom: '-9px'});
     }catch(e){}
   
   /*
    * Mapa google
    */  
   if (document.getElementById('mapa')) {
    if (typeof google == 'undefined') return;
    var latlng = COORDS.split(',');

    latlng = new google.maps.LatLng(latlng[0],latlng[1]);

    var mapDiv = document.getElementById('mapa');
    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/marker2.png",
        title: "PLAXMETAL"
    });
  }
  
    
  /*contato validate*/
  $("#fone").mask("(99) 9999-9999");
  $("#cep").mask("99999-999");
  $("#form-contato").validate({
      rules: {
        'nome':{required:true},
        'email2':{required:true, email:true},
        'fone':{required:true},
        'departamento':{required:true},
        'cidade':{required:true},
        'mensagem':{required:true}
      },
      messages: {   
        email2:{required:"<span style='color:red;'>Campo E-mail Obrigat�rio !</span></br>", email:"<span style='color:red;'>Campo E-mail Inv�lido !</span></br>"},
        nome:{required:"<span style='color:red;'>Campo Nome Obrigat�rio !</span></br>"},
        fone:{required:"<span style='color:red;'>Campo Telefone Obrigat�rio !</span></br>"},
        departamento:{required:"<span style='color:red;'>Campo Departamento Obrigat�rio !</span></br>"},
        cidade:{required:"<span style='color:red;'>Campo Cidade Obrigat�rio !</span></br>"},
        mensagem:{required:"<span style='color:red;'>Campo Mensagem Obrigat�rio !</span></br>"}
      },
      submitHandler:function(form){
        var options = 
        {   
          beforeSubmit:  showRequest,  
          success:       showResponse
        };
        
        function showRequest(formData, jqForm, options){
        } 
        
        function showResponse(data)  
        {
          if($.trim(data) == "true")
          {
            $("#msg-contato").html("<div style=\"color:green; \">Mensagem enviada com sucesso.</div>");
            setTimeout(function(){
               $("#msg-contato").html('');
            },1500);
            $('#form-contato').clearForm();      
            
          }else{          
            $("#msg-contato").html("<div style=\"color:red; \">Erro desconhecido.</div>");
            setTimeout(function(){
               $("#msg-contato").html('');
            },1500);       
          }
        }
        $("#msg-contato").append('<div id="contato-send">Aguarde um momento</div>');
        $("#form-contato").ajaxSubmit(options);
      },
      errorLabelContainer: $("#erro")
    });
  
  
  /* Newsletter validate */
  $("#newsletter-form").validate({
    rules: {
        'nome2':{required:true,nome2:true},
        'email2':{required:true, email:true,email2:true}
      },
      messages: {
        nome2:{required:"<span style='color:red;'>Campo Nome Obrigat�rio !</span></br>"},   
        email2:{required:"<span style='color:red;'>Campo E-mail Obrigat�rio !</span></br>", email:"<span style='color:red;'>Campo E-mail Inv�lido !</span></br>"}
      },
      submitHandler:function(form){
        var options = 
        {   
          beforeSubmit:  showRequest,  
          success:       showResponse
        };
        
        function showRequest(formData, jqForm, options){} 
   
        function showResponse(data)  
        { 
          if($.trim(data) == "true")
          {
            $("#msg-news").html("<div style=\"color:green; \">Email cadastrado com sucesso.</div>");
            setTimeout(function(){
               $("#msg-news").html('');
            },1500);
            $('#newsletter-form').clearForm();      
            
          }else if($.trim(data) == "false"){          
            $("#msg-news").html("<div style=\"color:red; \">Erro desconhecido.</div>");
            setTimeout(function(){
               $("#msg-news").html('');
            },1500);       
          }else{
            $("#msg-news").html("<div style=\"color:red; \">Este email j� est� cadastrado!</div>");
            setTimeout(function(){
               $("#msg-news").html('');
            },1500);   
          }
        } 
        $("#msg-news").append('<div id="contato-send">Aguarde um momento</div>');
        $("#newsletter-form").ajaxSubmit(options);
      },
      errorLabelContainer: $("#erro-news")
  });
  
  validate("Nome","nome2","<span style='color:red;'>Campo Nome Obrigat�rio !</span></br>");
  validate("E-Mail","email2","<span style='color:red;'>Campo E-mail Obrigat�rio !</span></br>");    
  
  /* Trabalhe validade */
  $("#trabalhe-form").validate({
  rules: {
        'nome':{required:true},
        'email':{required:true, email:true},
        'fone':{required:true},
        'cidade':{required:true},
        'estado':{required:true},
        'cep':{required:true},
        'curriculo':{required:true},
        'area':{required:true}
      },
      messages: {
        nome:{required:"<span style='color:red;'>Campo Nome Obrigat�rio !</span></br>"},   
        email:{required:"<span style='color:red;'>Campo E-mail Obrigat�rio !</span></br>", email:"<span style='color:red;'>Campo E-mail Inv�lido !</span></br>"},
        fone:{required:"<span style='color:red;'>Campo Fone Obrigat�rio !</span></br>"},
        cidade:{required:"<span style='color:red;'>Campo Cidade Obrigat�rio !</span></br>"},
        estado:{required:"<span style='color:red;'>Campo Estado Obrigat�rio !</span></br>"},
        cep:{required:"<span style='color:red;'>Campo CEP Obrigat�rio !</span></br>"},
        curriculo:{required:"<span style='color:red;'>Campo Curriculo Obrigat�rio !</span></br>"},
        area:{required:"<span style='color:red;'>Campo �rea de Interesse Obrigat�rio !</span></br>"}               
      },
      submitHandler:function(form){
        
        var options = 
        {   
          beforeSubmit:  showRequest,  
          success:       showResponse
        };
        
        function showRequest(formData, jqForm, options){
          $("#trabalhe-msg").append('<div id="contato-send">Aguarde um momento</div>');
        } 
   
        function showResponse(data)  
        {
          if($.trim(data) == "true")
          {

            $("#trabalhe-msg").html("<div style=\"color:green; \">Curr�culo enviado com sucesso.</div>");
            setTimeout(function(){
               $("#trabalhe-msg").html('');
            },1500);
            $('#trabalhe-form').clearForm();      
            
          }else if($.trim(data) == "false"){          
            $("#trabalhe-msg").html("<div style=\"color:red; \">Erro desconhecido.</div>");
            setTimeout(function(){
               $("#trabalhe-msg").html('');
            },1500);
          }else if($.trim(data) == "arquivoinvalido"){
            $("#trabalhe-msg").html("<div style=\"color:red; \">Arquivo inv�lido!</div>");
            setTimeout(function(){
               $("#trabalhe-msg").html('');
            },1500);
          }
        }
         
        $("#trabalhe-form").ajaxSubmit(options);
      },
      errorLabelContainer: $("#trabalhe-erro")
  });
  
  /* lightbox */
  $('.image-eventos').lightBox();
  $('.img-estrutura-link').lightBox();
  $('.dimensoes').lightBox();
  
  /* fucntion para pocisioanr paginacao do banner */
  setBannerPosition();
  if(page!='home')
    setBannerPosition2();
    
  /* banner interna underline */  
  $('.bloco-texto a').hover(function(){
    $('.bloco-texto div').css({textDecoration:'underline'});
  },function(){
    $('.bloco-texto div').css({textDecoration:'none'});  
  });
  
  /*videos*/
  $(".draggable").draggable({opacity:'0.7',containment:'body' ,revert: true, helper: 'clone', zIndex: 2700, iframeFix: true});
  
  $(".draggable").dblclick(function(){
    
    var video = $(this).data('video');
    
    $.ajax({
      url: SITE+"/gera_texto",
      global: false,
      type: "POST",
      data: {value : video},
      dataType: "html",
      async:false,
      success: function(msg){
         $('.video-info-g').html('').append(msg);
      }
    });
    
    var pathVideo = 'http://www.youtube.com/v/' + video +'?version=3&autoplay=1&feature=player_embedded';
    
    var object = $(
      '<object style="height: 430px; width: 650px"><param name="movie" value="'+pathVideo+'"> <param name="allowFullScreen" value="true"><param name="allowScriptAccess" value="always"><param name="wmode" value="transparent"><embed src="'+pathVideo+'" type="application/x-shockwave-flash" wmode="transparent" allowfullscreen="true" allowScriptAccess="always" width="650" height="420"></object>'      
    )
    
    $(".droppable").html('').append(object);
  });
  
  $('.draggable').each(function(){
    var elem = $(this).attr('name');
    $(this).data('video',elem);
  });
  
  function changeVideo(event,ui){
    
    $.ajax({
      url: SITE+"/gera_texto",
      global: false,
      type: "POST",
      data: {value : ui.draggable.attr('name')},
      dataType: "html",
      async:false,
      success: function(msg){
         $('.video-info-g').html('').append(msg);
      }
    });
    
    var pathVideo = 'http://www.youtube.com/v/' + ui.draggable.data('video')+'?version=3&autoplay=1&feature=player_embedded';
    
    var object = $(
      '<object style="height: 430px; width: 650px"><param name="movie" value="'+pathVideo+'"> <param name="allowFullScreen" value="true"><param name="allowScriptAccess" value="always"><param name="wmode" value="transparent"><embed src="'+pathVideo+'" type="application/x-shockwave-flash" wmode="transparent" allowfullscreen="true" allowScriptAccess="always" width="650" height="420"></object>'      
    )
    
    var app = $(".droppable").html('').append(object);
  }
  
  $(".droppable").droppable({
    hoverClass: 'hovered',
    drop:changeVideo  
  });
  
});




var email_regexp = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);

function valid_email(email) {
    return email_regexp.test(email);
}

jQuery(function($){
    
    jQuery.placeholderize();

});

(function($){

    $.placeholderize = function(){

        // Verifica se o browser suporta o atributo placeholder
        if ( true ) {//!$('<input placeholder="1" />')[0].placeholder ) {

            // Fallback para o atributo placeholder
            $('[placeholder]').each(function(){

                var input = $(this);

                input

                    .bind('focus, focus.mask', function(){
                        if (input.val() == input.attr('placeholder')) {
                            input.val('');
                        }
                    })

                    .bind('blur, blur.mask', function(){
                        if (input.val() == '') {
                            input.addClass('placeholder').val(input.attr('placeholder'));
                        }
                    })

                    .bind('focus, focus.mask', function(){
                        input.removeClass('placeholder');
                    })

                    // Invoca o evento, para aplicar a fun��o de fallback
                    .blur();
            });

        }
    };
})(jQuery);



/* funcoes banner */
function setBannerPosition(){
  var total = numBanners;
  var l = 950/(total-1);

  for(i=0;i<total;i++){
    var obj = '#pagination-move li[value='+i+']';
    $(obj).css({left:((l*i)-2)+'px'});
    positions[i] = l*i;
  }
}

function setBannerPosition2(){
  var total = numBanners2;
  var l = 950/(total-1);
  
  for(i=0;i<total;i++){
    var obj = '#pagination-move2 li[value='+i+']';
    $(obj).css({left:((l*i)-2)+'px'});
    positions2[i] = l*i;
  }
}

function validaReclamacao(){
  
  $("#form-reclamacao").validate({
  rules: {
        'nome':{required:true},
        'email':{required:true, email:true},
        'assunto':{required:true},
        'local':{required:true},
        'nf':{required:true},
        'codigo':{required:true},
        'dtcompra':{required:true},
        'descricaoprod':{required:true},
        'descricaoprob':{required:true}
      },
      messages: {
        nome:{required:"<span style='color:red;'>Campo Nome Obrigat�rio !</span></br>"},   
        email:{required:"<span style='color:red;'>Campo E-mail Obrigat�rio !</span></br>", email:"<span style='color:red;'>Campo E-mail Inv�lido !</span></br>"},
        assunto:{required:"<span style='color:red;'>Campo Assunto Obrigat�rio !</span></br>"},
        local:{required:"<span style='color:red;'>Campo Local Obrigat�rio !</span></br>"},
        nf:{required:"<span style='color:red;'>Campo Nota Fiscal Obrigat�rio !</span></br>"},
        codigo:{required:"<span style='color:red;'>Campo C�digo do produto Obrigat�rio !</span></br>"},
        dtcompra:{required:"<span style='color:red;'>Campo Data de Compra Obrigat�rio !</span></br>"},         
        descricaoprod:{required:"<span style='color:red;'>Descri��o do produto Obrigat�rio !</span></br>"},               
        descricaoprob:{required:"<span style='color:red;'>Descri��o do problema Obrigat�rio !</span></br>"}             
      },
      submitHandler:function(form){
        
        var options = 
        {   
          beforeSubmit:  showRequest,  
          success:       showResponse
        };
        
        function showRequest(formData, jqForm, options){
          $("#msg-reclamacao").append('<div id="contato-send">Aguarde um momento</div>');
        } 
   
        function showResponse(data)  
        {
          if($.trim(data) == "foto-true")
          {
            $("#msg-reclamacao").html("<div style=\"color:green; \">Enviado com sucesso.</div>");
            setTimeout(function(){
              $("#msg-reclamacao").html('');
            },1500);
            $('#form-reclamacao').clearForm();                
          }else if($.trim(data) == "foto-false"){          
            $("#msg-reclamacao").html("<div style=\"color:red; \">Erro desconhecido.</div>");
            setTimeout(function(){
              $("#msg-reclamacao").html('');
            },1500);
          }else if($.trim(data) == "foto-arquivoinvalido"){
            $("#msg-reclamacao").html("<div style=\"color:red; \">Arquivo inv�lido!</div>");
            setTimeout(function(){
              $("#msg-reclamacao").html('');
            },1500);
          }
        }
         
        $("#form-reclamacao").ajaxSubmit(options);
      },
      errorLabelContainer: $("#erro")
  });
  
}

