var name = "weather"
var proxy = 'http://app.drk7.jp/xml2json/';

function post(){
var day = $F("days");
var city = $F("areas");
var element = $("resultw");
while(element.hasChildNodes()){
var firstChild = element.firstChild;
element.removeChild(firstChild);
}
var url = proxy + 'var=' + name + '&url=' + escape('http://weather.livedoor.com/forecast/webservice/rest/v1?city=' + city + '&day=' + day); 
var scriptEl = document.createElement("script");
scriptEl.setAttribute('type', 'text/javascript');
scriptEl.setAttribute('src', url);
scriptEl.setAttribute('charset', 'utf-8');
$$('head')[0].appendChild(scriptEl);
}

var weather = {};
weather.onload = function(data){
var whbox = $("resultw");
var whtexta = $("text-area");
var whtexts = $("text-wh");
var whtextt = $("text-tp");
var whdisc = $("discription");
var copys = $("copyright");
var aream = data.location.pref;
var areas = data.location.city;
var telops = data.telop;
var discs = data.description;
var copy = data.copyright.title;
replace(copys, copy);
replace(whdisc, discs);
var tempsmax = data.temperature.max.celsius;
var tempsmin = data.temperature.min.celsius;
if((tempsmax<60) && (tempsmin<60)){
whtextt.innerHTML = '<font color=#cc0000>' + tempsmax + '</font>' + '/' + tempsmin;
}else if((tempsmax<60) && !(tempsmin<60)){
whtextt.innerHTML = '<font color=#cc0000>' + tempsmax + '</font>' + '/--';
}else if(!(tempsmax<60) && (tempsmin<60)){
whtextt.innerHTML = '<font color=#cc0000>--</font>' + '/' + tempsmin;
}else{
whtextt.innerHTML = '<font color=#cc0000>--</font>/--';
}
var images = data.image.url;
var imagttl = data.image.title;
var whall = aream + ' ' +areas;
replace(whtexta, whall);
replace(whtexts, telops);
var whico = document.createElement("img");
whico.setAttribute('src', images);
whico.setAttribute('title', imagttl);
whbox.appendChild(whico);

}



function replace(el, text){
if(el != null){
clearText(el);
var newNode = document.createTextNode(text);
el.appendChild(newNode);
}
}

function clearText(el){
if(el != null){
for(i=0; i<el.childNodes.length; i++){
var childNode = el.childNodes[i];
el.removeChild(childNode);
}
}
}
