
function setPageAndSubmit(param1)
{
    document.forms[0]['page'].value = param1;
    document.forms[0].submit();
}

function firstFocus()
{
   if (document.getElementById('query').value.length < 1) 
   {
       document.getElementById('query').focus();
   } 
}

function getNewNarrowWinSizeOpts()
{
   var left = parseInt(300);
   var top = parseInt(25);
   var width = parseInt(getMaxWinWidth() - 350);
   var height = parseInt(getMaxWinHeight() - 200);

   var sizewinopts = "width=" + width + ",height=" + height + ",left=" + left + ",top=" + top;

   return sizewinopts;
}

var studyinfoWindow = null;
function viewStudyInfo(url, studypath)
{
   var studyinfoUrl = url + '?';
   
   var extra = 'view=studyinfo';
   extra += '&studypath=' + encodeURIComponent(studypath);

   studyinfoUrl += extra;

   var basewinopts = 
      "toolbar=1,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,";
   var sizewinopts = getNewNarrowWinSizeOpts();
   var winfeatures = basewinopts + sizewinopts;

   studyinfoWindow=window.open(studyinfoUrl,'studyinfowin',winfeatures);
   if(window.focus)
   {
     studyinfoWindow.focus();
   }   
}

var descWindow = null;
function viewCollectionVar(varname, studypath, cgi, hsda3name, sdapath, subtmpdir)
{
   var descurl = cgi + '/' + hsda3name + '?';

   var extra = 'sdaprog=describe';
   extra += '&var=' + encodeURIComponent(varname);
   extra += '&sdapath=' + encodeURIComponent(sdapath);
   extra += '&study=' + encodeURIComponent(studypath);
   extra += '&subtmpdir=' + encodeURIComponent(subtmpdir);

   descurl += extra;

   var basewinopts = 
      "toolbar=1,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,";
   var sizewinopts = getNewNarrowWinSizeOpts();
   var winfeatures = basewinopts + sizewinopts;

   descWindow=window.open(descurl,'describewin',winfeatures);
   if(window.focus)
   {
     descWindow.focus();
   }
}

// Absolute limits on SDA window dimensions (pixels)
var winWidthLimit = 1024;
var winHeightLimit = 1024;

function getMaxWinWidth()
{
   if ( screen.availWidth < winWidthLimit )
      return screen.availWidth;
   else
      return winWidthLimit;
}

function getMaxWinHeight()
{
   if ( screen.availHeight < winHeightLimit )
      return screen.availHeight;
   else
      return winHeightLimit;
}


