function detectBrowser()
{
var browser=navigator.appName
var b_version=navigator.appVersion
var version=parseFloat(b_version)
if (!((browser=="Netscape"||browser=="Microsoft Internet Explorer") && (version>=4)))
  {alert("It's time to upgrade your browser!")}
}

function show_cdbk(xchrt,vbl) {
  cdbk=open("codebook.php?xxx="+xchrt+"&a="+vbl,"cdbkWindow","scrollbars=yes,width=640, height=480, resizable=yes");
}

function new_tags() {
  var j = 0;
  for (var i=0; i<document.gator.elements.length; i++) {
    if ((document.gator.elements[i].name.substr(0,3) == "vbl") &&
        (document.gator.elements[i].checked))  j++;
   }
   if (j > 0)
    return true;
   else
    return false;
}

function tagall() {
  for (var i=0; i<document.gator.elements.length; i++)
   if (document.gator.elements[i].name.substr(0,3) == "vbl")
    document.gator.elements[i].checked = true;
}

function cutall() {
  for (var i=0; i<document.gator.elements.length; i++)
   if (document.gator.elements[i].name.substr(0,3) == "vbl")
    document.gator.elements[i].checked = false;
}

function gator_sort(key) {
//  document.gator.runtype.value="sort";
  document.gator.sortkey.value = key;
  document.gator.sorting.value = "yes";
  document.gator.submit();
}

function gator_run(runtype,ordr) {
  document.gator.action = 'webgator.php'; 
  document.gator.sortkey.value=ordr;
  document.gator.runtype.value=runtype;
  if (runtype == 'extrora')
  { 
    document.gator.action = 'extrora.php'; 
    document.gator.tbl.value = '0'; 
  }
  if ((runtype == 'extract') || (runtype == 'extract-all'))
  { 
    document.gator.action = 'extract.php'; 
    document.gator.tbl.value = '0'; 
  }
  if (runtype == 'table')
  { 
    document.gator.action = 'extract.php'; 
    document.gator.tbl.value = '1'; 
  }
  if (document.gator.mytagname.value != '')
  { document.gator.mytagname.value = document.gator.mytagname.value; }
  else
  { document.gator.mytagname.value = 'default'; }
  if (((runtype == 'extract') || (runtype == 'extract-all') || 
       (runtype == 'table')   || (runtype == 'table-all')   || (runtype == 'review') || (runtype == 'newreview')) &&
    (document.gator.mytagcount.value == 0 ) && (!new_tags()))
  { alert("You have no tagged variables."); }
  else
  { document.gator.submit(); }
}

function opentag() {
  document.gator.runtype.value="upload";
  if (document.gator.userfile.value != "") {
    document.gator.action = "webgator.php";
    document.gator.fname.value = document.gator.userfile.value;
    document.gator.submit();
  } else {
    document.gator.action = "";
    alert("No Tag Set file specified.");
  }
}

function changeCohort() {
  document.gator.action="webgator.php";
  if (confirm('Are you sure you want to change cohorts?\nUnsaved changes to your tagset will be lost.')) {
    document.gator.runtype.value="cohort";
    document.gator.submit();
  }
  else {
    document.gator.newcohort.value = document.gator.mychrt.value;
  }
}

function save_tags() {
  document.gator.action="save_my_tagset.php";
  if ((document.gator.mytagcount.value == 0 ) && (!new_tags()))
  { alert("You have no tagged variables."); }
  else
  { document.gator.submit(); }
}

function open_vname() {
  document.gator.runtype.value="vnameset";
  if (document.gator.hoserfile.value != "") {
    document.gator.action = "webgator.php";
    document.gator.fname.value = document.gator.hoserfile.value;
    document.gator.submit();
  } else {
    document.gator.action = "";
    alert("No Vname Set file specified.");
  }
}

function save_vname() {
  document.gator.action="save_vnameset.php";
  if ((document.gator.mytagcount.value == 0 ) && (!new_tags()))
  { alert("Save Vname Set error: You have no tagged variables."); }
  else
  { document.gator.submit(); }
}

function filter_hint() {
 alert(
  '- Add a filter to limit the number of variable records returned.\n'+
  '- More than 1 filter can be added by choosing items from different filter categories.\n'+
  '- Complex searches can be constructed by "saving" filters and adding more filters\n'+
  '   from the same or from different categories.');
}

function cohort_hint() {
 alert(
  'To switch from "Public" to "Private" cohorts or vice versa\nclick on the "Restart" link.');
}

function save_hint() {
 alert(
  'Complex searches can be constructed by "saving" filters and adding more filters\n'+
  'from the same or from different categories. This can be useful when working with\n'+
  'categories with large numbers of variables, for instance the word "JOB". Adding\n'+
  'more filters can reduce the number of variable records returned to a more\n'+
  'manageable level' );
}

function recommended_hint() {
 alert(
/*  'Recommended variables call attention to their usefulness. "Show all variables"\n'+
  'will sometimes display a vast and perplexing array of variables depending on\n'+
  'the filter(s) applied. Difficulty in choosing variables to tag can be due to\n'+
  'complex skip patterns, inclusion of interviewer and machine check variables,\n'+
  'and multiple variables with similar titles. Recommended variables seek to reduce\n'+
  'this difficulty. Typically, recommended variables are ones that have been created\n'+
  'or revised, summarize a complex skip pattern, or distinguish between variables with\n'+
  'similar titles. Although variables may not be marked as recommended, they may\n'+
  'be vital to understanding many aspects of the data set.'
*/

	'Primary Variables call attention to their usefulness, and generally are ones that\n'+
	'have been created or revised, summarize a complex skip pattern, or distinguish\n'+
	'between variables with similar titles.\n\n'+  
  'Show All Variables will sometimes display a great number of variables, \n'+
  'depending on the filter(s) applied. Difficulty in choosing variables can\n'+ 
  'be due to complex skip patterns, inclusion of interviewer and machine check\n'+
  'variables, and multiple variables with similar titles.' 
);
}

function getRefnum(ref) {
  document.gator.refnum.value=ref;
  gator_run('filter','sasname');
}

function cohort_run(what,where) {
  document.gator.newcohort.value = what;
  document.gator.version.value = where;
  document.gator.submit();
}

function server_save() {
  document.gator.action="server_save.php";
  if ((document.gator.mytagcount.value == 0 ) && (!new_tags()))
  { alert("You have no tagged variables."); }
  else
  { document.gator.submit(); }
}

function server_open() {
  document.gator.action="server_open.php";
  document.gator.submit();
}
