    var WIZ_CONFIG_FILE_TYPE = "json";
    var WIZ_SELF_CONFIG_FILE_NAME = "config.json";
    //
    var g_objApp = null;
    var g_objCmn = null;
    //
    function GetUrlParam(name) {
        var reg = new RegExp("[?&]" + name + "=([^?&]*)[&]?", "i");
        var match = location.href.match(reg);
        return match == null ? "" : match[1];
    }
    function TOLOG(strLog) {
        try {
            if (g_objApp) {
                g_objApp.WriteToLog("OEM_GROUP_QUICK_CLASSIFY: " + strLog);
            }
        }
        catch (e) {
        }
    }
    function TOLOG1(strLog, param) {
        strLog = strLog.replace("%1", param);
        //
        TOLOG(strLog);
    }
    function TOLOG2(strLog, param0, param1) {
        strLog = strLog.replace("%1", param0).replace("%2", param1);
        //
        TOLOG(strLog);
    }
    function TOLOG3(strLog, param0, param1, param2) {
        strLog = strLog.replace("%1", param0)
        			   .replace("%2", param1)
        			   .replace("%3", param2);
        //
        TOLOG(strLog);
    }

    //
    function getArray(obj) {

    }

    function SafeArrayToJS(safeArray) {
        try {
            var arr = (new VBArray(safeArray)).toArray();
            return arr;
        }
        catch (err) {
            return safeArray;
        }    
    }
    function Remove_r_n_t(strText) {
        if (!strText)
            return strText;
        //
        strText = strText.replace(/[\n\t\r]/ig, '');
        return strText;
    }
    function CloneArray(arrayIn) {
        if (!IsArray(arrayIn))
            return;
        var arrayOut = [];
        for (var i = 0; i < arrayIn.length; i ++) {
            arrayOut.push(arrayIn[i]);
        }
        //
        return arrayOut;
    }
    function IsArray(array) {
        return (array instanceof Array);
    }
    function IsAChildArray(arrayParent, arrayChild) {
        if (!IsArray(arrayChild) || !IsArray(arrayParent))
            return false;
        //
        if ((arrayChild.length == 0 && arrayParent.length != 0) 
        	|| (arrayChild.length != 0 && arrayParent.length == 0))
            return false;
        // 
        for (var i = 0; i < arrayChild.length; i++) {
            var bIn = false;
            for (var j = 0; j < arrayParent.length; j++) {
                if (arrayChild[i] == arrayParent[j]) {
                    bIn = true;
                    break;
                }
            }
            //
            if (!bIn)
                return false;
        }
        //
        return true;
    }
    function CompareArray(array1, array2) {
        if (!(array1 instanceof Array) || !(array2 instanceof Array))
            return false;
        //
        if ((array1.length == 0 && array2.length != 0)
			|| (array1.length != 0 && array2.length == 0))
            return false;
        //
        return IsAChildArray(array1, array2) && 
        		IsAChildArray(array2, array1);
    }
    function RemoveHollowElement(array) {
        if (!IsArray(array))
            return;
        var arrayNew = [];
        for (var i = 0; i < array.length; i ++) {
            if (array[i]) {
                arrayNew.push(array[i]);
            }
        }
        //
        return arrayNew;
    }
    function CompareObject(obj1, obj2){
        if(obj1 == obj2) 
            return true;
        if(typeof(obj2)=="undefined"||obj2==null||typeof(obj2)!="object") 
            return false;
        var length = 0; var length1=0;
        for(var ele in obj1) {
            length++;
        }               
        for(var ele in obj2) {
            length1++;
        }               
        if(length!=length1) 
            return false;
        if(obj2.constructor==obj1.constructor){
            for(var ele in obj1){
                if(typeof(obj1[ele])=="object") {
                    if(!CompareObject(obj1[ele], obj2[ele]))
                        return false;
                }
                else if(typeof(obj1[ele])=="function"){
                    if(!CompareObject(obj1[ele].toString(), obj2[ele].toString())) 
                        return false;
                }
                else if(obj1[ele]!=obj2[ele]) 
                    return false;
            }
            return true;
        }
        return false;
    };
    function setSelectionRange(input, selectionStart, selectionEnd) {
      if (input.setSelectionRange) {
        input.focus();
        input.setSelectionRange(selectionStart, selectionEnd);
      }
      else if (input.createTextRange) {
        var range = input.createTextRange();
        range.collapse(true);
        range.moveEnd('character', selectionEnd);
        range.moveStart('character', selectionStart);
        range.select();
      }
    }

    function setCaretToPos (input, pos) {
      setSelectionRange(input, pos, pos);
    }            
    //////////////////////////////////////////////////////////////////////
    function WizSaveTextToFile(strFileName, strText) {
        if (!g_objCmn) {
            TOLOG("Can't to save text to file, g_objCmn is invalid.");
            return;
        }
        //
        try {
            g_objCmn.SaveTextToFile(strFileName, strText, "unicode");
        } catch (e) {
            TOLOG1("Failed to call SaveTextToFile, filename: %1", 
            	strFileName);
            alert(e);
        }
    }
    function WizLoadTextFromFile(strFileName) {
        if (!g_objCmn) {
            TOLOG("WizLoadTextFromFile, g_objCmn is invalid.");
            return;
        }
        //
        var strText;
        try {
            strText = g_objCmn.LoadTextFromFile(strFileName);
        } catch(e) {
            TOLOG1("Failed to call LoadTextFromFile, e: %1", e);
            return;
        }
        //
        return strText;
    }
    function WizGetDataStorePath() {
        if (!g_objApp)
            return;
        //
        return g_objApp.DataStore;
    }
    function WizCloseWindow(retValue) {
        
        if (!g_objApp)
            return;
        if (!retValue)
            retValue = 0;
        //
        g_objApp.Window.CloseHtmlDialog(document, retValue);
    }
    function WizLocalizeCurrentDocument(strFileName) {
        if (!g_objApp)
            return;
        //
        g_objApp.LocalizeHtmlDocument(strFileName, document);
    }
    //////////////////////////////////////////////////////////////////////
    function WizInit() {
	    if (g_objApp) {
	        return;
	    }
	    try {
	        g_objApp = window.external;
	        g_objCmn = g_objApp.CommonUIObject;
	    }
	    catch (err) {
	        g_objApp = new ActiveXObject("WizExplorer.WizExplorerApp");
	        g_objCmn = g_objApp.CommonUIObject;
	    }
	    if (!g_objApp)
	    	return;
	    //
        try {
            g_objCmn = g_objApp.CreateWizObject("WizKMControls.WizCommonUI");
        }
        catch (err) {
            g_objCmn = new ActiveXObject("WizKMControls.WizCommonUI");
        }
    }