// JavaScript file for graphical forecast rollover table.
// This file was created for nighttime.
// The time zone is set to CST.
 
// Mouse over effect initialized as on -- now set in php page (10/2004)
// var onoroff = "ON"
var imagedisplay = "yes"
 
var imagenumtemp = 1;
var imagecount = 1;
 
var browser = "Explorer";
var temp = navigator.appName;
if (temp == "Netscape"){browser = "Netscape"}
    var blank = "../staticimages/blank.gif"
    var blank2 = "../staticimages/blank.gif"
 
// Netscape does not refresh blank images, so substitute in
// for entries with no forecast with a graphic that has "-"
if (browser == "Netscape"){
    blank = "../staticimages/notavbl.gif"
    blank2 = "../staticimages/notavbl2.gif"
}
 
var LALmax = 16;
var MixHgtmax = 8;
var TransWindmax = 8;
var Hainesmax = 8;
var MaxMinRHmax = 14;
var WindGustFiremax = 56;
var Wind20ftmax = 28;
var VentRatemax = 6;
var PoPFiremax = 14;
var CWRmax = 12;
var TdFiremax = 56;
var WxFiremax = 56;
var SkyFiremax = 56;
var Fosbergmax = 24;
// Function to handle change of time periods, specific
// to each element displayed
function chgtimes(timeperiod,period,dow){
  weekday = dow
  if (dow != "change"){imageperiod = period}
     if(period == "up"){
       timeperiod = "day" ;
       imageperiod = imageperiod + 1 ;
       if(imageperiod > 12){imageperiod = 0 }
        if (Math.round(imageperiod/2) == imageperiod/2) {timeperiod = "night"}
            weekday = dategif[imageperiod] ;
     }
     if(period == "down"){
        timeperiod = "day" ;
        imageperiod = imageperiod - 1 ;
        if(imageperiod < 0){imageperiod = 12 }
         if (Math.round(imageperiod/2) == imageperiod/2) {timeperiod = "night"}
               weekday = dategif[imageperiod] ;
     }
  document.DayofWeek.src= weekday ;
  if (timeperiod == "day"){
        time1 = "../staticimages/6am.gif" ;
        time2 = "../staticimages/9am.gif" ;
        time3 = "../staticimages/12pm.gif" ;
        time4 = "../staticimages/3pm.gif" ;
        maxmin = "../staticimages/High.gif" ;
        maxtmintperiod = (imageperiod + 1) / 2 ;
        maxtmintperiod = Math.round(maxtmintperiod)
  }
  if (timeperiod == "night"){
        time1 = "../staticimages/6pm.gif" ;
        time2 = "../staticimages/9pm.gif" ;
        time3 = "../staticimages/12am.gif" ;
        time4 = "../staticimages/3am.gif" ;
        maxmin = "../staticimages/Low.gif" ;
        maxtmintperiod = (imageperiod + 1) / 2 ;
        maxtmintperiod = Math.round(maxtmintperiod)
  }
   if (((imageperiod + 1) * 4) > LALmax){
      document.LAL1.src = blank ;
      document.LAL2.src = blank ;
      document.LAL3.src = blank ;
      document.LAL4.src = blank ;
   }
   else {
   if ((LALmax > 24) && ((imageperiod + 1) > 6)){
      document.LAL1.src= time1 ;
      document.LAL2.src= blank ;
      document.LAL3.src= time3 ;
      document.LAL4.src= blank ;
   }
   else{
      document.LAL1.src= time1 ;
      document.LAL2.src= time2 ;
      document.LAL3.src= time3 ;
      document.LAL4.src= time4 ;
   }}
    if (((imageperiod + 1) * 2) > MixHgtmax){
        document.MixHgt1.src = blank ;
        document.MixHgt2.src = blank ;
    }
    else{
    document.MixHgt1.src= "../staticimages/MixHgt.gif" ;
    document.MixHgt2.src= "../staticimages/MixHgt.gif" ;
    }
    if (((imageperiod + 1) * 2) > TransWindmax){
        document.TransWind1.src = blank ;
        document.TransWind2.src = blank ;
    }
    else{
    document.TransWind1.src= "../staticimages/TransWind.gif" ;
    document.TransWind2.src= "../staticimages/TransWind.gif" ;
    }
    if (((imageperiod + 1) * 2) > Hainesmax){
        document.Haines1.src = blank ;
        document.Haines2.src = blank ;
    }
    else{
    document.Haines1.src= "../staticimages/Haines.gif" ;
    document.Haines2.src= "../staticimages/Haines.gif" ;
    }
    if (((imageperiod + 1) * 1) > MaxMinRHmax){
       document.MaxMinRH1.src = blank ;
    }
    else {
    document.MaxMinRH1.src= "../staticimages/MaxMinRH.gif" ;
    }
   if (((imageperiod + 1) * 4) > WindGustFiremax){
      document.WindGustFire1.src = blank ;
      document.WindGustFire2.src = blank ;
      document.WindGustFire3.src = blank ;
      document.WindGustFire4.src = blank ;
   }
   else {
   if ((WindGustFiremax > 24) && ((imageperiod + 1) > 6)){
      document.WindGustFire1.src= time1 ;
      document.WindGustFire2.src= blank ;
      document.WindGustFire3.src= time3 ;
      document.WindGustFire4.src= blank ;
   }
   else{
      document.WindGustFire1.src= time1 ;
      document.WindGustFire2.src= time2 ;
      document.WindGustFire3.src= time3 ;
      document.WindGustFire4.src= time4 ;
   }}
    if (((imageperiod + 1) * 2) > Wind20ftmax){
        document.Wind20ft1.src = blank ;
        document.Wind20ft2.src = blank ;
    }
    else{
    document.Wind20ft1.src= "../staticimages/Wind20ft.gif" ;
    document.Wind20ft2.src= "../staticimages/Wind20ft.gif" ;
    }
    if (((imageperiod + 1) * 1) > VentRatemax){
       document.VentRate1.src = blank ;
    }
    else {
    document.VentRate1.src= "../staticimages/VentRate.gif" ;
    }
    if (((imageperiod + 1) * 1) > PoPFiremax){
       document.PoPFire1.src = blank ;
    }
    else {
    document.PoPFire1.src= "../staticimages/PoPFire.gif" ;
    }
    if (((imageperiod + 1) * 2) > CWRmax){
        document.CWR1.src = blank ;
        document.CWR2.src = blank ;
    }
    else{
    document.CWR1.src= "../staticimages/CWR.gif" ;
    document.CWR2.src= "../staticimages/CWR.gif" ;
    }
   if (((imageperiod + 1) * 4) > TdFiremax){
      document.TdFire1.src = blank ;
      document.TdFire2.src = blank ;
      document.TdFire3.src = blank ;
      document.TdFire4.src = blank ;
   }
   else {
   if ((TdFiremax > 24) && ((imageperiod + 1) > 6)){
      document.TdFire1.src= time1 ;
      document.TdFire2.src= blank ;
      document.TdFire3.src= time3 ;
      document.TdFire4.src= blank ;
   }
   else{
      document.TdFire1.src= time1 ;
      document.TdFire2.src= time2 ;
      document.TdFire3.src= time3 ;
      document.TdFire4.src= time4 ;
   }}
   if (((imageperiod + 1) * 4) > WxFiremax){
      document.WxFire1.src = blank ;
      document.WxFire2.src = blank ;
      document.WxFire3.src = blank ;
      document.WxFire4.src = blank ;
   }
   else {
   if ((WxFiremax > 24) && ((imageperiod + 1) > 6)){
      document.WxFire1.src= time1 ;
      document.WxFire2.src= blank ;
      document.WxFire3.src= time3 ;
      document.WxFire4.src= blank ;
   }
   else{
      document.WxFire1.src= time1 ;
      document.WxFire2.src= time2 ;
      document.WxFire3.src= time3 ;
      document.WxFire4.src= time4 ;
   }}
   if (((imageperiod + 1) * 4) > SkyFiremax){
      document.SkyFire1.src = blank ;
      document.SkyFire2.src = blank ;
      document.SkyFire3.src = blank ;
      document.SkyFire4.src = blank ;
   }
   else {
   if ((SkyFiremax > 24) && ((imageperiod + 1) > 6)){
      document.SkyFire1.src= time1 ;
      document.SkyFire2.src= blank ;
      document.SkyFire3.src= time3 ;
      document.SkyFire4.src= blank ;
   }
   else{
      document.SkyFire1.src= time1 ;
      document.SkyFire2.src= time2 ;
      document.SkyFire3.src= time3 ;
      document.SkyFire4.src= time4 ;
   }}
   if (((imageperiod + 1) * 4) > Fosbergmax){
      document.Fosberg1.src = blank ;
      document.Fosberg2.src = blank ;
      document.Fosberg3.src = blank ;
      document.Fosberg4.src = blank ;
   }
   else {
   if ((Fosbergmax > 24) && ((imageperiod + 1) > 6)){
      document.Fosberg1.src= time1 ;
      document.Fosberg2.src= blank ;
      document.Fosberg3.src= time3 ;
      document.Fosberg4.src= blank ;
   }
   else{
      document.Fosberg1.src= time1 ;
      document.Fosberg2.src= time2 ;
      document.Fosberg3.src= time3 ;
      document.Fosberg4.src= time4 ;
   }}
}
 
function getnewimg(imagenam,imagenum,mov) {
         var imagenametemp = imagename
         imagecounttemp = imagecount
     if ((onoroff == "OFF") && (mov == 1)){return;}
     if((imagenam != "up") && (imagenam != "down")){imagename = imagenam}
     imagecounttemp = imagecount
     y = (imageperiod * 4) + imagenum ;
// 24 is the amount of images that are 3 hourly and
// at 25, images become 6 hourly.
     if (y > 24){
          imagetest = ((imageperiod * 4) + imagenum + 1) / 2 ;
          x = Math.round(imagetest);
          if (imagetest == x){
              imagedisplay = "yes"}
          if (imagetest != x){imagedisplay = "no"}
          }
          if (imagename == "MaxTMinT"){
     	      imagenamemaxmin = "MinT" ;
 	if (maxmin == "../staticimages/High.gif"){
   		imagenamemaxmin = "MaxT" ;
 	}
 	else {
   		imagenamemaxmin = "MinT" ;
         }
     imagecount = maxtmintperiod
     if(imagenam == "up"){imagecount = imagecounttemp + 1
         if (imagecount > 7){
           window.alert("You are at the last image for this weather element")
           imagecount = imagecount - 1
         imagename = imagenametemp
         }}
     if(imagenam == "down"){imagecount = imagecounttemp - 1
         if (imagecount < 1){
         window.alert("You are at the first image for this weather element")
         imagecount = 1
         imagename = imagenametemp
         }}
     image = "../images/" + sector + "/" + imagenamemaxmin + imagecount + "_" + sector + ".png" ;
     document.the_image.src= image ;
     return;
     }
   if (imagename == "MixHgt"){
   imagecount = 2 * imageperiod + imagenum ;
   if (imagecount > MixHgtmax){return;}
   if(imagenam == "up"){imagecount = imagecounttemp + 1
      if (imagecount > MixHgtmax){
   window.alert("You are at the last image for this weather element.")
   imagecount = imagecount - 1
   }}
   if(imagenam == "down"){imagecount = imagecounttemp - 1
   if (imagecount < 1){
   window.alert("You are at the first image for this weather element.")
   imagecount = 1
  }}
  image = "../images/" + sector + "/" + imagename + imagecount + "_" + sector + ".png" ;
  document.the_image.src= image ;
  imagenumtemp = imagenum ;
  return;
  }
   if (imagename == "TransWind"){
   imagecount = 2 * imageperiod + imagenum ;
   if (imagecount > TransWindmax){return;}
   if(imagenam == "up"){imagecount = imagecounttemp + 1
      if (imagecount > TransWindmax){
   window.alert("You are at the last image for this weather element.")
   imagecount = imagecount - 1
   }}
   if(imagenam == "down"){imagecount = imagecounttemp - 1
   if (imagecount < 1){
   window.alert("You are at the first image for this weather element.")
   imagecount = 1
  }}
  image = "../images/" + sector + "/" + imagename + imagecount + "_" + sector + ".png" ;
  document.the_image.src= image ;
  imagenumtemp = imagenum ;
  return;
  }
   if (imagename == "Haines"){
   imagecount = 2 * imageperiod + imagenum ;
   if (imagecount > Hainesmax){return;}
   if(imagenam == "up"){imagecount = imagecounttemp + 1
      if (imagecount > Hainesmax){
   window.alert("You are at the last image for this weather element.")
   imagecount = imagecount - 1
   }}
   if(imagenam == "down"){imagecount = imagecounttemp - 1
   if (imagecount < 1){
   window.alert("You are at the first image for this weather element.")
   imagecount = 1
  }}
  image = "../images/" + sector + "/" + imagename + imagecount + "_" + sector + ".png" ;
  document.the_image.src= image ;
  imagenumtemp = imagenum ;
  return;
  }
   if (imagename == "MaxMinRH"){
   imagecount = imageperiod + 1 ;
   if (imagecount > MaxMinRHmax){return;}
   if(imagenam == "up"){imagecount = imagecounttemp + 1
     if (imagecount > MaxMinRHmax){
   window.alert("You are at the last image for this weather element.")
   imagecount = imagecount - 1
   }}
   if(imagenam == "down"){imagecount = imagecounttemp - 1
   if (imagecount < 1){
   window.alert("You are at the first image for this weather element.")
   imagecount = 1
  }}
  image = "../images/" + sector + "/" + imagename + imagecount + "_" + sector + ".png" ;
  document.the_image.src= image ;
  imagenumtemp = imagenum ;
  return;
  }
   if (imagename == "Wind20ft"){
   imagecount = 2 * imageperiod + imagenum ;
   if (imagecount > Wind20ftmax){return;}
   if(imagenam == "up"){imagecount = imagecounttemp + 1
      if (imagecount > Wind20ftmax){
   window.alert("You are at the last image for this weather element.")
   imagecount = imagecount - 1
   }}
   if(imagenam == "down"){imagecount = imagecounttemp - 1
   if (imagecount < 1){
   window.alert("You are at the first image for this weather element.")
   imagecount = 1
  }}
  image = "../images/" + sector + "/" + imagename + imagecount + "_" + sector + ".png" ;
  document.the_image.src= image ;
  imagenumtemp = imagenum ;
  return;
  }
   if (imagename == "VentRate"){
   imagecount = imageperiod + 1 ;
   if (imagecount > VentRatemax){return;}
   if(imagenam == "up"){imagecount = imagecounttemp + 1
     if (imagecount > VentRatemax){
   window.alert("You are at the last image for this weather element.")
   imagecount = imagecount - 1
   }}
   if(imagenam == "down"){imagecount = imagecounttemp - 1
   if (imagecount < 1){
   window.alert("You are at the first image for this weather element.")
   imagecount = 1
  }}
  image = "../images/" + sector + "/" + imagename + imagecount + "_" + sector + ".png" ;
  document.the_image.src= image ;
  imagenumtemp = imagenum ;
  return;
  }
   if (imagename == "PoPFire"){
   imagecount = imageperiod + 1 ;
   if (imagecount > PoPFiremax){return;}
   if(imagenam == "up"){imagecount = imagecounttemp + 1
     if (imagecount > PoPFiremax){
   window.alert("You are at the last image for this weather element.")
   imagecount = imagecount - 1
   }}
   if(imagenam == "down"){imagecount = imagecounttemp - 1
   if (imagecount < 1){
   window.alert("You are at the first image for this weather element.")
   imagecount = 1
  }}
  image = "../images/" + sector + "/" + imagename + imagecount + "_" + sector + ".png" ;
  document.the_image.src= image ;
  imagenumtemp = imagenum ;
  return;
  }
   if (imagename == "CWR"){
   imagecount = 2 * imageperiod + imagenum ;
   if (imagecount > CWRmax){return;}
   if(imagenam == "up"){imagecount = imagecounttemp + 1
      if (imagecount > CWRmax){
   window.alert("You are at the last image for this weather element.")
   imagecount = imagecount - 1
   }}
   if(imagenam == "down"){imagecount = imagecounttemp - 1
   if (imagecount < 1){
   window.alert("You are at the first image for this weather element.")
   imagecount = 1
  }}
  image = "../images/" + sector + "/" + imagename + imagecount + "_" + sector + ".png" ;
  document.the_image.src= image ;
  imagenumtemp = imagenum ;
  return;
  }
     imagecount = 4 * imageperiod + imagenum ;
     if ((imagedisplay == "no") && (imagename == imagenam)){
     imagecount = imagecounttemp;
return;}
      if (imagename == "LAL") {tempmax = LALmax};
      if (imagename == "WindGustFire") {tempmax = WindGustFiremax};
      if (imagename == "TdFire") {tempmax = TdFiremax};
      if (imagename == "WxFire") {tempmax = WxFiremax};
      if (imagename == "SkyFire") {tempmax = SkyFiremax};
      if (imagename == "Fosberg") {tempmax = Fosbergmax};
     if (imagecount > tempmax ){return;}
     if(imagenam == "up"){
         if(imagecounttemp>24){imagecount = imagecounttemp + 2}
         if(imagecounttemp<=24){imagecount = imagecounttemp + 1}
         if(imagecount > tempmax){
         window.alert("You are at the last picture for this weather element.")
         imagecount = imagecount - 2
          }}
     if(imagenam == "down"){
         if(imagecounttemp<=25){imagecount = imagecounttemp - 1}
         if(imagecounttemp>25){imagecount = imagecounttemp -2}
         if (imagecount < 1){
         window.alert("You are at the first picture for this weather element.")
         imagecount = 1
         }}
         image = "../images/" + sector + "/" + imagename + imagecount + "_" + sector + ".png" ;
         document.the_image.src= image ;
         imagenumtemp = imagenum ;
         return;
         }
function get_img(imagename) {
        var slct = document.turnoncode.ingredient.selectedIndex;
        onoroff = document.turnoncode.ingredient.options[slct].value;
}

function mouseovereffect(tempvrbl) {
        var onoroff = tempvrbl;
}
