// JavaScript Document

$(window).ready(function(){
    jQuery(function(){jQuery(document).pngFix();});  
    manageColHeigths1();
});

//$(document).ready(function(){
	
	//sistema de tabs simples
//	$('#container-1 > ul').tabs();
//	
//	//fix colunas iguais para ie6
//	manageColHeigths1();
	//activar o png fix para pngs transparentes em ie6
//	$(document).pngFix();
//	$('body').pngFix();
	
	//fix as linhas verticais dos li previos dos links
//	$(".navigationBar a:not(.activeMenuLink)").hover(function() {
//		$(this).parent().prev().toggleClass("removeLiLine");								
//	}, function() {
//		$(this).parent().prev().toggleClass("removeLiLine");
//	});	
//	
//	//remove linha vertical do previo li do link activo do menu principal
//	$(".activeMenuLink").parent().prev().addClass("removeLiLine");
//	
//	$(".navigationBar a:last").parent().addClass("removeLiLine");
//	
//	
//	
//	//$(".blockNavContexto a:last").parent().addClass("removeLiLine");
//	$(".blockNavContexto li:last").addClass("removeLiLine");
//	
//	//detectar divs para alteracao font size
//	if($(".blockContentArtigo").length > 0 ){
//		changeFontSize(".blockContentArtigo");
//		changeFontSize(".blockUltimasEntradas");
//	}else if(($(".blockUltimasEntradas").length > 0 )){
//		changeFontSize(".blockUltimasEntradas");
//	}else if(($(".blockTemplateArtigo1").length > 0 )){
//		changeFontSize(".blockTemplateArtigo1");
//	}
//	//remover background li no ultimo a
//	$(".containerArtigoOpcoes a:last").parent().addClass("removeLiLine");
//	
//	//adicionar border bottom na ultima div do bloco
//	if($(".leftBlockColItem .blockColItem1 .leftBlockColItem1").length > 0 ){
//		var sibs = $(".leftBlockColItem").children(":last-child");
//		sibs.addClass("lastVerticalColItem");
//	}
//	
//	//remover padding na ultima div do bloco
//	if($(".blockRowListaEdicoes .blockColEdicao").length > 0 ){
//		var sibs = $(".blockRowListaEdicoes").children(":last-child");
//		sibs.prev().addClass("lastHorizontalColItem");
//	}
//	
//	//adicionar border bottom na ultima div do bloco
//	if($(".blockRowPesquisaArquivo").length > 0 ){
//		var sibs = $(".blockRowPesquisaArquivo").children(":last-child");
//		sibs.prev().addClass("noBorderBottom");
//	}
//});

//############# funcao para equal columnss ie 6 ####################

function manageColHeigths1(){
	var blockLeftHeigth, blockRigthHeigth, largestBlock;
	if(detectBrowserIE6_v1()){
		$('.mainBlock').css("height","auto");
		blockLeftHeigth = $('.mainBlock .leftBlock').height();
		blockRigthHeigth = $('.mainBlock .rightBlock').height();
		largestBlock = Math.max(blockLeftHeigth, blockRigthHeigth);
		$('.mainBlock').css("height",largestBlock);
		$('.mainBlock .leftBlock').css("height","100%");
		$('.mainBlock .rightBlock').css("height","100%");
		
	}
}

//############# funcao para aumentar diminui fontsize ( versão antiga ) ####################
var size = 12;
function IncFontSize(id) {
	if(size < 18){
		size = size + 1;
		document.getElementById(id).style.fontSize = size + "px";
	}
    return false;
}
function DecFontSize(id) {
	if(size > 7){
		size = size - 1;
		document.getElementById(id).style.fontSize = size + "px";
	}
    return false;
}

function changeFontSize() {
    var $speech = $(blockElement); 
	var currentSize = $speech.css('fontSize'); 
	var num = parseFloat(currentSize, 10);
	var unit = currentSize.slice(-2);
	if (this.id == 'switcher-large') { 
		num *= 1.4; 
	} else if (this.id == 'switcher-small') { 
		num /= 1.4; 
	} 
	if(num < 11){
		$speech.css('fontSize', 11 + unit);
	}else if(num > 10 && num < 24){
		$speech.css('fontSize', num + unit);
	}
	return false;
}


//############# funcao para aumentar diminui fontsize ####################

function changeFontSize(blockElement){
	//aumenta diminui font size
	$('.blockLinksControlText a').click(function() { 
		var $speech = $(blockElement); 
		var currentSize = $speech.css('fontSize'); 
		var num = parseFloat(currentSize, 10);
		var unit = currentSize.slice(-2);
		if (this.id == 'switcher-large') { 
			num *= 1.4; 
		} else if (this.id == 'switcher-small') { 
			num /= 1.4; 
		} 
		if(num < 11){
			$speech.css('fontSize', 11 + unit);
		}else if(num > 10 && num < 24){
			$speech.css('fontSize', num + unit);
		}
		//alert(num);
		manageColHeigths1();
		return false;
	});	
}

//############# funcao para detectar ie 6 v1 ####################

function detectBrowserIE6_v1(){
	jQuery.browser.msie6 = jQuery.browser.msie && parseInt(jQuery.browser.version) == 6 && !window["XMLHttpRequest"];
	return jQuery.browser.msie6;
}

//############# funcao para detectar ie 6 v2 ####################

function detectBrowserIE6_v2(){
	if (window.XMLHttpRequest) {
		// IE 7, mozilla, safari, opera 9
		var typeBrowser = false;
	}else{
		// IE6, older browsers
		var typeBrowser = true;
	}
	return typeBrowser;
}

//############# funcao para detectar ie 6 v3 ####################

function detectBrowserIE6_v3(){
	if(document.all && !window.opera && !window.XMLHttpRequest && $.browser.msie){
		var isIE6 = true;
	}else{ 
		var isIE6 = false;
	}
	return isIE6;
}

/*NAVIGATION*/
function GPSOnMouseOver(obj)
{
    if(obj.parentNode.previousSibling != null)
        obj.parentNode.previousSibling.className='removeLiLine';
}
function GPSOnMouseOut(obj)
{
    if(obj.parentNode.previousSibling != null)
        obj.parentNode.previousSibling.className='';
}

/* CUSTOM TABS TOP5 */
function showTab(value, obj) {
    if ( document.getElementById('fragment-'+value) ) {
        hideAll();
        document.getElementById('fragment-'+value).style.display = '';
        obj.className = "ui-tabs-selected";
    }
}

function hideAll(){
    for ( var i = 1; i <= 3; i++ ) {
        if ( document.getElementById('fragment-'+i) && document.getElementById("tab-"+i) ) {
            document.getElementById('fragment-'+i).style.display = 'none';
            document.getElementById("tab-"+i).className = "";
        }
    }
}

$(window).ready(function(){
    if ( document.getElementById("tab-1") ) {
        showTab(1,document.getElementById("tab-1"));
    }
});
