//funcao para apagar dados
function confirma_apaga(nome, ID, pagOk, pagCancel, tipo_pag)
{
	var r=confirm("Tem a certeza que deseja mesmo apagar"+" " + tipo_pag +" " + nome +"?");
	if (r==true)
	{
	  window.location = pagOk +"?" + tipo_pag + "=" + ID;
	} else {
	   window.location = pagCancel;
	}
}
//fim da funcao de apagar dados

<!--
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->

<!--preload das imagens
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
// fim preload das imagens-->

<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->

<!--open bronser windows centrado
function CenterPopup(theURL,width,height,scroolbars){
leftPos = 0
topPos = 0
// Set our PopUp size:
var Width=500  
var Height=400
if (screen) {
leftPos = (screen.width-Width)/2
topPos = (screen.height-Height)/2
}
{
window.open(theURL,'Visualizar','width='+width+',height='+height+',left='+leftPos+',top='+topPos+',scrollbars=yes');
}
}

<!--fim open bronser windows centrado

<!--valida pesquisa
function valida_pesquisa(theForm){			
if( theForm.pesq.value == "" ){
alert( "Tem que escrever a palavra para pode efectuar a pesquisa!" );
theForm.pesq.focus();
return(false);
}

if( theForm.pesq.value == " " ){
alert( "Tem que escrever a palavra para pode efectuar a pesquisa!" );
theForm.pesq.focus();
return(false);
}

if( theForm.pesq.value == "Pesquisar..." ){
alert( "Tem que escrever a palavra para pode efectuar a pesquisa!" );
theForm.pesq.focus();
return(false);
}

if( theForm.pesq.value.length < 2 ){
alert( "Tem que escrever pelo menos 2 caracteres !" );
theForm.pesq.focus();
return(false);
}
return (true);
}		
<!--fim valida pesquisa
<!--slide com jqery dos anchor do topo
$(document).ready(function(){
	$(".scroll").click(function(event){
		//prevent the default action for the click event
		event.preventDefault();
		
		//get the full url - like mysitecom/index.htm#home
		var full_url = this.href;
		
		//split the url by # and get the anchor target name - home in mysitecom/index.htm#home
		var parts = full_url.split("#");
		var trgt = parts[1];
		
		//get the top offset of the target anchor
		var target_offset = $("#"+trgt).offset();
		var target_top = target_offset.top;
		
		//goto that anchor by setting the body scroll top to anchor top
		$('html, body').animate({scrollTop:target_top}, 1500);
	});
});
<!--fim slide com jqery dos anchor do topo

// adicionar aos favoritos

function adicionarFavoritos(url)
{
    titulo = document.title;
	/*url = 'http://wwww.freguesias.pt';*/
	chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
	safari = navigator.userAgent.toLowerCase().indexOf('safari') > -1;

    if (chrome == true){// chrome favoritos
	   alert('Clique em CTRL + D para adicionar aos favoritos!')
	} 
	
    else if (window.sidebar){ // Mozilla Firefox favoritos
	   window.sidebar.addPanel(titulo, url,"");
	}
	
	else if(window.external){ // IE favoritos
	window.external.AddFavorite( url, titulo);
	}
	
	else if(window.opera && window.print){ // Opera favoritos
	}
	
	else if (safari == true){// safari favoritos
	   alert('Clique em CTRL + D para adicionar aos favoritos!')
	} 
	
	else if(alert('Não suportado!')){
	
    }
	
}
// fim adicionar aos favoritos


/***********************************************
altura iframe
***********************************************/

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["tempo", "agenda_eventos"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById)
resizeIframe(iframeids[i])
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}

function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
currentfr.style.display="block"
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; 
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustIframe, false)
else if (currentfr.attachEvent){
currentfr.detachEvent("onload", readjustIframe) // Bug fix line
currentfr.attachEvent("onload", readjustIframe)
}
}
}

function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
if (document.getElementById)
document.getElementById(iframeid).src=url
}

if (window.addEventListener)
window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller)
else
window.onload=resizeCaller


// Apagar ID da Base de Dados //////////////////////////////////////////////
function delPag(actualPag,tipoPag,idPag,nomePag,Pag,menuNV,menuCOD) {
	var answer = confirm("Tem a certeza que deseja apagar "+tipoPag+" ''"+nomePag+"''?")
	if (answer){
		if (Pag == "menu") {
			window.location = "?del="+idPag+"&nivel="+menuNV+"&cod="+menuCOD;
		} else if (Pag == "p") {
			window.location = "?del="+idPag+"&tipo=p";
		} else {
			window.location = "?del="+idPag;
		}
	}else{
		window.location = actualPag;
	}
}

// Alerta informando que não pode apagar este menu por conter sub-menus//////////////////////////////////////////////
function delPagOff(actualPag,tipoPag,idPag,nomePag) {
	alert("Não pode apagar o "+tipoPag+" ''"+nomePag+"'' porque contêm Sub-menus.\nApaga primeiro os Sub-menus de ''"+nomePag+"''")
	window.location = actualPag;
}
// Alerta informando que não pode apagar este menu está protegido//////////////////////////////////////////////
function delPagLock(actualPag,tipoPag,idPag,nomePag) {
	alert("Não pode apagar o "+tipoPag+" ''"+nomePag+"'' porque está protegido.")
	window.location = actualPag;
}
