// JavaScript file for graphical forecast rollover table.
// This file was created for daytime.
// The time zone is set to EDT.
 
// 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"
}

// 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 = "night" ;
       imageperiod = imageperiod + 1 ;
       if(imageperiod > 4){
         window.alert("You are at the end of this model run.")
         imageperiod = 4
       }
       if(imageperiod == 1 || imageperiod == 3) {timeperiod = "day"}
       if(imageperiod == 2 || imageperiod == 4) {timeperiod = "night"}
	 weekday = dategif[imageperiod] ;
     }
     if(period == "down"){
       timeperiod = "night" ;
       imageperiod = imageperiod - 1 ;
       if(imageperiod < 0){
         window.alert("You are at the beginning of this model run.")
         imageperiod = 0
       }
       if(imageperiod == 1 || imageperiod == 3) {timeperiod = "day"}
       if(imageperiod == 2 || imageperiod == 4) {timeperiod = "night"}
       weekday = dategif[imageperiod] ;
     }
  document.DayofWeek.src= weekday ;
  if (timeperiod == "day"){
        time1 = "../staticimages/8am.gif" ;
        time2 = "../staticimages/9am.gif" ;
        time3 = "../staticimages/10am.gif" ;
        time4 = "../staticimages/12am.gif" ;
        time5 = "../staticimages/12pm.gif" ;
        time6 = "../staticimages/1pm.gif" ;
        time7 = "../staticimages/2pm.gif" ;
        time8 = "../staticimages/3pm.gif" ;
        time9 = "../staticimages/4pm.gif" ;
        time10 = "../staticimages/5pm.gif" ;
        time11 = "../staticimages/6pm.gif" ;
        time12 = "../staticimages/7pm.gif" ;
  }
  if (timeperiod == "night"){
        time1 = "../staticimages/8pm.gif" ;
        time2 = "../staticimages/9pm.gif" ;
        time3 = "../staticimages/10pm.gif" ;
        time4 = "../staticimages/11pm.gif" ;
        time5 = "../staticimages/12am.gif" ;
        time6 = "../staticimages/1am.gif" ;
        time7 = "../staticimages/2am.gif" ;
        time8 = "../staticimages/3am.gif" ;
        time9 = "../staticimages/4am.gif" ;
        time10 = "../staticimages/5am.gif" ;
        time11 = "../staticimages/6am.gif" ;
        time12 = "../staticimages/7am.gif" ;
  }

document.wind1.src= time1 ;
document.wind2.src= time2 ;
document.wind3.src= time3 ;
document.wind4.src= time4 ;
document.wind5.src = time5 ;
document.wind6.src = time6 ;
document.wind7.src= time7 ;
document.wind8.src= time8 ;
document.wind9.src= time9 ;
document.wind10.src = time10 ;
document.wind11.src = time11 ;
document.wind12.src= time12 ;

document.wave1.src= time1 ;
document.wave2.src= time2 ;
document.wave3.src= time3 ;
document.wave4.src= time4 ;
document.wave5.src = time5 ;
document.wave6.src = time6 ;
document.wave7.src= time7 ;
document.wave8.src= time8 ;
document.wave9.src= time9 ;
document.wave10.src = time10 ;
document.wave11.src = time11 ;
document.wave12.src= time12 ;

}
 
function getnewimg(imagenam,imagenum,mov) {
var imagenametemp = imagename
imagecounttemp = imagecount

	if ((onoroff == "OFF") && (mov == 1)){return;}
	if((imagenam != "up") && (imagenam != "down")){imagename = imagenam}
  
	imagecount = 12 * imageperiod + imagenum ;
	if ((imagedisplay == "no") && (imagename == imagenam)){
		imagecount = imagecounttemp;
		return;}

     tempmax = 60;
     if(imagenam == "up"){
         if(imagecounttemp <= tempmax){imagecount = imagecounttemp + 1}
         if(imagecount > tempmax){
         window.alert("You are at the last picture for this weather element.")
         imagecount = imagecount - 1
          }}
     if(imagenam == "down"){
         if(imagecounttemp <= tempmax){imagecount = imagecounttemp - 1}
         if (imagecount < 1){
         window.alert("You are at the first picture for this weather element.")
         imagecount = 1
         }}
	
	image = "images/" + imagename + "_F" + imagecount + ".png" ;


document.the_image.src= image ;
imagenumtemp = imagenum ;
return;
}

function loopimage(imagenam,imagenum,mov) {
var imagenametemp = imagename
imagecounttemp = imagecount

if ((onoroff == "OFF") && (mov == 1)){return;}
  
imagecount = 12 * imageperiod + imagenum ;
if ((imagedisplay == "no") && (imagename == imagenam)){
	imagecount = imagecounttemp;
	return;}

tempmax = 60;
if(imagecounttemp <= tempmax){imagecount = imagecounttemp + 1}
if(imagecount > tempmax){imagecount = 1}

if(imagecount < 10){
	image = "images/" + imagename + "_0" + imagecount + ".gif" ;
}else {
	image = "images/" + imagename + "_" + imagecount + ".gif" ;
}

document.the_image.src= image ;
imagenumtemp = imagenum ;
timer = setTimeout(loopimage,500)
}

function stoploop() {
  clearInterval(timer);
  timer = null;
}

function get_img(imagename) {
        var slct = document.turnoncode.ingredient.selectedIndex;
        onoroff = document.turnoncode.ingredient.options[slct].value;
}

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

