function lightup(id, kolor) //podswietla element na wybrany kolor
{

document.getElementById(id).style.backgroundColor = kolor;

}









D=document,S=[],T=[],C=alert,B=unescape;

onload=function() {
    F=D.getElementById('message');
    Subj=D.getElementById('sub');
}



function confirmation(l, t) {
var answer = confirm(t)
if (answer){
window.location = l;
}
else{

}
}


function bbcode(x,z) {
    (z=s())?A('['+x+']'+z+'[/'+x+']'):R(x)
}

function on1(el) {
    el.className='bbcodeover';
}

function of1(el) {
    el.className='bbcode';
}

function resize() {
    ile = F.rows;
    
    if (ile>10) F.rows = ile-14;
}

function resize_a() {
	 
    ile = F.rows;
    
    if (ile<50) F.rows = ile+14;
}

function czysc()
{
F.value = '';
Subj.value = '';
}


function A(x) {
    D.selection?(F.focus(),D.selection.createRange().text=x):(F.selectionStart||F.selectionStart=='0')?F.value=F.value.substring(0,F.selectionStart)+x+F.value.substring(F.selectionEnd,F.value.length):F.value+=x
}

function s() {
    return D.selection?D.selection.createRange().text:F.value.substring(F.selectionEnd||0,F.selectionStart||0)
}

function R(x) {
    T[x]?'':T[x]=0;T[x]?CT(x):(S.push(x),T[x]=1,A('['+x+']'),St(x,'*'))
}

function St(i,x) {
}
Z='%52%4b';

function emot(x) {
    A(x)
}

function CT(x,a) {
    T[a=S.pop()]=0;A('[/'+a+']');St(a,'');a!=x?CT(x):''
}

function CA(e) {
    while(S[0]) {
        A('[/'+(e=S.pop())+']');T[e]=0;St(e,'')
    }
}


function List(x,li) {
    x='[list]\n';do {
        li=prompt('Type an item of this list (if you would like to stop, just add empty item or click \'Cancel\'','');x+=li?'[*]'+li+'[/*]\n':''
    }
    while(li);A(x+'[/list]')
}

function List2(x,li) {
    x='[list=2]\n';do {
        li=prompt('Type an item of this list (if you would like to stop, just add empty item or click \'Cancel\'','');x+=li?'[*]'+li+'[/*]\n':''
    }
    while(li);A(x+'[/list=2]')
}

function Url(u,d,z) {
    A("[url="+(u=prompt("Link to website or file","http://"))+"]"+(s()?s():((d=prompt("Description",""))?d:u))+"[/url]")
}

function mail(u,d,z) {
    A("[email="+(u=prompt("E-mail address",""))+"]"+(s()?s():((d=prompt("Description",""))?d:u))+"[/email]")
}

function Img(z) {
    A("[img]"+((z=s())?z:prompt("Path of picture","http://"))+"[/img]")
}

function sfc(l,t) {
    A("["+t+"="+l.value+"]"+s()+"[/"+t+"]")
}

function Quote(t) {
    A("[quote"+((t=prompt('Name of quoting person'))?"="+t:"")+"]"+s()+"[/quote]")
}



var tooltip=function(){
	var id = 'tt';
	var top = 3;
	var left = 3;
	var maxw = 300;
	var speed = 8;
	var timer = 20;
	var endalpha = 85;
	var alpha = 0;
	var tt,t,c,b,h;
	var ie = document.all ? true : false;
	return{
		show:function(v,w){
			if(tt == null){
				tt = document.createElement('div');
				tt.setAttribute('id',id);
				t = document.createElement('div');
				t.setAttribute('id',id + 'top');
				c = document.createElement('div');
				c.setAttribute('id',id + 'cont');
				b = document.createElement('div');
				b.setAttribute('id',id + 'bot');
				tt.appendChild(t);
				tt.appendChild(c);
				tt.appendChild(b);
				document.body.appendChild(tt);
				tt.style.opacity = 0;
				tt.style.filter = 'alpha(opacity=0)';
				document.onmousemove = this.pos;
			}
			tt.style.display = 'block';
			c.innerHTML = v;
			tt.style.width = w ? w + 'px' : 'auto';
			if(!w && ie){
				t.style.display = 'none';
				b.style.display = 'none';
				tt.style.width = tt.offsetWidth;
				t.style.display = 'block';
				b.style.display = 'block';
			}
			if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
			h = parseInt(tt.offsetHeight) + top;
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(1)},timer);
		},
		pos:function(e){
			var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
			var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
			tt.style.top = (u - h) + 'px';
			tt.style.left = (l + left) + 'px';
		},
		fade:function(d){
			var a = alpha;
			if((a != endalpha && d == 1) || (a != 0 && d == -1)){
				var i = speed;
				if(endalpha - a < speed && d == 1){
					i = endalpha - a;
				}else if(alpha < speed && d == -1){
					i = a;
				}
				alpha = a + (i * d);
				tt.style.opacity = alpha * .01;
				tt.style.filter = 'alpha(opacity=' + alpha + ')';
			}else{
				clearInterval(tt.timer);
				if(d == -1){tt.style.display = 'none'}
			}
		},
		hide:function(){
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
		}
	};
}();
