
function Row_Down(obj,sEmpresa,sNIPC)
{
    obj.bgColor = "#d0d0d0"
    document.all('empresa').value=sEmpresa
    document.all('nipc').value=sNIPC
    document.all('user').value="Ana Maria Gomes"
}
function numbersOnly(myfield, e, dec)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);

// control keys
if ((key==null) || (key==0) || (key==8) ||
    (key==9) || (key==13) || (key==27) )
   return true;

// numbers
else if ((("0123456789").indexOf(keychar) > -1))
   return true;

// decimal point jump
/*
else if (dec && (keychar == "."))
   {
   myfield.form.elements[dec].focus();
   return false;
   }
*/
else if (((keychar == ".")||(keychar == ",")) && dec && (dec==true))
   {
   return true;
   }
else
   return false;
}


  function numbersOnly_Paste(objEvent, dec) {
	
     var strPasteData = window.clipboardData.getData("Text"); 

     for(i=0;i<strPasteData.length;i++)
     {
		if((strPasteData.charAt(i) == '.'
			|| strPasteData.charAt(i) ==',')
			&& dec==true)
			return true;
		else if(isNaN(strPasteData.charAt(i)))
			return false;
     }  
}

function numbersOnly_dragDrop(dec) {
	
	var strDragDrop = window.event.dataTransfer.getData("TEXT")

     for(i=0;i<strDragDrop.length;i++)
     {
		if((strDragDrop.charAt(i) == '.'
			|| strDragDrop.charAt(i) ==',')
			&& dec==true)
			return true;
		else if(isNaN(strDragDrop.charAt(i)))
			return false;
     }   
}



function RadioChecked()
{
	var x = document.getElementsByTagName("input")
	for (i=0;i<x.length;i++)
	{
		if (x[i].type.toUpperCase()=="RADIO")
		{
			if (nipc != x[i].value)
			{
				x[i].checked = false;
			}else{
				x[i].checked = true;
			}
		}
	}
}

function UnSelectRadio()
{
	var x = document.getElementsByTagName("input")
	for (i=0;i<x.length;i++)
	{
		if (x[i].type.toUpperCase()=="RADIO")
		{
			x[i].checked = false;
		}
	}
}

function RadioFirmaFantasiaChecked(nipc,nome,marca)
{
	if (nipc!='')
	{
	    nipcHidden = document.getElementById('txtHiddenNIPC');
		nipcHidden.value = nipc;
		nomeHidden = document.getElementById('txtHiddenNome');
		nomeHidden.value = nome;
		marcaHidden = document.getElementById('txtHiddenMarca');
		marcaHidden.value = marca;
		nipcTxt = document.getElementById('txtNIPC');
		nipcTxt.value='';
		//document.all("imgBtnNIPC").style.visibility='hidden';
	}
}

function RadioFirmaFantasiaMNHChecked(nipc,nome,numero)
{
	if (nipc!='')
	{
	    nipcHidden = document.getElementById('txtHiddenNIPC');
		nipcHidden.value = nipc;
		nomeHidden = document.getElementById('txtHiddenNome');
		nomeHidden.value = nome;
		numeroProcessoHidden = document.getElementById('txtHiddenNumeroProcesso');
		numeroProcessoHidden.value = numero;
	}
}

function RadioEntidadeChecked(nipc)
{
	if (nipc!='')
	{
		nipcHidden = document.getElementById('PesquisaEntidade1_txtHiddenNIPC');
		nipcHidden.value = nipc;
	}
}

function NipcChecked()
{	
	nipcHidden = document.getElementById('txtNIPC');
	if(nipcHidden.value!='')
	{
		//document.all('dtlResults').disabled='disabled';
		//document.all("imgBtnContinuar").style.visibility='hidden';
		//document.all("imgBtnPesquisar").style.visibility='hidden';
		firmaName = document.getElementById('txtFirmaName');
		firmaName.value='';
		//document.all("txtFirmaName").disabled='disabled';
	}
}

function hiddeAuxObjects()
{
	
	window.history.go;
	nipcHidden = document.getElementById('txtHiddenNIPC');
	nipcHidden.style.visibility='hidden';
	nomeHidden = document.getElementById('txtHiddenNome');
	nomeHidden.style.visibility='hidden';
	marcaHidden = document.getElementById('txtHiddenMarca');
	marcaHidden.style.visibility='hidden';
	NumeroProcessoHidden = document.getElementById('txtHiddenNumeroProcesso');
	NumeroProcessoHidden.style.visibility='hidden';
	NipcChecked();
	RadioFirmaFantasiaChecked("","","");
	
}

function hiddeAuxObjectsMNH()
{
	window.history.go;
	nipcHidden = document.getElementById('txtHiddenNIPC');
	nipcHidden.style.visibility='hidden';
	nomeHidden = document.getElementById('txtHiddenNome');
	nomeHidden.style.visibility='hidden';
	NumeroProcessoHidden = document.getElementById('txtHiddenNumeroProcesso');
	NumeroProcessoHidden.style.visibility='hidden';
}

function hideNipcHidden()
{
	window.history.go;
	nipcHidden = document.getElementById('PesquisaEntidade1_txtHiddenNIPC');
	nipcHidden.style.visibility='hidden';
}

function hiddeConsola(value)
{

	var obj = document.getElementById("editConsole");
	if (obj!=null)
	
	obj.style.display=value; 
	
}

/*function CleanReserva()
{
	UnSelectRadio();
	nipcHidden = document.getElementById('txtHiddenNIPC');
	nipcHidden.value = '';
	document.all("txtHiddenNome").value = '';
	document.all("txtHiddenMarca").value = '';
	document.all("txtNipc").value = '';
	document.all("txtNipc").disabled='';
	document.all("imgBtnContinuar").style.visibility='visible';
	document.all("imgBtnPesquisar").style.visibility='visible';
	document.all('dtlResults').disabled='';
	document.all("txtFirmaName").value='';
	document.all("txtFirmaName").disabled='';
}*/

function nextPage(oDiv)
{
	if (document.all('dtlResults').disabled == false)
		oDiv.scrollTop=(oDiv.offsetHeight-1) + oDiv.scrollTop;
}

function prevPage(oDiv)
{
	if (document.all('dtlResults').disabled == false)
	{
		if (oDiv.scrollTop>0)
			oDiv.scrollTop=oDiv.scrollTop - (oDiv.offsetHeight-1);
	}
}

function clear_radio_buttons()
{
	try
	{
	for (var i = 0; i < document.ServerForm.rdbtn.length; i++) 
          document.ServerForm.rdbtn[i].checked = false;
    nipcHidden = document.getElementById('txtHiddenNIPC');
    nipcHidden.value = '';
    nomeHidden = document.getElementById('txtHiddenNome');
	nomeHidden.value = '';
	marcaHidden = document.getElementById('txtHiddenMarca');
	marcaHidden.value = '';
	}
	catch(ex)
	{
	}
}

function mudaFonte(size)
{
	obj.mudaFonte(size);
}

function browserApp(){
	var browser = new Browser();
	if (browser.name=='microsoft internet explorer')
	{	
		document.getElementById('AddFavorites').href = "javascript:window.external.AddFavorite(location.href, document.title);";
	}
	else if (browser.name=='opera')
	{
		document.getElementById('AddFavorites').href = '/PORTAL/pt';
		document.getElementById('AddFavorites').title = 'Portal da Empresa';
		document.getElementById('AddFavorites').rel = 'sidebar';
		document.getElementById('AddFavorites').onClick = 'return true;';
	}
	else if ((browser.name=='mozilla')||(browser.name='netscape'))
	{
		document.getElementById('AddFavorites').href = "javascript:window.sidebar.addPanel(document.title, location.href, '');";
	}
}


var obj = {
	
  max:1.5,
  min:1,
  normal:1,
  
  inicializa:function()
  {
	document.body.style.fontSize = this.normal;
    var cook = getCookie('pc_cookie_tamanho');
		
	if(cook!=null)
	{
		this.setvalores(cook);
	}
	else
	{
		this.setvalores(this.normal);
	}
},
 
  mudaFonte: function(val) {
	var tamanho = parseFloat(document.body.style.fontSize) ;
	tamanho += val;

    if ( tamanho > this.max ) 
    {
      tamanho = this.max;
    }
   
    if(tamanho < this.min )
    {
    tamanho=this.min;
    }
       
	this.setvalores(tamanho);
  },
  
  setvalores:function(tam)
  {
    document.body.style.fontSize = tam + 'em';
    this.completa(document);
    if (navigator.appVersion.indexOf('MSIE ')!=-1)
    {
		if(document.frames.length>0)
		{
		document.all[0].document.body.style.fontSize = tam + 'em';
		this.completa(document.all[0].document);
		var frame=document.getElementById('ifrm_list');
		if(frame!=null)
		    {
			frame.src=frame.src;
			}
		}
	}
	else
	{
		var frame=document.getElementById('ifrm_list');
		if(frame!=null)
		{
		frame.contentDocument.body.style.fontSize=tam + 'em';
		this.completa(frame.contentDocument);
		}
	}
		
	//document.body.style.fontSize = tam + 'em';
	 setCookie("pc_cookie_tamanho",tam,1);
},
  
  completa:function(objecto)
  {
  if (objecto.getElementsByTagName) 
	 { 
      tags = new Array ('table'); 

      for (j = 0; j < tags.length; j ++) 
      { 
     
         var tagElements = objecto.body.getElementsByTagName(tags[j]); 
         for (i = 0; i < tagElements.length; i ++) 
         { 
            currentElement = tagElements[i]; 
            currentElement.style.fontSize = objecto.body.style.fontSize; 
         } 
      }
      }
  }
  
}

function setCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	var ck = name+"="+value+expires+"; path=/";
	document.cookie = ck;
}

function getCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i<ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function delCookie(name)
{
	SetCookie(name,"",-1);
}

function confirm_cancel()
{
  code = String.fromCharCode(231);
  if (confirm("Tem a certeza que quer cancelar a opera" + String.fromCharCode(231) + String.fromCharCode(227) + "o? Os dados introduzidos ser" + String.fromCharCode(227) + "o removidos.")==true)
    return true;
  else
    return false;
}

function confirm_cancelPT()
{
  code = String.fromCharCode(231);
  if (confirm("Tem a certeza que quer cancelar a opera" + String.fromCharCode(231) + String.fromCharCode(227) + "o? Os dados introduzidos ser" + String.fromCharCode(227) + "o removidos.")==true)
    return true;
  else
    return false;
}

function confirm_cancelEN()
{
  code = String.fromCharCode(231);
  if (confirm("Are you sure you want to cancel the operation? All the data will be lost.")==true)
    return true;
  else
    return false;
}

function confirm_cancelMNH()
{
  code = String.fromCharCode(231);
  if (confirm("Aten" + String.fromCharCode(231) + String.fromCharCode(227) + "o: O pedido vai ser cancelado e a marca que foi reservada ser" + String.fromCharCode(225) + " devolvida " +  String.fromCharCode(224) + " bolsa de marcas na hora. Deseja continuar?")==true)
    return true;
  else
    return false;
}

function confirm_cancelMNHPT()
{
  code = String.fromCharCode(231);
  if (confirm("Aten" + String.fromCharCode(231) + String.fromCharCode(227) + "o: O pedido vai ser cancelado e a marca que foi reservada ser" + String.fromCharCode(225) + " devolvida " +  String.fromCharCode(224) + " bolsa de marcas na hora. Deseja continuar?")==true)
    return true;
  else
    return false;
}


function confirm_cancelMNHEN()
{
  code = String.fromCharCode(231);
  if (confirm("Attention: the request will be canceled and the reserved trademark will be returned to the List of On The Spot Trademarks. Continue?")==true)          
    return true;
  else
    return false;
}


function confirm_continue_ZMF_RD()
{
  if (confirm("Aten" + String.fromCharCode(231) + String.fromCharCode(227) + "o: O pedido de registo por dep" + String.fromCharCode(243) + "sito que pretende submeter ir" + String.fromCharCode(225) + " ser processado de imediato e as respectivas men" + String.fromCharCode(231) + String.fromCharCode(245) + "es ser" + String.fromCharCode(227) + "o colocadas na ficha de registo. Deseja efectivamente submeter o pedido?")==true)
    return true;
  else
    return false;
}

function confirm_continue_ZMF_RT()
{
  if (confirm("Aten" + String.fromCharCode(231) + String.fromCharCode(227) + "o: O pedido de registo que pretende submeter ir" + String.fromCharCode(225) + " ser processado de imediato e enviado para os servi"+ String.fromCharCode(231) +"os de Backoffice da Empresa Online. Deseja efectivamente submeter o pedido?")==true)
    return true;
  else
    return false;
}

function confirm_continue_ZMF_EO()
{
  if (confirm("Aten" + String.fromCharCode(231) + String.fromCharCode(227) + "o: o pedido de constitui" + String.fromCharCode(231) + String.fromCharCode(227) + "o de sociedade que pretende submeter ir" + String.fromCharCode(225) + " ser processado de imediato e enviado para os servi"+ String.fromCharCode(231) +"os de Backoffice da Empresa Online. Deseja efectivamente submeter o pedido?")==true)
    return true;
  else
    return false;
}

function confirm_remove(name)

{

  if (confirm("Tem a certeza que quer remover o " + name + "? Os dados introduzidos ser" + String.fromCharCode(227) + "o removidos.")==true)

    return true;

  else

    return false;

}

function setHomepage()
{
	var browser = new Browser();
	if (browser.name=='microsoft internet explorer'){
		document.body.style.behavior = "url(#default#homepage)";
		document.body.setHomePage(document.location);
	}
	
}

function Count(text,long) 
{
	var maxlength = new Number(long); // Change number to your max length.
	if (text.value.length > maxlength){
		text.value = text.value.substring(0,maxlength);
	}
}

function disableEmpresa()
{
	comboServico = document.getElementById('listservices_cmbTipoServico');
	comboEmpresa = document.getElementById('listservices_cmbEmpresa');
	
	if(comboServico!=null)
	{
		if(comboServico.value == '3')
			comboEmpresa.disabled = true;
		else
			comboEmpresa.disabled = false;
	}
}

function disableContinuar()
{
	buttonContinuar = document.getElementById('imgBtnContinuar');

	if(buttonContinuar!=null)		
		buttonContinuar.disabled = true;
}

function showDescricao_control()
{	
	dropDocumento = document.getElementById('UploadDocs1_drpDocumento');

	if(dropDocumento!=null)
	{		
		descricao = document.getElementById('UploadDocs1_txtDescricao');

		if(dropDocumento.value == -1)
			descricao.style.visibility='visible';
		else
			descricao.style.visibility='hidden';
	}
}

function showDescricao()
{	
	dropDocumento = document.getElementById('drpDocumento');

	if(dropDocumento!=null)
	{		
		descricao = document.getElementById('txtDescricao');

		if(dropDocumento.value == -1)
			descricao.style.visibility='visible';
		else
			descricao.style.visibility='hidden';
	}
}

function showFirmaFinal()
{
	firma = "-";
	firma2 = "-";
	firma3 = "-";
	
	rdbAprovacaoAutomatica = document.getElementById('rdbAprovacaoAutomatica');
	
	if(rdbAprovacaoAutomatica != null && rdbAprovacaoAutomatica.checked)
	{
		txtNomeFirma = document.getElementById('txtNomeFirma');
		if(txtNomeFirma != null && txtNomeFirma.value != "")
		{
			firma = txtNomeFirma.value;
			
			txtAditamento = document.getElementById('txtAditamento');
			if(txtAditamento != null && txtAditamento.value != "")
				firma += " - " + txtAditamento.value;
				
			drpNaturezaJuridica = document.getElementById("drpNaturezaJuridica");
			drpAditamento = document.getElementById("drpAditamento");
			if(drpNaturezaJuridica != null && drpAditamento != null)
			{
				for(var i=0;i<drpAditamento.length;i++){
					if(drpAditamento.options[i].value == drpNaturezaJuridica.options[drpNaturezaJuridica.selectedIndex].value)
					{
						drpAditamento.selectedIndex = i;
						break;
					}
				}
				if(drpAditamento != null && drpAditamento.value != "" && drpAditamento.options[drpAditamento.selectedIndex].text != "")
					firma += ", " + drpAditamento.options[drpAditamento.selectedIndex].text;
			}
				
			chkZFM = document.getElementById("chkZFM");
			if(chkZFM != null && chkZFM.checked)
				firma += " (ZONA FRANCA DA MADEIRA)";
		}
	
		document.getElementById("lblFirmaFinal").innerHTML = firma;
	}
	else
	{	
		txt1Preferencia = document.getElementById('txt1Preferencia');
		if(txt1Preferencia != null && txt1Preferencia.value != "")
		{
			firma = txt1Preferencia.value;
			
			txtAditamento = document.getElementById('txtAditamento');
			if(txtAditamento != null && txtAditamento.value != "")
				firma += " - " + txtAditamento.value;
			
			drpNaturezaJuridica = document.getElementById("drpNaturezaJuridica");
			drpAditamento = document.getElementById("drpAditamento");
			if(drpNaturezaJuridica != null && drpAditamento != null)
			{
				for(var i=0;i<drpAditamento.length;i++){
					if(drpAditamento.options[i].value == drpNaturezaJuridica.options[drpNaturezaJuridica.selectedIndex].value)
					{
						drpAditamento.selectedIndex = i;
						break;
					}
				}
				if(drpAditamento != null && drpAditamento.value != "" && drpAditamento.options[drpAditamento.selectedIndex].text != "")
					firma += ", " + drpAditamento.options[drpAditamento.selectedIndex].text;
			}
				
			chkZFM = document.getElementById("chkZFM");
			if(chkZFM != null && chkZFM.checked)
				firma += " (ZONA FRANCA DA MADEIRA)";
		}
		
		txt2Preferencia = document.getElementById('txt2Preferencia');
		if(txt2Preferencia != null && txt2Preferencia.value != "")
		{
			firma2 = txt2Preferencia.value;
			
			txtAditamento = document.getElementById('txtAditamento');
			if(txtAditamento != null && txtAditamento.value != "")
				firma2 += " - " + txtAditamento.value;
				
			drpNaturezaJuridica = document.getElementById("drpNaturezaJuridica");
			drpAditamento = document.getElementById("drpAditamento");
			if(drpNaturezaJuridica != null && drpAditamento != null)
			{
				for(var i=0;i<drpAditamento.length;i++){
					if(drpAditamento.options[i].value == drpNaturezaJuridica.options[drpNaturezaJuridica.selectedIndex].value)
					{
						drpAditamento.selectedIndex = i;
						break;
					}
				}
				if(drpAditamento != null && drpAditamento.value != "" && drpAditamento.options[drpAditamento.selectedIndex].text != "")
					firma2 += ", " + drpAditamento.options[drpAditamento.selectedIndex].text;
			}
				
			chkZFM = document.getElementById("chkZFM");
			if(chkZFM != null && chkZFM.checked)
				firma2 += " (ZONA FRANCA DA MADEIRA)";
		}
			
		txt3Preferencia = document.getElementById('txt3Preferencia');
		if(txt3Preferencia != null && txt3Preferencia.value != "")
		{
			firma3 = txt3Preferencia.value;
			
			txtAditamento = document.getElementById('txtAditamento');
			if(txtAditamento != null && txtAditamento.value != "")
				firma3 += " - " + txtAditamento.value;
				
			drpNaturezaJuridica = document.getElementById("drpNaturezaJuridica");
			drpAditamento = document.getElementById("drpAditamento");
			if(drpNaturezaJuridica != null && drpAditamento != null)
			{
				for(var i=0;i<drpAditamento.length;i++){
					if(drpAditamento.options[i].value == drpNaturezaJuridica.options[drpNaturezaJuridica.selectedIndex].value)
					{
						drpAditamento.selectedIndex = i;
						break;
					}
				}
				if(drpAditamento != null && drpAditamento.value != "" && drpAditamento.options[drpAditamento.selectedIndex].text != "")
					firma3 += ", " + drpAditamento.options[drpAditamento.selectedIndex].text;
			}
				
			chkZFM = document.getElementById("chkZFM");
			if(chkZFM != null && chkZFM.checked)
				firma3 += " (ZONA FRANCA DA MADEIRA)";
		}

		if(document.getElementById("lbl1Preferencia") != null)
			document.getElementById("lbl1Preferencia").innerHTML = firma;
		if(document.getElementById("lbl2Preferencia") != null)
			document.getElementById("lbl2Preferencia").innerHTML = firma2;
		if(document.getElementById("lbl3Preferencia") != null)
			document.getElementById("lbl3Preferencia").innerHTML = firma3;		
	}
}

function showFirmaFinalEN()
{
	firma = "-";
	firma2 = "-";
	firma3 = "-";
	
	rdbAprovacaoAutomatica = document.getElementById('rdbAprovacaoAutomatica');
	
	if(rdbAprovacaoAutomatica != null && rdbAprovacaoAutomatica.checked)
	{
		txtNomeFirma = document.getElementById('txtNomeFirma');
		if(txtNomeFirma != null && txtNomeFirma.value != "")
		{
			firma = txtNomeFirma.value;
			
			txtAditamento = document.getElementById('txtAditamento');
			if(txtAditamento != null && txtAditamento.value != "")
				firma += " - " + txtAditamento.value;
				
			drpNaturezaJuridica = document.getElementById("drpNaturezaJuridica");
			drpAditamento = document.getElementById("drpAditamento");
			if(drpNaturezaJuridica != null && drpAditamento != null)
			{
				for(var i=0;i<drpAditamento.length;i++){
					if(drpAditamento.options[i].value == drpNaturezaJuridica.options[drpNaturezaJuridica.selectedIndex].value)
					{
						drpAditamento.selectedIndex = i;
						break;
					}
				}
				if(drpAditamento != null && drpAditamento.value != "" && drpAditamento.options[drpAditamento.selectedIndex].text != "")
					firma += ", " + drpAditamento.options[drpAditamento.selectedIndex].text;
			}
				
			chkZFM = document.getElementById("chkZFM");
			if(chkZFM != null && chkZFM.checked)
				firma += " (FREE ZONE OF MADEIRA)";
		}
	
		document.getElementById("lblFirmaFinal").innerHTML = firma;
	}
	else
	{	
		txt1Preferencia = document.getElementById('txt1Preferencia');
		if(txt1Preferencia != null && txt1Preferencia.value != "")
		{
			firma = txt1Preferencia.value;
			
			txtAditamento = document.getElementById('txtAditamento');
			if(txtAditamento != null && txtAditamento.value != "")
				firma += " - " + txtAditamento.value;
			
			drpNaturezaJuridica = document.getElementById("drpNaturezaJuridica");
			drpAditamento = document.getElementById("drpAditamento");
			if(drpNaturezaJuridica != null && drpAditamento != null)
			{
				for(var i=0;i<drpAditamento.length;i++){
					if(drpAditamento.options[i].value == drpNaturezaJuridica.options[drpNaturezaJuridica.selectedIndex].value)
					{
						drpAditamento.selectedIndex = i;
						break;
					}
				}
				if(drpAditamento != null && drpAditamento.value != "" && drpAditamento.options[drpAditamento.selectedIndex].text != "")
					firma += ", " + drpAditamento.options[drpAditamento.selectedIndex].text;
			}
				
			chkZFM = document.getElementById("chkZFM");
			if(chkZFM != null && chkZFM.checked)
				firma += " (FREE ZONE OF MADEIRA)";
		}
		
		txt2Preferencia = document.getElementById('txt2Preferencia');
		if(txt2Preferencia != null && txt2Preferencia.value != "")
		{
			firma2 = txt2Preferencia.value;
			
			txtAditamento = document.getElementById('txtAditamento');
			if(txtAditamento != null && txtAditamento.value != "")
				firma2 += " - " + txtAditamento.value;
				
			drpNaturezaJuridica = document.getElementById("drpNaturezaJuridica");
			drpAditamento = document.getElementById("drpAditamento");
			if(drpNaturezaJuridica != null && drpAditamento != null)
			{
				for(var i=0;i<drpAditamento.length;i++){
					if(drpAditamento.options[i].value == drpNaturezaJuridica.options[drpNaturezaJuridica.selectedIndex].value)
					{
						drpAditamento.selectedIndex = i;
						break;
					}
				}
				if(drpAditamento != null && drpAditamento.value != "" && drpAditamento.options[drpAditamento.selectedIndex].text != "")
					firma2 += ", " + drpAditamento.options[drpAditamento.selectedIndex].text;
			}
				
			chkZFM = document.getElementById("chkZFM");
			if(chkZFM != null && chkZFM.checked)
				firma2 += " (FREE ZONE OF MADEIRA)";
		}
			
		txt3Preferencia = document.getElementById('txt3Preferencia');
		if(txt3Preferencia != null && txt3Preferencia.value != "")
		{
			firma3 = txt3Preferencia.value;
			
			txtAditamento = document.getElementById('txtAditamento');
			if(txtAditamento != null && txtAditamento.value != "")
				firma3 += " - " + txtAditamento.value;
				
			drpNaturezaJuridica = document.getElementById("drpNaturezaJuridica");
			drpAditamento = document.getElementById("drpAditamento");
			if(drpNaturezaJuridica != null && drpAditamento != null)
			{
				for(var i=0;i<drpAditamento.length;i++){
					if(drpAditamento.options[i].value == drpNaturezaJuridica.options[drpNaturezaJuridica.selectedIndex].value)
					{
						drpAditamento.selectedIndex = i;
						break;
					}
				}
				if(drpAditamento != null && drpAditamento.value != "" && drpAditamento.options[drpAditamento.selectedIndex].text != "")
					firma3 += ", " + drpAditamento.options[drpAditamento.selectedIndex].text;
			}
				
			chkZFM = document.getElementById("chkZFM");
			if(chkZFM != null && chkZFM.checked)
				firma3 += " (FREE ZONE OF MADEIRA)";
		}

		if(document.getElementById("lbl1Preferencia") != null)
			document.getElementById("lbl1Preferencia").innerHTML = firma;
		if(document.getElementById("lbl2Preferencia") != null)
			document.getElementById("lbl2Preferencia").innerHTML = firma2;
		if(document.getElementById("lbl3Preferencia") != null)
			document.getElementById("lbl3Preferencia").innerHTML = firma3;		
	}
}

function showFirmaFinalPT()
{
	firma = "-";
	firma2 = "-";
	firma3 = "-";
	
	rdbAprovacaoAutomatica = document.getElementById('rdbAprovacaoAutomatica');
	
	if(rdbAprovacaoAutomatica != null && rdbAprovacaoAutomatica.checked)
	{
		txtNomeFirma = document.getElementById('txtNomeFirma');
		if(txtNomeFirma != null && txtNomeFirma.value != "")
		{
			firma = txtNomeFirma.value;
			
			txtAditamento = document.getElementById('txtAditamento');
			if(txtAditamento != null && txtAditamento.value != "")
				firma += " - " + txtAditamento.value;
				
			drpNaturezaJuridica = document.getElementById("drpNaturezaJuridica");
			drpAditamento = document.getElementById("drpAditamento");
			if(drpNaturezaJuridica != null && drpAditamento != null)
			{
				for(var i=0;i<drpAditamento.length;i++){
					if(drpAditamento.options[i].value == drpNaturezaJuridica.options[drpNaturezaJuridica.selectedIndex].value)
					{
						drpAditamento.selectedIndex = i;
						break;
					}
				}
				if(drpAditamento != null && drpAditamento.value != "" && drpAditamento.options[drpAditamento.selectedIndex].text != "")
					firma += ", " + drpAditamento.options[drpAditamento.selectedIndex].text;
			}
				
			chkZFM = document.getElementById("chkZFM");
			if(chkZFM != null && chkZFM.checked)
				firma += " (ZONA FRANCA DA MADEIRA)";
		}
	
		document.getElementById("lblFirmaFinal").innerHTML = firma;
	}
	else
	{	
		txt1Preferencia = document.getElementById('txt1Preferencia');
		if(txt1Preferencia != null && txt1Preferencia.value != "")
		{
			firma = txt1Preferencia.value;
			
			txtAditamento = document.getElementById('txtAditamento');
			if(txtAditamento != null && txtAditamento.value != "")
				firma += " - " + txtAditamento.value;
			
			drpNaturezaJuridica = document.getElementById("drpNaturezaJuridica");
			drpAditamento = document.getElementById("drpAditamento");
			if(drpNaturezaJuridica != null && drpAditamento != null)
			{
				for(var i=0;i<drpAditamento.length;i++){
					if(drpAditamento.options[i].value == drpNaturezaJuridica.options[drpNaturezaJuridica.selectedIndex].value)
					{
						drpAditamento.selectedIndex = i;
						break;
					}
				}
				if(drpAditamento != null && drpAditamento.value != "" && drpAditamento.options[drpAditamento.selectedIndex].text != "")
					firma += ", " + drpAditamento.options[drpAditamento.selectedIndex].text;
			}
				
			chkZFM = document.getElementById("chkZFM");
			if(chkZFM != null && chkZFM.checked)
				firma += " (ZONA FRANCA DA MADEIRA)";
		}
		
		txt2Preferencia = document.getElementById('txt2Preferencia');
		if(txt2Preferencia != null && txt2Preferencia.value != "")
		{
			firma2 = txt2Preferencia.value;
			
			txtAditamento = document.getElementById('txtAditamento');
			if(txtAditamento != null && txtAditamento.value != "")
				firma2 += " - " + txtAditamento.value;
				
			drpNaturezaJuridica = document.getElementById("drpNaturezaJuridica");
			drpAditamento = document.getElementById("drpAditamento");
			if(drpNaturezaJuridica != null && drpAditamento != null)
			{
				for(var i=0;i<drpAditamento.length;i++){
					if(drpAditamento.options[i].value == drpNaturezaJuridica.options[drpNaturezaJuridica.selectedIndex].value)
					{
						drpAditamento.selectedIndex = i;
						break;
					}
				}
				if(drpAditamento != null && drpAditamento.value != "" && drpAditamento.options[drpAditamento.selectedIndex].text != "")
					firma2 += ", " + drpAditamento.options[drpAditamento.selectedIndex].text;
			}
				
			chkZFM = document.getElementById("chkZFM");
			if(chkZFM != null && chkZFM.checked)
				firma2 += " (ZONA FRANCA DA MADEIRA)";
		}
			
		txt3Preferencia = document.getElementById('txt3Preferencia');
		if(txt3Preferencia != null && txt3Preferencia.value != "")
		{
			firma3 = txt3Preferencia.value;
			
			txtAditamento = document.getElementById('txtAditamento');
			if(txtAditamento != null && txtAditamento.value != "")
				firma3 += " - " + txtAditamento.value;
				
			drpNaturezaJuridica = document.getElementById("drpNaturezaJuridica");
			drpAditamento = document.getElementById("drpAditamento");
			if(drpNaturezaJuridica != null && drpAditamento != null)
			{
				for(var i=0;i<drpAditamento.length;i++){
					if(drpAditamento.options[i].value == drpNaturezaJuridica.options[drpNaturezaJuridica.selectedIndex].value)
					{
						drpAditamento.selectedIndex = i;
						break;
					}
				}
				if(drpAditamento != null && drpAditamento.value != "" && drpAditamento.options[drpAditamento.selectedIndex].text != "")
					firma3 += ", " + drpAditamento.options[drpAditamento.selectedIndex].text;
			}
				
			chkZFM = document.getElementById("chkZFM");
			if(chkZFM != null && chkZFM.checked)
				firma3 += " (ZONA FRANCA DA MADEIRA)";
		}

		if(document.getElementById("lbl1Preferencia") != null)
			document.getElementById("lbl1Preferencia").innerHTML = firma;
		if(document.getElementById("lbl2Preferencia") != null)
			document.getElementById("lbl2Preferencia").innerHTML = firma2;
		if(document.getElementById("lbl3Preferencia") != null)
			document.getElementById("lbl3Preferencia").innerHTML = firma3;		
	}
}


function showFirmaFinalAA()
{
	showFirmaFinalAAPT();
}

function showFirmaFinalAAPT()
{
	showFirmaFinalAAUniv(' (ZONA FRANCA DA MADEIRA)');
}
	
function showFirmaFinalAAEN()
{
	showFirmaFinalAAUniv(' (FREE ZONE OF MADEIRA)');
}
	
function showFirmaFinalAAUniv(zfmText)
{
	firma = "-";
	txtNomeFirma = document.getElementById('denominacaoFirma_txtElementoNominal');
	if(txtNomeFirma != null && txtNomeFirma.value != "")
	{
		firma = txtNomeFirma.value;
		drpNaturezaJuridica = document.getElementById("denominacaoFirma_drpNaturezaJuridica");
		drpAditamento = document.getElementById("denominacaoFirma_drpAditamento");
		if(drpNaturezaJuridica != null && drpAditamento != null)
		{
			for(var i=0;i<drpAditamento.length;i++){
				if(drpAditamento.options[i].value == drpNaturezaJuridica.options[drpNaturezaJuridica.selectedIndex].value)
				{
					drpAditamento.selectedIndex = i;
					break;
				}
			}
			if(drpAditamento != null && drpAditamento.value != "" && drpAditamento.options[drpAditamento.selectedIndex].text != "")
				firma += ", " + drpAditamento.options[drpAditamento.selectedIndex].text;
		}
		chkZFM = document.getElementById("denominacaoFirma_chkZFM");
		if(chkZFM != null && chkZFM.checked)
			firma += zfmText;
		document.getElementById("denominacaoFirma_lblFirmaFinal").innerHTML = firma;
	}
}
