function addfavorits(e){	

var titulo = "DGAEP";
var url = "http://www.dgaep.gov.pt";

		if (e.type == "keydown"){
		var key=e.keyCode || e.which;
			if (key==13){//enter
				if (document.all){//IE
					window.external.AddFavorite(url,titulo);
				}else if (window.sidebar){ //FireFox
					window.sidebar.addPanel(titulo, url,"");
				};
			};
	}else if (e.type == "mousedown"){
		if (document.all){//IE
			window.external.AddFavorite(url,titulo);
		}else if (window.sidebar){ //FireFox
			window.sidebar.addPanel(titulo, url,"");
		};
	};	
};
//************************************************************************************************************************************************
// SWICH LANG
//************************************************************************************************************************************************
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}

//************************************************************************************************************************************************
// SHOW HIDE DIVS
//************************************************************************************************************************************************
/*
Highlight Image Script- 
© Dynamic Drive (www.dynamicdrive.com)
For full source code, installation instructions,
100's more DHTML scripts, and Terms Of
Use, visit dynamicdrive.com
*/

function makevisible(cur,which){
	if (which==0)
		cur.filters.alpha.opacity=75
	else
		cur.filters.alpha.opacity=100
}


/* Show / Hide */
if (parseInt(navigator.appVersion) > 3) {
	if (navigator.appName == "Netscape") {
		layerVar="document.layers";
		styleVar="";
	}else{
		layerVar="document.all";
		styleVar=".style";
	}
}

function skf_ShowHideLayer(TheLayer,TheAttrib) {
	if (parseInt(navigator.appVersion) > 3) {
		eval(layerVar + '["' + TheLayer + '"]' + styleVar + '.display = "' + TheAttrib + '"');
	}
}

function HideDIV(d) { document.getElementById(d).style.display = "none"; }
function DisplayDIV(d) { document.getElementById(d).style.display = "block"; }

function hideAll(){
//	skf_ShowHideLayer('layer1','none');
//	skf_ShowHideLayer('layer1a','none');
//	skf_ShowHideLayer('layer2','none');
//	skf_ShowHideLayer('layer2a','none');
//	skf_ShowHideLayer('layer3','none');
//	skf_ShowHideLayer('layer3a','none');
//	skf_ShowHideLayer('layer5','none');
//	skf_ShowHideLayer('layer5a','none');
//	skf_ShowHideLayer('layer6','none');
//	skf_ShowHideLayer('layer6a','none');
//	skf_ShowHideLayer('layer7','none');
//	skf_ShowHideLayer('layer7a','none');
//	skf_ShowHideLayer('layer8','none');
//	skf_ShowHideLayer('layer8a','none');
	hideallids();
}

//here you place the ids of every element you want.
var ids=new Array('layer1','layer2','layer3','layer4','layer5','layer6','layer7','layer8','layer9');

function switchid(id){	
	hideallids();
	showdiv(id);
}

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

/*
function toggle2(target)
{
   obj=(document.all) ? document.all[target] : document.getElementById(target);
   obj.style.display=(obj.style.display=='none') ? 'inline' : 'none';
}
*/

// toggle visibility 
function toggle(targetId){ 
	if (document.getElementById){
        target = document.getElementById( targetId );
           if (target.style.display == "none"){ 
              target.style.display = ""; 
           } else { 
              target.style.display = "none"; 
           } 
     } 
} 


/***********************************************
* Só números no campo do Form
***********************************************/
var isIE = document.all?true:false;
var isNS = document.layers?true:false;
function onlyDigits(e) {
var _ret = true;
if (isIE) {
	if (window.event.keyCode < 46 || window.event.keyCode > 57) {
		window.event.keyCode = 0;
		_ret = false;
	}
}
if (isNS) {
if (e.which < 46 || e.which > 57) {
	e.which = 0;
	_ret = false;
	}
}
	return (_ret); 
}
/***********************************************/

// Dynamic Version by: Nannette Thacker 
// http://www.shiningstar.net 
// Original by :  Ronnie T. Moore 
// Web Site:  The JavaScript Source 
// Use one function for multiple text areas on a page 
// Limit the number of characters per textarea 
// Begin
function textCounter(field,maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
}