var pics=new Array();
var count=0;
var i=0;
var ith=0;
var speed=1000;
var data="";
var k;
var dateStr="";
var filename="";
var variable="";
var dts="";

  function myWin(frm){
    dateStr=frm.yr.options[frm.yr.selectedIndex].value+frm.mn.options[frm.mn.selectedIndex].value+frm.dy.options[frm.dy.selectedIndex].value;
    newWin = open ("http://www.emc.ncep.noaa.gov/wx20pl/3x_tmp/"+dateStr+"/3X.html", "displayWindow", "width=800,height=600,menubar=yes,resizable=yes,scrollbars=yes,toolbar=yes,location=yes,status=yes");
  }
                                                                                                                                                             
function preload(img){
     pics[count] = new Image();
     pics[count].src = img;
     count++;
}

function get_speed(frm){
  if(frm.elements["spd"].selectedIndex == 0) speed=1000;
  if(frm.elements["spd"].selectedIndex == 1) speed=100;
  if(frm.elements["spd"].selectedIndex == 2) speed=2000;
  return speed;
}
                                                                                                                                                             
function increse_i(){
   i++;
   return i;
}
                                                                                                                                                             
function anim(){
     if(i>=47){
       i=0;
     }
     document.my_image.src =  pics[i].src;
     window.setTimeout("increse_i(); anim()", speed);
}
             
function animation(){
     if(i>=47){
       i=0;
     }
     if(document.form2.timerBox.checked){
       document.my_image.src =  pics[i].src;
       window.setTimeout("increse_i(); animation()", speed);
       ith=i;
     }
     else{
       return;
     }
}

                                                                                                                                                
function show(i){
  ith=i;
  document.my_image.src=pics[ith].src;
}

function next(){
  ith=ith+1;
  if(ith >= 47) ith=47;
   document.my_image.src=pics[ith].src;
}
                                                                                                                                                             
function prev(){
  ith=ith-1;
  if(ith < 0) ith=0;
   document.my_image.src=pics[ith].src;
}
                                                                                                                                                             
function rewind(){
  ith=0;
   document.my_image.src=pics[ith].src;
}
                                                                                                                                                             
function last(){
  ith=47;
   document.my_image.src=pics[ith].src;
}
                                                                                                                                                             
function openWin(url) {
  newWin=window.open(url);
}
                                                                                                                                                             
function reload(){
   open(this);
}

function load_image(frm){

  count = 0;
  dts="";

  if(frm.typ.options[frm.typ.selectedIndex].value=="precip.html"){
   variable="prcp";
  }
  else if (frm.typ.options[frm.typ.selectedIndex].value=="slp.html" || frm.typ.options[frm.typ.selectedIndex].value=="slp_prob.html"){   
   variable="SLP";
  }
  else if (frm.typ.options[frm.typ.selectedIndex].value=="t.html" || frm.typ.options[frm.typ.selectedIndex].value=="t_prob.html"){
   variable="T"; 

  }
  else if (frm.typ.options[frm.typ.selectedIndex].value=="wind.html" || frm.typ.options[frm.typ.selectedIndex].value=="wind_prob.html"){
   variable="VWND";
  }
  else if (frm.typ.options[frm.typ.selectedIndex].value=="rh.html" || frm.typ.options[frm.typ.selectedIndex].value=="rh_prob.html" ){
   variable="RH";
  }
  else if (frm.typ.options[frm.typ.selectedIndex].value=="dp.html" || frm.typ.options[frm.typ.selectedIndex].value=="dp_prob.html" ){
   variable="DPT";
  }
  else if (frm.typ.options[frm.typ.selectedIndex].value=="z.html" || frm.typ.options[frm.typ.selectedIndex].value=="z_prob.html"){
   variable="Z";
  }

 

    filename="../"+frm.yr.options[frm.yr.selectedIndex].value+"/"+variable+frm.lvl.options[frm.lvl.selectedIndex].value+"_"+frm.sts.options[frm.sts.selectedIndex].value+dts+frm.fhr.options[frm.fhr.selectedIndex].value+"_"+frm.mdl.options[frm.mdl.selectedIndex].value+".gif";
    preload(filename);

  show(0);
}

function get_i(){
 i=ith;
} 
