﻿var theForm;
function appendHidden(name, value) {
  var h = document.createElement("input");
  h.type = "hidden";
  h.name = h.id = name;
  h.value = value;
  theForm.appendChild(h);
}

function postForm(action) {
  if (!theForm) theForm = document.forms[0];
  if (!theForm) { alert("Form element not found"); return; }
  if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
    theForm.action = action;
    theForm.submit();
  }
}

function __doPostBack(eventTarget, eventArgument) {
  if (!theForm) theForm = document.forms[0];
  if (!theForm) { alert("Form element not found"); return; }
  if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
    if (!theForm.__EVENTTARGET) appendHidden("__EVENTTARGET", eventTarget);
    else theForm.__EVENTTARGET.value = eventTarget;
    if (!theForm.__EVENTARGUMENT) appendHidden("__EVENTARGUMENT", eventArgument);
    else theForm.__EVENTARGUMENT.value = eventArgument;
    if (theForm.action != location.href) {
      if (!theForm.__POSTURL) appendHidden("__POSTURL", theForm.action);
      else theForm.__POSTURL.value = theForm.action;
      theForm.action = location;
    }
    if (document.getElementById("invdash")) appendHidden("__INVDASH", "1");
    theForm.submit();    
  }
}

