function buildWindowFeaturesString(
    left,
    top,
    screenX,
    screenY,
    height,
    width,
    menubar,
    scrollbars,
    titlebar,
    directories,
    fullscreen,
    status,
    toolbar,
    location,
    resizable) {

    var windowFeatures =
      "left=" + left + "," +
      "top=" + top + "," +
      "screenX=" + screenX + "," +
      "screenY=" + screenY + "," +
      "height=" + height + "," +
      "width=" + width + "," +
      "menubar=" + menubar + "," +
      "scrollbars=" + scrollbars + "," +
      "titlebar=" + titlebar + "," +
      "directories=" + directories + "," +
      "fullscreen=" + fullscreen + "," +
      "status=" + status + "," +
      "toolbar=" + toolbar + "," +
      "location=" + location + "," +
      "resizable=" + resizable;

    return windowFeatures;
}

function popupDynamic(windowURL, windowWidth, windowHeight) {
    var left = 0;
    var top = 0;
    var screenX = 0;
    var screenY = 0;
    var height = windowHeight;
    var width = windowWidth;
    var menubar = 0;
    var scrollbars = 0;
    var titlebar = 0;
    var directories = 0;
    var fullscreen = 0;
    var status = 1;
    var toolbar = 0;
    var location = 0;
    var resizable = 0;

    var windowFeatures = buildWindowFeaturesString(
      left,
      top,
      screenX,
      screenY,
      height,
      width,
      menubar,
      scrollbars,
      titlebar,
      directories,
      fullscreen,
      status,
      toolbar,
      location,
      resizable);

    popup(windowURL, "popup_dynamic", windowFeatures);
}

function popupFixed2(windowURL) {
    var left = 0;
    var top = 0;
    var screenX = 0;
    var screenY = 0;
    var height = 500;
    var width = 720;
    var menubar = 0;
    var scrollbars = 'yes';
    var titlebar = 0;
    var directories = 0;
    var fullscreen = 0;
    var status = 1;
    var toolbar = 0;
    var location = 0;
    var resizable = 0;

    var windowFeatures = buildWindowFeaturesString(
      left,
      top,
      screenX,
      screenY,
      height,
      width,
      menubar,
      scrollbars,
      titlebar,
      directories,
      fullscreen,
      status,
      toolbar,
      location,
      resizable);

    popup(windowURL, "popup_fixed", windowFeatures);
}

function popupFixed(windowURL) {
    var left = 0;
    var top = 0;
    var screenX = 0;
    var screenY = 0;
    var height = 500;
    var width = 720;
    var menubar = 0;
    var scrollbars = 0;
    var titlebar = 0;
    var directories = 0;
    var fullscreen = 0;
    var status = 1;
    var toolbar = 0;
    var location = 0;
    var resizable = 0;

    var windowFeatures = buildWindowFeaturesString(
      left,
      top,
      screenX,
      screenY,
      height,
      width,
      menubar,
      scrollbars,
      titlebar,
      directories,
      fullscreen,
      status,
      toolbar,
      location,
      resizable);

    popup(windowURL, "popup_fixed", windowFeatures);
}

function popupOptimum(windowURL) {

    var left = 0;
    var top = 0;
    var screenX = 0;
    var screenY = 0;
    var height = (screen.availHeight - 50);
    var width = (screen.availWidth - 10);
    var menubar = 0;
    var scrollbars = 0;
    var titlebar = 0;
    var directories = 0;
    var fullscreen = 0;
    var status = 1;
    var toolbar = 0;
    var location = 0;
    var resizable = 1;


    var windowFeatures = buildWindowFeaturesString(
      left,
      top,
      screenX,
      screenY,
      height,
      width,
      menubar,
      scrollbars,
      titlebar,
      directories,
      fullscreen,
      status,
      toolbar,
      location,
      resizable);

    popup(windowURL, "popup_optimum", windowFeatures);

}

function popup(windowURL, windowName, windowFeatures) {

    var popupWindow = window.open(windowURL, windowName, windowFeatures);
    popupWindow.focus();

}

function popupTest() {

    var left = 5000;
    var top = 5000;
    var screenX = 5000;
    var screenY = 5000;
    var height = 1;
    var width = 1;
    var menubar = 0;
    var scrollbars = 0;
    var titlebar = 0;
    var directories = 0;
    var fullscreen = 0;
    var status = 0;
    var toolbar = 0;
    var location = 0;
    var resizable = 1;


    var windowFeatures = buildWindowFeaturesString(
      left,
      top,
      screenX,
      screenY,
      height,
      width,
      menubar,
      scrollbars,
      titlebar,
      directories,
      fullscreen,
      status,
      toolbar,
      location,
      resizable);

    var popupTest = window.open("", "popup_test", windowFeatures);
    if (!popupTest && document.location.href.indexOf("popup_blocked") == -1) {
        var querystring = "popup_blocked=true";
        if (document.location.href.indexOf("?") == -1) {
            querystring = "?" + querystring;
        } else {
            querystring = "&" + querystring;
        }
        document.location.href = document.location.href + querystring;
    } else {
        if (popupTest != null) {
            popupTest.close();
        }
    }

}

function toggleDiv(id){
  var obj = document.getElementById(id);
  if (obj.className == 'hidden'){
    obj.className = 'visible';
  }
  else {
    obj.className = 'hidden';
  }
}

function validateFormParcel() {
  if (document.agreeForm.agree.checked == false) {
     alert("You must agree to the terms and conditions");
  } else {
     popupOptimum('/imf51002/imf.jsp?site=rdos_public');
     //window.close();
  }
}

function validateFormTrails() {
  if (document.agreeForm.agree.checked == false) {
     alert("You must agree to the terms and conditions");
  } else {
     popupOptimum('/imf51002/imf.jsp?site=rdos_trails');
     //window.close();
  }
}

function validateFormParcelNew() {
  if (document.agreeForm.agree.checked == false) {
     alert("You must agree to the terms and conditions");
  } else {
    var left = 0;
    var top = 0;
    var screenX = 0;
    var screenY = 0;
    var height = (screen.availHeight - 50);
    var width = (screen.availWidth - 10);
    var menubar = 0;
    var scrollbars = 0;
    var titlebar = 0;
    var directories = 0;
    var fullscreen = 0;
    var status = 1;
    var toolbar = 0;
    var location = 0;
    var resizable = 1;


    var windowFeatures = buildWindowFeaturesString(
      left,
      top,
      screenX,
      screenY,
      height,
      width,
      menubar,
      scrollbars,
      titlebar,
      directories,
      fullscreen,
      status,
      toolbar,
      location,
      resizable);
      
      //window.open('/imf51002/imf.jsp?site=rdos_public&checked=true','_self',windowFeatures);
      window.open('/imf51002/sites/rdos/jsp/disclaimerCheckPublic.jsp?checked=true','_self',windowFeatures);
  }
}

function validateFormTrailsNew() {
  if (document.agreeForm.agree.checked == false) {
     alert("You must agree to the terms and conditions");
  } else {
    var left = 0;
    var top = 0;
    var screenX = 0;
    var screenY = 0;
    var height = (screen.availHeight - 50);
    var width = (screen.availWidth - 10);
    var menubar = 0;
    var scrollbars = 0;
    var titlebar = 0;
    var directories = 0;
    var fullscreen = 0;
    var status = 1;
    var toolbar = 0;
    var location = 0;
    var resizable = 1;


    var windowFeatures = buildWindowFeaturesString(
      left,
      top,
      screenX,
      screenY,
      height,
      width,
      menubar,
      scrollbars,
      titlebar,
      directories,
      fullscreen,
      status,
      toolbar,
      location,
      resizable);
      
      //window.open('/imf51002/imf.jsp?site=rdos_trails','_self',windowFeatures);
      window.open('/imf51002/sites/rdos/jsp/disclaimerCheckTrails.jsp?checked=true','_self',windowFeatures);
  }
}

function validateFormCemeteryNew() {
  if (document.agreeForm.agree.checked == false) {
     alert("You must agree to the terms and conditions");
  } else {
    var left = 0;
    var top = 0;
    var screenX = 0;
    var screenY = 0;
    var height = (screen.availHeight - 50);
    var width = (screen.availWidth - 10);
    var menubar = 0;
    var scrollbars = 0;
    var titlebar = 0;
    var directories = 0;
    var fullscreen = 0;
    var status = 1;
    var toolbar = 0;
    var location = 0;
    var resizable = 1;


    var windowFeatures = buildWindowFeaturesString(
      left,
      top,
      screenX,
      screenY,
      height,
      width,
      menubar,
      scrollbars,
      titlebar,
      directories,
      fullscreen,
      status,
      toolbar,
      location,
      resizable);
      
      //window.open('/imf51002/imf.jsp?site=naramata_cemetery','_self',windowFeatures);
      window.open('/imf51002/sites/rdos/jsp/disclaimerCheckCemetery.jsp?checked=true','_self',windowFeatures);
  }
}