// JavaScript Document

function custommsg() {
	$('#form-message').show(); 
	$('#form-message').html('Obrigado pelo contato!'); 
	$('#modal_form').hide();
}

function slideSwitch() {
    var $active = '';
	$active = $('#slideshow IMG.active');

    if ( ($active.length == 0) || ($active.length == null) || ($active.length == undefined) )
	{
		$active = $('#slideshow IMG:last');
	}
	 
    var $next =  $active.next().length ? $active.next() : $('#slideshow IMG:first').addClass('active');
	
    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

function closemodal(){
	$('#modal_form').fadeOut('fast');
	$('#modal').fadeOut('fast');
	$('#form-message').fadeOut('fast');
}

function openmodal(){
	$('#modal').show();
	$('#modal_form').show();
	
	$('#modal').live('click', function(){
		closemodal();
	});
}


$(document).ready(function($){
	
	$('.pacotes').click(function(){
	 target = $('#pacotes').offset().top;
	 $('html, body').animate({scrollTop:target}, 2000);
	  return false; 
	});
	
	$('.topo').click(function(){
	 target = $('#topo').offset().top;
	 $('html, body').animate({scrollTop:target}, 2000);
	  return false; 
	});
	
	setInterval( "slideSwitch()", 4000 );
	
	
	
	$('input[type="text"]').each(function() {
		var default_value = this.value;
		$(this).focus(function() {
			if(this.value == default_value) {
				this.value = '';
			}
		});
		$(this).blur(function() {
			if(this.value == '') {
				this.value = default_value;
			}
		});
	});
	
	$('textarea').each(function() {
		var default_value = this.value;
		$(this).focus(function() {
			if(this.value == default_value) {
				this.value = '';
			}
		});
		$(this).blur(function() {
			if(this.value == '') {
				this.value = default_value;
			}
		});
	});
	
	
});
