// JavaScript file for graphical forecast rollover table.
// This file was created for daytime.
// The time zone is set to EST.
 
// 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 PoP12max = 13;
var Wxmax = 52;
var Tmax = 52;
var Tdmax = 52;
var Skymax = 52;
var QPFmax = 10;
var SnowAmtmax = 6;
var IceAccum6hrmax = 6;
var ApparentTmax = 20;
var RHmax = 52;
var WindSpdmax = 52;
var WindGustmax = 52;
// 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/7am.gif" ;
        time2 = "../staticimages/10am.gif" ;
        time3 = "../staticimages/1pm.gif" ;
        time4 = "../staticimages/4pm.gif" ;
        maxmin = "../staticimages/High.gif" ;
        maxtmintperiod = (imageperiod + 1) / 2 ;
        maxtmintperiod = Math.round(maxtmintperiod)
  }
  if (timeperiod == "night"){
        time1 = "../staticimages/7pm.gif" ;
        time2 = "../staticimages/10pm.gif" ;
        time3 = "../staticimages/1am.gif" ;
        time4 = "../staticimages/4am.gif" ;
        maxmin = "../staticimages/Low.gif" ;
        maxtmintperiod = (imageperiod + 1) / 2 ;
        maxtmintperiod = Math.round(maxtmintperiod)
  }
    if (((imageperiod + 1) * 1) > PoP12max){
       document.PoP121.src = blank ;
    }
    else {
    document.PoP121.src= "../staticimages/PoP12.gif" ;
    }
   if (((imageperiod + 1) * 4) > Wxmax){
      document.Wx1.src = blank ;
      document.Wx2.src = blank ;
      document.Wx3.src = blank ;
      document.Wx4.src = blank ;
   }
   else {
   if ((Wxmax > 20) && ((imageperiod + 1) > 5)){
      document.Wx1.src= time1 ;
      document.Wx2.src= blank ;
      document.Wx3.src= time3 ;
      document.Wx4.src= blank ;
   }
   else{
      document.Wx1.src= time1 ;
      document.Wx2.src= time2 ;
      document.Wx3.src= time3 ;
      document.Wx4.src= time4 ;
   }}
   if (((imageperiod + 1) * 4) > Tmax){
      document.T1.src = blank ;
      document.T2.src = blank ;
      document.T3.src = blank ;
      document.T4.src = blank ;
   }
   else {
   if ((Tmax > 20) && ((imageperiod + 1) > 5)){
      document.T1.src= time1 ;
      document.T2.src= blank ;
      document.T3.src= time3 ;
      document.T4.src= blank ;
   }
   else{
      document.T1.src= time1 ;
      document.T2.src= time2 ;
      document.T3.src= time3 ;
      document.T4.src= time4 ;
   }}
   if (((imageperiod + 1) * 4) > Tdmax){
      document.Td1.src = blank ;
      document.Td2.src = blank ;
      document.Td3.src = blank ;
      document.Td4.src = blank ;
   }
   else {
   if ((Tdmax > 20) && ((imageperiod + 1) > 5)){
      document.Td1.src= time1 ;
      document.Td2.src= blank ;
      document.Td3.src= time3 ;
      document.Td4.src= blank ;
   }
   else{
      document.Td1.src= time1 ;
      document.Td2.src= time2 ;
      document.Td3.src= time3 ;
      document.Td4.src= time4 ;
   }}
   if (((imageperiod + 1) * 4) > Skymax){
      document.Sky1.src = blank ;
      document.Sky2.src = blank ;
      document.Sky3.src = blank ;
      document.Sky4.src = blank ;
   }
   else {
   if ((Skymax > 20) && ((imageperiod + 1) > 5)){
      document.Sky1.src= time1 ;
      document.Sky2.src= blank ;
      document.Sky3.src= time3 ;
      document.Sky4.src= blank ;
   }
   else{
      document.Sky1.src= time1 ;
      document.Sky2.src= time2 ;
      document.Sky3.src= time3 ;
      document.Sky4.src= time4 ;
   }}
    if (((imageperiod + 1) * 2) > QPFmax){
        document.QPF1.src = blank ;
        document.QPF2.src = blank ;
    }
    else{
    document.QPF1.src= "../staticimages/QPF.gif" ;
    document.QPF2.src= "../staticimages/QPF.gif" ;
    }
    if (((imageperiod + 1) * 2) > SnowAmtmax){
        document.SnowAmt1.src = blank ;
        document.SnowAmt2.src = blank ;
    }
    else{
    document.SnowAmt1.src= "../staticimages/SnowAmt.gif" ;
    document.SnowAmt2.src= "../staticimages/SnowAmt.gif" ;
    }
    if (((imageperiod + 1) * 2) > IceAccum6hrmax){
        document.IceAccum6hr1.src = blank ;
        document.IceAccum6hr2.src = blank ;
    }
    else{
    document.IceAccum6hr1.src= "../staticimages/IceAccum6hr.gif" ;
    document.IceAccum6hr2.src= "../staticimages/IceAccum6hr.gif" ;
    }
   if (((imageperiod + 1) * 4) > ApparentTmax){
      document.ApparentT1.src = blank ;
      document.ApparentT2.src = blank ;
      document.ApparentT3.src = blank ;
      document.ApparentT4.src = blank ;
   }
   else {
   if ((ApparentTmax > 20) && ((imageperiod + 1) > 5)){
      document.ApparentT1.src= time1 ;
      document.ApparentT2.src= blank ;
      document.ApparentT3.src= time3 ;
      document.ApparentT4.src= blank ;
   }
   else{
      document.ApparentT1.src= time1 ;
      document.ApparentT2.src= time2 ;
      document.ApparentT3.src= time3 ;
      document.ApparentT4.src= time4 ;
   }}
   if (((imageperiod + 1) * 4) > RHmax){
      document.RH1.src = blank ;
      document.RH2.src = blank ;
      document.RH3.src = blank ;
      document.RH4.src = blank ;
   }
   else {
   if ((RHmax > 20) && ((imageperiod + 1) > 5)){
      document.RH1.src= time1 ;
      document.RH2.src= blank ;
      document.RH3.src= time3 ;
      document.RH4.src= blank ;
   }
   else{
      document.RH1.src= time1 ;
      document.RH2.src= time2 ;
      document.RH3.src= time3 ;
      document.RH4.src= time4 ;
   }}
   if (((imageperiod + 1) * 4) > WindSpdmax){
      document.WindSpd1.src = blank ;
      document.WindSpd2.src = blank ;
      document.WindSpd3.src = blank ;
      document.WindSpd4.src = blank ;
   }
   else {
   if ((WindSpdmax > 20) && ((imageperiod + 1) > 5)){
      document.WindSpd1.src= time1 ;
      document.WindSpd2.src= blank ;
      document.WindSpd3.src= time3 ;
      document.WindSpd4.src= blank ;
   }
   else{
      document.WindSpd1.src= time1 ;
      document.WindSpd2.src= time2 ;
      document.WindSpd3.src= time3 ;
      document.WindSpd4.src= time4 ;
   }}
   if (((imageperiod + 1) * 4) > WindGustmax){
      document.WindGust1.src = blank ;
      document.WindGust2.src = blank ;
      document.WindGust3.src = blank ;
      document.WindGust4.src = blank ;
   }
   else {
   if ((WindGustmax > 20) && ((imageperiod + 1) > 5)){
      document.WindGust1.src= time1 ;
      document.WindGust2.src= blank ;
      document.WindGust3.src= time3 ;
      document.WindGust4.src= blank ;
   }
   else{
      document.WindGust1.src= time1 ;
      document.WindGust2.src= time2 ;
      document.WindGust3.src= time3 ;
      document.WindGust4.src= time4 ;
   }}
  document.MaxTMinT.src= maxmin ;
}
 
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 ;
// 20 is the amount of images that are 3 hourly and
// at 21, images become 6 hourly.
     if (y > 20){
          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" ;
         }
     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 == "PoP12"){
   imagecount = imageperiod + 1 ;
   if (imagecount > PoP12max){return;}
   if(imagenam == "up"){imagecount = imagecounttemp + 1
     if (imagecount > PoP12max){
   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 == "QPF"){
   imagecount = 2 * imageperiod + imagenum ;
   if (imagecount > QPFmax){return;}
   if(imagenam == "up"){imagecount = imagecounttemp + 1
      if (imagecount > QPFmax){
   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 == "SnowAmt"){
   imagecount = 2 * imageperiod + imagenum ;
   if (imagecount > SnowAmtmax){return;}
   if(imagenam == "up"){imagecount = imagecounttemp + 1
      if (imagecount > SnowAmtmax){
   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 == "IceAccum6hr"){
   imagecount = 2 * imageperiod + imagenum ;
   if (imagecount > IceAccum6hrmax){return;}
   if(imagenam == "up"){imagecount = imagecounttemp + 1
      if (imagecount > IceAccum6hrmax){
   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 == "Wx") {tempmax = Wxmax};
      if (imagename == "T") {tempmax = Tmax};
      if (imagename == "Td") {tempmax = Tdmax};
      if (imagename == "Sky") {tempmax = Skymax};
      if (imagename == "ApparentT") {tempmax = ApparentTmax};
      if (imagename == "RH") {tempmax = RHmax};
      if (imagename == "WindSpd") {tempmax = WindSpdmax};
      if (imagename == "WindGust") {tempmax = WindGustmax};
     if (imagecount > tempmax ){return;}
     if(imagenam == "up"){
         if(imagecounttemp>20){imagecount = imagecounttemp + 2}
         if(imagecounttemp<=20){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<=21){imagecount = imagecounttemp - 1}
         if(imagecounttemp>21){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;
}
