//jQuery.noConflict();
//delay
jQuery.fn.delay = function(time,func){
	this.each(function(){
		setTimeout(func,time);
	});
	
	return this;
};


jQuery(document).ready(function() {

	if ( jQuery("#s3slider").length > 0 ) { jQuery('#s3slider').s3Slider({ timeOut: 10000 }); }
	
    jQuery('#carousel-site').jcarousel({ });
	
    jQuery('#carousel-common').jcarousel({ });	

	jQuery('#toggle-footer').click( function() {
	
		jQuery('#footer-casas').slideToggle('slow', function() { 
			
			jQuery('#toggle-footer').html( jQuery(this).is(':visible') ? '-' : '+' ); 
			
		} );
	
	} );

	jQuery('#toggle-blog').click( function() {

		jQuery('#blog-container').slideToggle();

	} );

	jQuery('#filtro-casa').change( function() {

		var filtro = window.location.protocol + "//" + window.location.host;
		filtro += '?s=' + jQuery('#s').val();
		filtro += (jQuery(this).val() != '') ? '&casa=' + jQuery(this).val() : '';
		
		window.location = filtro;
		
	} );
	
	jQuery('a[href=#map]').click( function() {
			
		jQuery(this).delay(1000, function() {
			
			jQuery('#footer-casas:hidden').slideDown('slow', function() { jQuery('#toggle-footer').html('-'); } );
		
		});
		
	} );
	
	
	jQuery('#s').focus( function() {
		
		var texto = (jQuery(this).val() == 'Buscar no portal') ? '' : jQuery(this).val();
		
		jQuery(this).val( texto );
		
	} );	

	jQuery('#s').blur( function() {
		
		var texto = (jQuery(this).val() == '') ? 'Buscar no portal' : jQuery(this).val();
		
		jQuery(this).val( texto );
		
	} );
	
	jQuery('#club').focus( function() {
		
		var texto = (jQuery(this).val() == 'Clube Matriz: digite seu email') ? '' : jQuery(this).val();
		
		jQuery(this).val( texto );
		
	} );	

	jQuery('#club').blur( function() {
		
		var texto = (jQuery(this).val() == '') ? 'Clube Matriz: digite seu email' : jQuery(this).val();
		
		jQuery(this).val( texto );
		
	} );	
	
});

