<!--

var cropname, crop, dolist;
var locn, args;
var Q, i, words, argis;

locn = window.location.href;
crop = "Unknown";
cropname = "Unknown crop";
dolist = "no";

// Find the arguments to the URL and put them in words[]
Q = locn.indexOf ("?");
if (Q > 0) {
  args = locn.substr (Q+1, locn.length);
  words = args.split ("&");
  // Split each argument into keyword argis[0] and value argis[1]
  // Deal with crop and list arguments; ignore any others
  for (i=0; i<words.length; i++) {
    argis = words[i].split ("=");
    if (argis[0] == "crop") {
      crop = argis[1];
    }
    if (argis[0] == "list") {
      dolist = "yes";
    }
  }
}

if (crop == "testcrop") {
  cropname = "Test Crop";
} else if (crop == "aw") {
  cropname = "Late autumn sown wheat";
} else if (crop == "sb") {
  cropname = "Spring barley";
} else if (crop == "so") {
  cropname = "Spring oats";
} else if (crop == "sw") {
  cropname = "Spring wheat";
} else if (crop == "wb") {
  cropname = "Winter barley";
} else if (crop == "wo") {
  cropname = "Winter oats";
} else if (crop == "wr") {
  cropname = "Winter oilseed Rape";
} else if (crop == "ww") {
  cropname = "Winter wheat";
} else {
  crop = "unknown";
  cropname = "Unknown crop";
}


function has1(crop) {
  // returns 1 if the crop has level 1 data
  // returns 0 if it does not
  // returns -1 if the crop is unknown
  // at present all crops have it

  if (crop == "sb" || crop == "wb" || crop == "wr" || crop == "aw" || 
      crop == "so" || crop == "sw" || crop == "wo" ||
      crop == "ww" || crop == "testcrop") {
    return (1);
  }
  return (-1);
}


function has23(crop) {
  // returns 1 if the crop has level 2/3 data
  // returns 0 if the crop does not
  // returns -1 if the crop is unknown

  if (crop == "sb" || crop == "wb" || crop == "wr" || crop == "ww" || 
      crop == "so" || crop == "sw" || crop == "wo" || crop == "testcrop") {
    return (1);
  } 
  if (crop == "aw") {
    return (0);
  }
  return (-1);
}


function has4(crop) {
  // returns 1 if the crop has level 4 data
  // returns 0 if it does not
  // returns -1 if the crop is unknown

  if (crop == "ww" || crop == "testcrop") {
    return (1);
  } 
  if (crop == "sb" || crop == "wb" || crop == "wr" || crop == "aw" || 
      crop == "so" || crop == "sw" || crop == "wo") {
    return (0);
  }
  return (-1);
}


function pleasel() {
  if (crop == "unknown") {
    document.write ("<\CENTER><\P><\B>Please <\a href=\"index.html\">");
    document.write ("select a crop.<\/A><\/B><\P><\/CENTER>");
  }
}

// -->

