
function popup(width, height, url, top, left, returnResult)
{


    if (width > screen.availWidth)
    {
        width = (screen.availWidth - 100)
    }
    if (height > screen.availHeight)
    {
        height = (screen.availHeight - 100)
    }
    if (top == null) top = (screen.availHeight - height) / 2;
    if (left == null) left = (screen.availWidth - width) / 2;
    var args = "scrollbars=yes,toolbar=no,directories=no,menubar=no,resizable=yes," + "status=no,width=" + width + ",height=" + height + ",top=" + top + ",left=" + left;
    // create a window name with _ in place of any non-word characters
    var windowName = url.replace(/\W/g, "_");
    var popWindow = window.open(url, windowName, args);
    popWindow.focus();
    // if we always return this, some browsers show a page with the text: [object]
    if (returnResult == true)
    {
        return popWindow;
    }
}

function popupName(width, height, url, top, left, returnResult,windowName)
{


    if (width > screen.availWidth)
    {
        width = (screen.availWidth - 100)
    }
    if (height > screen.availHeight)
    {
        height = (screen.availHeight - 100)
    }
    if (top == null) top = (screen.availHeight - height) / 2;
    if (left == null) left = (screen.availWidth - width) / 2;
    var args = "scrollbars=yes,toolbar=no,directories=no,menubar=no,resizable=yes," + "status=no,width=" + width + ",height=" + height + ",top=" + top + ",left=" + left;
    // create a window name with _ in place of any non-word characters
    //var windowName = url.replace(/\W/g, "_");
    var popWindow = window.open(url, windowName, args);
    popWindow.focus();
    // if we always return this, some browsers show a page with the text: [object]
    if (returnResult == true)
    {
        return popWindow;
    }
}



function taxPopup(width, height, url, top, left, returnResult, scrollbars, resizable, status, toolbar,menubar) {
  if ( width > screen.availWidth ) {
    width = (screen.availWidth - 100)
  }
  if ( height > screen.availHeight ) {
    height = (screen.availHeight - 100)
  }
  if ( top == null ) top = (screen.availHeight - height) / 2;
  if ( left == null ) left = (screen.availWidth - width) / 2;
  if (scrollbars == null) {
    scrollbars = "yes";
  }
  if (resizable == null) {
    resizable = "yes";
  }

  if (status == null) {
    status = "no";
  }
  if (toolbar == null) {
    toolbar = "no";
  }
 if (menubar == null) {
    menubar = "no";
  }
  var args = "scrollbars="+scrollbars+",toolbar="+toolbar+",directories=no,menubar="+menubar+",resizable="+resizable+"," +"status="+status+",width=" + width + ",height=" + height + ",top=" + top + ",left=" + left;
  // create a window name with _ in place of any non-word characters
  var windowName = url.replace(/\W/g, "_");
  var popWindow = window.open(url, windowName, args);
  popWindow.focus();
  // if we always return this, some browsers show a page with the text: [object]
  if (returnResult == true){
    return popWindow;
  }
}

function popupFormSubmit(width, height, url, top, left, returnResult, form)
{

    if (width > screen.availWidth)
    {
        width = (screen.availWidth - 100)
    }
    if (height > screen.availHeight)
    {
        height = (screen.availHeight - 100)
    }
    if (top == null) top = (screen.availHeight - height) / 2;
    if (left == null) left = (screen.availWidth - width) / 2;
    var args = "scrollbars=yes,toolbar=no,directories=no,menubar=no,resizable=yes," + "status=no,width=" + width + ",height=" + height + ",top=" + top + ",left=" + left;
    // create a window name with _ in place of any non-word characters
    //var windowName = url.replace(/\W/g, "_");
    windowName = "popup";
    var popWindow = window.open("/dlm/dlmReports/popupMessage.jsp", windowName, args);

    popWindow.focus();
    // if we always return this, some browsers show a page with the text: [object]
    if (returnResult == true)
    {
        return popWindow;
    }

    form.action = url;
    //.onsubmit not fired when calling .submit directly from code
    //form.onsubmit = function() { openTarget(this, 'width=300,height=300,resizable=1,scrollbars=1'); }

    form.target = windowName;
    form.method = 'POST';

    form.submit();
    popWindow.focus();
}

function popupFormSubmitNoSize(url, form)
{

    var args = "scrollbars=yes,toolbar=no,directories=no,menubar=no,resizable=yes,status=no";
    // create a window name with _ in place of any non-word characters
    //var windowName = url.replace(/\W/g, "_");
    windowName = "popup";
    var popWindow = window.open("/dlm/dlmReports/popupMessage.jsp", windowName, args);
    popWindow.focus();

    form.action = url;
    //.onsubmit not fired when calling .submit directly from code
    //form.onsubmit = function() { openTarget(this, 'width=300,height=300,resizable=1,scrollbars=1'); }

    form.target = windowName;
    form.method = 'POST';

    form.submit();
    popWindow.focus();
}
function popupFormSubmitPDF(width, height, url, top, left, returnResult, form)
{

    if (width > screen.availWidth)
    {
        width = (screen.availWidth - 100)
    }
    if (height > screen.availHeight)
    {
        height = (screen.availHeight - 100)
    }
    if (top == null) top = (screen.availHeight - height) / 2;
    if (left == null) left = (screen.availWidth - width) / 2;
    var args = "scrollbars=yes,toolbar=no,directories=no,menubar=no,resizable=yes," + "status=no,width=" + width + ",height=" + height + ",top=" + top + ",left=" + left;
    // create a window name with _ in place of any non-word characters
    //var windowName = url.replace(/\W/g, "_");
    windowName = "popup";
    var savedReportId = form.savedReportId.value;
    var popWindow = window.open("/DlmPdfServlet.pdf?savedReportId="+savedReportId, windowName, args);

    popWindow.focus();
    // if we always return this, some browsers show a page with the text: [object]
    if (returnResult == true)
    {
        return popWindow;
    }

    form.action = url;
    //.onsubmit not fired when calling .submit directly from code
    //form.onsubmit = function() { openTarget(this, 'width=300,height=300,resizable=1,scrollbars=1'); }

    form.target = windowName;
    form.method = 'POST';

    form.submit();
    popWindow.focus();
}
function popupFormSubmitName(width, height, url, top, left, returnResult, form, name)
{

    if (width > screen.availWidth)
    {
        width = (screen.availWidth - 100)
    }
    if (height > screen.availHeight)
    {
        height = (screen.availHeight - 100)
    }
    if (top == null) top = (screen.availHeight - height) / 2;
    if (left == null) left = (screen.availWidth - width) / 2;
    var args = "scrollbars=yes,toolbar=no,directories=no,menubar=no,resizable=yes," + "status=no,width=" + width + ",height=" + height + ",top=" + top + ",left=" + left;
    // create a window name with _ in place of any non-word characters
    //var windowName = url.replace(/\W/g, "_");
    var windowName = "popup";
    if (name != null) windowName = name;
    var popWindow = window.open("/dlm/dlmReports/popupMessage.jsp", windowName, args);

    popWindow.focus();
    // if we always return this, some browsers show a page with the text: [object]
    if (returnResult == true)
    {
        return popWindow;
    }

    form.action = url;
    //.onsubmit not fired when calling .submit directly from code
    //form.onsubmit = function() { openTarget(this, 'width=300,height=300,resizable=1,scrollbars=1'); }

    form.target = windowName;
    form.method = 'POST';

    form.submit();
    popWindow.focus();
}

function sendEmailOrEcard(form) {

    alert(form);

}

function resetFormSelfSubmit(form, url){
      form.target = '_self';
      form.action = url;
      form.submit();

}

function resetFormSelfSubmitAjax(form, url){
      form.target = '_self';
      form.action = url;
      loadDlmData(true);
      //form.submit();
}


function submitFormReset(form, url){
      form.target = '_self';
      form.action = url;
      form.submitType.value='reset'
      form.submit();

}


function submitToPopup(form, args) {

    form.action = '/dlm/dlmReports/outputExcel.jsp';

    form.target = 'newpopup';
    form.method = 'POST';

    window.open('', 'newpopup', args);
    form.submit();
}

