/* Global variables */ var searchPrefix = "http://pesquisa.sapo.pt/sHP?channel=noticias&barra=noticias&t=&q=", selectedChartView = "day", commentNews, ajaxOpts, curmenu = null, mrecTag = null, mrecLoaded = false; /* Include some external stuff */ document.write(""); document.write(""); /* Common functions */ function l ( url ) { location.href = url; } function goHome ( ) { location.href = '/'; } function minWidth ( width ) { return this.width < width ? width : this.width; } function minHeight ( height ) { return this.height < height ? height : this.height; } function maxWidth ( width ) { return this.width > width ? width : this.width; } function maxHeight ( height ) { return this.height > height ? height : this.height; } function getAndShowFileOn ( url, elementId, onCompleteHandler ) { return new Ajax.Request ( url, { method: 'get', parameters: null, encoding: 'UTF-8', onComplete: function (response) { if ( elementId != null ) document.getElementById(elementId).innerHTML = response.responseText; if ( onCompleteHandler != null ) onCompleteHandler(response); } } ); } /* Search tabs */ // Swap a tab function searchTagSwap ( tab, noFocus ) { var prefixes = { "tabnot": "http://pesquisa.sapo.pt/sHP?channel=noticias&barra=noticias&t=&q=", "tabweb": "http://pesquisa.sapo.pt/search?st=&barra=resumo&q=", "tabimg": "http://pesquisa.sapo.pt/search?st=.pt&barra=imagens&q=", "tabprd": "http://pesquisa.sapo.pt/shopping?q=", "tablog": "http://pesquisa.sapo.pt/sHP?barra=blogs&q=", "tabpai": "http://pesquisa.sapo.cv/sHP?location=cv&channel=pai&barra=pai&t=&q=", "tabdir": "http://pesquisa.sapo.cv/search?barra=directorio&channel=directorio&location=cv&q=" }, lis = document.getElementsByTagName("li"), li; for ( tabName in prefixes ) { li = document.getElementById(tabName); if ( (li != null) && (tabName != tab) ) li.className = ""; } document.getElementById(tab).className = "active"; searchPrefix = prefixes[tab]; if ( !noFocus ) document.getElementById("q").focus(); } // Perform search function performSearch ( ) { var qTextbox = document.getElementById('q'); location.href = searchPrefix + qTextbox.value; return false; // Skip submit } // Initialize tabs function initTabs ( ) { // Defaults to tabnot searchTagSwap("tabnot",1); } /* Submenus */ function showpm ( el ) { var subel; for ( var x = 0 ; x < el.childNodes.length ; x++ ) if ( (subel = el.childNodes[x]).className == "popup" ) _showpm(el,subel); } function _showpm ( pel, el ) { pel.onmouseout = function(){_showpm(pel,null)} if ( curmenu ) curmenu.style.visibility = 'hidden'; if ( el ) { el.style.visibility = 'visible'; curmenu = el; } } /* Simulate a site interaction */ function siteInteraction ( affiliate ) { var mrec; // Identify MREC if ( ((mrec = document.getElementById('mrec')) == null) && ((mrec = document.getElementById('pub300x250')) == null) ) return true; if ( mrec.nodeName.toLowerCase() == 'div' ) mrec = (mrec.getElementsByTagName("IFRAME"))[0]; // Refresh MREC if ( mrec ) { window.mrecLoaded = false; if ( mrecTag == null ) mrecTag = mrec.src; if ( affiliate == null ) mrec.src = mrecTag; else mrec.src = mrecTag+"&affiliate="+affiliate; } // Hit Netscope if ( typeof(w_counter) != 'undefined' ) w_counter.count(); if ( typeof(nsAccounts) != 'undefined' ) { for ( var x = 0 ; x < nsAccounts.length ; x++ ) { if ( nsAccounts[x].obj ) nsAccounts[x].obj.count(); } } return true; } /* Show MREC */ function showMREC() { siteInteraction(); return setMRECVisibility('visible'); } function hideMREC() { return setMRECVisibility('hidden'); } function setMRECVisibility(value) { var mrec = null; // Identify MREC if ( ((mrec = document.getElementById('mrec')) == null) && ((mrec = document.getElementById('pub300x250')) == null) ) return true; // Set visibility mrec.style.visibility = value; } /* Evaluate anchor */ function evalAnchor() { var urlParts = location.href.split('#'); if ( urlParts.length > 1 ) location.href = "#"+urlParts[1]; } /* Newspapers functions */ function loadNewspapers ( ) { return getAndShowFileOn("/banca/__column_left.html","contentBancaLeft",evalAnchor) && getAndShowFileOn("/banca/__column_right.html","contentBancaRight"); } function np ( file, title ) { lw('/banca/'+file+'.html',(title?'Banca de Jornais > '+title:''),'lightwindow_width=670,lightwindow_height=490'); return false; } /* Local functions */ // Go to a specific municipality (called from flash) function gotoConcelho ( code ) { location.href = "/local/"+code+"/"; } // Select a municipality on the municipality widget function selectMun ( mun ) { var box; // Get municipality select box if ( (box = (document.getElementsByName('pickconcelho'))[0]) == null ) return; for ( var x = 0 ; box.options[x] ; x++ ) { if ( box.options[x].value == mun ) { box.options[x].selected = true; break; } } } // Get municipality widget function showMunList ( selectmun ) { var widget = document.getElementById('boxConcelho'), commands = locChildWithClass(widget,'commands_sapo') || locChildWithClass(widget,'commands'), widDiv = locChildWithClass(widget,'formlocal'), list; widDiv.id = "concelho_formlocal"; // Show municipalities on list getAndShowFileOn("/xml/municipalities.html",'concelho_formlocal',function() { if(selectmun) selectMun(selectmun); commands.style.display = "none"; widDiv.style.display = "block"; } ); } // Hide municipalitites list function hideMunList ( ) { var widget = document.getElementById('boxConcelho'), commands = locChildWithClass(widget,'commands_sapo') || locChildWithClass(widget,'commands'), widDiv = locChildWithClass(widget,'formlocal'); widDiv.innerHTML = ""; commands.style.display = "block"; widDiv.style.display = "none"; } // Set municipality function setMunicipality ( ) { var obj = (document.getElementsByName("pickconcelho"))[0]; if ( obj == null ) return null; location.href = '/local/'+obj.value+'/'; } /* Weather functions */ function _showWeatherLocals ( code ) { var widget = document.getElementById('boxWeather'), widDiv = locChildWithClass(widget,'footer'); widDiv.innerHTML = code; } function showWeatherLocals ( ) { return getMunicipalities(_showWeatherLocals); } /* Reuters quotes */ // Change quote view function chQuoteView ( quote, type ) { var curChart = document.getElementById(selectedChartView+'Chart'), newChart = document.getElementById(type+'Chart'), curChartSel = document.getElementById(selectedChartView+'ChartSel'), newChartSel = document.getElementById(type+'ChartSel'); if ( curChart == null || newChart == null ) return; curChart.style.display = "none"; newChart.style.display = "block"; curChartSel.className = ""; newChartSel.className = "active"; selectedChartView = type; } /* Newsletter */ // Subscribe newsletter function subscribeNL ( ) { var addrBox = (document.getElementsByName("mailaddress"))[0], widDiv = locParWithClass(addrBox,"snBoxContent"), synd = new SAPO.Communication.Syndication(), nlSubId; // Subscribe to newsletter via syndication nlSubId = synd.push('/xml/newsletter.html?addr='+addrBox.value, { timeout: 10, onComplete: function (nl,widDiv) { if ( nl.result == 'ok' ) widDiv.innerHTML = "
Obrigado por ter subscrito a nossa newsletter.
"; else document.getElementById('nlerror').innerHTML = "Erro: "+nl.message+"."; }, optOnComplete: widDiv, onTimeout: function (widDiv) { document.getElementById('nlerror').innerHTML = "Erro: O pedido excedeu o tempo."; }, optOnTimeout: widDiv } ); synd.run(nlSubId); } /* Initialize site */ function init () { // Tabs initTabs(); // Correct PNG's for IE if ( browser.isIE() ) correctPNG(); } /* Include some external stuff */ document.write(""); document.write(""); document.write(""); document.write(""); document.write(""); document.write(""); document.write(""); document.write(""); document.write(""); document.write(""); document.write(""); document.write(""); document.write(""); document.write("");