//document.write('<script type="text/javascript" src="/inclib/_js/mootools.v1.1-full.js"></script>');

function removePopElm(id){
	elm = $(id);
	elmds = $(id+'-ds');
	var body = document.getElementsByTagName('BODY')[0]
	body.removeChild(elm)
	//body.removeChild(elmds)
}

function createTip(refElm, id, title, text) {
	if(!$('id')){
		elm = $(refElm);
		var body = document.getElementsByTagName('BODY')[0]
		
		var p = Position.positionedOffset(elm)
		var t = p[1] - 53;	
		var l = p[0] +300;
		
		var c = document.createElement('div');
		c.id = id;
		c.className = 'tool-container';
		c.style.left = l+'px';
		c.style.top = t+'px';
		
		//dropshadow
		var ct = document.createElement('div')
		ct.id = id + '-ct'
		ct.className = 'tool-title'
		
		var cntnt = document.createElement('div')
		cntnt.id = id + '-cntnt'
		cntnt.className = 'tool-text'
		
		c.appendChild(ct);
		c.appendChild(cntnt);
		
		//add it to the parent
		//body.appendChild(ds);
		body.appendChild(c);
		
	}
}

function createPopElm(refElm, id, title, text) {

	if(!$('id')){
		elm = $(refElm);
		var body = document.getElementsByTagName('BODY')[0]
		
		var p = Position.positionedOffset(elm)
		var t = p[1] - 53;	
		var l = p[0] +300;
		
		//dropshadow
		var ds = document.createElement('div')
		ds.id = id + '-ds'
		ds.className = 'bubble dropshadow'
		ds.style.left = (l+6)+'px';
		ds.style.top = (t+7)+'px';
		
		//top of bubble
		var dsct = document.createElement('span');
		dsct.className = 'ct';
		var dscl = document.createElement('span');
		dscl.className = 'cl';
		ds.appendChild(dscl);
		
		//content of bubble
		var dscntnt = document.createElement('div');
		dscntnt.className = 'cntnt';
		var dst = document.createElement('h3');
		dst.innerHTML = title
		dscntnt.appendChild(dst);
		
		//body of bubble
		var dsp = document.createElement('p')
		dsp.innerHTML = text
		dscntnt.appendChild(dsp)
			
		//bottom of bubble
		var dscb = document.createElement('span');
		dscb.className = 'cb';
		var dscbl = document.createElement('span');
		dscbl.className = 'cl';
		dscb.appendChild(dscbl);
		
		//put together the bubble
		ds.appendChild(dsct);
		ds.appendChild(dscntnt);
		ds.appendChild(dscb)
		
	//container
		var c = document.createElement('div');
		c.id = id;
		c.className = 'bubble';
		c.style.left = l+'px';
		c.style.top = t+'px';
		
		//close bubble 'X'
		var x = document.createElement('div');
		x.className = 'close-window';
		x.onclick = function(){
			displayNone(c);
			displayNone(ds);
		}
		x.onmouseover = function(){
			x.style.backgroundPosition = '0px -14px;'
		}
		x.onmouseout = function(){
			x.style.backgroundPosition = '0px 0px;'
		}
		
		//top of bubble
		var ct = document.createElement('span');
		ct.className = 'ct';
		var cl = document.createElement('span');
		cl.className = 'cl';
		ct.appendChild(cl);
		
		//content of bubble
		var cntnt = document.createElement('div');
		cntnt.className = 'cntnt';
		var t = document.createElement('h3');
		t.innerHTML = title
		cntnt.appendChild(x);
		cntnt.appendChild(t);
		
		//body of bubble
		var p = document.createElement('p')
		if(typeof text == 'object'){
			var el = document.createElement(text['elm'])
			var h = $H(text)
			h.keys().each(function(iterator){
				el[iterator] = text[iterator]
			})	
			
			if(el.tagName == 'IMG'){
				p.appendChild(el)
				if($(el).getStyle('width')) c.style.width = parseInt($(el).getStyle('width')) + 20 + 'px';
				
				el.onload = function(){
					if($(el).getStyle('width')) c.style.width = parseInt($(el).getStyle('width')) + 20 + 'px';
				}
			}
		}
		
		if(typeof text == 'string'){
			p.innerHTML = text
		}
		cntnt.appendChild(p)
			
		//bottom of bubble
		var cb = document.createElement('span');
		cb.className = 'cb';
		var cbl = document.createElement('span');
		cbl.className = 'cl';
		cb.appendChild(cbl);
		
		//put together the bubble
		c.appendChild(ct);
		c.appendChild(cntnt);
		c.appendChild(cb)
		
		//add it to the parent
		//body.appendChild(ds);
		body.appendChild(c);
	}
}