d=document
var FEM={
id:null,
show:function(v,id,el){
	if(this.id==id){this.hide();return}
	if(this.id)this.hide()
	this.id=id
	var e=EV.ev(v),o=$(id),s=o.style,t=0,l=0
	s.display="block"
	var w=o.offsetWidth,h=o.offsetHeight
	var sT=d.body.scrollTop,sL=d.body.scrollLeft
	var cW=d.body.clientWidth,cH=d.body.clientHeight
	if(el){
		var x,y,w2=el.offsetWidth
		while(el.tagName!="BODY" && el.tagName!="HTML"){
			y=el.style.top
			x=el.style.left
			t+=(y!="")?y.substring(1,y.length-2)*1:el.offsetTop
			l+=(x!="")?x.substring(1,x.length-2)*1:el.offsetLeft		
			el=el.offsetParent
		}
		s.left=(cW-l<w)?sL+l-w+w2:sL+l
		s.top=(sT+cH-t>h)?t+1:t-h+1
	}else{
		t=e.clientY;l=e.clientX
		s.left=(cW-l<w)?sL+l-w:sL+l
		if(cH-t<h||t<h)	s.top=(cH>h)?sT+(cH-h)/2:sT
		else s.top=(cH-t>h)?t+sT:t-h+sT
	}
	this.selects(0)
	e.stopPropagation()
	//alert('aaa')
	return false
},
hide:function(){
	if(!this.id)return
	this.selects(1)
	$(this.id).style.display="none"
	this.id=null
},
selects:function(m){
	var i,b=document.getElementsByTagName('SELECT')
	for(i=0;i<b.length;i++){if(this.intersect(b[i])&&!this.depend(b[i]))b[i].style.visibility=m?'visible':'hidden'}
},
depend:function(e){
	if(e){while(e&&e.nodeName!='BODY'){if(e.id==this.id)return true;e=e.parentNode}}
	return false
},
intersect:function(o){
	var o1=getCoord($(this.id)),o2=getCoord(o)
	var cx=o1.x>o2.x?o1.x<o2.x+o2.w:o1.x+o1.w>o2.x,cy=o1.y>o2.y?o1.y<o2.y+o2.h:o1.y+o1.h>o2.y
	return cx&&cy
},
docOnclick:function(e){
	e=EV.ev(e)
	e=e.src
	if(e){while(e&&e.nodeName!='BODY'){if(e.id==FEM.id)return;e=e.parentNode}}
	FEM.hide()
}
}
function getCoord(o){
	var o2={w:o.offsetWidth,h:o.offsetHeight,x:o.offsetLeft,y:o.offsetTop}
	var p=o.offsetParent
	while(p!=null){o2.y+=p.offsetTop;o2.x+=p.offsetLeft;p=p.offsetParent}
	return o2
}
CEl=function(tagName,parent,doc){
	if(!doc)doc=document
	var el=doc.createElement(tagName)
	if(parent)parent.appendChild(el)
	return el
}
var EV={
	add:function(o,t,fp,cap){
		cap=cap||false
		if(o.addEventListener)o.addEventListener(t,fp,cap)
		else if(o.attachEvent)o.attachEvent('on'+t,fp)
	}, 
	remove:function(o,t,fp,cap){
		cap=cap||false
		if(o.removeEventListener)o.removeEventListener(t,fp,cap)
		else if(o.detachEvent)o.detachEvent('on'+t,fp)
	},
	ev:function(e){ 
		e=e?e:window.event
		if(!e)return
		e.src=e.srcElement?e.srcElement:e.target
		if(!e.preventDefault)e.preventDefault=function(){return false}
		if(!e.stopPropagation)e.stopPropagation=function(){
			if(window.event)window.event.cancelBubble=true;
		}
		return e
	}
}

var TAB={
i:0,
a:[],
add:function(n){
	this.a[this.a.length]=n
},
draw:function(ii){
	var h='',i
	for(i=0;i<this.a.length;i++){
		if(ii!=null&&ii!=i)continue
h+='<LI id=tab_'+i+' onclick="TAB.open('+i+')" onmouseout="TAB.mout(this)" onmouseover="TAB.mover(this)"><span>'+this.a[i]+'</span></LI>'
	}
	h='<UL class=tab1>'+h+'</UL>'
	document.write(h)
},
mover:function(e){e.childNodes[0].className='hover'},
mout:function(e){e.childNodes[0].className=''},
open:function(ii){
	this.i=ii
	for(i=0;i<this.a.length;i++){
		var id='tab_'+i,t=$(id)
		if(!t)continue
		t.className=ii==i?'current':''
		bl=$('tab_block_'+i)
		if(bl)bl.style.display=ii==i?'block':'none'
	}
}
}
chkInt=function(){var k=event.keyCode;return ((k>47&&k<58)||k==37)}
insFile=function(id,t){
	var e=$(id)
	var i=showModalDialog(t?'insImage.htm':'insFile.htm',e.value,
	'resizable:no;help:no;status:no;scroll:no;dialogWidth:500px;dialogHeight:450px')
	if(i){e.value=i;e.fireEvent('onchange')}
}
cap=function(str){
var i,v=str.toLowerCase().split('-')
for(i=1;i<v.length;i++)v[i]=v[i].substring(0,1).toUpperCase()+v[i].substring(1,v[i].length)
return v.join('')
}
function getE(id){return document.getElementById(id)}
function $(el){if(typeof el=='string')el=document.getElementById(el);return el}
if(!Array.prototype.push){
	Array.prototype.push=function(){
	var i,L=this.length
	for(i=0;i<arguments.length;i++)this[L+i]=arguments[i]
	return this.length
  }
}

mouse={x:0,y:0,
	get:function(e){
		if(window.event){
			mouse.x=window.event.clientX+document.body.scrollLeft
			mouse.y=window.event.clientY+document.body.scrollTop
		}else{
			mouse.x=e.pageX;mouse.y=e.pageY
		}
	}
}


