function IntermecScannerApi() {
    var self = {};

    self.activeWindow = {};
    self.scanObj = null;

    self.isInitialized = false;
    self.canUseIntermecApi = false;

    self.EnableScanner = function (isChecked) {
        if (self.scanObj == null) {
            self.scanObj = new MyScanner();
            if (self.scanObj == null) {
                //alert('You have not Created the Sensor');            
            }
            else {
                self.scanObj.enablebarcode = isChecked;
            }
        }
    }

    self.ScannerNavigate=function(data, type, time) {
        //alert('Value received');
        //alert(data);
    }
    self.addScannerOutput = function (newOutput) {
        //alert('Value received');
        //alert(newOutput);
        if (self.activeWindow.handleScannedValues) {
            //alert('We can Parse Data');
            self.activeWindow.handleScannedValues(newOutput);
        }

    }

    self.init = function () {
        if (self.isInitialized == false) {
            try {
                console.log('initializing scanner object');
                if (self.scanObj == null) {
                    //alert('initializing scanner');
                    self.scanObj = new MyScanner();
                    self.scanObj.enablebarcode = true;
                    //alert("done");                    
                    self.canUseIntermecApi = true;
                }
            }
            catch (err) {
                //alert('in err');
                //alert(err);
            }
            self.isInitialized = true;
        }
        else {
            //alert('Intermec Is initialized');
            console.log('Intermec Is initialized');
        }
        self.isInitialized = true;
    }
    return self;
}

var intermecscannerapi = IntermecScannerApi();

