function bookmark(){
var title = 'Title of Bookmark';
var url = 'http://yourdomain.com';
   if (document.all)
     window.external.AddFavorite(url, title);
   else if (window.sidebar)
     window.sidebar.addPanel(title, url, "")
   else if (window.sidebar&&window.sidebar.addPanel)
     window.sidebar.addPanel(title,url,"");
}

// ***********************************************************************************************************
// ***********************************************************************************************************

function textSize(dir) {
    if (dir == 'up') {
        if (currentTextSize <= 17) {
            currentTextSize += 2;
        }
    } else if (dir == 'down') {
        if (currentTextSize >= 11) {
            currentTextSize -= 2;
        }
    }
    currentLineHeight = currentTextSize + 5;
    document.getElementById('bodyText').style.fontSize = currentTextSize + 'px';
    document.getElementById('bodyText').style.lineHeight = currentLineHeight + 'px';
    // write/rewrite cookie
    //createCookie("ihtfontsize",currentTextSize,1000);
}
// ***********************************************************************************************************
// ***********************************************************************************************************

function toggleDiv(divid){
	if(document.getElementById(divid).style.display == 'none')
	{
    	document.getElementById(divid).style.display = 'block';
    }
	else
	{
    	document.getElementById(divid).style.display = 'none';
    }
}
// ***********************************************************************************************************
function formLogin(f)
{
 	f.login.focus();
   	return (true);
}
// ***********************************************************************************************************
function escondeStatus()
{
	var statusMsg=""
	window.status=statusMsg
	return true
}
// ***********************************************************************************************************
function RedirectOpener(url)
{
	window.opener.location = url;
	window.close();
}
// ***********************************************************************************************************
function imprime() 
{
	var agt=navigator.userAgent.toLowerCase();	
	if (window.print) 
	{
		setTimeout('window.print();',200);
	}
	else if (agt.indexOf("mac") != -1) 
		{
			alert("Pressione 'Cmd+p' no seu teclado para imprimir este artigo.");
		}
		else 
		{
			alert("Pressione 'Ctrl+p' no seu teclado para imprimir este artigo.")
		}
}
// ***********************************************************************************************************
function openpopupsize(url,larg,alt,barrasscroll)
{
	var popurl = url
	var esq = screen.width/2-(larg/2)
	var topo = screen.height/2-(alt/2)-50
	var tam="width=" + larg + ",height=" + alt
	winpops=window.open(popurl,"CMTN", tam + ",screenX=" + esq + ",left=" + esq + ",screenY=" + topo + ",top=" + topo + ",scrollbars=" + barrasscroll)
}
// ***********************************************************************************************************
var winModalWindow

function IgnoreEvents(e)
{
  return false
}

function openModal(url,larg,alt)
{
  if (window.showModalDialog)
  {
    window.showModalDialog(url,null,"dialogWidth=" + larg + "px;dialogHeight=" + alt + "px;edge:Sunken;center:Yes;resizable:No;status:Yes;scrollbars=	No")
  }
  else
  {
    window.top.captureEvents (Event.CLICK|Event.FOCUS)
    window.top.onclick=IgnoreEvents
    window.top.onfocus=HandleFocus 
    winModalWindow = 
    window.open ("ModalChild.htm","ModalChild",
       "dependent=yes,width=200,height=100")
    winModalWindow.focus()
  }
}
function HandleFocus()
{
  if (winModalWindow)
  {
    if (!winModalWindow.closed)
    {
      winModalWindow.focus()
    }
    else
    {
      window.top.releaseEvents (Event.CLICK|Event.FOCUS)
      window.top.onclick = ""
    }
  }
  return false
}
// ***********************************************************************************************************
// Valida se alguma das opções do inquerito foi seleccionada
// ***********************************************************************************************************
function validate_form_inq(f) 
{
	var radioGrp = f.inquerito;
	var ok = false;
	//alert("número de opções =" + radioGrp.length);
	for(i=0; i < radioGrp.length; i++)
	{
		if (radioGrp[i].checked)
			ok = true;
	}
	if (ok == false)
	{
		alert("Escolha uma resposta!");	
	}
	return ok;
}

// ***********************************************************************************************************
// Valida se colocou pwd
// ***********************************************************************************************************
function validate_form_pwd(f) 
{
	var ok = false
	if (f.pwd.value != "")
	{
		ok = true		
	}
	if (ok == false)
	{
		alert("Escreva uma Palavra-passe!")
		return ok
	}
	ok = false
	if (f.pwd.value.length >= 4)
	{
		ok = true
	}
	if (ok == false)
	{
		alert("A Palavra-passe tem que ter pelo menos 4 cracteres!")
	}
	return ok
}



// ***********************************************************************************************************
// Função mostra relógio
// ***********************************************************************************************************
function Wryt(ID, S) {
	document.getElementById(ID).innerHTML = S 
}

function TimeStr(D) { 
	return D.toString().match(/\d\d:\d\d:\d\d/) 
}


function DataPT() { 
	var mydate=new Date()
	var year=mydate.getYear()
	if (year < 1000)
		year+=1900
	var day=mydate.getDay()
	var month=mydate.getMonth()
	var daym=mydate.getDate()
	if (daym<10)
		daym="0"+daym
	var dayarray=new Array("Domingo","Segunda","Terça","Quarta","Quinta","Sexta","S&aacute;bado")
	var montharray = new Array("Janeiro","Fevereiro","Mar&ccedil;o",
	"Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro")
	//document.write(dayarray[day] + ", " + daym + "/" + montharray[month]+ "/" + year)
	//return (dayarray[day] + ", " + daym + " de " + montharray[month]+ " de " + year)
	return (daym + " de " + montharray[month]+ " de " + year)
}

function TimeNow() {
	var D = new Date()
	var S = TimeStr(D)
  	setTimeout("TimeNow()",1050-D.getTime()%1000)
	
  	Wryt('Timer', DataPT()+'&nbsp;&bull;&nbsp;'+S) 
	/*Wryt('Timer', '<span>' + S + '<\/span">') */
}
// ***********************************************************************************************************
function formdefaultfocus()
{
		var foo = typeof document.forms[0] != 'undefined';
		if (foo == true)
		{
			document.forms[0].elements[0].focus();
		}	
}
// ***********************************************************************************************************
function formDefaultFocus(f,e)
{
		//f = nº do form (inicio em 0)
		//e = elemento ou campo do form (inicio em 9)
		
		// cloca Focus no 1º campo do 1º Form
		var existe = typeof document.forms[f] != 'undefined';
		//alert('form 0 existe: ' + existe);
		
		if (existe == true)
		{
			try
   			{
				document.forms[f].elements[e].focus();
   			}
			catch(err)
   			{
   				//txt="There was an error on this page.\n\n"
   				//txt+="Error description: " + err.description + "\n\n"
   				//txt+="Click OK to continue.\n\n"
   				//alert(txt)
   			}
		}
}


