<!-- alterValue(this, 'nome'); -->
browser = {
    'isFF' : (navigator.userAgent.indexOf("Firefox") > -1),
    'isIE' : (navigator.userAgent.indexOf("MSIE") > -1),
    'isIE6': (navigator.userAgent.indexOf("MSIE 6") > -1),
    'isIE7': (navigator.userAgent.indexOf("MSIE 7") > -1),
    'isIE8': (navigator.userAgent.indexOf("MSIE 8") > -1),
    'isOpera' : (navigator.userAgent.indexOf("Opera") > -1),
    'isSafari': (navigator.userAgent.indexOf("Safari") > -1)
}

function alterValue(component, val) {
    if (component.value == '') {
        component.value = val;
    } else if (component.value == val) {
        component.value = '';
    }
}

/**
 * Preenche uma combo box a partir de um array
*/
function fillSelectFromArray(selectCtrl, itemArray, goodPrompt, badPrompt, defaultItem) {
    var i, j;
    var prompt;
    
    if ((itemArray == '0') || (itemArray == -1) || (itemArray == null)) {
        selectCtrl.disabled = true;
    } else {
        selectCtrl.disabled = false;
    }
    
    // empty existing items
    for (i = selectCtrl.options.length; i >= 0; i--) {
        selectCtrl.options[i] = null; 
    }
    prompt = (itemArray != null) ? goodPrompt : badPrompt;
    if (prompt == null) {
        j = 0;
    } else {
        selectCtrl.options[0] = new Option(prompt);
        j = 1;
    }
    if (itemArray != null) {
        // add new items
        for (i = 0; i < itemArray.length; i++) {
            selectCtrl.options[j] = new Option(itemArray[i][0]);
            if (itemArray[i][1] != null) {
                selectCtrl.options[j].value = itemArray[i][1]; 
            }
            j++;
        }
        // select first item (prompt) for sub list
        selectCtrl.options[0].selected = true;
    }
}

// HACK PARA FAZER O RECISE DAS DIVS CROSS BROWSER COMPATIVEL
function dosizeSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  
 var totalwidth = myWidth-233;
// $('menuspotter').style.width = totalwidth+'px';
  
 if(myHeight > 606){
 	var footerHeight = myHeight-30;
 } else {
 	var footerHeight = 606-30;
 }
 $('footer').style.top = footerHeight+'px';
 
 
//COMENTEI ESTAS 2 LINHAS PARA NAO CORTAR O BANNER

// var totalwidth = myWidth-233;
 //$('homepagelogo').style.width = totalwidth+'px';
 dosizeSize2();

 
}

function dosizeSizefolio() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

 var totalwidth = myWidth-20;
 /*
 if($('portfolio')){
	 $('portfolio').style.width = totalwidth+'px';
 }
*/
// if($('portfolio_1680')){
	// $('portfolio_1680').style.width = totalwidth+'px';
 //}
 

 

dosizeSize2();
 
 if(myHeight > 606){
 	var footerHeight = myHeight-40;
 } else {
 	var footerHeight = 606-40;
 }
 $('footer').style.top = footerHeight+'px';
 
}

function dosizeSize2() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

 var totalwidth = myWidth-233;
// $('menuspotter').style.width = totalwidth+'px';
 
 
}



function dosizeSize3() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

 var totalwidth = myWidth-233;
  var totalwidth2 = myWidth-258;
 $('menuspotter').style.width = totalwidth+'px';
 $('output_back').style.width = totalwidth2+'px';
 $('output_transparent').style.width = totalwidth+'px';
 
 
$('interstitial2').style.width = myWidth+'px';
$('interstitial2').style.height = myHeight+'px';
$('interstitial').style.width = myWidth+'px';
$('interstitial').style.height = myHeight+'px';
 
  if(myHeight > 606){
 	var footerHeight = myHeight-20;
 } else {
 	var footerHeight = 606-20;
 }
 $('footer').style.top = footerHeight+'px';
 
 
}

function dosizeSize4() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

 var totalwidth = myWidth-233;
  var totalwidth2 = myWidth-258;


//$('menuspotter').style.width = totalwidth+'px';


//$('output_back').style.width = totalwidth2+'px';
 //$('output_transparent').style.width = totalwidth+'px';

if(myHeight > 606){
var footerHeight = myHeight-30;
} else {
var footerHeight = 606-20;
}
$('footer').style.top = footerHeight+'px';

if (browser.isFF == true){
$('output').style.marginTop = '-450px';
	
}
buildScroll2();
 
}



function dosizeSize_not() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

 var totalwidth = myWidth-233;
  var totalwidth2 = myWidth-258;




if (browser.isIE){
	$('content_logo2').style.marginTop = '50px';
}


if(myHeight > 606){
var footerHeight = myHeight-30;
} else {
var footerHeight = 606-30;
}
$('footer').style.top = footerHeight+'px';

if (browser.isFF == true){
	$('output').style.marginTop = '-460px';
}
buildScroll2();
 
}




function buildScroll2(){

	var size_container_Scroll_content = $('output_holder').getSize().y;
	
	var size_not_detail_texto = $('output').getSize().y;
	$('areaScroll2').setStyle('visibility','hidden');
	if ( size_container_Scroll_content > size_not_detail_texto ) {
										$('areaScroll2').setStyle('visibility','visible');
										myScrollFx = new Fx.Scroll('output', {
											wait: false
										});
										mySlide = new Slider($('areaScroll2'), $('knobScroll2'), {
											steps: size_container_Scroll_content-size_not_detail_texto,
											mode: 'vertical',
											onChange: function(step){
												$('output').scrollTo(0,step);
											}
										}).set(0);
									} else {
										$('areaScroll2').setStyle('visibility','hidden');
									}
	if ( size_container_Scroll_content > size_not_detail_texto ) {
		document.addEvent('mousewheel', function(e) {
			e = new Event(e).stop();
			var step = mySlide.step - e.wheel * 10;
			mySlide.set(step);
		
		});
}
}



function dosizeSize5() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

 var totalwidth = myWidth-233;
  var totalwidth2 = myWidth-258;
// $('menuspotter').style.width = totalwidth+'px';
// $('output_back').style.width = totalwidth2+'px';
// $('output_transparent').style.width = totalwidth+'px';

 if(myHeight > 606){
 	var footerHeight = myHeight-30;
 } else {
 	var footerHeight = 606-30;
 }
 $('footer').style.top = footerHeight+'px';
 

buildScroll2();
/*loadGoogleMap();*/
mapLoad();
}

function dosizeSize6() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

 var totalwidth = myWidth-233;
  var totalwidth2 = myWidth-258;
 $('menuspotter').style.width = totalwidth+'px';
 $('output_back').style.width = totalwidth2+'px';
 $('output_transparent').style.width = totalwidth+'px';

 if(myHeight > 606){
 	var footerHeight = myHeight-20;
 } else {
 	var footerHeight = 606-20;
 }
 $('footer').style.top = footerHeight+'px';
 

 
}
/*    function loadGoogleMap() {

      if (GBrowserIsCompatible()) {
		// cria mapa
		var map = new GMap2(document.getElementById("map"));
        map.setCenter(new GLatLng(38.720474,-9.160194), 14);
		map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
		//cria icon
		tinyIcon = new GIcon();
		tinyIcon.image = "http://mcmarkers.googlepages.com/iimm1-red.png";
		//tinyIcon.image = "/media/images/point.png";
		tinyIcon.shadow = "http://mcmarkers.googlepages.com/iimm1-shadow.png ";
		tinyIcon.iconSize = new GSize(32, 32);
		tinyIcon.shadowSize = new GSize(49, 32);
		tinyIcon.iconAnchor = new GPoint(15, 27);
		tinyIcon.infoWindowAnchor = new GPoint(16, 0);
		
		var htmlText = "<div><b>ASMARQ Lda</b><br/>Av. Infante Santo, nš 63 - r/c Esq.<br/>1350-177 Lisboa <br/></div>";
		var eqpoint = new GLatLng(38.720474,-9.160194);
		var marker=createMarker(eqpoint, htmlText, tinyIcon );
		map.addOverlay(marker);
		//map.openInfoWindow(htmlText);
        GEvent.trigger(marker, "click"); //comentar se n?o for para abrir qdo abre o mapa
		
//40.854888,-8.610342&spn=0.0028,0.004828&t=h&z=18
      }
    }
	
	function createMarker(spoint, text, icon) {
	  var marker = new GMarker(spoint, icon);
	  //marker.openInfoWindowHtml(text);
	  GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml(text);
	  });
	  
	 // marker.openInfoWindowHtml(text);
	  return marker;
	}
*/
	
	
function loadThisNews(id, div, urls){
	//$(div).innerHTML = '';
	$('areaScroll2').setStyle('visibility','hidden');
	$(div).innerHTML = '<div style="padding-top:100px; padding-left:230px;"><img src="/media/images/ajax_load.gif" border="0" /></div>';
	
	//PROTOTYPE
    /*var myAjax = new Ajax.Updater(myDiv,
                                 url,
                                 {
                                     method: 'get'
                                 }
                                 );
	*/
	
	//MOOTOOLS
	var myAjax = new Request.HTML({url:urls+id, method: 'get',  
						onSuccess: function(html) {
							$(div).set('text', '');
							//$('areaScroll2').setStyle('visibility','hidden');
							$(div).adopt(html);
							//buildScroll2();
						},
						onFailure: function() {
							$('result').set('text', 'ERRO..........');
						}
					}).send();

//buildScroll2().delay(600);
setTimeout("buildScroll2();",600);
//setTimeout("buildScroll2();",1000);

}

function showhideserv(id, titulo){
	if($('noticia_desc_'+id).style.display == 'none'){
		$('noticia_desc_'+id).style.display = 'block';
		$('noticia_titulo_'+id).innerHTML = '<span class="noticia_titulo"><span style="color:#0BA8DB;">-</span> '+titulo+'</span>';
	} else {
		$('noticia_desc_'+id).style.display = 'none';
		$('noticia_titulo_'+id).innerHTML = '<span class="noticia_titulo"><span style="color:#0BA8DB;">+</span> '+titulo+'</span>';
	}
setTimeout("buildScroll2();",600);
}


function verifyScreenRes(){
	
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

  var url = '/galeria/get_res/width/'+myWidth+'/height/'+myHeight+'/';
  var pars = '';
  var myAjax = new Ajax.Request(url,
	                            {
	                                method: 'get',
	                                onSuccess: function(transport) {
	                                  var result = transport.responseText;
	                                  
									  	if (result == 1){
										 //alert(result);
										 window.location.reload();
										}
	                                },
	                                 parameters: pars
	                            }
	                            );



}




function verifyScreenRes2(){
	
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

  var url = '/galeria/get_res/width/'+myWidth+'/height/'+myHeight+'/';




	//MOOTOOLS
	var myAjax = new Request({url:url, method: 'get',  
						onComplete: function(responseText) {
	                                  var result = responseText;
	                                  //alert(result);
									  	if (result == 1){
										 window.location.reload();
										}
						},
						onSuccess: function(responseText) {
	                                  var result = responseText;
	                                  //alert(result);
									  	if (result == 1){
										 window.location.reload();
										}
						},
						onFailure: function() {
							//$('result').set('text', 'ERRO..........');
						}
					}).send();
}

function openLightBox(url) {
	
	SWFDelegate(url,'600','600','');
	
}
function SWFDelegate(url,width,height,caption) {
   var objLink = document.createElement('a');
   objLink.setAttribute('href',url);
   objLink.setAttribute('rel','lightbox');
   objLink.setAttribute('title',caption);
   if(typeof width != 'undefined') {
      objLink.setAttribute('width',width);
   }
   if(typeof height != 'undefined') {
      objLink.setAttribute('height',height);
   }
   Lightbox.prototype.start(objLink);
}

