﻿/*
Version:	VDCS Javascript 1.0
*/

dcs.popup=new Object();
dcs.popup._isLoad=false;
dcs.popup.p=null;
dcs.popup.pText=null;
dcs.popup.ps=null;
dcs.popup.et=null;
dcs.popup.style="";

dcs.popup.doLoad=function()
{
	if (this._isLoad) return true;
	var tmpstr="";
	tmpstr+="<style type=\"text/css\" id=\"stylePopLayer\">";
	tmpstr+="div.PopLayer { border:1px #888888 solid; background-color:#FFFFD9; font-family:Tahoma,Verdana; font-size:12px; line-height:18px; padding:0px; visibility:hidden;";
	if (dcs.browser.isIE) tmpstr+=" filter:Alpha(Opacity=90);";
	tmpstr+=" }";
	tmpstr+="div.PopText { border:1px #EDEDED solid; padding:2px 4px 2px 4px; }";
	tmpstr+="</style>";
	tmpstr+="<div><div id=\"PopLayer\" class=\"PopLayer\" style=\"position:absolute; z-index:1000;\"><div id=\"PopText\" class=\"PopText\"></div></div>";
	put(tmpstr);
	this.p=$("PopLayer");
	this._isLoad=true;
}

dcs.popup.doBox=function()
{
	var o=this.et.srcElement ? this.et.srcElement : this.et.target;
	if (!o) return;
	this.MouseX = this.et.clientX;
	this.MouseY = this.et.clientY;
	if(o.alt != null && o.alt != '') { o.pop = o.alt; o.alt = ''; }
	if(o.title != null && o.title != '') { o.pop = o.title; o.title = ''; }
	if(o.pop != this.ps)
	{
		if (!this.p) this.p=$("PopLayer");
		this.ps = o.pop;
		if(this.ps == null || this.ps == '')
		{
			this.doHide();
		}
		else
		{
			this.style = o.dyclass != null ? o.dyclass : 'PopLayer';
			this.p.style.visibility = "visible";
			this.doShow();
		}
	}
}

dcs.popup.doHide=function()
{
	this.p.style.visibility = "hidden";
}

dcs.popup.doShow=function()
{
	if (!this.pText) this.pText=$("PopText");
	this.p.className = this.style;
	this.pText.innerHTML = this.ps.replace(/<(.*)>/g,"&lt;$1&gt;").replace(/\n/g,"<br>");
	var popWidth = this.p.clientWidth;
	var popHeight = this.p.clientHeight;
	var popLeftAdjust = this.MouseX + 12 + popWidth > document.documentElement.clientWidth ? -popWidth - 24 : 0;
	var popTopAdjust = this.MouseY + 12 + popHeight > document.documentElement.clientHeight ? -popHeight - 24 : 0;
	this.p.style.left = (this.MouseX + 12 + document.documentElement.scrollLeft + popLeftAdjust) + 'px';
	this.p.style.top = (this.MouseY + 12 + document.documentElement.scrollTop + popTopAdjust) + 'px';
}

if(!document.onmouseover)
{
	dcs.popup.doLoad();
	document.onmouseover=function(e)
	{
		dcs.popup.et=e ? e : window.event;
		dcs.popup.doBox();
	}
}

