
var defax=new Ajax();
var defaxlock=false;
document.getElementById('ajax_working').style.display='none';
document.getElementById('ajax_msg').style.display='none';

function fav_add(sec, secid, ouid)
	{
	if(defaxlock) return false;
	defaxlock=true;
	var url='/wwwroot/inc-bottom.fav.php?act=add';
	url+='&sec='+sec;
	url+='&secid='+secid;
	if(ouid)
		url+='&ouid='+ouid;
	defax.open('GET', url, fav_add_act, '');
	}
function fav_add_act(txt)
	{
	defaxlock=false;
	if(/^ok:/.exec(txt)!=null)
		{
		txt=txt.replace(/^ok:/,'');
		alert('เพิ่มหน้านี้เป็นรายการโปรดเรียบร้อยแล้ว');
		}
	else alert(txt);
	}

document.write('<div id="noti_div">');
document.write('<table class="xhtb" cellspacing="0" style="background-image:url(\''+notihost+'/image/icon-noti2.gif\');"><th onclick="noti_close()">แจ้งเตือน</th><td><a href="#" onclick="noti_close(); return false;">x</a></td></table>');
document.write('<iframe id="noti_iframe" frameborder="0"></iframe>');
document.write('</div>');
var noti_div=document.getElementById('noti_div');
var noti_iframe=document.getElementById('noti_iframe');
var noti_first=true;
var noti_firstclose=true;
function noti_show(ocall)
	{
	var x=-4, y=-3, o=ocall;
	while(o)  { x+=o.offsetLeft; y+=o.offsetTop; o=o.offsetParent; }
	if(noti_first)
		{
		noti_first=false;
		noti_iframe.src=notihost+'/box.php';
		}
	noti_div.style.left=x+'px';
	noti_div.style.top=y+'px';
	noti_div.style.visibility='visible';
	}
function noti_close()
	{
	noti_div.style.visibility='hidden';
	if(noti_firstclose)
		{
		noti_firstclose=false;
		noti_load();
		}
	}
function noti_load()
	{
	if(defaxlock) return false;
	defaxlock=true;
	var url='/wwwroot/inc-bottom.noti.php?act=load';
	defax.open('GET', url, noti_load_act, '');
	}
function noti_load_act(txt)
	{
	defaxlock=false;
	if(/^ok:/.exec(txt)!=null)
		{
		txt=txt.replace(/^ok:/,'');
		document.getElementById('noti1').innerHTML=txt;
		}
	else alert(txt);
	}
if(isuser) noti_load();


var pjtooltip=new function()
	{
	document.write('<table id="pjtooltip_div" cellspacing="0" style="position:absolute; left:0; top:0; visibility:hidden; z-index:5;"><td id="pjtooltip_str" style=" background-image:url(/pic-tem/pjtooltip.png); background-position:bottom left; background-repeat:repeat-x; padding:10px 0 10px 10px; white-space:nowrap; font-size:10pt; color:#fff;"></td> <td style="background-image:url(/pic-tem/pjtooltip.png); background-position:bottom right; background-repeat:repeat-x; padding:0; width:8px; font-size:8px;">&nbsp;</td></table>');
	document.write('<table id="pjtooltipr_div" cellspacing="0" style="position:absolute; left:0; top:0; visibility:hidden; z-index:5;"> <td style="background-image:url(/pic-tem/pjtooltipr.png); background-position:bottom left; background-repeat:repeat-x; padding:0; width:8px; font-size:8px;">&nbsp;</td><td id="pjtooltipr_str" style=" background-image:url(/pic-tem/pjtooltipr.png); background-position:bottom right; background-repeat:repeat-x; padding:10px 10px 10px 0; white-space:nowrap; font-size:10pt; color:#fff;"></td></table>');
	this.box=document.getElementById('pjtooltip_div');
	this.boxstr=document.getElementById('pjtooltip_str');
	this.boxr=document.getElementById('pjtooltipr_div');
	this.boxrstr=document.getElementById('pjtooltipr_str');
	this.show=function(target, str)
		{
		this.boxstr.innerHTML=str.replace(/</g, '&lt;');
		var o, x=Math.round(target.offsetWidth/2), y=0;
		for(o=target ; o ; o=o.offsetParent) { x+=o.offsetLeft; y+=o.offsetTop; }
		if(x+this.box.offsetWidth<document.body.offsetWidth)
			{
			this.box.style.left=(x-15)+'px';
			this.box.style.top=(y-this.box.offsetHeight)+'px';
			this.box.style.visibility='visible';
			}
		else
			{
			this.boxrstr.innerHTML=this.boxstr.innerHTML;
			this.boxr.style.left=(x+15-this.boxr.offsetWidth)+'px';
			this.boxr.style.top=(y-this.boxr.offsetHeight)+'px';
			this.boxr.style.visibility='visible';
			}
		}
	this.close=function()
		{
		this.box.style.visibility='hidden';
		this.boxr.style.visibility='hidden';
		}
	this.regis=function(olist)
		{
		if(/MSIE [56][^0-9]/i.exec(navigator.userAgent)!=null) return false;
		var x;
		for(i in olist)
			{
			x=olist[i];
			if(x && x.hasAttribute && x.hasAttribute('pjtooltip'))
				{
				x.onmouseover=function(){ pjtooltip.show(this,this.getAttribute('pjtooltip')); };
				x.onmouseout=function(){ pjtooltip.close(); };
				}
			}
		}
	}
pjtooltip.regis(document.getElementsByTagName('a'));
pjtooltip.regis(document.getElementsByTagName('img'));

