function muda_tab(item_on, item_off) {

//	var tab_on = document.getElementById('tab_'+item_on);

	var seta_on = document.getElementById('tab_'+item_on+'_seta');

	var cx_on = document.getElementById('cx_'+item_on);

	var items_off = item_off.split(',');



	for(var i=0; i <items_off.length; i++) {

//		var tab_off = document.getElementById('tab_'+items_off[i]);

		var seta_off = document.getElementById('tab_'+items_off[i]+'_seta');

		var cx_off = document.getElementById('cx_'+items_off[i]);



//		tab_off.className = "tab_box_off";

		seta_off.className = "tab_seta_off";

		cx_off.className = "div_off";

	}



//	tab_on.className = "tab_box_on";

	seta_on.className = "tab_seta_on";

	cx_on.className = "div_on";

	return false;



}

function muda_tab2(item_on,item_off,color,sid) {
	//	var tab_on = document.getElementById('tab_'+item_on);
	var seta_on = document.getElementById('tab_'+item_on+'_seta');
	var cx_on = document.getElementById('cx_'+item_on);
	var id=document.getElementById('link_'+item_on);
	var items_off = item_off.split(',');


	if (seta_on.className.indexOf('_on') > -1) {
		location.href="/gen.pl?sid="+sid;
	} else {
		
		for(var i=0; i <items_off.length; i++) {
			var seta_off = document.getElementById('tab_'+items_off[i]+'_seta');
			var cx_off = document.getElementById('cx_'+items_off[i]);
			var link_off = document.getElementById('link_'+items_off[i]);
		
            if( link_off ){
			    link_off.style.color = "#484848";
            }
            if( seta_off ){
			    seta_off.className = "mName_off";
            }
            if( cx_off ){
			    cx_off.className = "div_off";
            }
		}
		
		id.style.color = color;
		seta_on.className = "mName_on";
		cx_on.className = "div_on";

	}
	
	//return false;
}


function swap(obj){

	if(document.getElementById) {

	do_obj = document.getElementById(obj);

	for(var i=0; i <15; i++) {

		if (document.getElementById('noticiario_c_'+i)) {


			do_obj1 = document.getElementById('noticiario_c_'+i);
	
			do_obj2 = document.getElementById('noticiario_o_'+i);

			if (((obj) == ('noticiario_c_'+i)) || ((obj) == ('noticiario_o_'+i))) {

			do_obj1.style.visibility="hidden";
			do_obj1.style.display="none";
			do_obj2.style.visibility="hidden";
			do_obj2.style.display="none";

			} else {
	
			do_obj1.style.visibility="visible";
			do_obj1.style.display="block";
			do_obj2.style.visibility="hidden";
			do_obj2.style.display="none";

			}

		}

	}

	do_obj.style.visibility="visible";
	do_obj.style.display="block";

	}

}

// Inicio Aumentar/diminuir texto
var MAX_FONTSIZE = 7;
var MIN_FONTSIZE = -2;
var ACTUAL_FONTSIZE = 0;
var DEFAULT_FONTSIZE = 12;

function MagnifyText(iDirection) {
	var oDiv = document.getElementById("BodyText");	

	if ( oDiv && (oDiv.innerHTML!="") &&  ACTUAL_FONTSIZE + 1*iDirection >= MIN_FONTSIZE &&  ACTUAL_FONTSIZE + 1*iDirection <= MAX_FONTSIZE){

		ACTUAL_FONTSIZE = ACTUAL_FONTSIZE + 1*iDirection;
		SaveActualFontSize();
	
		var iGap = ( ACTUAL_FONTSIZE <= 0 ? 10: 30 );
		if ( ACTUAL_FONTSIZE == 0 ) {
			oDiv.style.fontSize = DEFAULT_FONTSIZE+"px";
		} else {
			oDiv.style.fontSize = 100 + ACTUAL_FONTSIZE*iGap + "%";
		}
	}
}

function SaveActualFontSize() {
	var expire = new Date ();
	expire.setTime (expire.getTime() + (6000 * 24 * 3600000));
	expire = expire.toGMTString();
	document.cookie="newFontSize=" + ACTUAL_FONTSIZE + "; path=/; expires=" + expire;
}

function LoadActualFontSize() {
	tempArray = document.cookie.split(";");
	for (tA = 0; tA < tempArray.length; tA++){
		if (tempArray[tA].indexOf('newFontSize') > -1){
			fontSizeValue = tempArray[tA].split("=")
			ACTUAL_FONTSIZE = parseInt(fontSizeValue[1]);
		}
	}
}

function viewcoment(id,who,mode) {
    ori="comment"+id;
    tmp="comment"+id+"tmp";

    newtmp = document.getElementById(ori).innerHTML;

    if (document.getElementById(tmp).innerHTML=="") {
    
      this.frames["commentiframeid"].location.href="/gen.pl?p=comments:view&fokey="+who;
      
    } else {
        document.getElementById(ori).innerHTML=document.getElementById(tmp).innerHTML;
    }

    if(document.getElementById){
        document.getElementById(tmp).innerHTML=newtmp;
    }
    this.focus();
}

function closecoment(id) {

    ori="comment"+id;
    tmp="comment"+id+"tmp";


    newtmp = document.getElementById(ori).innerHTML;
    document.getElementById(ori).innerHTML=document.getElementById(tmp).innerHTML;
    document.getElementById(tmp).innerHTML=newtmp;

    this.focus();

}



function hideshowcontextSTOP(event, who, where){


    var ie5=document.all&&document.getElementById;

    var menuobj=document.getElementById(who);

    var state = menuobj.style.visibility;

    if (state.indexOf("hid")!=-1) {

            top.frames['moderateiframe'].location.href=where;




        var rightedge=ie5? document.body.clientWidth-event.clientX : window.innerWidth-event.clientX;
        var bottomedge=ie5? document.body.clientHeight-event.clientY : window.innerHeight-event.clientY;


        if (rightedge<menuobj.offsetWidth) {

            leftvalue=ie5? (document.body.scrollLeft+event.clientX-menuobj.offsetWidth)-50 : window.pageXOffset+event.clientX-menuobj.offsetWidth;
        } else {
            leftvalue=ie5? (document.body.scrollLeft+event.clientX)+30 : window.pageXOffset+event.clientX;
        }

        if (bottomedge<menuobj.offsetHeight) {
            topvalue=ie5? (document.body.scrollTop+event.clientY-menuobj.offsetHeight)-20 : window.pageYOffset+event.clientY-menuobj.offsetHeight-15;
        } else {
            topvalue=ie5? (document.body.scrollTop+event.clientY)+10 : window.pageYOffset+event.clientY+15;
        }

        menuobj.style.top=topvalue+'px';
        menuobj.style.left=leftvalue+'px';

        menuobj.style.visibility="visible";

    } else {
        menuobj.style.visibility="hidden";
        menuobj.style.top=-500+'px';
        menuobj.style.left=-500+'px';
    }


}




function hideshowcontext(event, who, where){


    var ie5=document.all&&document.getElementById;

    var menuobj=document.getElementById(who);

    var state = menuobj.style.visibility;

    if (state.indexOf("hid")!=-1) {

            top.frames['moderateiframe'].location.href=where;




		if (self.innerHeight) // all except Explorer
		{
			rightedge = self.innerWidth;
			bottomedge = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight)
			// Explorer 6 Strict Mode
		{
			rightedge = document.documentElement.clientWidth;
			bottomedge = document.documentElement.clientHeight;
		}
		else if (document.body) // other Explorers
		{
			rightedge = document.body.clientWidth;
			bottomedge = document.body.clientHeight;
		}






        if (rightedge<menuobj.offsetWidth) {
			if (self.innerHeight){
				leftvalue = window.pageXOffset+event.clientX-menuobj.offsetWidth;
			} else if (document.documentElement && document.documentElement.clientHeight){
				leftvalue = (document.documentElement.scrollLeft+event.clientX-menuobj.offsetWidth)-50;
			} else if (document.body) {
				leftvalue = (document.body.scrollLeft+event.clientX-menuobj.offsetWidth)-50;
			}

        } else {
			if (self.innerHeight){
				leftvalue = window.pageXOffset+event.clientX;
			} else if (document.documentElement && document.documentElement.clientHeight){
				leftvalue = (document.documentElement.scrollLeft+event.clientX)+30;
			} else if (document.body) {
				leftvalue = (document.body.scrollLeft+event.clientX)+30;
			}
        }

        if (bottomedge<menuobj.offsetHeight) {
			if (self.innerHeight){
				topvalue = window.pageYOffset+event.clientY-menuobj.offsetHeight-15;
			} else if (document.documentElement && document.documentElement.clientHeight){
				topvalue = (document.documentElement.scrollTop+event.clientY-menuobj.offsetHeight)-20
			} else if (document.body) {
				topvalue = (document.body.scrollTop+event.clientY-menuobj.offsetHeight)-20;
			}
        } else {
			if (self.innerHeight){
				topvalue = window.pageYOffset+event.clientY+15;
			} else if (document.documentElement && document.documentElement.clientHeight){
				topvalue = (document.documentElement.scrollTop+event.clientY)+10;
			} else if (document.body) {
				topvalue = (document.body.scrollTop+event.clientY)+10;
			}
        }

        menuobj.style.top=topvalue+'px';
        menuobj.style.left=leftvalue+'px';

        menuobj.style.visibility="visible";

    } else {
        menuobj.style.visibility="hidden";
        menuobj.style.top=-500+'px';
        menuobj.style.left=-500+'px';
    }


}



function openpopup(sitepop, winpop, width, height){

    if (sitepop=="") {sitepop="about:blank"}
    if (winpop=="") {winpop="popupsite"}

    if (width=="") {width=600}
    if (height=="") {height=400}


    leftPosition = ((screen.width)-width)/2 ;
    topPosition = ((screen.height)-height)/2 ;

    popedwindow = window.open( sitepop, winpop,"toolbar=no,location=no,directories=no,status=0,menubar=no,scrollbars=yes,noresizable,width="+width+",height="+height+',left='+leftPosition+',top='+topPosition);
    popedwindow.focus();
}
//Comentários
if (document.images) {

		arrow_n = new Image;

		arrow_n.src = "/i/forum_seta_cinza.gif";

		arrow_anime = new Image;

		arrow_anime.src = "/i/forum_anim_cinza.gif";

		arrow_n2 = new Image;

		arrow_n2.src = "/i/forum_seta_verde.gif";

		arrow_anime2 = new Image;

		arrow_anime2.src = "/i/forum_anim_verde.gif";

}



function ShowPermaLink(id){
	var obj = document.getElementById('div' + id);

	if ((obj) && (obj.style.visibility == 'visible') && (obj.style.display == 'none')) {
		HidePermaLink(id);
	} else if (obj){
		obj.style.visibility = 'visible';
		obj.style.display = 'block';
		if (document.getElementById('txt' + id).value=="") {
			document.getElementById('txt' + id).value=top.location.href;
		}
		obj = document.getElementById('txt' + id); 
		obj.select();
	}
}

function HidePermaLink(id)
{
   var obj = document.getElementById('div' + id);
   if (obj){ 
    obj.style.visibility='hidden';
    obj.style.display = 'none';
  }
}


// ----------- CARTOONS --------------------
function showCartoon(id,bmod) 
{
   document.getElementById('cartoonMainImg'+bmod).innerHTML=document.getElementById('cartoonImg'+bmod+id).innerHTML;
   document.getElementById('cartoonMainTit'+bmod).innerHTML=document.getElementById('cartoonTit'+bmod+id).innerHTML;
   document.getElementById('cartoonMainInt'+bmod).innerHTML=document.getElementById('cartoonInt'+bmod+id).innerHTML;
   document.getElementById('cartoonMainDat'+bmod).innerHTML=document.getElementById('cartoonDat'+bmod+id).innerHTML;
 
   for(var i=1; i<21; i++) 
   {
      if(document.getElementById('linkCartoon'+bmod+i)){
          document.getElementById('linkCartoon'+bmod+i).style.fontWeight="normal";
      }
   }

   document.getElementById('linkCartoon'+bmod+id).style.fontWeight="bold";
   
   var proximo=id+1;
   var anterior=id-1;
   
   if(id==1){
      document.getElementById('cartoonAnterior'+bmod).innerHTML='';
      document.getElementById('cartoonSeguinte'+bmod).innerHTML='<a href="javascript:void(showCartoon('+proximo+',\''+bmod+'\'))">Seguinte</a> <a href="javascript:void(showCartoon('+proximo+',\''+bmod+'\'))"><img src="i/icon_right.gif" alt="Seguinte" title="Seguinte" height="20" width="20"></a>';
   } else if( document.getElementById('cartoon'+bmod+proximo)==undefined ){
      document.getElementById('cartoonAnterior'+bmod).innerHTML='<a href="javascript:void(showCartoon('+anterior+',\''+bmod+'\'))"><img src="i/icon_left.gif" alt="Anterior" title="Anterior" height="20" width="20"></a> <a href="javascript:void(showCartoon('+anterior+',\''+bmod+'\'))">Anterior</a>';
      document.getElementById('cartoonSeguinte'+bmod).innerHTML="";
   } else {
      document.getElementById('cartoonAnterior'+bmod).innerHTML='<a href="javascript:void(showCartoon('+anterior+',\''+bmod+'\'))"><img src="i/icon_left.gif" alt="Anterior" title="Anterior" height="20" width="20"></a> <a href="javascript:void(showCartoon('+anterior+',\''+bmod+'\'))">Anterior</a>';
      document.getElementById('cartoonSeguinte'+bmod).innerHTML='<a href="javascript:void(showCartoon('+proximo+',\''+bmod+'\'))">Seguinte</a> <a href="javascript:void(showCartoon('+proximo+',\''+bmod+'\'))"><img src="i/icon_right.gif" alt="Seguinte" title="Seguinte" height="20" width="20"></a>';
   }
   
   return false;
}


//<![CDATA[

function adiciona_homepage() {

	if (document.all) {
		document.body.style.behavior = "url(#default#homepage)";
		document.body.setHomePage('http://www.visao.pt/');
	} else if (document.getElementById) {
		alert('Arraste o logótipo da Visão para o ícone de Home do seu Browser para fazer da Visão a sua homepage.');
		return false();
	}
}

function adicionar_favorito() {
    var title = "VISAO.PT";
    var url = "http://www.visao.pt/";

	if (document.all) { // Para o IE
		window.external.AddFavorite(url, title);
	} else if (window.sidebar) { // Para o Firefox
		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 { // Para outros browsers
		alert("Para adicionar a Visão aos seus Favoritos, pressione CTRL+D.");
	}
}

var zahirglobaldir = "";


function positionItAny(who){
	masterdivobj=document.getElementById(who);

	if (self.innerHeight){
		topvalue = window.pageYOffset+event.clientY-menuobj.offsetHeight+10;
	} else if (document.documentElement && document.documentElement.clientHeight){
		topvalue = (document.documentElement.scrollTop+event.clientY-menuobj.offsetHeight)+10;
	} else if (document.body) {
		topvalue = (document.body.scrollTop+event.clientY-menuobj.offsetHeight)+10;
	}

	masterdivobj.style.top=topvalue+"px";

}


function showImg(who, where){

	var ie5=document.all&&document.getElementById;

	if(document.getElementById) {
		doin = document.getElementById(who);
		state = doin.style.visibility;

		if ((state.indexOf("hid")!=-1) && (where)) {
			doin.style.visibility="visible";
			doin.style.display="block";
			doin.style.top=10+"px";
			doin.style.left=20+"px";

			if (ie5 && who=="imageidiframe"){
				timerID = setInterval("positionItAny(who)", 100);
//				timerID = setInterval("positionit()", 100)
			}
			top.frames["imgchooseiframe"].location.href=where;
			//top.showImgResize(who);
		} else {
			doin.style.visibility="hidden";
			doin.style.display="none";
			doin.style.top=-500+"px";
			doin.style.left=-500+"px";
			if (ie5 && who=="imageidiframe"){
				clearInterval(timerID);
			}
			top.frames["imgchooseiframe"].location.href="about:blank";
		}
	}
	
}


function _popup(x,y,endereco){
    window.open( endereco, "WndName2","toolbar=no,location=no,directories=no,top=0,left=0',status=0,menubar=no,scrollbars=yes,noresizable,width="+x+",height="+y);
	}


//]]>
