/**
*
* JavaScript knihovna s metodami pro práci s obrázky
*
* @package		sllibs3
* @subpackage	jslibs
* @version		$Id: sl.image.js 2325 2008-03-12 17:46:07Z michal $
* @encoding		UTF-8
* @author		Michal Kouďa <michal.kouda@e4you.cz>
* @copyright	(c) e4you spol. s r.o. 2002-2008, <design@e4you.cz>
*
* Obsah tohoto souboru je majetkem e4you spol. s r.o. Jeho kopírování,
* pozměňování, šíření a jakékoli další využití je možné výhradně
* se souhlasem e4you spol. s r.o.
*
*/

/// pokud neexistuje jmenný prostor sl. vytvoříme ho
if(!sl) { var sl = {} };

/// definujeme modul a jeho metody
sl.image = {


	/**
	* Zobrazí náhled obrázku, jehož jméno je předáno jako parametr
	* @param string jméno obrázku který chceme zobrazit
	* @param string popis obrázku
	*/
	preview: function (picture, comment) {

		try {
			if(this.previewWindow) {
				this.previewWindow.close();
			}
		} catch (error) {}

		this.previewWindow = window.open('','picturedetail','resizable=no,location=no,status=no,scrollbars=no');

		with(this.previewWindow) {

			document.open();
			document.write('<html>\n<head>\n\t<title>' + comment + '</title>\n\t<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\n</head>\n');
			document.write('<body style="background-color:#333; color:#eee; margin:.4em; text-align:center;">');
			document.write('<img id="image" src="' + picture + '" alt="' + comment + '" onclick="window.close();">');

			if(comment) {
				document.write('<div id="description">' + comment + '</div>\n');
			}

			document.write('</body>\n</html>\n');
			document.close();

			if(document.images[0]) {

				document.images[0].onload = function () {

					var document_width = document.images[0].width + 20;
					var document_height = document.images[0].height + 40;
					if(comment) {
						document_height += 16;
					}
					resizeTo(document_width, document_height);

				}

				document.images[0].onload();

			}

			focus();

		}

	}

}

