bln=new Image(140,25)
bln.src="bln.jpg"
clk=new Image(140,25)
clk.src="clk.jpg"
msg=new Image(220,25)
msg.src="msg.jpg"
function swap_imgs(imagename,objectsrc){
}
function plate_field(a)
{
  document.dateform.elements["platenum"].value = a;
  if (document.images) {
    document.images[ttp].src=eval("msg.src")
    document.images[btm].src=eval("clk.src")
  }
  return true;
}

function fix_select()
{
  var am=document.dateform.Smonth.options[document.dateform.Smonth.selectedIndex].value;
  var ad=document.dateform.Sday.options[document.dateform.Sday.selectedIndex].value;
  var ay=document.dateform.Syear.options[document.dateform.Syear.selectedIndex].value;

  var bm=document.dateform.Emonth.options[document.dateform.Emonth.selectedIndex].value;
  var bd=document.dateform.Eday.options[document.dateform.Eday.selectedIndex].value;
  var by=document.dateform.Eyear.options[document.dateform.Eyear.selectedIndex].value;

  var ax = ay+am+ad;
  var bx = by+bm+bd;

  if(bx<ax) { 
    document.dateform.Eyear.selectedIndex=document.dateform.Syear.selectedIndex; 
    document.dateform.Emonth.selectedIndex=document.dateform.Smonth.selectedIndex; 
    document.dateform.Eday.selectedIndex=document.dateform.Sday.selectedIndex; 
    alert("Second date must be in the future from the first date"); 
    //alert("aY:"+ay+" m:"+am+" d:"+ad+"  bY:"+by+" m:"+bm+" d:"+bd);
    //alert("A:"+ax+" B:"+bx);
  }

  // set the score select box = to nothing and the rvcode field empty is a date is touched
  document.dateform.score.options.selectedIndex=0;
  document.dateform.rvcode.value='';
  document.dateform.platenum.value='';
}
function clear_other_fields(a)
{
  // If this functions is called, a shipper name has been selected so we zero all other field
  if(a==1) {
    document.dateform.score.options.selectedIndex=0;
    document.dateform.rvcode.value='';
    document.dateform.platenum.value='';
  }
  else if(a==2) {
    document.dateform.shippers.options.selectedIndex=0;
    document.dateform.rvcode.value='';
    document.dateform.platenum.value='';
  }
  else if(a==3) {
    document.dateform.score.options.selectedIndex=0;
    document.dateform.shippers.options.selectedIndex=0;
    document.dateform.platenum.value='';
  }
  else if(a==4) {
    document.dateform.score.options.selectedIndex=0;
    document.dateform.shippers.options.selectedIndex=0;
    document.dateform.rvcode.value='';
  }
}
function make_select(a)
{
  var m,dd,ty,tt,lastweek,lastmonth,ntd,ntm,nty;
  tday = new Date();
  m= (tday.getMonth() + 1);
  d= tday.getDate();
  ty= tday.getYear() + 1900;

  if(m<10) tm="0"+m; 
  else tm=m;
  if(d<10) td="0"+d; 
  else td=d;
  tt=ty+tm+td;

  nty=0;ntd=0;ntm=0; // initializing

  if(a==0)
  {
    document.dateform.Eyear.selectedIndex=ty-2001;
    document.dateform.Eday.selectedIndex=td-1; 
    document.dateform.Emonth.selectedIndex=tm-1; 
  }
  else if(a==1)
  {
    // choosing last week
    ntd = td - 7;
    if(ntd <= 0) {
      ntd += 30;
      ntm = tm - 1;
      if(ntm <= 0)
      {
        ntm = 12;
	nty = ty - 1;
      }
      else { nty = ty; }
    }
    else {
      ntm = tm;
      nty = ty;
    }
  }
  else if(a==2)
  {
    // choosing last 2 weeks
    ntd = td - 14;
    if(ntd <= 0) {
      ntd += 30;
      ntm = tm - 1;
      if(ntm <= 0)
      {
        ntm = 12;
	nty = ty - 1;
      }
      else { nty = ty; }
    }
    else {
      ntm = tm;
      nty = ty;
    }
  }
  else if(a==3)
  {
    ntd=td;
    ntm = tm - 1;
    if(ntm <= 0)
    {
      ntm = 12;
      nty = ty - 1;
    }
    else { nty = ty; }
  }
  else if(a==4)
  {
    ntd=td;
    ntm = tm - 2;
    if(ntm <= 0)
    {
      if (ntm == -1)
	ntm = 11;
      else
	ntm = 12;
      nty = ty - 1;
    }
    else { nty = ty; }
  }

  tt=ty+":"+tm+":"+td+" >"+nty+":"+ntm+":"+ntd;
  if(nty==0) { nty=ty; }
  //alert(tt);
  var Nyy = nty-2001; 
  var Oyy = ty-2001; 
  //alert("NTY="+Nyy);
  //alert("OTY="+Oyy);
  document.dateform.Syear.selectedIndex=Nyy;
  document.dateform.Sday.selectedIndex=ntd-1; 
  document.dateform.Smonth.selectedIndex=ntm-1; 
  document.dateform.Eyear.selectedIndex=Oyy; 
  document.dateform.Eday.selectedIndex=td-1; 
  document.dateform.Emonth.selectedIndex=tm-1; 
}
