// JScript source code

function confirmPopup(question, url)
{
    if (confirm(question))
    {
        document.location.href = url;
    }
}

function limparCampo(id_campo, texto){

var campo = document.getElementById(id_campo);

if (campo.value == texto)
{
    campo.value = '';
}

}

function repoeCampo(id_campo, texto){

var campo = document.getElementById(id_campo);

if (campo.value == '')
{
    campo.value = texto;
}

}
//function to display or hide a given element
function showHideItems_old(myItem){

//this is the ID of the hidden item
//var mydropdown = document.getElementById(mydropdown);
var myItemTransf = document.getElementById("TRANS");
var myItemMbnet = document.getElementById("MBNET");

myItemTransf.style.display = "none";
myItemMbnet.style.display = "none";

if (myItem== "3"){
myItemTransf.style.display="block";
}

if (myItem== "1"){
myItemMbnet.style.display="block";
}
}
//function to display or hide a given element
function showHideItems(divname, sender){

var myItem = document.getElementById(divname + "-" + sender.options[sender.selectedIndex].value);

var elem = document.getElementsByTagName('div');
    for(var i = 0; i < elem.length; i++)
    {
       if (elem[i].id.substring(0,divname.length)==divname)
        {
        elem[i].style.display = 'none'
        }
    }
    
    myItem.style.display="block";
	
}


//function to display or hide a given element
function showHideItemsByVal(divname, value){

var myItem = document.getElementById(divname + "-" + value);
    myItem.style.display="block";
}

//LIMITA O INPUT SÓ A NÚMEROS

var numbersonly = "0123456789";
var numb = "0123456789";
var alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";

function res(t,v){
	var w = "";
	for (i=0; i < t.value.length; i++) {
		x = t.value.charAt(i);
		if (v.indexOf(x,0) != -1)
			w += x; 
	}
	t.value = w;
}

// function NumberCardCheck(source, arguments)
// {
  // even number?
 //  if (arguments.Value == "")
  //  arguments.IsValid = true;
//   else
  //  arguments.IsValid = false;
// }
function openCTT (){

var guia_numero = document.getElementById('txt_procurar').value

if (guia_numero != '')
{
    window.open('http://www2.ctt.pt/feapl/jsp/pesqobjectos/public/pesqobjectosresult.jsf?lang=def&trackTrace=' + guia_numero, 'ctt');
}
}

//configure the two variables below to match yoursite's own info


function addbookmark(){
var bookmarkurl="http://www.enetural.pt"
var bookmarktitle="Enetural"
if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle)
}

function setFocus(control, color)
{
    control.style.border =  'solid 1px #' + color;
}


