/**
   * Funçoes do jQuery
   **/
$(document).ready(function(){

	$('.bt-back').click(function(){ history.back(); });			// BOTÃO VOLTAR
	$('.bt-imprimir').click(function(){ window.print(); });		// BOTÃO IMPRIMIR
	$('.externo').attr('target','_blank');						// HABILITA TARGET BLANK
	$('.external').attr('target','_blank');						// HABILITA TARGET BLANK
	$("a[rel=external]").attr('target','_blank');				// HABILITA TARGET BLANK
	$("a[rel=external nofollow]").attr('target','_blank');		// HABILITA TARGET BLANK
	
	$('input[type=submit]').css('cursor','pointer');			// HABILITA CURSOR POINTER NOS BOTÕES DOS FORMS
	$('input[type=button]').css('cursor','pointer');			// HABILITA CURSOR POINTER NOS BOTÕES DOS FORMS
	
	//CONTROLADOR DO TAMANHO DAS FONTES
	if($('#font')){
		$('.font-small').click(function(){
			$('.texto-editor').css('font-size', '10px');
		});
		$('.font-normal').click(function(){
			$('.texto-editor').css('font-size', '11px');
		});
		$('.font-big').click(function(){
			$('.texto-editor').css('font-size', '16px');
		});
		$('.font-up').click(function(){
			var currentFontSize = $('.texto-editor').css('font-size');
			var currentFontSizeNum = parseFloat(currentFontSize, 10);
			if(currentFontSizeNum<18){
				var newFontSize = currentFontSizeNum*1.1;
				$('.texto-editor').css('font-size', newFontSize);
			}
		});
		$('.font-down').click(function(){
			var currentFontSize = $('.texto-editor').css('font-size');
			var currentFontSizeNum = parseFloat(currentFontSize);
			if(currentFontSizeNum>10){
				var newFontSize = currentFontSizeNum*0.9;
				$('.texto-editor').css('font-size', newFontSize);
			}
		});
	}
	
});

/*
 * RESET FORMS
 *
 * MODO DE USO $('#form').clearForm();
 *
 */
$.fn.clearForm = function() {
	
	return this.each(function() {
	
		var type = this.type, tag = this.tagName.toLowerCase();
		if (tag == 'form')
			return $(':input',this).clearForm();
		if (type == 'text' || type == 'password' || tag == 'textarea')
			this.value = '';
		else if (type == 'checkbox' || type == 'radio')
			this.checked = false;
		else if (tag == 'select')
			this.selectedIndex = -1;
		
	});
	
};