function slide(){
	$('#simpleNext').click();
}
var intervalId = window.setInterval(slide, 5000);

jQuery(document).ready(function($){
	
	/* Home */
	
	$(".submit-form ").click(function(){
		    $(this).parents().find("form").submit();
		});

		$('.clearMeFocus').each(function(){
		    $(this).attr('title', $(this).val());
		});
	
	
	
	$('.ct .cl.conheca h2 a, .ct .cl.conheca .bt-seta').mouseenter(function(){
		$('.ct .cl.conheca .bt-seta').css({
			'color' : '#ff3399'
		})
	})
	
	$('.ct .cl.conheca h2 a, .ct .cl.conheca .bt-seta').mouseleave(function(){
		$('.ct .cl.conheca .bt-seta').css({
			'color' : '#424242'
		})
	})
	
	/* Rodape */
	
	$('.rp ul.menu li a').colorbox({width:'80%', height:'80%', scrolling: true});
	
	/* Fale conosco */
	
	var clearMePrevious = '';

	// clear input on focus
	$('.clearMeFocus').focus(function() {
		if($(this).val()==$(this).attr('title')) {
			clearMePrevious = $(this).val();
			$(this).val('');
		}
	});
	
	// if field is empty afterward, add text again
	$('.clearMeFocus').blur(function()
	{
	if($(this).val()=='')
	{
	$(this).val(clearMePrevious);
	}
	});
	
	/* Faq - Lidas */
	function close_question(dd){
	    dd.removeClass('opened');
	    dd.slideUp(function(){
	        dd.children('p.b').hide();
	        dd.children('p.a').show();
	        dd.css('background', 'transparent');
	        dd.slideDown();
	    });
	}
	$('.ct.lidas dl dd p.b').click(function(){
        close_question($(this).parents('dd'));
    });
		
	$('.ct.lidas dl dd p.a a.more').click(function(){
	    var dd = $(this).parents('dd');
	    var id = $(this).attr('id');
	    
	    $('.ct.lidas dl dd.opened').each(function(){
	       var dd = $(this);
	       close_question(dd); 
	    });
	    
	        
	    dd.children('p.a').fadeOut(function(){
	        dd.css('background', '#fff');
	    	    dd.children('p.b').slideDown('slow');
	    	    dd.addClass('opened');
	    	    $.get(window.__root_url__ + 'faq/' + id + '/view/');
	    });
		return false;
	});
	
	
	
	$('.ct.lidas dl dd p.b a.less, .ct.lidas dl dd p.background').click(function(){
	        close_question($(this).parents('dd'));
	        
	        return false;
		
	});
	

	
	/* Faq - Lidas */
	
	$('.ct.duvidas dl dd').hide();
		
	function close_question_doubt(dd){
	    dd.removeClass('opened');
	    dd.slideUp(function(){
	        //dd.show();
	        dd.css('background', 'transparent');
	        dd.slideUp();
	    });
	}
	
	$('.ct.duvidas dl dt').click(function(){
	    var dd = $(this).next('dd');
	    var id = $(this).attr('id');
	    
	    if(dd.hasClass('')){
	    
    	    $('.ct.duvidas dl dd.opened').each(function(){
    	       var dd = $(this);
    	       close_question_doubt(dd); 
    	    });
	    
        
    	    dd.fadeOut(function(){
    	        dd.css('background', '#fff');
        	    dd.slideDown('slow');
        	    dd.addClass('opened'); 
	        
        	    $.get(window.__root_url__ + 'faq/' + id + '/view/');
    	    });
    	}else{
                $(this).next().removeClass('opened');
    		    $(this).next().slideUp();
            return false;
    	}
		return false;
	});
	

	
	$('.ct.duvidas dl dd,').click(function(){
        $(this).removeClass('opened');
		$(this).slideUp();
        
        return false;
		
	});
	
	
	
	/* Leia MAis */
	
	
	$('.faq dl dd a').hover(function(){
		$(this).parent().css('color', '#ff3399');
		$(this).parent().css('text-decoration', 'underline');
		$(this).parent().prev().css('color', '#ff3399');
		$(this).parent().prev().css('text-decoration', 'underline');
	},function(){
		$(this).parent().css('color', '#55a0b7');
		$(this).parent().css('text-decoration', 'none');
		$(this).parent().prev().css('color', '#424242');
		$(this).parent().prev().css('text-decoration', 'none');
	});
	
	$('.faq dl dt').hover(function(){
		$(this).next().css('color', '#ff3399');
		$(this).next().css('text-decoration', 'underline');
		$(this).next().prev().css('color', '#ff3399');
		$(this).next().prev().css('text-decoration', 'underline');
	},function(){
		$(this).next().css('color', '#55a0b7');
		$(this).next().css('text-decoration', 'none');
		$(this).next().prev().css('color', '#424242');
		$(this).next().prev().css('text-decoration', 'none');
	});
	
	
});
