function StyleDbMainCtl(strDataJson)
{
    this.Construct = function() 
    {
        var strId = this.m_strId;

        var elemDivCtl = document.getElementById(strId);
        this.m_elemDivCtl = elemDivCtl;
        //this.SetupElems();
    }
    
    this.SetFromElem = function(strPage)
    {
        var elemTd = document.getElementById(strPage);
        this.m_elemDiv.innerHTML = elemTd.innerHTML;
    }

    this.SetProperty = function(strName, oValue)
    {
        this.m_arrProps[strName] = oValue;
    }

    this.OnLoad = function()
    {
        var strTabContainer = this.m_arrProps["tabpanel"];
        var elemTab = g_arrControls[strTabContainer];

        var strDesignCtlId = this.m_arrProps["designctl"];
        this.m_ctlDesignCode  = g_arrControls[strDesignCtlId];

        //this.m_ctlDesignCode.DoOnload("5", this.m_strId);
    }
    
    this.getChildElementById = function(strId)
    {
        return getChildNodeIdOf(this.m_elemDivCtl, strId);
    }

    this.HandleXmlCmd = function (oCmd, strResultId, nRow, nCount)
    {
    }

    //@
    //public
    this.TestManage = function () {
        this.UpdateStyleData();
    }

    this.CreateDBBackup = function (cmds, strType) {

        //sqlupdatehex
        cmds.CmdStartTag("backupdb");
        cmds.CmdPair("id", "idid");
        cmds.CmdPair("tagname", "ph");

        cmds.CmdPair("backuptype", strType);

        cmds.CmdPair("db", "financedb2");
        cmds.CmdPair("user", "copycatcher");
        cmds.CmdPair("pass", "copycatcher");
        cmds.CmdCloseAttribs();

        //cmds.SqlDataStart();
        //cmds.SqlDataValue("datacol", "xyz");
        //cmds.SqlDataEnd();

        cmds.CmdEnd("backupdb");
    }

    this.UpdateStyleData = function () {

        var cmds = new XmlCmds();
        cmds.PrepareId(0);

        this.CreateDBBackup(cmds, "test");

        cmds.EndPrepare();
        var strCmds = cmds.GetXml();

        var req = NewXmlHttp();
        var func = CreateDelegate(this.m_strId, "UpdateStyleDataCtd");
        req.onreadystatechange = function () {
            if (req.readyState == 4 && req.status == 200) {
                func(req.responseText);
            }
        }
        PostReqData(req, strCmds);
    }

    this.UpdateStyleDataCtd = function (strResponse) {
        var strDataJsonEval = "(" + strResponse + ")";
        var objResults = eval(strDataJsonEval);

        var strResultId = objResults.result.id;
        var arrCmds = objResults.result.cmd;
        var i, nCount = arrCmds.length;

        var oCmd0 = arrCmds[0];
        if (oCmd0.success != "true") {
            alert(HexToString(oCmd0.errorstr));
            return;
        }

        this.BackupDone();

    }

    this.BackupDone = function () {
        //var ctlLoadMenus = GetCtlElemNamed("m_ctlLoadMenus");
        //ctlLoadMenus.RefreshStyleTxtData();

        this.m_ctlDesignCode.SetStylePropsDBAll();
        
        var func = CreateDelegate(this.m_strId, "PostBackupSaved ");
        this.m_ctlDesignCode.UpdateStylePropsOnServer(func);
    }

    this.PostBackupSaved = function () {
        toastr.info('Web site has now been updated', 'Information');
    }

    //public
    this.LoadPage = function () {
        var oData = GetOrigArgObject(arguments);

        var strPageIs = oData.keyid;
        var strLink = oData.recid;

        if (this.m_ctlDesignCode) {
            //var str=this.m_arrProps["linklayouts"];
            //this.m_ctlDesignCode.SetLinkStr(strLink);
            this.m_ctlDesignCode.DoOnload(strPageIs, this.m_strId);
        }
    }

    //copy and paste here to .htm

    //end copy and paste here to .htm
    
    //Constuctor
    var strDataJsonEval = "({" + strDataJson + "})";

    this.m_objJson = eval(strDataJsonEval);
    this.m_strId = this.m_objJson.id;

    this.m_arrProps = new Array();
    this.m_strXmlTag = "tagStyleDbMainCtl";

    this.m_ctlDesignCode = null;
}
