// JavaScript Document
function homeTabber(idBtn, maxBtn){
	for(i=1;i<=maxBtn;i++){
		switch(trim(document.getElementById("btn"+i).className)){
			case "first selected":
			document.getElementById("btn"+i).className="first";
			break;
			case "last selected":
			document.getElementById("btn"+i).className="last";
			break;
			case "selected":
			document.getElementById("btn"+i).className="";
			break;
		}
		document.getElementById("homeTabAreaImgTop").className="";
		document.getElementById("homeArea"+i).className="closed";
	}
	//alert(trim(document.getElementById("btn"+idBtn).className));
	switch(trim(document.getElementById("btn"+idBtn).className)){
		case "first":
		document.getElementById("btn"+idBtn).className="first selected";
		document.getElementById("homeTabAreaImgTop").className="first";
		break;
		case "last":
		document.getElementById("btn"+idBtn).className="last selected";
		document.getElementById("homeTabAreaImgTop").className="last";
		break;
		case "":
		document.getElementById("btn"+idBtn).className="selected";
		document.getElementById("homeTabAreaImgTop").className="";
		break;
	}
	document.getElementById("homeArea"+idBtn).className="homeTabAreaContent";
}

function contactTabber(idBtn, maxBtn){
		for(i=1;i<=maxBtn;i++){
		if(document.getElementById("contactBtn"+i).className=="selected"){
			document.getElementById("contactBtn"+i).className="";
			document.getElementById("contactBox"+i).className="closed";
		}
	}
		document.getElementById("contactBtn"+idBtn).className="selected";
		document.getElementById("contactBox"+idBtn).className="innerContactBox";
}

function openJump(id,subId){
	document.getElementById(id).className="jump open";
	document.getElementById(subId).style.top=document.getElementById(id).offsetTop+"px";
}
function closeJump(id){
	document.getElementById(id).className="jump";
}
function sendValue(idBtn,idContainer){
	document.getElementById(idContainer).innerHTML=document.getElementById(idBtn).innerHTML;
	//closeJump(document.getElementById(idBtn).parentNode.parentNode.id)
}
$(document).ready(function(){
	$("#mapaAbrir").click(function(){
		$("#sitemapArea").slideToggle("slow",function(){if(jQuery.browser.opera){ document.body.scrollTop=15;}document.getElementById("mapaAbrir").className="closed";document.getElementById("mapaFechar").className="mapBtnFechar";});
		//$(this).toggleClass("active"); return false;
			
	});
	$("#mapaFechar").click(function(){
		$("#sitemapArea").slideToggle("slow",function(){if(jQuery.browser.opera){ document.body.scrollTop=15;}document.getElementById("mapaAbrir").className="mapBtn"; document.getElementById("mapaFechar").className="closed";});
		//$(this).toggleClass("active"); return false;
			
	});
});

function bigFont(){
	document.getElementById("body").className='big';
}
function smallFont(){
	document.getElementById("body").className='';
}


$(document).ready(function(){
//	$('body').pngFix( );
});


function addFav(){
    var url      = "http://www.globaz.pt";
    var title    = "Globaz, S.A.";
    if (window.sidebar) window.sidebar.addPanel(title, url,"");
    else if(window.opera && window.print){
        var mbm = document.createElement('a');
        mbm.setAttribute('rel','sidebar');
        mbm.setAttribute('href',url);
        mbm.setAttribute('title',title);
        mbm.click();
    }
    else if(document.all){window.external.AddFavorite(url, title);}
}


function trim(s)
{
	return rtrim(ltrim(s));
}

function ltrim(s)
{
	var l=0;
	while(l < s.length && s[l] == ' ')
	{	l++; }
	return s.substring(l, s.length);
}

function rtrim(s)
{
	var r=s.length -1;
	while(r > 0 && s[r] == ' ')
	{	r-=1;	}
	return s.substring(0, r+1);
}
