﻿function RegisterNameSpace(ns)
{
    var nsParts = ns.split(".");
    var root = window;

    for(var i=0; i<nsParts.length; i++)
    {
        if(typeof root[nsParts[i]] == "undefined")
        root[nsParts[i]] = new Object();

        root = root[nsParts[i]];
    }
}

RegisterNameSpace("RDI.Utilities.Upload");

RDI.Utilities.Upload =
{
    //
    // AbcDoUpload
    //
    // Used by the WebSupergoo ABC Upload control.
    //
    AbcDoUpload: function (inForm, sApplicationVirtualPath, sHdnUploadButtonClicked)
    {
        if ((typeof(Page_BlockSubmit) == 'boolean') && (Page_BlockSubmit == true)) return;
    
        var oHdnUploadButtonClicked = RDI.Utilities.GetObject(sHdnUploadButtonClicked);
        if (oHdnUploadButtonClicked.value == "false") return;
    
        theFeats = 'height=160,width=600,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no';
        theUniqueID = Math.floor(Math.random() * 1000000) * ((new Date()).getTime() % 1000);
    
        var sPath = location.href.substring(0, location.href.indexOf('\/',location.href.indexOf('\/')+2)) + sApplicationVirtualPath + "/ProgressBar.aspx?ProgressID=" + theUniqueID;
    
        var newWindow = window.open(sPath, theUniqueID, theFeats);
        newWindow.opener = self;
    
        inForm = inForm.document.forms[0];
        thePos = inForm.action.indexOf('?');
    
        if (thePos >= 0) inForm.action = inForm.action.substring(0, thePos);
    
        inForm.action += '?UploadID=' + theUniqueID;
        return true;
    }
}

