var pics=new Array();
var count=0;
var i=0;
var ith=0;
var speed=1000;
var data="";
var kk;
var dateStr;
var filename="";
var begin=0;
var prd="";

  function myWin(){
    newWin = open ("http://wwwt.emc.ncep.noaa.gov/mmb/SREF/FCST/COM_US/winter_back_see/html/"+prd+".COM_HI"+".html", "displayWindow", "width=1000,height=800,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>=30-begin){
       i=0;
     }
     document.my_image.src =  pics[i].src;
     window.setTimeout("increse_i(); anim()", speed);
}
                                                                                                                                                             
function show(i){
  ith=i;
  document.my_image.src=pics[ith].src;
}

function next(){
  ith=ith+1;
  if(ith >= 29-begin) ith=29-begin;
   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=29-begin;
   document.my_image.src=pics[ith].src;
}
                                                                                                                                                             
function openWin(url) {
  newWin=window.open(url);
}
                                                                                                                                                             
function reload(){
   open(this);
}

                                                                                                                                                                                                                                                               
function load_image(frm){
  if(frm.elements["prd"].selectedIndex ==0 || frm.elements["prd"].selectedIndex ==4 || frm.elements["prd"].selectedIndex ==5 || frm.elements["prd"].selectedIndex ==6 ) begin=1;
  if(frm.elements["prd"].selectedIndex ==1) begin=2;
  if(frm.elements["prd"].selectedIndex ==2) begin=4;
  if(frm.elements["prd"].selectedIndex ==3) begin=8;
  if(frm.elements["prd"].selectedIndex > 6) begin=0;

  count=0;
  for(k=begin; k<30; k++){
    kk=k*3
    if(kk<10) data="0"+kk;
    else data=kk;

    if(frm.elements["prd"].selectedIndex == 7 || frm.elements["prd"].selectedIndex == 8){
       filename="../../../../../SREF_avia/FCST/AVN/"+frm.dy.options[frm.dy.selectedIndex].value+"/wind/"+frm.cat.options[frm.cat.selectedIndex].value+frm.tz.options[frm.tz.selectedIndex].value+"z."+data+".gif";    
    }
    else {
     filename="../../../COM_HI"+"/"+"ens."+frm.dy.options[frm.dy.selectedIndex].value+frm.tz.options[frm.tz.selectedIndex].value+"/"+frm.cat.options[frm.cat.selectedIndex].value+data+".gif";
    }
    preload(filename);
  }
  show(0);
}

function load_indiv(frm){
  if(frm.elements["sts"].selectedIndex <3 ) {
   document.location=frm.sts.options[frm.sts.selectedIndex].value;
  }
  else {
   filename="../../../COM_HI"+"/ens."+frm.dy.options[frm.dy.selectedIndex].value+frm.tz.options[frm.tz.selectedIndex].value+"/"+frm.sts.options[frm.sts.selectedIndex].value;
   document.location=filename;
  }
}

