﻿function edit_listing(ID) {
    var form = document.createElement("form");
    form.setAttribute("method", "post");
    form.setAttribute("action", "/manage-listings.asp");

    var hiddenField = document.createElement("input");
    hiddenField.setAttribute("type", "hidden");
    hiddenField.setAttribute("name", "action");
    hiddenField.setAttribute("value", "Edit Listing");
    form.appendChild(hiddenField);

    var hiddenField = document.createElement("input");
    hiddenField.setAttribute("type", "hidden");
    hiddenField.setAttribute("name", "ID");
    hiddenField.setAttribute("value", ID);
    form.appendChild(hiddenField);

    document.body.appendChild(form);
    form.submit(); 
} 

var IFrameObj;

function update_ajax(ajax_url) {

  if (!document.createElement) {return true};

  var IFrameDoc;

  if (!IFrameObj && document.createElement) {
    try {
      var tempIFrame=document.createElement('iframe');
      tempIFrame.setAttribute('id','RSIFrame');
      tempIFrame.style.border='0px';
      tempIFrame.style.width='0px';
      tempIFrame.style.height='0px';
      IFrameObj = document.body.appendChild(tempIFrame);
      if (document.frames) {
        IFrameObj = document.frames['RSIFrame'];
      }
    } catch(exception) {
      iframeHTML='<iframe id="RSIFrame" style="';
      iframeHTML+='border:0px;';
      iframeHTML+='width:0px;';
      iframeHTML+='height:0px;';
      iframeHTML+='"><\/iframe>';
      document.body.innerHTML+=iframeHTML;
      IFrameObj = new Object();
      IFrameObj.document = new Object();
      IFrameObj.document.location = new Object();
      IFrameObj.document.location.iframe = document.getElementById('RSIFrame');
      IFrameObj.document.location.replace = function(location) {
        this.iframe.src = location;
      }
    }
  }

  if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument) {
    setTimeout('callToServer("'+theFormName+'")',10);
    return false;
  }

  if (IFrameObj.contentDocument) {
    IFrameDoc = IFrameObj.contentDocument; 
  } else if (IFrameObj.contentWindow) {
    IFrameDoc = IFrameObj.contentWindow.document;
  } else if (IFrameObj.document) {
    IFrameDoc = IFrameObj.document;
  } else {
    return true;
  }
  IFrameDoc.location.replace(ajax_url);
  return false;
}

