WSort=function()
{
	this._div=null;
	this._evObj=null;
	this._timer=null;
	this.mouseOn=true;
	this.adv=false;
	var pg=$("#pgInf")
	if(pg.length>0 && pg[0].innerText!="")
		this.pgInf=pg[0];
	else
		this.pgInf=null;
}
WSort.prototype.init=function(srcObj)
{
	var wTab=srcObj
	var _div=document.createElement("div");
	_div.id="_wSortDiv";
	_div.style.backgroundColor ="#efefef";
	_div.style.borderStyle  ="none";
	_div.style.width="140px";
	_div.style.height="25px";
	_div.style.display="none";
	_div.style.overflow ="hidden";
	_div.style.position="absolute";
	
	_div.innerHTML='<iframe  src="/lib/wSort/wSort.htm" name="_wSortFm" width="100%" height="100%"  scrolling="no" frameborder="0" id="_wSortFm" border="0" ></iframe>'
	document.body.appendChild(_div);
	this._div=_div;
	$("#_wSortFm",_div)[0].wSort=this

	
	var jqDiv=$(_div);
	//jqDiv.bind("mouseout",{wSort:this},function(e){e.data.wSort._div.mouseOn=false;e.data.wSort.hide()});
	jqDiv.bind("mouseout",{wSort:this},function(e){
		e.data.wSort.mouseOn=false;
		try{clearTimeout(e.data.wSort._timer);}catch(err){}
		if(e.data.wSort.adv)
			e.data.wSort._timer=setTimeout(function(){e.data.wSort.hide()},500); 
		else
			e.data.wSort._timer=setTimeout(function(){e.data.wSort.hide()},100); 
	})


	jqDiv.bind("mouseover",{wSort:this},function(e){
		e.data.wSort.mouseOn=true;
		try{clearTimeout(e.data.wSort._timer);}catch(err){}}
	);
	$("body").bind("mousedown",{wSort:this},function(e){
		if(!e.data.wSort._div.mouseOn)
			e.data.wSort.hide()
	})
	
}
WSort.prototype.show=function(srcObj)
{
	if(this.pgInf==null)
		return;
	this.mouseOn=true;
	try{clearTimeout(e.data.wSort._timer);}catch(err){}
	this.srcObj=srcObj;
	if(this._div==null)
		this.init(srcObj);
	else
		$("#_wSortFm",this._div)[0].contentWindow.setSortTit();
	
	var p= $(srcObj).offset();
	var left=p.left;
	var win_wid=$(window).width()
	var jqDiv=$(this._div);//this._div)
	var layer_wid= jqDiv.width()
	if(p.left+layer_wid>win_wid)
		this._div.style.left=win_wid-layer_wid-4;
	else
		this._div.style.left=p.left;
	
	this._div.style.top=p.top+$(srcObj).height()+2;
	this._evObj=srcObj;
	$(srcObj).bind("mouseout",{wSort:this},function(e){
		clearTimeout(e.data.wSort._timer);
		e.data.wSort._timer=setTimeout(function(){e.data.wSort.hide()},100); 
	})
	jqDiv.fadeIn("fast");
}
WSort.prototype.hide=function()
{
	if(!this.mouseOn)
	{
		var jqDiv=$(this._div)
		jqDiv.fadeOut("fast");
	}
		
}
var _wSort=null;
$(document).ready(function(){
	_wSort=new WSort();
});
function wSort(srcObj)
{
	if(_wSort!=null)
		_wSort.show(srcObj);
}


