/***********************************************************************
 * Desenvolvido por: Afixar - Desenvolvimento Web e Design             *
 * Conteúdo protegido pela lei Nº 9.610/98 de Direitos Autorais.       *
 * É expressamente proibida a cópia ou reprodução sem autorização.     *
 ***********************************************************************/

/***************************************************************************
 * VERSAO DO NAVEGADOR                                                     * 
 ***************************************************************************/

if ($.browser.msie) { 
    if($.browser.version <= "6.0"){
            document.write("<div id=ie><b>Atenção:</b> Você está usando o Internet Explorer 6 ou inferior, um navegador obsoleto e com falhas de segurança. Para uma melhor visualização do site atualize <a href='http://www.updateyourbrowser.net/pt/' style='color: #333399; text-decoration:none;'><b>clicando aqui</b></a> .</div>");
    }
}


/***************************************************************************
 * FONTES                                                                  * 
 ***************************************************************************/ 


Cufon.replace('.kozuka-light', { hover: true, fontFamily: 'kozuka-light' });
Cufon.replace('.kozuka', { hover: true, fontFamily: 'kozuka'});

Cufon.replace('.menu_nav', { hover: true, fontFamily: 'kozuka'});



/***************************************************************************
 * DROPDOWN                                                                * 
 ***************************************************************************/


	$(document).ready(function (){ 
	   
       
       $('#obra_dropdown').hover(function (){ 
	       $("#sub_obras").fadeIn();   
        });
       $('#sub_obras').hover(function (){ 
	       $("#sub_obras").fadeIn();   
        },function (){
           $("#sub_obras").hide(); 
            
        }); 
        
       
	});
    
    
    
    


/***************************************************************************
 * IMPRIMIR                                                                * 
 ***************************************************************************/
 
$(document).ready(function(){

   $("#imprimir").click(function(){  window.print(); });

});

 
 


/***************************************************************************
 * BANNER                                                                  * 
 ***************************************************************************/ 

(function($){
	$(function(){
		$('#nav>li>a').hover(
			function(){
				$(this).stop(1);
				$(this).animate({'background-position':'0px 0'});
			},
			function(){
				$(this).stop(1);
				$(this).animate({'background-position':'-140px 0'});
			}
		)
		
		$('.boxgrid').each(function(){
			var $caption = $(this).find('span.boxcaption');
			var pheight = $(this).height();
			$caption.css('top', pheight );
			
			$(this).hover(
				function(){
					$caption.stop(1);
					$caption.animate({ top: pheight - $caption.height() });
				},
				function(){
					$caption.stop(1);
					$caption.animate({ top: pheight	})
				}
			)
		});
	});
})(jQuery);



    
/***************************************************************************
 * CAROUSEL                                                                * 
 ***************************************************************************/

var carousel = 3; 
var carouselN = 0;

function cBack(obj,width){


    carouselN--;    
  
    if(carouselN < 0){ 
        ult = width*2;

        $("#"+obj).animate({marginLeft: "-"+ult},1200);
        carouselN = 2;     
    } else {
        $("#"+obj).animate({marginLeft: "+="+width},1200);
    }
}

function cNext(obj,width){
                
    carouselN++;    
    if(carouselN==carousel){ 
        $("#"+obj).animate({marginLeft: 0},1200);   
        carouselN = 0;     
    } else {
        $("#"+obj).animate({marginLeft: "-="+width},1200);
    }
    
}




    
/***************************************************************************
 * VALORES                                                                 * 
 ***************************************************************************/

function getValores(val){ 
    
        if (val=="venda") { 
        
            var newOptions = {
                    '0@0' : 'Faixa de preço',
                    '0@200.000' : 'Até 200 Mil',
                    '200.000@200.000' : '200 Mil até 400 Mil',
                    '400.000@600.000' : '400 Mil até 600 Mil',
                    '600.000@800.000' : '600 Mil até 800 Mil',
                    '800.000@1.000.000' : '800 Mil até 1 Milhão',
                    '1.000.000@0' : 'Acima de 1 Milhão'
            };
          
        
        
        } else if (val=="aluguel") {
        
            var newOptions = {
                    '0@0' : '--', 
                    '0@500' : 'Até 500 Reais',
                    '500@1.000' : '500 reais até 1 Mil',
                    '1.000@2.000' : '1 Mil até 2 Mil',
                    '2.000@3.000' : '2 Mil até 3 Mil',
                    '3.000@4.000' : '3 Mil até 4 Mil',
                    '4.000@5.000' : '4 Mil até 5 Mil',
                    '5.000@0' : 'Acima de 5 Mil'
            };
        }
        
        
        
        $('#selectValor').html('<select id="valor" name="valor" style="width:110px;"></select>');
        
        var select = $('#valor');
        if(select.prop) {  var options = select.prop('options');   }
        else { var options = select.attr('options'); }
        $('option', select).remove();
        
        $.each(newOptions, function(val, text) { options[options.length] = new Option(text, val);  });
        
        
        $("#valor").selectbox();
        
        
   
}


/***************************************************************************
 * ADICIONAR AOS FAVORITOS                                                 * 
 ***************************************************************************/
 
    function favoritos(){
        
    	var url      = location;
    	var title    = "Linea Jr";
        if (window.sidebar){ 
    		window.sidebar.addPanel(title, url,""); 
    	} 
    	else if(window.opera && window.print){
            var mbm = document.createElement('a');
                mbm.setAttribute('rel','sidebar');
                mbm.setAttribute('href',url);
                mbm.setAttribute('title',title);
                mbm.click();
        }
        else if(document.all){
    		window.external.AddFavorite(url, title);
    	}

    }


  
/***************************************************************************
 * FONTE                                                                   * 
 ***************************************************************************/
 
// Para usar coloque o comando: "javascript:mudaTamanho('tag_ou_id_alvo', -1);" para diminuir
// e o comando "javascript:mudaTamanho('tag_ou_id_alvo', +1);" para aumentar

var tagAlvo = new Array('p'); //pega todas as tags p//

// Especificando os possíveis tamanhos de fontes, poderia ser: x-small, small...
var tamanhos = new Array( '12px','13px','14px','15px','16px','17px','18px','19px','20px' );
var tamanhoInicial = 2;

function mudaTamanho( idAlvo,acao ){
  if (!document.getElementById) return
  var selecionados = null,tamanho = tamanhoInicial,i,j,tagsAlvo;
  tamanho += acao;
  if ( tamanho < 0 ) tamanho = 0;
  if ( tamanho > 6 ) tamanho = 6;
  tamanhoInicial = tamanho;
  if ( !( selecionados = document.getElementById( idAlvo ) ) ) selecionados = document.getElementsByTagName( idAlvo )[ 0 ];

  selecionados.style.fontSize = tamanhos[ tamanho ];
  
  $(idAlvo).each(function(){
        
        $(this).css('font-size',tamanhos[ tamanho ]);
    
  });
  
  
  $('#conteudo div').each(function(){
        
        $(this).css('font-size',tamanhos[ tamanho ]);
    
  });  
  fontSize = tamanhos[ tamanho ]; 
  setCookie("font-size",fontSize,365);
    

  for ( i = 0; i < tagAlvo.length; i++ ){
    tagsAlvo = selecionados.getElementsByTagName( tagAlvo[ i ] );
    for ( j = 0; j < tagsAlvo.length; j++ ) tagsAlvo[ j ].style.fontSize = tamanhos[ tamanho ];
  }
}






/* View */

    $(document).ready(function() {
 

      var navF = $("#fotoview");
    				
        navF.find("a").each(function() {

  		        $(this).mouseenter(function() {

    
                    $(this).find(".view").animate({ opacity: "0"}, 1 );
                    
    				$(this).find(".view").animate({ opacity: "0.5"}, 100 );

                     
        		});
        		
        		$(this).mouseleave(function() {
        			$(this).find(".view").animate({  opacity: "0"}, 200 );
                    
        		});
            
        });
        
        navF.find("a").each(function() {
                
                $(this).find(".view").css({  opacity: "0"});
            
        });
        
  
});








var TRange=null;


function findString (str) {

 if (parseInt(navigator.appVersion)<4) return;

 var strFound;

 if (window.find) {


  strFound=self.find(str);

  if (!strFound) {

   strFound=self.find(str,0,1);

   while (self.find(str,0,1)) continue;

  }

 }

 else if (navigator.appName.indexOf("Microsoft")!=-1) {



  // EXPLORER-SPECIFIC CODE



  if (TRange!=null) {

   TRange.collapse(false);

   strFound=TRange.findText(str);

   if (strFound) TRange.select();

  }

  if (TRange==null || strFound==0) {

   TRange=self.document.body.createTextRange();

   strFound=TRange.findText(str);

   if (strFound) TRange.select();

  }

 }

 else if (navigator.appName=="Opera") {

  alert ("Opera browsers not supported, sorry...")

  return;

 }

 if (!strFound) alert ("String '"+str+"' not found!")

 return;

}


    
/***************************************************************************
 * FALE CONOSCO                                                            * 
 ***************************************************************************/

$(document).ready(function() {
 
    
 
    $("#telefone").mask("(99) 9999-9999");

	$("#form").bind("submit", validar);
 
    function validar(e){

        canSubmit = true;

        $("[req=true]").each(function(){
            if($(this).val().length < 1){
                 canSubmit = false; 
                 $(this).css('background','#FAF6D9');    
            } else { 
                $(this).css('background','white'); 
            }
        });
 
        
        if(canSubmit == false) { 
                           
            $('#msgRetornoInsc').html('Preencha todos os campos');
            $('#dialogAlerta').fadeIn();
            setTimeout(function(){ $('#dialogAlerta').fadeOut() }, 5500); 
           return false;

        } else { 
             $('#dialogOk').fadeIn();
 
             setTimeout(function(){  $('#formContato').submit(); }, 5500); 
            
        } 
    
    }
 
});





function relacionamento(){ 
        
        $(function(){
                        
             $("#relacionamento").dialog({
                modal: true,
                autoResize:true,
                dialogClass: 'alert',
                resizable: false,
            	autoOpen: true,
                title: 'Relacionamento com o Cliente',
            	width: 760,
                height: 400,
                zindex: 1000,
                draggable: false,
                buttons:{ "FECHAR": function(){  $(this).dialog("close"); } }                
             });
             
             $(".ui-dialog-titlebar").hide();
             
        });
    
}


    
/***************************************************************************
 * NEWSLETTER                                                              * 
 ***************************************************************************/

function newsletter(){ 
    
     if($("#newsletter_nome").val()=="Seu nome" || $("#newsletter_email").val()=="E-mail"){ 
     
        alert('Preencha todos os campos corretamente.')   
        
     } else { 
     
     
        $.post('newsletter/cadastrar', { 
               nome: $("#newsletter_nome").val(), 
               email: $("#newsletter_email").val()
        }, 
        function(data) {
    
           alert(data);

    
            
        });
    }
}

