
function show(name) {
  el=document.getElementById(name);
  el.style.display='block';
}

function hide(name) {
  el=document.getElementById(name);
  el.style.display='none';
}

var http = false;

if(navigator.appName == "Microsoft Internet Explorer") {
  http = new ActiveXObject("Microsoft.XMLHTTP");
} else {
  http = new XMLHttpRequest();
}

function changeCity(name) {
  http.abort();



  http.open("GET", "/main/name/" + name + "/rightcol/changecity.html", true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {

      tab=http.responseText.split('^#');
      document.getElementById('Wspeed').innerHTML = tab[0];
      document.getElementById('Wdirection').innerHTML = tab[1];
      document.getElementById('Wpressure').innerHTML = tab[2];
      document.getElementById('WtodLow').innerHTML = tab[3];
      document.getElementById('WtodHigh').innerHTML = tab[4];
      document.getElementById('WtomLow').innerHTML = tab[5];
      document.getElementById('WtomHigh').innerHTML = tab[6];
      document.getElementById('Wcity').innerHTML ='<a class href="http://www.tawernaskipperow.pl/main/plocID/'+tab[8]+'/bylismy/index.html" style="text-decoration: underline">'+tab[7]+'</a> ';
      document.getElementById('WtodCode').src = "http://l.yimg.com/a/i/us/nws/weather/gr/"+ tab[9] +"s.png";
     
      document.getElementById('WtomCode').src = "http://l.yimg.com/a/i/us/nws/weather/gr/"+tab[10].replace(/\t\r\n/g, '')+"s.png";

    }
  }
  http.send(null);
}

function changeCountry(user,country) {
  http.abort();


  http.open("GET", "/main/country/" + user + "/rightcol/changecity.html", true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      document.getElementById('chosenCountry').innerHTML=country;
      document.getElementById('countries').innerHTML=http.responseText;
      document.getElementById('Wbuttons').innerHTML='<input type="button" class="submit" value="Powrót do listy krajów" onclick="getCountries();">';
    }
  }
  http.send(null);
}

function getCountries() {
  http.abort();


  http.open("GET", "/main/rightcol/changecity.html", true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      document.getElementById('chosenCountry').innerHTML="Wybierz kraj";
      document.getElementById('countries').innerHTML=http.responseText;
      document.getElementById('Wbuttons').innerHTML='';
    }
  }
  http.send(null);
}


function updateField(name) {
  val=document.getElementsByName(name)[0].value;
  obj=document.getElementsByName('title' + name.substr(8))[0];
  obj.value=val;
}
