﻿//Note: The logic behind this code are used from ANTHEM.JS [ANTHEM.NET] and some of the JS methods used here are copied from anthem.js
//http://www.koders.com/javascript/fidDEA7EA7869F327B1610632C5A89D895B726DB8AC.aspx

// Main Function
//Post() gets called upon Submit button's click [Button2]
function post(name) {
    action = "?ifra=1&name=" + name;
    var id = 'ifra';
    var ioframe = null;
    if (window.ActiveXObject) {
        ioframe = document.createElement("<iframe name=\"" + id + "\" id=\"" + id + "\" onload=\"Anthem_HandleIOFrameResponse('" + id + "');\"/>");
    } else {
        ioframe = document.createElement("iframe");
        ioframe.id = "ifra";
        ioframe.name = "ifra";
        ioframe.onload = function() { Anthem_HandleIOFrameResponse("ifra"); } //Attach Callback function
    }

    ioframe.style.display = "none";
    ioframe.style.height = "1px";
    document.body.appendChild(ioframe);
    var theForm = Anthem_GetForm();
    var tempActionUri = theForm.action;
    theForm.action = tempActionUri + action;
    theForm.target = id;

    try {
        theForm.submit();
    } catch (e) {
    }

    theForm.target = "";
    theForm.action = tempActionUri;
    return false;
}

// Utility Function
// Returns form object
function Anthem_GetForm() {
    var form = document.getElementById("aspnetForm");
    return form;
}

// Returns the iframe document
function Anthem_ExtractIFrameDocument(iFrameEl) {
    var doc = null;
    if (iFrameEl.contentDocument) { // For NS6
        doc = iFrameEl.contentDocument;
    } else if (iFrameEl.contentWindow) { // For IE5.5 and IE6
        doc = iFrameEl.contentWindow.document;
    } else if (iFrameEl.document) { // For IE5
        doc = iFrameEl.document;
    } else {
        return null;
    }
    return doc;
}

// CallBack Function
function Anthem_HandleIOFrameResponse(frameid) {
    var iframe = document.getElementById(frameid);
    if (iframe != null) {
        setTimeout("document.body.removeChild(document.getElementById(\"" + frameid + "\"))", 10);
    }
    document.forms[0].reset();
    $('UploadProgress').style.display = 'none';
    $('ctl00_body_file').style.display = 'inline';

    TabbedPanels1.showPanel('tabMyLists');
    __doPostBack('ctl00_body_panLists', '');
}
