var hits = 5;
function fontSize(action, container){
	container = typeof(container) != 'undefined' ? container : '#conteudo';
	var hitIncrease = 0;
	var hitDecrease = 0;
	
	var pegaTodos = {pega : function(maiorDeTodos){
	var filho;
	
	// Passo por todos os controles.
	jQuery(maiorDeTodos).children().each(function(i){
	filho = jQuery(this);
	
	$fs = parseInt(jQuery(filho).css('font-size'));
	if(action=="plus" && $fs<16) $fs+=1;
    else if(action=="minus" && $fs>8) $fs-=1;
	jQuery(filho).css('font-size', $fs);
	
	if (jQuery(filho).children().length != 0) {
	pegaTodos.pega(jQuery(filho));
	}
	});
	}};
	
	pegaTodos.pega(jQuery(container));
	
	if (hitIncrease == 1)hits+=1;
	else if (hitDecrease == 1)hits-=1;
	
}

function abrirPopup(urlPopup)
{
	document.getElementById('indique').style.display='';
	document.getElementById('layerOpaco2').style.display='';
	document.getElementById('indique').style.height=(document.body.offsetHeight+130)+'px';
	document.getElementById('indique').style.width=(document.body.offsetWidth+50)+'px';
	document.getElementById('layerOpaco2').style.height=(document.body.offsetHeight+130)+'px';
	document.getElementById('layerOpaco2').style.width=(document.body.offsetWidth+50)+'px';
	jQuery("#carregando-popup").css('display', 'block');
	jQuery("#miolo-popup").load(urlPopup, '', function(){jQuery("#carregando-popup").css('display', 'none');});
}

function versaoImpressao()
{
	container = "body";
	jQuery(container).attr("background", "");
	jQuery(container).css("display", "none");
	jQuery(container).html('<img onclick="window.print();" src="images/icon_impr.png" width="20" height="20" align="absmiddle"/><a href="javascript:void(0);" onclick="window.print();" class="cinzalink">Imprimir</a>'+ jQuery("#conteudo").html());
	jQuery(container).css("display", "block");
}

function sendForm(forme)
{
	var params = {}; 
	var $inputs = jQuery('#'+forme+' input, #'+forme+' textarea, #'+forme+' select');
	$inputs.each(function(i, el) {
		params[el.name] = jQuery(el).val();
	});
	jQuery("#carregando-popup").css('display', 'block');
	jQuery("#miolo-popup").load(jQuery("#"+forme).attr("action"), params, function(){jQuery("#carregando-popup").css('display', 'none');});
}

jQuery(function(){
	jQuery('#decrease').click(function(){ fontSize('minus'); });
	jQuery('#increase').click(function(){ fontSize('plus'); });
	jQuery('#imprimir').click(function(){ window.open(location.href+"&impressao=1", '', 'location=no, resizable=no, scrollbars=yes, menubar=no, left=100, top=100, width=682, height='+jQuery("#conteudo").height()); });
	jQuery('#enviarparaamigo').click(function(){ abrirPopup();});
});
