Function.prototype.bind = function(object)
	{
	var method = this;
	return function(){return method.apply(object, arguments)};
	}

function wait_please_tools(debug)
	{
	function init()
		{
		//var tool_obj=eval(tool_obj_name_str);
		//alert(tool_obj);
		this.trace('write object[image_tag] to document');
		//document.open();
		document.writeln('<img id="'+String(this.object_id_str)+'" src="'+String(this.object_image_path_str)+'" border="0" hspace="0" vspace="0" alt=""  style="position:absolute; display:none; z-index:'+String(this.object_zindex_num)+';"/>');
		}

	function set_position(top_offset,left_offset)
		{
		this.top_offset=((top_offset!=null) && !isNaN(top_offset))?Number(top_offset):null;
		this.left_offset=((left_offset!=null) && !isNaN(left_offset))?Number(left_offset):null;
		}
	
	function recalc_position()
		{
		if(this.top_offset==null)
			{
			this.top_offset_in=Math.floor(Number(document.body.clientHeight/2));
			}
		else
			{
			this.top_offset_in=Math.floor(Number(this.top_offset));
			}
		
		if(this.left_offset==null)
		
			{
			this.left_offset_in=Math.floor(Number(document.body.clientWidth/2));
			}
		else
			{
			this.left_offset_in=Math.floor(Number(this.left_offset));
			}

		}

	function start()
		{
		var obj=this.get_obj();
		if(obj)
			{
			if(obj.style && obj.style.display)
				{
				obj.style.display='block';
				if(!(this.refresh_timer))
					{
					this.trace('wait_please_tool.start: starting refresh because timer is null');
					this.refresh();
					}
				}
			else
				{
				this.trace('wait_please_tools.start: невозможно получить стиль display объекта');
				}
			}
		}

	function stop()
		{
		var obj=this.get_obj();
		if(obj)
			{
			if(obj.style && obj.style.display)
				{
				obj.style.display='none';
				if(this.refresh_timer)
					{
					this.trace('wait_please_tool.stop: stoping refresh because timer is not null');
					clearTimeout(this.refresh_timer);
					this.refresh_timer=null;
					}
				}
			else
				{
				this.trace('wait_please_tools.stop: невозможно получить стиль display объекта');
				}
			}
		}

		
	function refresh()
		{
		this.refresh_timer=setTimeout(function(){this.refresh()}.bind(this),this.refresh_timer_rest);
		var obj=this.get_obj();
		this.recalc_position();
		this.status('wait_please_tool.refresh().->'+String(Math.random())+'->('+String(this.top_offset_in)+'x'+String(this.left_offset_in)+')');
		if(obj)
			{
			if(Number(this.top_offset_in)>=0 && Number(this.left_offset_in)>=0)
				{
				obj.style.top=this.top_offset_in;
				obj.style.left=this.left_offset_in;
				obj.title=String(this.object_title_str);
				}
			else
				{
				this.trace('wait_please_tools.refresh: this.top_offset_in('+String(this.top_offset_in)+') и this.left_offset_in('+String(this.left_offset_in)+') должны быть более нуля.');
				}
			}
		}
		
	function get_obj()
		{
		var obj=document.getElementById(this.object_id_str);
		if(!(obj))
			{
			this.trace('wait_please_tools.get_obj: document.getElementById('+this.object_id_str+') не вернул ничего. Видимо объект не проинстализирован в документе');
			}
		return obj;
		}

	function trace(str,force)
		{
		if(this.debug || force)
			{
			alert(str);
			}
		}
		
	function status(str,force)
		{
		if(this.debug || force)
			{
			window.status=String(str);
			}
		}
	//var iConnId,oArray;
	//oArray=document.location.href.match(/\d+/g);
	//iConnId=oArray[1];
	//if(iConnId===undefined)iConnId=1;
	//Request.QueryString[sVar]
	function sValue(sVar)
	{
		var str=String(document.location.search).substring(1);
		var arr=str.split('&');
		var re=new RegExp("%([0-9A-F]{2})","ig");
		var sReturn="";
		var i=0;
		var iMax=arr.length-1;
		for(i=0;i<=iMax;++i)
		{
			var arr2=String(arr[i]).split('=',2);
			var key=arr2[0];
			var val=arr2[1];
			//alert(String(key)+'->'+(String(val).replace(re,String.fromCharCode("$1"))));
			val=String(val).replace(re,unescape("$1"));
			if(key.toLowerCase()==sVar.toLowerCase())
			{
				sReturn=val;
				i=iMax;
			}//if
		}//for
		return sReturn;
	}//sValue
		
	
	
	this.debug=debug;
	//this.tool_obj_name_str=(typeof(tool_obj_name_str)=="String")?String(tool_obj_name_str):'';
	this.top_offset_in=-1;
	this.left_offset_in=-1;
	this.top_offset=null;
	this.left_offset=null;

	this.object_title_str='Wait 	please';
	this.object_id_str='wait_please_animated_picture_'+String(Math.random())+'_id';
	this.object_image_path_str='/images/gif/Image-024.gif?'+String(Math.random());
	this.object_zindex_num=255;
	
	this.init=init;
	this.trace=trace;
	this.status=status;
	this.get_obj=get_obj;
	this.init=init;
	this.start=start;
	this.stop=stop;
	this.refresh=refresh;
	this.set_position=set_position;
	this.recalc_position=recalc_position;
	
	this.refresh_timer=null;
	this.refresh_timer_rest=400;
	
	this.sValue=sValue;
	}