
function AInstance()
{
	this.handle = 0;
	this.vendor = 0;
	this.index = 0;
	this.ret = 0;
	
	this.InitResource = function(){
		document.getElementById("LivActiveX").InitResource();
	};
		
	this.CloseResource = function(){
		document.getElementById("LivActiveX").CloseResource();
	};
	
	this.FindDevice = function(vendor ,type, pin){
		this.index = document.getElementById("LivActiveX").LivFindDevice(vendor ,type, pin);
		this.vendor = vendor;
		return this.index;
	};
	
	this.open = function(){
		this.handle = document.getElementById("LivActiveX").LivOpen(this.vendor,this.index);
		return this.handle;
	};

	this.close = function(){
		this.ret = document.getElementById("LivActiveX").LivClose(this.handle);
		return this.ret;
	};
	
	this.passwd = function(type , pin){
		this.ret = document.getElementById("LivActiveX").Livpasswd(this.handle,type,pin);
		return this.ret;
	};
	
	this.verify = function(str){
		var MD5Str = document.getElementById("LivActiveX").LivVerify(this.handle, str);
		return MD5Str;
	};
	
	this.hmac = function(is_Hex,text,textlen){
		var degest = document.getElementById("LivActiveX").Livhmac(this.handle,is_Hex, text,textlen);
		return degest;
	};	
	
	this.readfunction = function(block,is_Hex,offset,length){
		this.ret = document.getElementById("LivActiveX").LivRead(this.handle,block,is_Hex,offset,length);
		return this.ret;
	};	
	
	this.getserialnumfuntion = function(is_Hex){
		this.ret = document.getElementById("LivActiveX").LivGetSerialNum(this.handle,is_Hex);
		return this.ret;
	};
	this.writefunction = function(block,is_Hex,offset,length,input_text){
		this.ret = document.getElementById("LivActiveX").LivWrite(this.handle,block,is_Hex,offset,length,input_text);
		return this.ret;
	};	
			
	this.updatefunction = function(buff){
		this.ret = document.getElementById("LivActiveX").LivUpdate(this.handle,buff);
		return this.ret;
	};	
			
	this.setkeyfunction = function(type,is_hex,input_key){
		this.ret = document.getElementById("LivActiveX").LivSetKey(this.handle,type,is_hex,input_key);
		return this.ret;
	};
	this.changepasswdfunction = function(type,is_hex,oldpasswd,newpasswd){
		this.ret = document.getElementById("LivActiveX").LivChangePasswd(this.handle,type,is_hex,oldpasswd,newpasswd);
		return this.ret;
	};
	this.setpasswdfunction = function(type,is_hex,passwd,retries){
		this.ret = document.getElementById("LivActiveX").LivSetPasswd(this.handle,type,is_hex,passwd,retries);
		return this.ret;
	};
	
			
}
