// 	Who	When		Revision
//	---	----		--------
//	AS	5/23/00		Modified Sort function to include
//				Michael Yu's changes
//      Kamau   2/19/01         Added chart function to make trend charts
//

function Chart(field, chartnum) {
   var newurl = document.URL;
 //  alert(newurl);
   newurl += '&CHARTNUM='+chartnum+'&GRF_FLD='+field+'&GRF_DISP=YES' ;
   location = newurl; 
}


function Sort( field, dir ) {
   var newurl = document.URL;
   document.resort.sort.value= field;
   document.resort.sort_fmt.value= dir;
   //location = newurl;
   document.resort.submit();
}

function oldSort(field, dir) {
   var sort_fld, sort_dir;
   var parms = document.URL.split('&');
   var newurl = parms[0];
   for (var i=1; i<parms.length; i++) {
      var s = parms[i].split('=');
      var parmname = s[0];
      var parmvalue = s[1];
      if (parmname == 'sort') {
         sort_fld = parmvalue;
         parmvalue = field;
      }
      else if (parmname == 'sort_fmt') {
         sort_dir = parmvalue;
         parmvalue = dir;
      }
      newurl += '&' + parmname + '=' + parmvalue;
   }
  
   if (sort_fld==field && sort_dir==dir) return;
// run the new sort
// alert(newurl);
   location = newurl; 
}


function help() {
   alert(
        "File saving instructions:\n\n" +
        "When you click the 'Download' button,\n" +
        "a 'Save As' dialogue box will appear.\n" +
        "The file is a comma-delimited text file\n" +
        "so it should be given extension of .CSV"
        );
}

function help_dataset()
{
        
    SmallWin = window.open(helpBase + 'hlpdata.htm', 
        'HelpWindow','scrollbars=yes,toolbar=yes,resizable=yes,height=480,width=471');

    if( ! isIE4() ) {
       if (window.focus) {
                SmallWin.focus();
       }
    }

    if (SmallWin.opener == null) SmallWin.opener = window;
    SmallWin.opener.name = "PUMain";
}


function changeTime( disp ) {
  var now= new Date();
  var hrs= now.getHours();
  var time_now= (( hrs > 12 ) ? ( hrs + (-12)) : hrs ) + ":";
  time_now += now.getMinutes() + ":" + now.getSeconds();
  time_now += (( hrs > 12 ) ? " PM" : " AM" );
  /* document.form1.currentTime.value= disp; */
  window.status= disp + ", " + time_now;   
  theTimer= setTimeout( "changeTime( disp )", 1000 );
}

function printver() {
   var newurl = document.URL;
   location = newurl+"&printver=YES";
   //document.resort.submit();
}

