//<DIV ID="overDiv" style="position:absolute;z-index:201;visibility:hidden;; left: 0; top: 0;overflow: hidden;"></DIV>

var balloon2 = {
	mes:null,ex:0,ey:0,xpos:-205,ypos:20,bodyobject:null
}

balloon2.showballoon = function(e,w,xp,yp){ //xp = left , yp = top
	with(balloon2){
		if(!e)e = window.event;
		var alink = (e.target)? e.target : e.srcElement;
		while(alink != null && alink.onmouseover == null)alink = alink.parentNode;
		mes = alink.parentNode.getElementsByTagName("DIV")[0];
		bodyobject = (document.documentElement && document.documentElement.clientWidth)? document.documentElement : document.body
		mes.style.width=w+"px";
		mes.style.display = "block";
		xpos=(xp==null)?(-1*mes.offsetWidth-10):xp;
		ypos=(yp==null)?(-1*mes.offsetHeight-10):yp;
		document.onmousemove = doDrag;
		doDrag(e);
		
	}
}

balloon2.doDrag = function(e) {
	if (!e) e = window.event
	with(balloon2){
		ex = e.pageX ? e.pageX : e.clientX + bodyobject.scrollLeft
		ey = e.pageY ? e.pageY : e.clientY + bodyobject.scrollTop
		moveit()
	}
}

balloon2.moveit = function(){
	with(balloon2){
		mes.style.left=ex+xpos+"px";
		mes.style.top=ey+ypos+"px";
	}
}

balloon2.hideballoon = function(){
	with(balloon2){
		mes.style.display = "none";
	}
}


var message = {
	bk:null,fg:null,bheight:null, scrollh:0,txt:"",onclose:null
}

message.init = function(){
	with(message){
		if(bk!=null)return;
		bk = document.createElement('div');	
		bk.id="messagebk";
		fg = document.createElement('div');	
		fg.id="messagefg";
		var bodyobject = document.getElementsByTagName("BODY")[0] 
		bodyobject.appendChild(bk)
		bk.style.height = (document.getElementById('pgMainContent').parentNode.offsetHeight + 100) + "px"
		bk.appendChild(fg)
	}
}

message.setMsg = function(html,title){
	with(message){
		if(bk==null)message.init();
		txt = '<div class="frameWindowDefault">'
		txt = txt + '<div class="boxHead">'
		txt = txt + '<h4 id="fwdTitle">' + title + '</h4>';
		txt = txt + '<a href="#" onclick="return message.mclose()" id="fwdClose" class="btn bt2">CLOSE WINDOW</a>'
		txt = txt + '</div>	'
		txt = txt + '<div class="boxBody" id="messagebody">'
		txt = txt + html 
	 	txt = txt + '</div>'
		txt = txt + '</div>'
		fg.innerHTML = txt
	}
}

message.pageHeight = function() {return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;}

message.show = function(){
	with(message){
		if(bk==null)message.init();
		scrollh = (window.pageYOffset>0)? window.pageYOffset : (document.documentElement)? document.documentElement.scrollTop : (document.body)? document.body.scrollTop : 0
		//if (!/MSIE (6)/.test(navigator.userAgent)){ 
		//fg.style.top = (scrollh + 50)+"px"
			bk.style.position = "fixed";
			fg.style.left = ((bk.offsetWidth-fg.offsetWidth)/2)+"px"
	//	}
		var wheight = pageHeight()
		if(fg.offsetHeight+30 > wheight)document.getElementById('messagebody').style.height = (wheight-120)+"px";
		bk.style.visibility = "visible";
	}
}

message.hide = function(){
	with(message){
		if(bk==null)message.init();
		bk.style.visibility = "hidden";
	}
}

message.mclose = function(){
	message.hide();
	if(message.onclose!=null)eval(message.onclose)
	return false;
}


function showhelp(txt,w,xp,yp,obj) {
	if(obj && obj.title){obj.title=""}
	balloon.showhelp(txt,w,xp,yp)
}

function showpopup(txt,w,xp,yp,e,titleTxt,color) {
	var html=""
	if(txt.length>0){
		var dcolor = (color=='g')?"#7CC828":"#0072BC"
		var lcolor = (color=='g')?"#D8EEBF":"#E8F3F9"
		html = "<table width='100%' border='0' cellpadding='4' cellspacing='0'><tr><td bgcolor='" + dcolor + "' class='white10'><strong>"
		html = html + ((titleTxt==null || titleTxt.length==0)?"info":titleTxt);
		html = html + "</strong></td><td align='right' bgcolor='" + dcolor + "'><a href='#' onclick='hidehelp();return false;' title='click to close window'><img height='16' src='images/closewindow.gif' width='16' border='0' alt='click to close window'></a></td></tr><tr><td colspan='2' bgcolor='" + lcolor + "'>"
		html = html + txt
		html = html + "</td></tr></table>"
		txt=html
	}
	balloon.showpopup(txt,w,xp,yp,e)
}

function hidehelp(clear) {
	balloon.hide()
}


var balloon = {
	divlayer:null,displayed:false,ex:0,ey:0,xpos:-205,ypos:20,bodyobject:null
}
balloon.init = function(){
	with(balloon){
		if(divlayer!=null)return;
		divlayer = document.createElement('div');	
		divlayer.id="overDiv";
		bodyobject = document.getElementsByTagName("BODY")[0] 
		bodyobject.appendChild(divlayer)
	}
}
balloon.writeit = function(txt){
	balloon.divlayer.innerHTML = txt;
}
balloon.hide = function(){
	document.onmousemove = null
	with(balloon){
		init()
		displayed = false
		divlayer.style.width="0px"
		divlayer.style.visibility = "hidden"
	}
}
balloon.show = function(){
	with(balloon){
		displayed = true
		divlayer.style.visibility = "visible"
	}
}
balloon.moveit = function(){
	with(balloon){
		divlayer.style.left=ex+xpos+"px";
		divlayer.style.top=ey+ypos+"px";
		show()
	}
}
balloon.doDrag = function(e) {
	if (!e) e = window.event
	with(balloon){
		ex = e.pageX ? e.pageX : e.clientX + bodyobject.scrollLeft
		ey = e.pageY ? e.pageY : e.clientY + bodyobject.scrollTop
		moveit()
	}
}
balloon.showpopup = function(txt,w,xp,yp,e){
	with(balloon){
		init()
		var y = 0
		if(e) {
			y = e.pageY ? e.pageY : e.clientY+bodyobject.scrollTop
			ey=y
		}
		if (window.innerWidth && window.pageXOffset){ //firefox
			ex = (window.innerWidth/2)+window.pageXOffset;
			if(y==0)ey = (window.innerHeight/2)+window.pageYOffset;
		}else if (bodyobject && bodyobject.clientWidth){ //ie
			ex = (bodyobject.clientWidth/2)+bodyobject.scrollLeft;
			if(y==0)ey = (bodyobject.clientHeight/2)+bodyobject.scrollTop;
		}else{
			ex = window.innerWidth/2
			if(y==0)ey = window.innerHeight/2
		}
		if(txt.length>0){writeit(txt);}
		divlayer.style.width=w+"px"
		divlayer.style.padding = "0px"
		xpos=(xp==null)?(-1*divlayer.offsetWidth-15):xp
		ypos=(yp==null)?(-1*divlayer.offsetHeight-15):yp	
		if((ypos+ey)<0)ypos=0-ey
		moveit()
	}
}
balloon.showhelp = function(txt,w,xp,yp){
	with(balloon){
		init()
		if(txt.length>0){writeit(txt);}
		divlayer.style.width=w+"px"
		divlayer.style.padding = "10px"
		xpos=(xp==null)?(-1*divlayer.offsetWidth-10):xp
		ypos=(yp==null)?(-1*divlayer.offsetHeight-10):yp	
		document.onmousemove = doDrag
	}
}

