var flashcolor = '#000000'; 
var flashtime  = 2000;       
var reloadTime = 5000;       
var maxupdates = 0;	         
                             
var clientrawFile = '/clientraw.txt'; 
var ajaxLoaderInBody = false; 
var imagedir = './ajax-images';  
var useunits = 'M';         
var useKnots = false;        
							
var useMPS   = true;       
var useMPH   = false;       
var useFeet  = false;       
var showUnits = true;       
var thermometer = './thermometer.php'; 
var wrName   = 'wr-';       
var wrType   = '.png';      
var wrHeight = '58';        
var wrWidth  = '58';        
var wrCalm   = 'wr-calm.png';  
var langPauseMsg = 'Updates paused - reload page to start'; 
                             
var langMonths = new Array ( "January","February","March","April","May",
			"June","July","August","September","October","November","December");
var langDays = new Array ( "Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sun");	
var langBaroTrend = new Array (
 "Steady", "Rising Slowly", "Rising Rapidly", "Falling Slowly", "Falling Rapidly");
var langUVWords = new Array (
 "None", "Low", "Medium", "High",
 "Very&nbsp;High", 
 "Extreme" );
var langBeaufort = new Array ( 
 "Calm", "Light air", "Light breeze", "Gentle breeze", "Moderate breeze", "Fresh breeze",
 "Strong breeze", "Near gale", "Gale", "Strong gale", "Storm",
 "Violent storm", "Hurricane"
);
var langWindDir = new Array( 
	"N", "NNE", "NE", "ENE", 
	"E", "ESE", "SE", "SSE", 
	"S", "SSW", "SW", "WSW", 
	"W", "WNW", "NW", "NNW");
var langWindCalm = 'Calm';
var langGustNone = 'None';
var langWindFrom = 'Wind from '; 
var langBaroRising = 'Rising %s '; 
var langBaroFalling = 'Falling %s ';
var langBaroPerHour = '/hour.'; 
var langThermoCurrently = 'Currently: '; 
var langThermoMax     = 'Max: ';
var langThermoMin     = 'Min: ';
var langTempRising = 'Warmer %s '; 
var langTempFalling = 'Colder %s ';
var langTempLastHour = ' than last hour.';
var langTransLookup = new Object;
var langHeatWords = new Array (
 'Unknown', 'Extreme Heat Danger', 'Heat Danger', 'Extreme Heat Caution', 'Extremely Hot', 'Uncomfortably Hot',
 'Hot', 'Warm', 'Comfortable', 'Cool', 'Cold', 'Uncomfortably Cold', 'Very Cold', 'Extreme Cold' );
var ie4=document.all;
var browser = navigator.appName;
var counterSecs = 0;  
var updates = 0;		
var lastajaxtimeformat = 'unknown'; 
var doTooltip = 0;   
var uomTemp = '&deg;F';
var uomWind = ' mph';
var uomBaro = ' inHg';
var uomRain = ' in';
var uomHeight = ' ft';
var dpBaro = 2;
var dpRain = 2;
function ajax_set_units( units ) {
  useunits = units;
  if (useunits != 'E') { 
	uomTemp = '&deg;C';
	uomWind = ' km/h';
	uomBaro = ' hPa';
	uomRain = ' mm';
	uomHeight = ' m';
	dpBaro = 1;
	dpRain = 1;
  }
  if(useKnots) { uomWind = ' kts'; }
  if(useMPS)   { uomWind = ' m/s'; }
  if(useMPH)   { uomWind = ' mph'; }
  if(useFeet)  { uomHeight = ' ft'; }
  if (! showUnits) {
	uomTemp = '';
	uomWind = '';
	uomBaro = '';
	uomRain = '';
	uomHeight = '';
  }
}
ajax_set_units(useunits);
function get_ajax_tags ( ) {
  if (ie4 && browser != "Opera") {
    var elem = document.body.getElementsByTagName('span');
	var lookfor = 'className';
  } else {
    var elem = document.getElementsByTagName('span');
	var lookfor = 'class';
  }
     var arr = new Array();
	 var iarr = 0;
     for(var i = 0; i < elem.length; i++) {
          var att = elem[i].getAttribute(lookfor);
          if(att == 'ajax') {
               arr[iarr] = elem[i];
               iarr++;
          }
     }

     return arr;
}
function reset_ajax_color( usecolor ) {

      var elements = get_ajax_tags();
	  var numelements = elements.length;
	  for (var index=0;index!=numelements;index++) {
         var element = elements[index];
	     element.style.color=usecolor;
 
      }
}
function set_ajax_obs( name, value ) {


		var element = document.getElementById(name);
		if (! element ) { return; } 
		var lastobs = element.getAttribute("lastobs");
		element.setAttribute("lastobs",value);
		if (value != unescape(lastobs)) {
          element.style.color=flashcolor;
		  if ( doTooltip ) { element.setAttribute("title",'AJAX tag '+name); }
		  element.innerHTML =  value; 
		}
}
function set_ajax_uom( name, onoroff ) {


		var element = document.getElementById(name);
		if (! element ) { return; } 
		if (onoroff) {
          element.style.display='inline';
		} else {
          element.style.display='none';
		}
}
function windDir ($winddir)
{
   $windlabel = new Array("N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW");
   return $windlabel[Math.floor(((parseInt($winddir) + 11) / 22.5) % 16 )];
}
function windDirLang ($winddir)
{
   return langWindDir[Math.floor(((parseInt($winddir) + 11) / 22.5) % 16 )];
}
function ajax_wxIcon ( iconWD ) { 
  $iconList = new Array(
	"day_clear.gif",           
	"night_clear.gif",         
	"day_partly_cloudy.gif",   
	"day_partly_cloudy.gif",   
	"night_partly_cloudy.gif", 
	"day_clear.gif",           
	"fog.gif",                 
	"haze.gif",                
	"day_heavy_rain.gif",      
	"day_mostly_sunny.gif",    
	"mist.gif",                
	"fog.gif",                 
	"night_heavy_rain.gif",    
	"night_cloudy.gif",        
	"night_rain.gif",          
	"night_light_rain.gif",    
	"night_snow.gif",          
	"night_tstorm.gif",        
	"day_cloudy.gif",          
	"day_partly_cloudy.gif",   
	"day_rain.gif",            
	"day_rain.gif",            
	"day_light_rain.gif",     
	"day_sleet.gif",           
	"day_sleet.gif",           
	"day_snow.gif",            
	"day_snow.gif",            
	"day_snow.gif",            
	"day_clear.gif",           
	"day_tstorm.gif",         
	"day_tstorm.gif",          
	"day_tstorm.gif",          
	"tornado.gif",             
	"windy.gif",               
	"day_partly_cloudy.gif",   
	"windyrain.gif"            
	);					
  if (iconWD >= 0 && iconWD <= 35) { 
    return ("<img src=\"" + imagedir + "/" + $iconList[iconWD] + "\" " +
				"width=\"25\" height=\"25\" alt=\"Current condition icon\" />" );
  } else {
	return '';
  }

}
function ajax_wxIconGIF ( iconWD ) { 
  $iconList = new Array(
	"skc.GIF",          
	"nskc.GIF",         
	"bkn.GIF",          
	"sct.GIF",          
	"nbkn.GIF",         
	"sct.GIF",          
	"fg.GIF",           
	"hazy.GIF",         
	"ra.GIF",           
	"few.GIF",          
	"mist.GIF",         
	"nfg.GIF",          
	"nra.GIF",          
	"novc.GIF",         
	"nra.GIF",          
	"nshra.GIF",        
	"nsn.GIF",          
	"ntsra.GIF",        
	"ovc.GIF",          
	"sct.GIF",          
	"ra.GIF",           
	"ra.GIF",           
	"shra.GIF",         
	"ip.GIF",           
	"ip.GIF",           
	"sn.GIF",           
	"sn.GIF",          
	"sn.GIF",           
	"skc.GIF",          
	"scttsra.GIF",      
	"hi_tsra.GIF",      
	"tsra.GIF",         
	"nsvrtsra.GIF",     
	"wind.GIF",         
	"ra1.GIF",          
	"windyrain.GIF"     
	);					
  if (iconWD >= 0 && iconWD <= 35) { 
    return ("<img src=\"" + imagedir + "/" + $iconList[iconWD] + "\" " +
				"width=\"55\" height=\"58\" alt=\"Current condition icon\" />" );
  } else {
	return '';
  }

}
function convertTemp ( rawtemp ) {
	if (useunits == 'E') { 
		return( (1.8 * rawtemp) + 32.0);
	} else {  
		return (rawtemp * 1.0);
	}
}
function convertWind  ( rawwind ) {
	if (useKnots) { return(rawwind * 1.0); } 
	if (useunits == 'E' || useMPH ) { 
		return(rawwind * 1.1507794);
	} else {  
	    if (useMPS) { 
		  return (rawwind * 0.514444444);
		} else { 
		  return (rawwind * 1.852);
		}
	}
}
function convertBaro ( rawpress ) {
	if (useunits == 'E') { 
	   return (rawpress  / 33.86388158);
	} else {
	   return (rawpress * 1.0); 
	}
}
function convertRain ( rawrain ) {
	if (useunits == 'E') { 
	   return (rawrain * .0393700787);
	} else {
	   return (rawrain * 1.0); 
	}
}
function convertHeight ( rawheight ) {
	if (useunits == 'E' || useFeet ) { 
	   return (Math.round(rawheight * 1.0).toFixed(0)); 
	} else {
	   return (Math.round(rawheight / 3.2808399).toFixed(0));
	}
}
function ajax_get_beaufort_number ( wind ) { 
  if (wind < 1 ) {return("0"); }
  if (wind < 4 ) {return("1"); }
  if (wind < 7 ) {return("2"); }
  if (wind < 11 ) {return("3"); }
  if (wind < 17 ) {return("4"); }
  if (wind < 22 ) {return("5"); }
  if (wind < 28 ) {return("6"); }
  if (wind < 34 ) {return("7"); }
  if (wind < 41 ) {return("8"); }
  if (wind < 48 ) {return("9"); }
  if (wind < 56 ) {return("10"); }
  if (wind < 64 ) {return("11"); }
  if (wind >= 64 ) {return("12"); }
  return("0");
}
function ajax_get_barotrend(btrnd) {
   if ((btrnd >= -0.7) && (btrnd <= 0.7)) { return(langBaroTrend[0]); }
   if ((btrnd > 0.7) && (btrnd < 2.0)) { return(langBaroTrend[1]); }
   if (btrnd >= 2.0) { return(langBaroTrend[2]); }
   if ((btrnd < -0.7) && (btrnd > -2.0)) { return(langBaroTrend[3]); }
   if (btrnd <= -2.0) { return(langBaroTrend[4]); }
  return(btrnd);
}
function ajax_getUVrange ( uv ) { 
   var uvword = "Unspec.";
   if (uv <= 0) {
       uvword = langUVWords[0];
   } else if (uv < 3) {
       uvword = "<span style=\"border: solid 1px; color: black; background-color: #A4CE6a;\">&nbsp;"+langUVWords[1]+"&nbsp;</span>";
   } else if (uv < 6) {
       uvword = "<span style=\"border: solid 1px; color: black; background-color: #FBEE09;\">&nbsp;"+langUVWords[2]+"&nbsp;</span>";
   } else if (uv < 8) {
       uvword =  "<span style=\"border: solid 1px; color: black; background-color: #FD9125;\">&nbsp;"+langUVWords[3]+"&nbsp;</span>";
   } else if (uv < 11) {
       uvword =  "<span style=\"border: solid 1px; color: #FFFFFF; background-color: #F63F37;\">&nbsp;"+langUVWords[4]+"&nbsp;</span>";
   } else {
       uvword =  "<span style=\"border: solid 1px; color: #FFFF00; background-color: #807780;\">&nbsp;"+langUVWords[5]+"&nbsp;</span>";
   }
   return uvword;
} 
function ajax_genarrow( nowTemp, yesterTemp, Legend, textUP, textDN, numDp) {	
  var diff = nowTemp.toFixed(3) - yesterTemp.toFixed(3);
  var absDiff = Math.abs(diff);
  var diffStr = '' + diff.toFixed(numDp);  
  var absDiffStr = '' + absDiff.toFixed(numDp); 
  var image = '';
  var msg = '';
  
  if (diff == 0) {
 
    image = '&nbsp;'; 
  } else if (diff > 0) { 
	msg = textUP.replace(/\%s/,absDiffStr);
    image = "<img src=\"" + imagedir + "/rising.gif\" alt=\"" + msg + 
	"\" title=\""+ msg + 
	"\" width=\"7\" height=\"8\" style=\"border: 0; margin: 1px 3px;\" />";
  } else {
    msg = textDN.replace(/\%s/,absDiffStr);  
    image = "<img src=\"" + imagedir + "/falling.gif\" alt=\"" + msg + 
	"\" title=\""+ msg + 
	"\" width=\"7\" height=\"8\" style=\"border: 0; margin: 1px 3px;\" />";  
  }
   if (Legend) {
       return (diff + Legend + image);
	} else {
	   return image;
	}
}  
function heatColor(temp,WindChill,Humidex) {
  var hcWord = langHeatWords[0];
 if (temp > 32 && Humidex > 29) {
  if (Humidex > 54) { return ('<span style="border: solid 1px; color: white; background-color: #BA1928;">&nbsp;'+langHeatWords[1]+'&nbsp;</span>'); }
  if (Humidex > 45) { return ('<span style="border: solid 1px; color: white; background-color: #E02538;">&nbsp;'+langHeatWords[2]+'&nbsp;</span>'); }
  if (Humidex > 39) { return ('<span style="border: solid 1px; color: black; background-color: #E178A1;">&nbsp;'+langHeatWords[4]+'&nbsp;</span>'); }
  if (Humidex > 29) { return ('<span style="border: solid 1px; color: white; background-color: #CC6633;">&nbsp;'+langHeatWords[6]+'&nbsp;</span>'); }
 } else if (WindChill < 16 ) {
  if (WindChill < -26) { return ('<span style="border: solid 1px; color: black; background-color: #91ACFF;">&nbsp;'+langHeatWords[13]+'&nbsp;</span>'); }
  if (WindChill < -18)  { return ('<span style="border: solid 1px; color: white; background-color: #806AF9;">&nbsp;'+langHeatWords[12]+'&nbsp;</span>'); }
  if (WindChill < -10)  { return ('<span style="border: solid 1px; color: white; background-color: #3366FF;">&nbsp;'+langHeatWords[11]+'&nbsp;</span>'); }
  if (WindChill < 0)   { return ('<span style="border: solid 1px; color: white; background-color: #6699FF;">&nbsp;'+langHeatWords[10]+'&nbsp;</span>'); }
  if (WindChill < 10)  { return ('<span style="border: solid 1px; color: black; background-color: #89B2EA;">&nbsp;'+langHeatWords[9]+'&nbsp;</span>'); }
 }  else if (WindChill >= 16 && temp <= 32) {
  if (temp < 26) { return ('<span style="border: solid 1px; color: black; background-color: #C6EF8C;">&nbsp;'+langHeatWords[8]+'&nbsp;</span>'); }
  if (temp <= 32) { return ('<span style="border: solid 1px; color: black; background-color: #CC9933;">&nbsp;'+langHeatWords[7]+'&nbsp;</span>'); }
  }
  return hcWord;
}
function ajax_countup() {
 var element = document.getElementById("ajaxcounter");
 if (element) {
  element.innerHTML = counterSecs;
  counterSecs++;
 }
}
function ucFirst ( str ) {
   return str.substr(0,1).toUpperCase() + str.substr(1,str.length);
}
function ajaxFixupCondition( rawcond ) {
  var cond = rawcond;
  cond = cond.replace(/_/gm,' ');  
  cond = cond.replace(/[\r\n]/gm,'');  
  var conds = cond.split('/');  
  var tstr = '';
  for (var i = 0;i<conds.length;i++) {
    var t = conds[i];
	t = t.toLowerCase();
	t = ucFirst(t);
    t = t.replace(/\s+$/,'');  
	if(langTransLookup[t]) { 
	  conds[i] = langTransLookup[t];
	} else {
	  conds[i] = t;
	}
  }
  if (conds[0].length == 0) { conds.splice(0,1);  } 
  if (conds[0] == conds[2]) { conds.splice(2,1); }   
  return(conds.join(', '));


}
function ajaxLoader(url) {
  if (document.getElementById) {
    var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(url);
  }
  if (x) { 
    x.onreadystatechange = function() {
    try { if (x.readyState == 4 && x.status == 200) {  
    var clientraw = x.responseText.split(' ');	
	var wdpattern=/\d+\.\d+.*!!/;  
		if(clientraw[0] == '12345' && wdpattern.test(x.responseText) && 
	    ( updates <= maxupdates || maxupdates > 0  ) ) {
		if (maxupdates > 0 ) {updates++; } 

		
		temp = convertTemp(clientraw[4]);
		set_ajax_obs("ajaxtemp", temp.toFixed(1) + uomTemp);
		set_ajax_obs("ajaxtempNoU", temp.toFixed(1));
		set_ajax_obs("gizmotemp", temp.toFixed(1) + uomTemp);
		set_ajax_obs("ajaxbigtemp",temp.toFixed(0) + uomTemp);

		templast = convertTemp(clientraw[90]);
		temparrow = ajax_genarrow(temp, templast, '', 
			 langTempRising+uomTemp+langTempLastHour,
			 langTempFalling+uomTemp+langTempLastHour,1)
		
		set_ajax_obs("ajaxtemparrow",temparrow); 
		set_ajax_obs("gizmotemparrow",temparrow); 
		   
	    temprate = temp - templast;
		temprate = temprate.toFixed(1);
		if (temprate > 0.0) { temprate = '+' + temprate;} // add '+' for positive rates
		set_ajax_obs("ajaxtemprate",temprate + uomTemp);
		set_ajax_obs("gizmotemprate",temprate + uomTemp);

		tempmax = convertTemp(clientraw[46]);
		set_ajax_obs("ajaxtempmax",tempmax.toFixed(1) + uomTemp);

		tempmin = convertTemp(clientraw[47]);
		set_ajax_obs("ajaxtempmin",tempmin.toFixed(1) + uomTemp);
		
		thermometerstr = langThermoCurrently +  + temp.toFixed(1) + uomTemp + 
		  ", " + langThermoMax + tempmax.toFixed(1) + uomTemp +
		  ", " + langThermoMin + tempmin.toFixed(1) + uomTemp;

		set_ajax_obs("ajaxthermometer",
			"<img src=\"" + thermometer + "?t=" + temp.toFixed(1) + "\" " +
				"width=\"54\" height=\"170\" " +
				"alt=\"" + thermometerstr + "\" " +
				"title=\"" + thermometerstr + "\" />" );

		
		humidity = clientraw[5];
		set_ajax_obs("ajaxhumidity",humidity);
		set_ajax_obs("gizmohumidity",humidity);
		
		
		
		dew = convertTemp(clientraw[72]);
		set_ajax_obs("ajaxdew",dew.toFixed(1) + uomTemp);
		set_ajax_obs("gizmodew",dew.toFixed(1) + uomTemp);
		dewmin = convertTemp(clientraw[139]);
		set_ajax_obs("ajaxdewmin",dewmin.toFixed(1) + uomTemp);
		dewmax = convertTemp(clientraw[138]);
		set_ajax_obs("ajaxdewmax",dewmax.toFixed(1) + uomTemp);

		
		humidex = convertTemp(clientraw[45]);
		set_ajax_obs("ajaxhumidex",humidex.toFixed(1) + uomTemp);
		humidexmin = convertTemp(clientraw[76]);
		set_ajax_obs("ajaxhumidexmin",humidexmin.toFixed(1) + uomTemp);
		humidexmax = convertTemp(clientraw[75]);
		set_ajax_obs("ajaxhumidexmax",humidexmax.toFixed(1) + uomTemp);

		
		windchill = convertTemp(clientraw[44]);
		set_ajax_obs("ajaxwindchill",windchill.toFixed(1) + uomTemp);
		windchillmin = convertTemp(clientraw[78]);
		set_ajax_obs("ajaxwindchillmin",windchillmin.toFixed(1) + uomTemp);
		windchillmax = convertTemp(clientraw[77]);
		set_ajax_obs("ajaxwindchillmax",windchillmax.toFixed(1) + uomTemp);

		
		heatidx = convertTemp(clientraw[112]);
		set_ajax_obs("ajaxheatidx",heatidx.toFixed(1) + uomTemp);
		heatidxmin = convertTemp(clientraw[111]);
		set_ajax_obs("ajaxheatidxmin",heatidxmin.toFixed(1) + uomTemp);
		heatidxmax = convertTemp(clientraw[110]);
		set_ajax_obs("ajaxheatidxmax",heatidxmax.toFixed(1) + uomTemp);

		
		temp = clientraw[4]; 
        if (temp <= 16.0 ) {
		  feelslike = clientraw[44]; 
		} else if (temp >=27.0) {
		  feelslike = clientraw[45]; 
		} else {
		  feelslike = temp;   
		}
		feelslike  = Math.round(convertTemp(feelslike));
        set_ajax_obs("ajaxfeelslike",feelslike + uomTemp);

		
		var heatColorWord = heatColor(clientraw[4],clientraw[44],clientraw[45]);
		set_ajax_obs("ajaxheatcolorword",heatColorWord);
		
		
		apparenttemp = convertTemp(clientraw[130]);
		set_ajax_obs("ajaxapparenttemp",apparenttemp.toFixed(1) + uomTemp);
		apparenttempmin = convertTemp(clientraw[136]);
		set_ajax_obs("ajaxapparenttempmin",apparenttempmin.toFixed(1) + uomTemp);
		apparenttempmax = convertTemp(clientraw[137]);
		set_ajax_obs("ajaxapparenttempmax",apparenttempmax.toFixed(1) + uomTemp);
		
		
		pressure = convertBaro(clientraw[6]);
		set_ajax_obs("ajaxbaro",pressure.toFixed(dpBaro) + uomBaro);
		set_ajax_obs("ajaxbaroNoU",pressure.toFixed(dpBaro));
		set_ajax_obs("gizmobaro",pressure.toFixed(dpBaro) + uomBaro);
		pressuretrend = convertBaro(clientraw[50]);
		pressuretrend = pressuretrend.toFixed(dpBaro+1);
		if (pressuretrend > 0.0) {pressuretrend = '+' + pressuretrend; } 
		set_ajax_obs("ajaxbarotrend",pressuretrend + uomBaro);
		set_ajax_obs("gizmobarotrend",pressuretrend + uomBaro);
		set_ajax_obs("ajaxbaroarrow",
		   ajax_genarrow(pressure, pressure-pressuretrend, '', 
			 langBaroRising+uomBaro+langBaroPerHour,
			 langBaroFalling+uomBaro+langBaroPerHour,2)
			 );	
		barotrendtext = ajax_get_barotrend(clientraw[50]);
		set_ajax_obs("ajaxbarotrendtext",barotrendtext);
		set_ajax_obs("gizmobarotrendtext",barotrendtext);

		pressuremin = convertBaro(clientraw[132]);
		set_ajax_obs("ajaxbaromin",pressuremin.toFixed(dpBaro) + uomBaro);
		pressuremax = convertBaro(clientraw[131]);
		set_ajax_obs("ajaxbaromax",pressuremax.toFixed(dpBaro) + uomBaro);

        
		gust    = convertWind(clientraw[140]);
		maxgust = convertWind(clientraw[71]);
		if (maxgust > 0.0 ) {
		  set_ajax_obs("ajaxmaxgust",maxgust.toFixed(1) + uomWind);
		} else {
		  set_ajax_obs("ajaxmaxgust",'None');
		}

		
		wind = convertWind(clientraw[2]);
		beaufortnum = ajax_get_beaufort_number(clientraw[2]);
		set_ajax_obs("ajaxbeaufortnum",beaufortnum);
		set_ajax_obs("ajaxbeaufort",langBeaufort[beaufortnum]);

       
        val = windDir(clientraw[3]);
		valLang = windDirLang(clientraw[3]); /* to enable translations */

       if (wind > 0.0) {
		set_ajax_obs("ajaxwind",wind.toFixed(1) + uomWind);
		set_ajax_obs("ajaxwindNoU",wind.toFixed(1));
		set_ajax_obs("gizmowind",wind.toFixed(1) + uomWind);
		set_ajax_uom("ajaxwinduom",true);
	   } else {
		set_ajax_obs("ajaxwind",langWindCalm);
		set_ajax_obs("ajaxwindNoU",langWindCalm);
		set_ajax_obs("gizmowind",langWindCalm);
		set_ajax_uom("ajaxwinduom",false);
	   }
	   
	   if (gust > 0.0) {
		set_ajax_obs("ajaxgust",gust.toFixed(1) + uomWind);
		set_ajax_obs("ajaxgustNoU",gust.toFixed(1));
		set_ajax_obs("gizmogust",gust.toFixed(1) + uomWind);
		set_ajax_uom("ajaxgustuom",true);
	   } else {
		set_ajax_obs("ajaxgust",langGustNone);
		set_ajax_obs("ajaxgustNoU",langGustNone);
		set_ajax_obs("gizmogust",langGustNone);
		set_ajax_uom("ajaxgustuom",false);
	   }
	   
   	   if (gust > 0.0 || wind > 0.0) {
		windicon = 	"<img src=\"" + imagedir + "/" +  val + ".gif\" width=\"14\" height=\"14\" alt=\"" + 
		  langWindFrom + valLang + "\" title=\"" + langWindFrom + valLang + "\" /> ";
 		set_ajax_obs("ajaxwindicon",windicon);
		set_ajax_obs("gizmowindicon",windicon);
 		set_ajax_obs("ajaxwindiconwr",
		  "<img src=\"" + imagedir + "/" +wrName +  val + wrType + "\" width=\""+
		   wrWidth+"\" height=\""+wrHeight+"\" alt=\"" + 
		  langWindFrom + valLang + "\" title=\"" +langWindFrom + valLang + "\" /> ");
		set_ajax_obs("ajaxwinddir",valLang);
		set_ajax_obs("gizmowinddir",valLang);
	   } else {
 		set_ajax_obs("ajaxwindicon","");
 		set_ajax_obs("gizmowindicon","");
		set_ajax_obs("ajaxwinddir","");
		set_ajax_obs("gizmowinddir","");
		if (wrCalm != '') {
 		 set_ajax_obs("ajaxwindiconwr",
		  "<img src=\"" + imagedir + "/" + wrCalm + "\" width=\""+
		   wrWidth+"\" height=\""+wrHeight+"\" alt=\"" + 
		  langBeaufort[0] + "\" title=\"" +langBeaufort[0] + "\" /> ");
		}
	   }

		windmaxavg = convertWind(clientraw[113]);
		set_ajax_obs("ajaxwindmaxavg",windmaxavg.toFixed(1) + uomWind);
		
		windmaxgust = convertWind(clientraw[71]);
		set_ajax_obs("ajaxwindmaxgust",windmaxgust.toFixed(1) + uomWind);

		windmaxgusttime = clientraw[135];
		windmaxgusttime = windmaxgusttime.toLowerCase();
		windmaxgusttime = windmaxgusttime.replace( "_" , "");
		set_ajax_obs("ajaxwindmaxgusttime",windmaxgusttime);
		

		
		solar    = clientraw[127] * 1.0;
		set_ajax_obs("ajaxsolar",solar.toFixed(0));

        solarpct = clientraw[34];
		set_ajax_obs("ajaxsolarpct",solarpct);
		
			
		uv       = clientraw[79];
		set_ajax_obs("ajaxuv",uv) ;
		set_ajax_obs("gizmouv",uv) ;

		uvword = ajax_getUVrange(uv);
		set_ajax_obs("ajaxuvword",uvword);
		set_ajax_obs("gizmouvword",uvword);

		
		rain = convertRain(clientraw[7]);
		set_ajax_obs("ajaxrain",rain.toFixed(dpRain) + uomRain);
		set_ajax_obs("ajaxrainNoU",rain.toFixed(dpRain));
		set_ajax_obs("gizmorain",rain.toFixed(dpRain) + uomRain);

		rainydy = convertRain(clientraw[19]);
		set_ajax_obs("ajaxrainydy",rainydy.toFixed(dpRain)+ uomRain);

		rainmo = convertRain(clientraw[8]);
		set_ajax_obs("ajaxrainmo",rainmo.toFixed(dpRain) + uomRain);

		rainyr = convertRain(clientraw[9]);
		set_ajax_obs("ajaxrainyr",rainyr.toFixed(dpRain) + uomRain);

		rainratehr = convertRain(clientraw[10]) * 60; 
		set_ajax_obs("ajaxrainratehr",rainratehr.toFixed(dpRain+1) + uomRain);

		rainratemax = convertRain(clientraw[11]) * 60; 
		set_ajax_obs("ajaxrainratemax",rainratemax.toFixed(dpRain+1) + uomRain);


		ntime = clientraw[29] + ":" + clientraw[30];
		ndate = langMonths[ clientraw[36] -1 ].substring(0,3) + " " + clientraw[35] + " " + clientraw[141];
		ndate2 = clientraw[35] + "-" +langMonths[ clientraw[36] -1 ].substring(0,3) + "-" +  clientraw[141];
		myDate = new Date( langMonths[ clientraw[36] - 1 ] + " " + clientraw[35] + ", " + clientraw[141] );
		tday = langDays[myDate.getDay()];

		set_ajax_obs("ajaxndate", ndate );
		set_ajax_obs("ajaxndate2",ndate2);
		set_ajax_obs("ajaxntime", ntime );
		set_ajax_obs("ajaxntimess", ntime + ":" + clientraw[31]);
		set_ajax_obs("ajaxdname", tday );

		
		ajaxtimeformat = clientraw[32];
		ajaxdateformat = clientraw[74];
		ajaxtimeformat = ajaxtimeformat.split('-')[1];
		ajaxtimeformat = ajaxtimeformat.replace( "_" , "");
		ajaxtimeformat = ajaxtimeformat.toLowerCase();

		set_ajax_obs("ajaxdatetime",ajaxdateformat + " " +ajaxtimeformat);
		set_ajax_obs("ajaxdate",ajaxdateformat);
		set_ajax_obs("ajaxtime",ajaxtimeformat);
		set_ajax_obs("gizmodate",ajaxdateformat);
		set_ajax_obs("gizmotime",ajaxtimeformat);
		
		if (lastajaxtimeformat != ajaxtimeformat) {
			counterSecs = 0;                      
			lastajaxtimeformat = ajaxtimeformat; 
		}
		
		
		set_ajax_obs("ajaxconditionicon",
			ajax_wxIcon(clientraw[48])
			);

		set_ajax_obs("ajaxconditionicon2",
			ajax_wxIconJPG(clientraw[48])
			);


		currentcond = clientraw[49];


		currentcond = currentcond.replace(/\\/g,', ');

        currentcond = ajaxFixupCondition(currentcond);
		set_ajax_obs("ajaxcurrentcond",currentcond);
		set_ajax_obs("gizmocurrentcond",currentcond);
		
		
		cloudheight = clientraw[73];
		set_ajax_obs("ajaxcloudheight",convertHeight(cloudheight) + uomHeight);
		
		
        var element = document.getElementById("ajaxindicator");
		if (element) {
          element.style.color = flashcolor;
		}
        var element = document.getElementById("gizmoindicator"); 
		if (element) {
          element.style.color = flashcolor;
		}
		if (maxupdates > 0 && updates > maxupdates-1) { 
			set_ajax_obs("ajaxindicator",langPauseMsg);
		}
		set_ajax_obs('ajaxupdatecount',updates);       
		set_ajax_obs('ajaxmaxupdatecount',maxupdates); 

 	  } 

	 } 

    } 

   	catch(e){}  

    } 
    x.open("GET", url, true);
    x.send(null);
    setTimeout("reset_ajax_color('')",flashtime);  
	if ( (maxupdates == 0) || (updates < maxupdates-1)) {
      setTimeout("ajaxLoader(clientrawFile + '?' + new Date().getTime())", reloadTime); 
    }
  }
} 
 window.setInterval("ajax_countup()", 1000); 
if (! ajaxLoaderInBody) { ajaxLoader(clientrawFile + '?' + new Date().getTime(), reloadTime); }
