// JavaScript Document
fbPageOptions = {
	theme:          'black'    ,// 'auto'|'black'|'white'|'blue'|'yellow'|'red'|'custom'
	padding:         5       ,// pixels
	panelPadding:    5        ,// pixels
	outerBorder:     1        ,// pixels
	innerBorder:     0        ,// pixels
	overlayOpacity:  55       ,// 0-100
	controlOpacity:  60       ,// 0-100
	autoSizeImages:  true     ,// true|false
	autoSizeOther:   false    ,// true|false
	resizeImages:    true     ,// true|false
	resizeOther:     false    ,// true|false
	resizeTool:     'cursor'  ,// 'cursor'|'topleft'|'both'
	infoPos:        'bl'      ,// 'tl'|'tc'|'tr'|'bl'|'bc'|'br'
	controlPos:     'br'      ,// 'tl'|'tr'|'bl'|'br'
	boxLeft:        'auto'    ,// 'auto'|pixels|'[-]xx%'
	boxTop:         'auto'    ,// 'auto'|pixels|'[-]xx%'
	shadowType:     'drop'    ,// 'drop'|'halo'|'none'
	shadowSize:      8        ,// 8|12|16|24
	enableDrag:      true     ,// true|false
	showCaption:     true     ,// true|false
	showItemNumber:  true     ,// true|false
	showClose:       true     ,// true|false
	hideFlash:       true     ,// true|false
	hideJava:        true     ,// true|false
	disableScroll:   true    ,// true|false
	autoGallery:     false    ,// true|false
	preloadAll:      true     ,// true|false
	enableCookies:   false    ,// true|false
	cookieScope:    'site'    ,// 'site'|'folder'
	language:       'auto'    ,// 'auto'|'en'|... (see the languages folder)
	graphicsType:   'auto'    ,// 'auto'|'international'|'english'
	urlGraphics:    '/floatbox/graphics/'   ,// change this if you install in another folder
	urlLanguages:   '/floatbox/languages/' // change this if you install in another folder
};

/****************************************/

var GM="41.27638889,-8.61722222";
var GM_Mensagem="<div style='margin-top:5px;'><b>Junta de Freguesia de Avioso (S. Pedro)</b><br /><br /><div id='gpsformat' style='padding:4px; display:inline;'>N: 41.27638889&ordm; W: 8.61722222&ordm; </div></div>";
var GM_Zoom = 15;
var D=document;
function instalarGMaps(i){
	if (!GM)return;
	
	var coordenadas = GM.split(',');
	var GM_LAT = coordenadas[0];
	var GM_LON = coordenadas[1];
	var zoom = Number(GM_Zoom);
	
	if(!zoom)zoom = 15;
	
	try{GBrowserIsCompatible()}catch(e){
		setTimeout("instalarGMaps(true)",100);
		return;
	}
	
	if(GBrowserIsCompatible()){
		var map = new GMap2(document.getElementById("GM"));
		map.addControl(new GLargeMapControl3D());
		map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng(GM_LAT, GM_LON), zoom, G_HYBRID_MAP);
	

		function createMarker(point) {
			  var marker = new GMarker(point);
		
			  GEvent.addListener(marker, "click", function() {
				if (GM_Mensagem){
					GM_Mensagem=GM_Mensagem.replace(/\n/g,'<br />');
					var gmmsg=document.createElement("<div>");
					gmmsg.innerHTML=GM_Mensagem;
					marker.openInfoWindowHtml(gmmsg);
				}
			  });
			  return marker;
		}
		
		var bounds = map.getBounds();
		map.addOverlay(createMarker(new GLatLng(GM_LAT, GM_LON)));
	}	
}

/* e-MAIL / URL */
function addRowToTable()
{
  var tbl = document.getElementById('tbl_EMAIL_URL');
  var lastRow = tbl.rows.length;
 
 
 // if there's no header row in the table, then iteration = lastRow + 1
  var iteration = lastRow;
  var row = tbl.insertRow(lastRow);
  
  var classSelection = lastRow%2 == 0 ? 'grid_tr_par':'grid_tr_impar';
  // left cell
  var cellLeft = row.insertCell(0);
  var textNode = document.createTextNode(iteration);
  cellLeft.className=classSelection;
  cellLeft.align='center';
  cellLeft.style.fontWeight= 'bold';
  cellLeft.appendChild(textNode);
  
  // Tipo LINK
  var cellRight = row.insertCell(1);
  cellRight.className = classSelection;
  
  var el = document.createElement('input');
  el.type = 'text';
  el.name = 'nome_agregado' + iteration;
  el.id = 'required';
  el.accept='true';
  el.width = '235';
  cellRight.appendChild(el);
  
  // Lingua
  var cellRight = row.insertCell(2);cellRight.className = classSelection;
  var el = document.createElement('input');
  el.type = 'text';
  el.name = 'idade' + iteration;
  el.id = 'required';
  el.accept='true';
  el.width = '60';
  cellRight.appendChild(el);
  // LEVEL
  var cellRight = row.insertCell(3);cellRight.className = classSelection;
  var el = document.createElement('input');
  el.type = 'text';
  el.name = 'parentesco' + iteration;
  el.id = 'required';
  el.accept='true';
  el.width = '100';
  cellRight.appendChild(el);
  
  // LEVEL
  var cellRight = row.insertCell(4);cellRight.className = classSelection;
  var el = document.createElement('input');
  el.type = 'text';
  el.name = 'profissao' + iteration;
  el.id = 'required';
  el.accept='true';
  el.width = '100';
  cellRight.appendChild(el);
  
  // LEVEL
  var cellRight = row.insertCell(5);
  cellRight.className = classSelection;
  cellRight.colSpan='2';
  
  var el = document.createElement('input');
  el.type = 'text';
  el.name = 'salario' + iteration;
  el.id = 'salario' + iteration;
  el.width = '60';
  cellRight.appendChild(el);

  var cellRight = row.insertCell(6);
  cellRight.className = classSelection;  
  cellRight.align='center';
  cellRight.innerHTML='<input name="button2" type="button" onclick="removeRowFromTableId('+iteration+');" value="-" style="height:12px; background:transparent; color:#000000; border:0; padding:0; margin-bottom:3px; font-size:12px;" />';

	var x = document.getElementById('escondido').value = iteration;
}
function keyPressTest(e, obj){
  var validateChkb = document.getElementById('chkValidateOnKeyPress');
  if (validateChkb.checked) {
    var displayObj = document.getElementById('spanOutput');
    var key;
    if(window.event) {
      key = window.event.keyCode; 
    }
    else if(e.which) {
      key = e.which;
    }
    var objId;
    if (obj != null) {
      objId = obj.id;
    } else {
      objId = this.id;
    }
    displayObj.innerHTML = objId + ' : ' + String.fromCharCode(key);
  }
}

function removeRowFromTable(){
  var tbl = document.getElementById('tbl_EMAIL_URL');
  var lastRow = tbl.rows.length;
  
  if (lastRow > 2) tbl.deleteRow(lastRow - 1);
  var x = document.getElementById('escondido').value = tbl.rows.length-1;
}
function removeRowFromTableId(id){
  var tbl = document.getElementById('tbl_EMAIL_URL');
  var lastRow = tbl.rows.length;
  
  if (lastRow > 2) tbl.deleteRow(id);
  else tbl.deleteRow(lastRow-1);
 
 var x = document.getElementById('escondido').value = tbl.rows.length-1;
}

/*************ACOORDIONS***************/
ddaccordion.init({
	headerclass: "th", //Shared CSS class name of headers group
	contentclass: "content", //Shared CSS class name of contents group
	revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click" or "mouseover"
	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [], //index of content(s) open by default [index1, index2, etc]. [] denotes no content.
	onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: true, //persist state of opened contents within browser session?
	toggleclass: ["closedlanguage", "openlanguage"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["none", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "fast", //speed of animation: "fast", "normal", or "slow"
	oninit:function(expandedindices){ //custom code to run when headers have initalized
		//do nothing
	},
	onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
		//do nothing
	}
})
/******************************************************************************/
function eMail(utilizador,dominio,terminacao,site){
	var addr = Array(utilizador,' at ',dominio,' dot ',terminacao);
	var addr_assunto = 'Contactos do site '+site;
	addr = addr.join('');
	addr = addr.replace(' at ','@');
	addr = addr.replace(' dot ','.');
	//document.getElementById('mailaddr').innerHTML='<a href="mailto:'+addr+'?subject='+addr_assunto+'">'+addr+'</a>';
	return document.write('<a href="mailto:'+addr+'?subject='+addr_assunto+'">'+addr+'</a>');
}

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];}}
}

function inicio(){
	MM_preloadImages('imagens/banner/00001.jpg',
					 'imagens/banner/00002.jpg',
					 'imagens/banner/00003.jpg',
					 'imagens/banner/00004.jpg',
					 'imagens/banner/00005.jpg',
					 'imagens/banner/00006.jpg',
					 'imagens/banner/00007.jpg',
					 'imagens/banner/00008.jpg',
					 'imagens/banner/00009.jpg',
					 'imagens/banner/00010.jpg',
					 'imagens/banner/00011.jpg',
					 'imagens/banner/00012.jpg'
					);
	try{instalarGMaps(true);}catch(e){	}
}	
window.onload=inicio;

