function format_zobrazit(obj,verze) {
	var cesta='http://www.chmatakov.cz/img/format/';
	var cestasm='http://www.chmatakov.cz/img/smajlici/';
	var tlacitka=new Array();
	tlacitka['b']='<img src="'+cesta+'b.gif" onclick="uprava(\'[b]\',\'[/b]\',\''+obj+'\')" onmouseover="document.getElementById(\''+obj+'-format-popis\').innerHTML=this.alt" onmouseout="document.getElementById(\''+obj+'-format-popis\').innerHTML=\'\'" alt="Tučné" width="16" height="16" /> ';
	tlacitka['i']='<img src="'+cesta+'i.gif" onclick="uprava(\'[i]\',\'[/i]\',\''+obj+'\')" onmouseover="document.getElementById(\''+obj+'-format-popis\').innerHTML=this.alt" onmouseout="document.getElementById(\''+obj+'-format-popis\').innerHTML=\'\'" alt="Kurzíva" width="16" height="16" /> ';
	tlacitka['url']='<img src="'+cesta+'url.gif" onclick="uprava(\'[url]\',\'[/url]\',\''+obj+'\')" onmouseover="document.getElementById(\''+obj+'-format-popis\').innerHTML=this.alt" onmouseout="document.getElementById(\''+obj+'-format-popis\').innerHTML=\'\'" alt="Odkaz" width="16" height="16" /> ';
	tlacitka['img']='<img src="'+cesta+'img.gif" onclick="uprava(\'[img]\',\'[/img]\',\''+obj+'\')" onmouseover="document.getElementById(\''+obj+'-format-popis\').innerHTML=this.alt" onmouseout="document.getElementById(\''+obj+'-format-popis\').innerHTML=\'\'" alt="Obrázek" width="16" height="16" /> ';
	tlacitka['quote']='<img src="'+cesta+'quote.gif" onclick="uprava(\'[quote]\',\'[/quote]\',\''+obj+'\')" onmouseover="document.getElementById(\''+obj+'-format-popis\').innerHTML=this.alt" onmouseout="document.getElementById(\''+obj+'-format-popis\').innerHTML=\'\'" alt="Citace" width="16" height="16" /> ';
	tlacitka['code']='<img src="'+cesta+'code.gif" onclick="uprava(\'[code]\',\'[/code]\',\''+obj+'\')" onmouseover="document.getElementById(\''+obj+'-format-popis\').innerHTML=this.alt" onmouseout="document.getElementById(\''+obj+'-format-popis\').innerHTML=\'\'" alt="Kód" width="16" height="16" /> ';
	tlacitka['size']='<br />Velikost: <strong onclick="uprava(\'[size=1]\',\'[/size]\',\''+obj+'\')">velmi malá</strong> | <strong onclick="uprava(\'[size=2]\',\'[/size]\',\''+obj+'\')">malá</strong> | <strong onclick="uprava(\'[size=3]\',\'[/size]\',\''+obj+'\')">normální</strong> | <strong onclick="uprava(\'[size=4]\',\'[/size]\',\''+obj+'\')">větší</strong> | <strong onclick="uprava(\'[size=5]\',\'[/size]\',\''+obj+'\')">velká</strong>';
	tlacitka['color']='<br />Barva: <strong onclick="uprava(\'[color=black]\',\'[/color]\',\''+obj+'\')">černá</strong> | <strong onclick="uprava(\'[color=blue]\',\'[/color]\',\''+obj+'\')">modrá</strong> | <strong onclick="uprava(\'[color=red]\',\'[/color]\',\''+obj+'\')">červená</strong> | <strong onclick="uprava(\'[color=green]\',\'[/color]\',\''+obj+'\')">zelená</strong> | <strong onclick="uprava(\'[color=grey]\',\'[/color]\',\''+obj+'\')">šedá</strong>';
	tlacitka['smajlici']='<br /><img src="'+cestasm+'1.gif" onclick="uprava(\'\',\':-)\',\''+obj+'\')" alt=":-)" width="15" height="15" /> <img src="'+cestasm+'2.gif" onclick="uprava(\'\',\':-D\',\''+obj+'\')" alt=":-D" width="15" height="15" /> <img src="'+cestasm+'3.gif" onclick="uprava(\'\',\':-(\',\''+obj+'\')" alt=":-(" width="15" height="15" /> <img src="'+cestasm+'4.gif" onclick="uprava(\'\',\':\\\'(\',\''+obj+'\')" alt=":\'(" width="15" height="15" /> <img src="'+cestasm+'5.gif" onclick="uprava(\'\',\':-|\',\''+obj+'\')" alt=":-|" width="15" height="15" /> <img src="'+cestasm+'6.gif" onclick="uprava(\'\',\';-)\',\''+obj+'\')" alt=";-)" width="15" height="15" /> <img src="'+cestasm+'7.gif" onclick="uprava(\'\',\':-[\',\''+obj+'\')" alt=":-[" width="15" height="15" /> <img src="'+cestasm+'8.gif" onclick="uprava(\'\',\':lol:\',\''+obj+'\')" alt=":lol:" width="15" height="15" /> <img src="'+cestasm+'9.gif" onclick="uprava(\'\',\':-!\',\''+obj+'\')" alt=":-!" width="15" height="15" /> <img src="'+cestasm+'10.gif" onclick="uprava(\'\',\'3-(\',\''+obj+'\')" alt="3-(" width="15" height="15" /> <img src="'+cestasm+'11.gif" onclick="uprava(\'\',\':-P\',\''+obj+'\')" alt=":-P" width="15" height="15" /> <img src="'+cestasm+'12.gif" onclick="uprava(\'\',\'8-)\',\''+obj+'\')" alt="8-)" width="15" height="15" /> <img src="'+cestasm+'13.gif" onclick="uprava(\'\',\':-O\',\''+obj+'\')" alt=":-O" width="15" height="15" /> <img src="'+cestasm+'14.gif" onclick="uprava(\'\',\':evil:\',\''+obj+'\')" alt=":evil:" width="15" height="15" /> <img src="'+cestasm+'15.gif" onclick="uprava(\'\',\':twisted:\',\''+obj+'\')" alt=":twisted:" width="15" height="15" /> <img src="'+cestasm+'16.gif" onclick="uprava(\'\',\':idea:\',\''+obj+'\')" alt=":idea:" width="15" height="15" /> <img src="'+cestasm+'17.gif" onclick="uprava(\'\',\'xD\',\''+obj+'\')" alt="xD" width="15" height="15" />';
	tlacitka['popis']='<em id="'+obj+'-format-popis"></em>';
	if(verze==1) document.getElementById(obj+'-format').innerHTML=tlacitka['b']+tlacitka['i']+tlacitka['url']+tlacitka['img']+tlacitka['quote']+tlacitka['code']+tlacitka['popis']+tlacitka['size']+tlacitka['color']+tlacitka['smajlici'];
	else if(verze==2) document.getElementById(obj+'-format').innerHTML=tlacitka['b']+tlacitka['i']+tlacitka['url']+tlacitka['popis']+tlacitka['size']+tlacitka['color']+tlacitka['smajlici'];
	else if(verze==3) document.getElementById(obj+'-format').innerHTML=tlacitka['b']+tlacitka['i']+tlacitka['url']+tlacitka['img']+tlacitka['popis']+tlacitka['size']+tlacitka['color']+tlacitka['smajlici'];
	else if(verze==4) document.getElementById(obj+'-format').innerHTML=tlacitka['b']+tlacitka['i']+tlacitka['url']+tlacitka['popis']+tlacitka['smajlici'];
	document.getElementById(obj+'-format').style.display='block';
}
function format_skryt(obj) {
	//
}

function setSelectionRange(input,selectionStart,selectionEnd) {
	if(input.setSelectionRange) {
		input.focus();
		input.setSelectionRange(selectionStart,selectionEnd);
	}
	else if(input.createTextRange) {
		var range=input.createTextRange();
		range.collapse(true);
		range.moveEnd('character',selectionEnd);
		range.moveStart('character',selectionStart);
		range.select();
	}
}
function uprava(textpre,textpost,pole) { 
	var ele;
	if(ele=document.getElementById(pole)) {
		if(ele.setSelectionRange) {
			var start=ele.selectionStart;
			var end=ele.selectionEnd; 
			ele.value=ele.value.substring(0,start)+textpre+ele.value.substring(start,end)+textpost+ele.value.substring(end);
			//var pos=start+textpre.length+textpost.length+(end-start)+1;
			setSelectionRange(ele,start,end+textpre.length+textpost.length);
		}
		else if(document.selection) {
			ele.focus();
			document.selection.createRange().text=textpre+document.selection.createRange().text+textpost;
		}
	}
}

isIE=(document.all)?true:false;
function styleAbbr() {
	if(isIE) {
		var oldBodyText,newBodyText,reg;
		oldBodyText=document.body.innerHTML;
		reg=/<abbr([^>]*)>([^<]*)<\/abbr>/g;
		newBodyText=oldBodyText.replace(reg,'<abbr $1><span class=\"abbr\" $1>$2</span></abbr>');
		document.body.innerHTML=newBodyText;
	}
}
window.onload=function() {styleAbbr();};

var ajax_obj=new Array();
function ajax_request(obj,skript,msg) {
	ajax_obj[obj]=false;
	var mozno=1;
	if(window.XMLHttpRequest) {
		ajax_obj[obj]=new XMLHttpRequest();
	}
	else if(window.ActiveXObject) {
		try {
			ajax_obj[obj]=new ActiveXObject('Microsoft.XMLHTTP');
		}
		catch(e) {
			ajax_obj[obj]=new ActiveXObject('Msxml2.XMLHTTP');
		}
	}
	else mozno=0;
	if(mozno) {
		var url='/ajaxoviny/'+skript+'.php?'+new Date().getTime();
		ajax_obj[obj].open('POST',url,true);
		ajax_obj[obj].setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		ajax_obj[obj].onreadystatechange=function() {ajax_request2(obj);};
		ajax_obj[obj].send(msg);
		return false;
	}
	else return true;
}
function ajax_request2(obj) {
	if(ajax_obj[obj].readyState==4) {
		if(ajax_obj[obj].status==200) {
			if(ajax_obj[obj].responseText.substring(0,2)=='1|') {
				eval(ajax_obj[obj].responseText.substring(2));
			}
			else if(ajax_obj[obj].responseText.substring(0,2)=='0|') {
				alert(ajax_obj[obj].responseText.substring(2));
			}
			else {
				alert('Chyba při provádění požadavku. Zkuste to prosím za chvíli znovu.');
			}
			ajax_obj[obj]=false;
		}
	}
}
function ajax_request_ne(obj,skript,msg,cil,typ) {
	ajax_obj[obj]=false;
	var mozno=1;
	if(window.XMLHttpRequest) {
		ajax_obj[obj]=new XMLHttpRequest();
	}
	else if(window.ActiveXObject) {
		try {
			ajax_obj[obj]=new ActiveXObject('Microsoft.XMLHTTP');
		}
		catch(e) {
			ajax_obj[obj]=new ActiveXObject('Msxml2.XMLHTTP');
		}
	}
	else mozno=0;
	if(mozno) {
		var url='/ajaxoviny/'+skript+'.php?'+new Date().getTime();
		ajax_obj[obj].open('POST',url,true);
		ajax_obj[obj].setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		ajax_obj[obj].onreadystatechange=function() {ajax_request_ne2(obj,cil,typ);};
		ajax_obj[obj].send(msg);
		return false;
	}
	else return true;
}
function ajax_request_ne2(obj,cil,typ) {
	if(ajax_obj[obj].readyState==4) {
		if(ajax_obj[obj].status==200) {
			if(ajax_obj[obj].responseText.substring(0,2)=='1|') {
				var reqdata=ajax_obj[obj].responseText.substring(2);
				var datpozice=reqdata.indexOf('|');
				var reqjs=reqdata.substring(0,datpozice);
				reqdata=reqdata.substring(datpozice+1);
				if(typ=='innerHTML') document.getElementById(cil).innerHTML=reqdata;
				else if(typ=='value') document.getElementById(cil).value=reqdata;
				if(reqjs) eval(reqjs);
			}
			else if(ajax_obj[obj].responseText.substring(0,2)=='0|') {
				alert(ajax_obj[obj].responseText.substring(2));
			}
			else {
				alert('Chyba při provádění požadavku. Zkuste to prosím za chvíli znovu.');
			}
			ajax_obj[obj]=false;
		}
	}
}

function fprozmer(pid) {
	return (document.getElementById('p'+pid+'t').offsetWidth-33)+'x'+(document.getElementById('p'+pid+'t').offsetHeight-38);
}
function fpupravit(fid,pid) {
	document.getElementById('p'+pid+'t2').disabled=true;
	ajax_request_ne('fpupravit_p'+pid,'f_pupravit','f='+fid+'&p='+pid+'&text='+encodeURIComponent(document.getElementById('p'+pid+'t2').value),'p'+pid+'t','innerHTML');
}