jQuery.fn.extend({
    printLabel: function( label ) {

        $(this).val(label);
        $(this).focus(function(){ if($(this).val() == label) {$(this).val(''); }});
        $(this).blur(function(){ if($(this).val() == '') {$(this).val(label); }});
    }
});
// JavaScript Document
$(document).ready(function(){
	
	// Validação
 	$("#contato").validate();
	$("#newsletter").validate();

        $("form[name=enviar_boletim]").validate({
                rules: {
                        btlm_nome: {
                                required: true
                        },
                        btlm_email: {
                                required: true,
                                email: true
                        },
                        btlm_mensagem: "required"
                }

        });

	// Máscara
        $(".telefone").mask("(99) 9999-9999");
	$(".data").mask("99/99/9999");
	$(".cep").mask("99999-999");

        $("input[name=btlm_nome]").printLabel("Nome...");
        $("input[name=btlm_email]").printLabel("E-mail...");
        $("textarea[name=btlm_mensagem]").printLabel("Mensagem...");
	
	// Máscara
	$('#como_conheceu').change(function(){

        if(($(this).val() == 'Outro')) {
            $('li.como_conheceu').css('display','block');

            if($('body').find('#outro').size() == 0) {

                var html = '<label for="outro">Favor especificar</label><input type="text" name="outro" id="outro" class="required" value="" />';

                $(html).appendTo('li.como_conheceu');
            }

        } else {
            $('li.como_conheceu').css('display','none');

        }

    }); 
	
    // Abrir div
    $(".link-to-content-expand").click(function(){
       var indice = $(".link-to-content-expand").index(this);
       $(".content-expand").eq(indice).slideToggle("slow");
       return false;
    });
	
	//Painel
	// Expand Panel
	/*$("#open").click(function(){
		$("div#panel").slideDown("slow");
	
	});
	
	// Collapse Panel
	$("#close").click(function(){
		$("div#panel").slideUp("slow");	
	});		
	
	// Switch buttons from "Log In | Register" to "Close Panel" on click
	$("#toggle a").click(function () {
		$("#toggle a").toggle();
	});*/
	
	//Menu dropdown
	$(document).ready(function(){
		$('.nav li.sub').hover(
			function() { $('ul', this).css('display', 'block'); },
			function() { $('ul', this).css('display', 'none'); });
	});
	
	//Carrossel
	jQuery(document).ready(function() {
    	jQuery('#mycarousel_1').jcarousel();
	});
	
	jQuery(document).ready(function() {
    	jQuery('#mycarousel_2').jcarousel();
	});

}); //Fim JS



