
function request_object()
{
   try
   {
      return new ActiveXObject('Msxml2.XMLHTTP');
   }
   catch(e)
   {
      try
      {
         return new ActiveXObject('Microsoft.XMLHTTP');
      }
      catch(e)
      {
         return new XMLHttpRequest();
      }
   }
}

function call()
{
   if (request_var)
   {
      d=document;

      request_var.open("GET","../upload/config.txt",true);
      request_var.onreadystatechange=load;
      request_var.send(null);
   }
}

function weatherFeed()
{
   //if (request_var)
   //{
   //   d=document;

   //   request_var.open("GET","http://webcraft.co.uk/feed2js/feed2js.php?src=http://feeds.bbc.co.uk/weather/feeds/rss/5day/id/1809.xml&desc=-1",true);
   //   request_var.onreadystatechange=weatherHtml;
   //   request_var.send(null);
   //}
}

function weatherHtml()
{
   if (request_var.readyState==4)
   {
      var feed    =request_var.responseText;
      var leftPos =feed.indexOf("United Kingdom on ");
      var rightPos=feed.indexOf("BST'");

      if ((leftPos!=-1) && (rightPos!=-1))
      {
         feed=feed.substring(leftPos+18,rightPos+3);
         feed=feed.replace('.',',');

         var weatherArray=feed.split(',');

         var html;

         html+='<div><table width="97%"><tr><td>';
         html+='<table>';

         for (var i=0;i<weatherArray.length;i++)
         {
             var pos;

             pos=weatherArray[i].indexOf("Max Temp");
             if (pos>-1)
             {
                pos=weatherArray[i].indexOf("C");
                if (pos>-1)
                   weatherArray[i]=weatherArray[i].substring(0,pos-1)+'&#176;'+weatherArray[i].substring(pos);

                pos=weatherArray[i].indexOf("F");
                if (pos>-1)
                   weatherArray[i]=weatherArray[i].substring(0,pos-1)+'&#176;'+weatherArray[i].substring(pos);
             }

             pos=weatherArray[i].indexOf("Min Temp");
             if (pos>-1)
             {
                pos=weatherArray[i].indexOf("C");
                if (pos>-1)
                   weatherArray[i]=weatherArray[i].substring(0,pos-1)+'&#176;'+weatherArray[i].substring(pos);

                pos=weatherArray[i].indexOf("F");
                if (pos>-1)
                   weatherArray[i]=weatherArray[i].substring(0,pos-1)+'&#176;'+weatherArray[i].substring(pos);
             }



             html+='<tr><td class="pageLastChanged">'+weatherArray[i]+'</td></tr>';
         }

         html+='</table>'; 
         html+='</</td></tr></table></div>';

         document.getElementById('weatherDiv').innerHTML=html;
      }
   }
}
