/***************************
LIGHTBOX GALERIA
***************************/
$(function() {
	$('#galeria .lb').lightBox();
});
$(function() {
	$('#galeria .lb').lightBox({
		overlayBgColor: '#000',
		overlayOpacity: 0.6,
		imageLoading: 'lightbox/img/loading.gif',
		imageBtnClose: 'lightbox/img/close.gif',
		imageBtnPrev: 'lightbox/img/prev.gif',
		imageBtnNext: 'lightbox/img/next.gif',
		txtImage: 'Imagem',
		txtOf: 'de'
	});
});

$(document).ready(function(){

	if($.browser.msie == true){
            var browserVersion = jQuery.browser.version;
            if(browserVersion == '6.0' || browserVersion == '7.0'){
                window.location.href = "http://www.rz2.com.br/atualize-seu-navegador.php";
            }
	}

	/***************************
	PULA CAMPO DDD
	***************************/
	$('#ddd').keyup(function(){
		var tamanho = $(this).val().length;
		if(tamanho >= 2) {
			$('#telefone').focus();
		}
	});

	/***************************
	CARREGA CIDADES
	***************************/
	$('#estado').change(function(){
		if($(this).val() != ""){
			$('#cidade').html('<option value="">carregando...</option>');
			var estado = $(this).val();
			$.post("config/ajax_carregar_cidade.php", {estado:estado}, function(result){
				$('#cidade').html(result);
			});
		}
		else{
			$('#cidade').html('<option value=""></option>');
		}
	});

	/***************************
	VALIDA FORM DE CONTATO
	***************************/
	$('#enviar').click(function(){
		var erro = false;
		$('input[req=1]').each(function(){
			if($(this).val() == ""){
				erro = true;
			}
		});
		if(erro){
			alert("Por favor, preencha nome e telefone");
			return false;
		}
		else{
			return true;
		}
	});
        
        $(".abremenu").hover(
            function() {
                $(this).find("#submenu").show();
            },
            function() {
                $(this).find("#submenu").hide();
            }
	);
        
        $('#newsletter2').focus(function(){
                    $(this).val('');
        });
    
         $('#newsletter2').blur(function(){
            if($(this).val() == ''){
                $(this).val('Digite aqui seu email e clique no envelope para cadastrar-se.');
        }
    });
	
	 $('#newsletter3').focus(function(){
                    $(this).val('');
        });
    
         $('#newsletter3').blur(function(){
            if($(this).val() == ''){
                $(this).val('Enter your email address here and click the envelope to register.');
        }
    });
	
        

});
