//initialize
function wnInit(swebnote_obj){
	var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

	var o=new Object();
	o.wnObj=swebnote_obj;
	o.wnTStr=new Array("freeline","curve","line","clean","object");


	o.wnSetData=function(param,obj){
		this.wnObj.SetVariable(param,obj);
	};
	o.wnGetData=function(param){
		return this.wnObj.GetVariable(param);
	};
	o.wnCallFunction=function(f_name,obj,obj2){
		if(obj!=undefined)
			f_name+="\t"+obj;
		if(obj2!=undefined)
			f_name+="\t"+obj2;
		this.wnSetData("callf",f_name);
	};
	o.wnAddMenu=function(str_label){
		this.wnCallFunction("mAddMenu",str_label);
	};
	if(!isInternetExplorer){
		o.__defineGetter__("wnType",function(){return this.wnGetData("mg_type");});
		o.__defineSetter__("wnType",function(obj){return this.wnSetData("mg_type",obj);});
	
		o.__defineGetter__("wnSize",function(){return this.wnGetData("mg_size");});
		o.__defineSetter__("wnSize",function(obj){return this.wnSetData("mg_size",obj);});
	
		o.__defineGetter__("wnAlpha",function(){return this.wnGetData("mg_alpha");});
		o.__defineSetter__("wnAlpha",function(obj){return this.wnSetData("mg_alpha",obj);});
	
		o.__defineGetter__("wnColor",function(){return this.wnGetData("mg_color");});
		o.__defineSetter__("wnColor",function(obj){return this.wnSetData("mg_color",obj);});
	
		o.__defineGetter__("wnFill",function(){return this.wnGetData("mg_fill");});
		o.__defineSetter__("wnFill",function(obj){return this.wnSetData("mg_fill",obj);});
		
		o.__defineGetter__("wnLayer",function(){return this.wnGetData("mg_layer");});
		o.__defineSetter__("wnLayer",function(obj){return this.wnSetData("mg_layer",obj);});
		
	
		
		o.__defineGetter__("wnTypeStr",function(){return this.wnTStr[this.wnType];});
		o.__defineSetter__("wnTypeStr",function(obj){
			for(var i=0;i<this.wnTStr.length;i++){
				if(this.wnTStr[i]==obj){
					this.wnType=i;
					return obj;
				}
			}
			return obj;
		});
	}
	o.wnInitServer=function(){
		document.write('<iframe name="wn_server" width="1" height="1" scrolling="false" frameborder="0"></iframe>');
	}
	o.wnSendToServer=function(url,str){
		window.wn_server.location.href=url+"?"+str;
	}
	o.wnRefresh=function(){
		this.wnCallFunction("mRefreshJS");
	};
	o.wnSetStatus=function(status_xml){
		this.wnCallFunction("mSetXML",status_xml);
	}
	o.wnCommand=function(xml_str){
		this.wnCallFunction("mCommand",xml_str);
	};
	o.wnAddImage=function(name_str,url_str,x,y,layer){
		if(layer==null)
			layer=this.wnLayer;
		this.wnCommand('<obj type="object" name="'+name_str+'" x="'+x+'" y="'+y+'" layer="'+layer+'">'+url_str+"</obj>");
	}
	o.wnMoveImage=function(name_str,x,y,z){
		var l_str=(z==null)? "" : "z="+z;
		this.wnCommand('<obj type="object" name="'+name+'" x="'+x+'" y="'+y+'" '+l_str+'></obj>');
	}
	o.wnRemoveImage=function(name_str){
		this.wnCommand('<obj type="object" name="'+name_str+'" remove="1"></obj>');
	}
	o.wnSend=function(){
		this.wnCallFunction("mSend");
	};
	o.wnSendStr=function(str){
		this.wnCallFunction("mSend",str);
	}
	o.wnLogin=function(id_str,pass_str){
		this.wnCallFunction("mLogin",id_str,pass_str);
	};
	o.wnSetCursor=function(url_str){
	
		var str;
		if(url_str!=null&&url_str.length>0)
			str='<cursor url="'+url_str+'" />';
		else
			str="<cursor />";
		this.wnCommand(str);
	};
	return o;
}