FloatMsgObj = function (objId, title, e, zindex, showClose)
{
	this.objId = objId;
	this.title = title;
	this.evt = e;
	this.defaultzindex = 600;
	this.zindex = this.defaultzindex+zindex;
	this.showClose = showClose;
	this.init();
}

FloatMsgObj.prototype.init = function()
{
	this.id = "floatMsgObj"+this.objId;
	this.coverId = "floatMsgObjCover"+this.objId;
	this.loadingId = "floatMsgObjLoading"+this.objId;
	this.headId = "floatMsgObjHead"+this.objId;
	this.detailId = "floatMsgObjDetail"+this.objId;
	this.contentId = "floatMsgObjContent"+this.objId;
}
FloatMsgObj.prototype.show = function(content)
{
	var pageSize = this.getPageSize();
	// show cover div
	this.showCover(pageSize[5],pageSize[4]);
	// show loading
	//this.showLoading(pageSize[3]/2+document.documentElement.scrollTop,pageSize[2]/2);
	// show content
	this.showContent(pageSize[3]/2+document.documentElement.scrollTop-200,pageSize[2]/2-250,content);
	HOSSelect(true);
}

FloatMsgObj.prototype.showCover = function(height,width)
{
	var obj = document.getElementById(this.coverId);
	if(!obj)
	{
		var html = "<div id=\"" + this.coverId + "\" style=\"display:;filter:alpha(opacity=30); -moz-opacity:0.3;  opacity: 0.3; background:#000; position:absolute; z-index:"+this.defaultzindex+"; left:0; top:0;height:"+height+"px;width:"+width+"px\" class=\"cover\"></div>";
		//document.write(html);
		$(document.body).append(html);
	}
	obj = document.getElementById(this.coverId);
	if(obj)
	{
		obj.style.height = height + "px";
		obj.style.width = width + "px";
		obj.style.display = "";
	}
}

FloatMsgObj.prototype.showLoading = function(top,left)
{
	var obj = document.getElementById(this.loadingId);
	if(!obj)
	{
		var html = "<div id=\"" + this.loadingId + "\" style=\"display:; position:absolute; z-index:"+(this.defaultzindex+1)+ ";top:"+top+"px;left:"+left+"px\" /><table style=\"width:40px; height:40px; border:0\"><tr><td style=\"text-align:center\"><img border=\"0\" src=\"../ui/themes/common/loading1.gif\" /></td></tr></table></div>";
		//document.write(html);
		$(document.body).append(html);
	}
	obj = document.getElementById(this.loadingId);
	if(obj)
	{
		obj.style.top = top + "px";
		obj.style.left = left + "px";
		obj.style.display = "";
	}
}

FloatMsgObj.prototype.showContent = function(top,left,content)
{
	var obj = document.getElementById(this.detailId);
	if(!obj)
	{
		var html = "<div style='display:; top:"+top+"px;left:"+left+"px;' id='" +this.detailId+ "' class='floatDiv'><div id='"+this.headId+"' style='display:' onmousedown=\"document.onmousemove = mouseMove;document.onmousedown = mouseDown;document.onmouseup = mouseUp;makeDraggable(document.getElementById('"+this.detailId+"'));\" class='headLine'><div class='title'><div class='left11'>"+this.title+"</div></div>";
		if(this.showClose)
		{
			html += "<div class='closeBox' onclick=\"javascript:hideFloatMsgObj('"+this.coverId+"','"+this.headId+"','"+this.contentId+"','"+this.detailId+"');\" onmousedown=\"document.onmousemove = mouseMove;document.onmousedown = mouseDown;document.onmouseup = mouseUp;makeDraggable(document.getElementById('"+this.detailId+"'));\"><img src='../ui/themes/common/close_icon.gif' /></div>";
		}
		html += "</div><div class='contentBox' style='width:"+this.width+";height="+this.height+";' id='"+this.contentId+"'>"+content+"</div></div>";
		//document.write(html);
		$(document.body).append(html);
		//$("#"+this.detailId).dropShadow({left:3, top:7, opacity:0.2, blur:2, color: "#000"});
	}
	obj = document.getElementById(this.detailId);
	if(obj)
	{
		obj.style.top = top + "px";
		obj.style.left = left + "px";
		obj.style.display = "";
	}
}
FloatMsgObj.prototype.resize=function()
{
	var divCover = document.getElementById("divCover");

	if(divCover.style.display!='none')
	{
		var arrayPageSize = getPageSize();
		divCover.style.height = arrayPageSize[5] + "px";
		divCover.style.width = arrayPageSize[4] + "px";
		divCover.style.display="";
	}
}

FloatMsgObj.prototype.fetchPos=function()
{
	var x,y;
	var a = new Array();
	if(!document.all)
	{
		x=this.evt.pageX; 
		y=this.evt.pageY;
		a[0] = x;
		a[1] = y;
	}
	else
	{
		x=document.body.scrollLeft + document.documentElement.scrollLeft+event.clientX;
		y=document.body.scrollTop + document.documentElement.scrollTop+event.clientY; 
		a[0] = x;
		a[1] = y;
	}
	//alert(a);
	return a;
}

FloatMsgObj.prototype.getPageSize=function()
{  
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY)
	{
		xScroll = document.body.scrollWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	}
	else if (document.body.scrollHeight > document.body.offsetHeight)
	{ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	}
	else
	{ // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.scrollWidth;
		//xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight)
	{  // all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{ // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{ // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}  
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight)
	{
		pageHeight = windowHeight;
	}
	else
	{ 
		pageHeight = yScroll;
	}
	
	if(xScroll < windowWidth)
	{  
		pageWidth = windowWidth;
	}
	else
	{
		pageWidth = xScroll;
	}
	
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight,xScroll,yScroll) 
	return arrayPageSize;
}

function getPageSize()
{  
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY)
	{
		xScroll = document.body.scrollWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	}
	else if (document.body.scrollHeight > document.body.offsetHeight)
	{ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	}
	else
	{ // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.scrollWidth;
		//xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight)
	{  // all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{ // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{ // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}  
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight)
	{
		pageHeight = windowHeight;
	}
	else
	{ 
		pageHeight = yScroll;
	}
	
	if(xScroll < windowWidth)
	{  
		pageWidth = windowWidth;
	}
	else
	{
		pageWidth = xScroll;
	}
	
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight,xScroll,yScroll) 
	return arrayPageSize;
}

FloatMsgObj.prototype.hide = function()
{           
    var divCover = document.getElementById(this.coverId);
	divCover.style.display="none";
	var divHead = document.getElementById(this.headId);
	divHead.style.display="none";
    var frmDetail = document.getElementById(this.contentId);    
    frmDetail.style.display='none';  
    var detailDiv = document.getElementById(this.detailId);    
    detailDiv.style.display='none'; 
    HOSSelect(false);
}

function hideFloatMsgObj(coverId,headId,contentId,detailId)
{           
    var divCover = document.getElementById(coverId);
	divCover.style.display="none";
	var divHead = document.getElementById(headId);
	divHead.style.display="none";
    var frmDetail = document.getElementById(contentId);    
    frmDetail.style.display='none';  
    var detailDiv = document.getElementById(detailId);    
    detailDiv.style.display='none'; 
    HOSSelect(false);
}

function HOSSelect(hos)
{
	var sels = document.getElementsByTagName('select'); 
	for (var i = 0; i < sels.length; i++) 
	{
		if(hos)
		{
            sels[i].style.visibility='hidden';
		}
		else
		{
            sels[i].style.visibility='visible';
		}
	}
}
