var myDomain = 'http://www.avui.cat'; var myMeteoEncoding = 'iso-8859-1'; var myMeteoBaseURL = 'http://www.avui.cat' + '/client/avui_cat/components/meteorologia/behaviour/'; function getMunicipis(idSelectComarques, idSelectMunicipis, indexComarcaSelect) { var idComarca = getSelectedValue(idSelectComarques, indexComarcaSelect); var myParams = 'comarca=' + idComarca; var myURL = myMeteoBaseURL + 'municipisByComarca.php'; var myAjax = new Ajax.Request( myURL, { method: 'get', encoding: myMeteoEncoding, parameters: myParams, onComplete: function(transport) { if (200 == transport.status) { changeMuncipiContent(transport.responseXML, idSelectMunicipis); } } }); } function changeMuncipiContent(xml, idSelectMunicipis) { var xmlDoc = xml.documentElement; var xmlOptions = xmlDoc.getElementsByTagName("option"); removeEverythingSelect(idSelectMunicipis); for (i=0; i< xmlOptions.length; i++) { var selectValue = xmlOptions[i].attributes[0].nodeValue; // id var selectText = xmlOptions[i].childNodes[0].nodeValue; //municipi addSelect(idSelectMunicipis, selectValue, selectText); } } function getSelectedValue(idSelect, indexSelect) { var mySelect = document.getElementById(idSelect); return mySelect.getElementsByTagName("option")[indexSelect].value; } function removeEverythingSelect(idSelect) { var mySelect = document.getElementById(idSelect); while (mySelect.length != 0) { for (i=0; i < mySelect.length; i++) { mySelect.remove(mySelect[i]); } } } function addSelect(idSelect, valueSelect, textSelect) { /* var option = new Element('option', { value: valueSelect }).update(textSelect); try { $(idSelect).add(option, null); } catch(ex) // IE { */ var IEoption = document.createElement('option'); IEoption.value = valueSelect; IEoption.text = textSelect; if (navigator.appName=="Microsoft Internet Explorer") document.getElementById(idSelect).add(IEoption); else $(idSelect).add(IEoption, null); //} } function getMeteoInfo(idSelectMunicipis, indexMunicipiSelect, urlXML, urlImages, idMeteoInfo) { var idMunicipi = getSelectedValue(idSelectMunicipis, indexMunicipiSelect); var myParams = 'municipi=' + idMunicipi + '&urlXML=' + urlXML + '&urlImages=' +urlImages; var myURL = myMeteoBaseURL + 'meteoInfo.php'; var myAjax = new Ajax.Request( myURL, { method: 'get', encoding: myMeteoEncoding, parameters: myParams, onComplete: function(transport) { if (200 == transport.status) { changeMeteoInfo(transport.responseText, idMeteoInfo); } } }); } function changeMeteoInfo(response, idMeteoInfo) { document.getElementById(idMeteoInfo).innerHTML = response; } function sendMeteoForm(idMeteoForm) { document.getElementById(idMeteoForm).submit(); }