/*

Js functions
---------------------------------------------------------------------

Copyright (C) 2005 Marek 'juneau' Klusak, <stopar@tiscali.cz>
Web: http://rs.reality-show.net

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

*/





/*
	Tato funkce je prirazena odkazum typu "maly obrazek odkazuje na jeho puvodni velikost".
	Je predavana jen adresa obrazku.
	Jenze drive se predavala cela url (popup-img.php?...) a je nutne to odlisit pro zpetnou kompatibilitu.
*/
function popup(img)
	{
	var re = new RegExp("popup-img\.php");
	var nalez = img.search(re);
	
	if (nalez == -1) {
		// nove napsane
		window.open('./popup-img.php?img='+img,'popup','resizable,statusbar=no');		
	} else {
		// stara verze
		window.open(img,'popup','resizable,statusbar=no');		
	}
	return true;
	}


/*
// taky otevirani obrazku (test)
function image_open(file) {
var str_buffer = new String (
"<html>\n"+
"<head>\n"+
"<title>Kliknutím na obrázek zavřete okno</title>\n"+
"<script type=\"text/javascript\">\n"+
"function velikost() {\n"+
"if ((obr.width>(screen.availWidth-20)) || (obr.height>(screen.availHeight-40)))\n"+
"window.resizeTo(obr.width+26, obr.height/2);\n"+
"else\n"+
"window.resizeTo(obr.width, obr.height);\n"+
"}\n"+
"</script>\n"+
//"<link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\">\n"+
"</head>\n"+
"<body onload=\"velikost();\" bgcolor=\"White\" leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" style=\"margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;\">\n"+
"<a href=\"javascript:window.close();\"><img name=\"obr\" src=\"" + file + "\"  alt=\"Kliknutím na obrázek zavřete okno\" border=\"0\" /></a>\n"+
        "</body>\n</html>");
var okno = window.open("","okno1",'width=1,height=1,left=20,top=20,location=no,toolbar=no,directories=no,statusbar=no,scrollbars=no,copyhistory=no');
okno.opener = self;
okno.focus();
var okno_doc = okno.document;
okno_doc.write (str_buffer);
okno_doc.close();
}
*/


function vlozSyntaxi(co,formular)
	{
	var t;
	switch(co)
		{
		case 'bold':	t = '**...**';
		break;
		case 'em':	t = '*...*';
		break;
		case 'q':	t = '>>...<<';
		break;
		case 'a':	t = '\"odkaz\":[adresa]';
		break;
		case 'code':	t = '`...`';
		break;
		case 'list': t = '-  ...\n-  ...\n-  ...';
		break;
		case 'acronym':	t = '"..."((vysvětlení))';
		break;
		}
	
	var text = document.getElementById(formular).value;
	document.getElementById(formular).value = text + t;
	}




// zvyraznovani odstavce
var pole = window.location.href.split("#");

if(pole[1])
{
	if(pole[1].substring(0,9) == "odstavec-")
		{
		var odstavec = pole[1];
		document.getElementById(odstavec).className +=" zvyraznit";
		}
	else if(pole[1].substring(0,5) == "comm-")
		{
		var odstavec = pole[1];
		document.getElementById(odstavec).className +=" komentar-zvyraznit";
		}
	else if(pole[1].substring(0,5) == "post-")
		{
		var odstavec = pole[1];
		document.getElementById(odstavec).className +=" post-blok-zvyraznit";
		}
}

// o tomhle se hezky rozepsal pixy: http://www.pixy.cz/pixylophone/2005_03_archiv.html#1110561223




function reference(cislo,formular) {
	var obsahPole = document.getElementById(formular).value;
	if (obsahPole != '')
		obsahPole += '\n';
	document.getElementById(formular).value = obsahPole + '['+cislo+']';
}
