var animovane_fotky = {

	casovac : null,
	
	init : function() {
		if( $("#animovane-fotky").html() != null ) {
			$("#animovane-fotky").attr( 'class', 'animovane-fotky' );
			$("#animovane-fotky").append('<div class="stara"></div>');
			$("#animovane-fotky").append('<div class="nova"></div>');
			$("#animovane-fotky").append('<div class="sponka"></div>');
			this.animuj();
		}
	},
	
	animuj : function() {
		if( $('#zobrazeny-lightbox').attr('value') == 'ne' ) {
			$.get("/etc/animovane-fotky.php", function(data) {
				animovane_fotky.casovac = setTimeout("animovane_fotky.animuj()", 5000);
				$(".animovane-fotky div.stara").hide().html( data );
				$(".animovane-fotky img").load( function(e) {
					clearTimeout( animovane_fotky.casovac );
					$(".animovane-fotky div.nova").attr( 'class', 'stara2' );
					$(".animovane-fotky div.stara").attr( 'class', 'nova' );
					$(".animovane-fotky div.stara2").attr( 'class', 'stara' );
					$(".animovane-fotky div.nova a").lightbox();
					$(".animovane-fotky div.nova").fadeIn("slow", function() {
						$(".animovane-fotky div.stara").fadeOut("slow");
						setTimeout("animovane_fotky.animuj()", 3000);
					} );
				} );

			});
		} else {
			setTimeout("animovane_fotky.animuj()", 3000);
		}
	}

}

function load() {

	/**
	 * GMap2.showBounds() method
	 * @ author Esa 2008
	 * @ param bounds_ GLatLngBounds()
	 * @ param opt_options Optional options object {top, right, bottom, left, instant, save}
	 */
	GMap2.prototype.showBounds = function(bounds_, opt_options){
		var opts = opt_options||{};
		opts.top = opt_options.top*1||0;
		opts.left = opt_options.left*1||0;
		opts.bottom = opt_options.bottom*1||0;
		opts.right = opt_options.right*1||0;
		opts.save = opt_options.save||true;
		opts.disableSetCenter = opt_options.disableSetCenter||false;
		var ty = this.getCurrentMapType();
		var port = this.getSize();
		if(!opts.disableSetCenter){
		var virtualPort = new GSize(port.width - opts.left - opts.right,
								port.height - opts.top - opts.bottom);
		this.setZoom(ty.getBoundsZoomLevel(bounds_, virtualPort));
		var xOffs = (opts.left - opts.right)/2;
		var yOffs = (opts.top - opts.bottom)/2;
		var bPxCenter = this.fromLatLngToDivPixel(bounds_.getCenter());
		var newCenter = this.fromDivPixelToLatLng(new GPoint(bPxCenter.x-xOffs, bPxCenter.y-yOffs));
		this.setCenter(newCenter);
		if(opts.save)this.savePosition();
		}
		var portBounds = new GLatLngBounds();
		portBounds.extend(this.fromContainerPixelToLatLng(new GPoint(opts.left, port.height-opts.bottom)));
		portBounds.extend(this.fromContainerPixelToLatLng(new GPoint(port.width-opts.right, opts.top)));
		return portBounds;
	}

	
}

var mapa = {

	map : null, // instance mapy
	nactena_mapa : 0,
	markers : new Array(), // vygenerované body do mapy
	marker : null, // výběrový bod
	vybrana_pozice : 0,
	vychozi_souradnice : { zem_sirka : 50.52432, zem_delka : 14.21527 },
	geocoder : null,

	vyber_polohy : function()
	{
		var WINDOW_HTML = "<div style='width: 210px; padding-right: 10px'>Požadované umístění vyberete přetažením ukazatele.</div>";
		var CHOSEN_HTML = "<div style='width: 210px; padding-right: 10px'>Toto místo bylo zaznamenáno.</div>";

		if( !this.zobraz_mapu() ) return false;
		this.map.clearOverlays();
		if( this.marker == null )
		{
			this.marker = new GMarker( new GLatLng( this.vychozi_souradnice.zem_sirka, this.vychozi_souradnice.zem_delka ), {draggable: true} );
			marker = this.marker;
			GEvent.addListener(this.marker, "dragend", function() {
				marker.openInfoWindowHtml(CHOSEN_HTML);
				var newloc = marker.getPoint();
				$('#zem_sirka').val( newloc.lat() );
				$('#zem_delka').val( newloc.lng() );
			});
		}

		if( $('#zem_delka').val() != 0 && $('#zem_sirka').val() != 0 )
		{
			pozice = new GLatLng( $('#zem_sirka').val(), $('#zem_delka').val() );
			this.vybrana_pozice = 1;
		} else
		{
			pozice = new GLatLng( this.vychozi_souradnice.zem_sirka, this.vychozi_souradnice.zem_delka );
		}
		this.marker.setPoint( pozice );

		this.map.addOverlay( this.marker );
		this.map.setCenter( pozice, 13 );
		if( this.vybrana_pozice == 0 ) this.marker.openInfoWindowHtml(WINDOW_HTML);
	},
	
	zobraz_polohu : function( zem_sirka, zem_delka ) {
		this.zobraz_mapu();
		this.pridej_bod( zem_sirka, zem_delka );
		this.pridej_bod( this.vychozi_souradnice.zem_sirka, this.vychozi_souradnice.zem_delka );
		this.zobraz_body();
	},
	
	pridej_bod : function( zem_sirka, zem_delka ) {
		marker = new GMarker( new GLatLng( zem_sirka, zem_delka ) );
		this.markers.push( marker );
		return marker;
	},
	
	zobraz_body : function() {
		if( this.markers.length > 0 && this.map != null ) {
			for( i=0; i<this.markers.length; i++ )
			{
				this.map.addOverlay( this.markers[i] );
			}
			bounds = new GLatLngBounds();
			for(var i=0; i<this.markers.length; i++)
			{
				bounds.extend(this.markers[i].getLatLng());
			}
			var paddings = {top:30, right:10, left:50};
			this.map.showBounds(bounds, paddings);
		}
	},
	
	ukaz_adresu : function() {
		adresa = $('#adresa').val();
		if( this.geocoder && adresa != '' ) {
			this.geocoder.getLatLng(adresa, function(point) {
					if (!point) {
						alert(adresa + " nenalezeno");
						return;
					} else {
						$('#zem_sirka').val( point.lat() );
						$('#zem_delka').val( point.lng() );
						mapa.vyber_polohy();
					}
			} );
		}
	},
	
	zobraz_mapu : function() {

		if( !this.nactena_mapa && GBrowserIsCompatible() )
		{
			// inicializace mapy
			this.map = new GMap2(document.getElementById("mapa"));

			load();

			// nastavení mapy
			this.map.setCenter(new GLatLng( this.vychozi_souradnice.zem_sirka, this.vychozi_souradnice.zem_delka ), 15);
			this.map.addControl(new GLargeMapControl());
			this.map.addControl(new GMapTypeControl());
			this.map.disableScrollWheelZoom();

			this.geocoder = new GClientGeocoder();

			this.nactena_mapa = true;

		}
		return true;
	},
	
	init : function()
	{
		if( $('.zemepisna_poloha #mapa').length != 0 )
		{
			mapa.vyber_polohy();
			$('#polohy').change( function(e) {
				if( this.selectedIndex != 0 ) {
					souradnice = this.value.split('|');
					$('#zem_sirka').val( souradnice[0] );
					$('#zem_delka').val( souradnice[1] );
					mapa.map.clearOverlays();
					mapa.vyber_polohy();
				}
			} );
			$('#vyhledej_adresu').click(function() {
				mapa.ukaz_adresu();
				return false;
			} );
		}

		if( $('#mapa-vnejsi').length == 1 && $("#zem_sirka").text() != 0 && $("#zem_delka").text() != 0 )
		{
			//alert('poloha OK');
			mapa.zobraz_polohu( $("#zem_sirka").text(), $("#zem_delka").text() );
			$('#mapa-vnejsi').hide();
			$('#mapa-vnejsi').css('height','auto');
			//$('#mala-mapa img').after('<span>Zvětšit mapu</span>');
			$('#mala-mapa').attr('href','#');
			$('#mala-mapa').attr('title','Zobrazit / skrýt velkou mapu');
			$('#mala-mapa').click( function() {
				$('#mapa-vnejsi').slideToggle("slow");
				return false;
			} );
		}
	}
}

var anketa = {

	init : function() {
		$(".anketa .odpoved-hlas").each( function(e) {
			if( $(this).find('input').length != 0 ) $(this).find('label').replaceWith('<a title="Hlasuj!" href="/etc/anketa-hlasovat.php?id_odpovedi='+$(this).find('input').attr('value')+'" onclick="return !anketa.hlasovat('+"'"+$(this).closest('form').attr('id')+"'"+', '+ $(this).find('input').attr('value')+')">'+$(this).find('label').text()+'</a>');
		} );
	},

	hlasovat : function( id_ankety, id_hlasu ) {
		$.ajax({
			type: "GET",
			url: "/etc/anketa-hlasovat.php",
			data: "ajax=true&id_odpovedi=" + id_hlasu,
			dataType: "html",
			beforeSend : function() {
			var i = 0;
			if( $( "#"+id_ankety ).length == 0) alert('Ukládá se!');
			$( "#"+id_ankety ).find(".chyba-uspech").html("<div class='provadim'><ul><li>Ukládám<span></span></li></ul></div>");
			timer = setInterval(function() {
				if( i%4 == 0 ) $( "#"+id_ankety+" .chyba-uspech li span" ).text("");
				else $( "#"+id_ankety+" .chyba-uspech li span" ).text( $( "#"+id_ankety+" .chyba-uspech li span" ).text()+"." );
				i++;
			}, 300 );
			},
			success: function(msg){
			clearInterval( timer );
			$( "#"+id_ankety ).children().eq(0).replaceWith( msg );
			$( "#"+id_ankety ).children().eq(0).effect('pulsate', {times: 2});
			return true;
			},
			error: function() {
			clearInterval( timer );
			return false;
			}
		});

	return true;
	}

}

var sprava = {

	/*pridavani_polozek : function()
	{
		$('.pridatelna-skupina').each( function()
		{
			$(this).find('input[type="submit"]:last')
			.click( function()
			{
				$(this).attr('disabled', 'disabled');
				
				// vytvori se nove docasne id pro novy zaznam
				nove_id = eval( Math.ceil(Math.random()*10000) );

				// zkopiruje se vychozi nova polozka
				stara_nova = $(this).closest('.pridatelna-skupina').find(':input[name*=novy\]]').eq(0).closest('.pridatelna-polozka');
				
				if( stara_nova == null || stara_nova === null ) return true;
				
				vkladany = stara_nova.clone();

				// puvodni nove se nastavi nove id
				stara_nova.attr('id', stara_nova.attr('id').replace( /novy([0-9\-]+)?/, 'novy-'+nove_id ) );
				stara_nova.find('label').each( function() { $(this).attr('for', $(this).attr('for').replace( /novy([0-9\-]+)?/, 'novy-'+nove_id ) ) });
				stara_nova.find(':input').each( function() { $(this).attr('id', $(this).attr('id').replace( /novy([0-9\-]+)?/, 'novy-'+nove_id ) ) });
				stara_nova.find(':input').each( function() { $(this).attr('name', $(this).attr('name').replace( /novy([0-9\-]+)?/, 'novy-'+nove_id ) ) });
				stara_nova.find('a').each( function() { $(this).attr('href', $(this).attr('href').replace( /novy([0-9\-]+)?/, 'novy-'+nove_id ) ) });
				//stara_nova.html( stara_nova.html().replace( /novy([0-9\-]+)?/g, 'novy-'+nove_id ) );

				// nove vkladana se vynuluje, vlozi na konec a presune se fokus na prvni policko
				//vkladany = $(this).closest('.pridatelna-skupina').find(':input[name*=novy\]]').eq(0).closest('.pridatelna-polozka');
				//alert( vkladany.length );
				vkladany.find('select').attr('selectedIndex',0);
				vkladany.find('input[type="text"]').val('');
				vkladany.insertBefore( this );
				vkladany.find(':input:first').focus();

				// puvodni se ukaze odkaz pro smazani
				stara_nova.removeClass('nesmazatelny');
				//stara_nova.addClass('oddel-vespod');

                $(this).attr('disabled', '');
				return false;
			})
			.each( function() {
				$(this).attr('value', '+ '+$(this).attr('value'));
			});
		});
	},*/
	
pridavani_polozek : function()
	{
		$('.pridatelna-skupina').each( function()
		{
			$(this).find('input[type="submit"]:last')
			.click( function()
			{
				add_tlacitko = $(this);
				polozka = $(this).attr('id').substr(4);
				kategorie = polozka.substr( 0, polozka.indexOf('-') );

				$(this).attr('disabled', 'disabled');

				// vytvori se nove docasne id pro novy zaznam
				nove_id = eval( Math.ceil(Math.random()*10000) );

				// zkopiruje se vychozi nova polozka
				stara_nova = $(this).closest('.pridatelna-skupina').find(':input[name*=novy\]]').eq(0).closest('.pridatelna-polozka');
				vzor = $('#'+kategorie+'-vzor');

				if( vzor == null || vzor === null ) return true;

				vkladany = vzor.clone();

                if( stara_nova != null && stara_nova !== null && stara_nova.html() !== null )
                {
					// puvodni nove se nastavi nove id
					stara_nova.attr('id', stara_nova.attr('id').replace( /novy([0-9\-]+)?/, 'novy-'+nove_id ) );
					stara_nova.find('label').each( function() { $(this).attr('for', $(this).attr('for').replace( /novy([0-9\-]+)?/, 'novy-'+nove_id ) ) });
					stara_nova.find(':input').each( function() { $(this).attr('id', $(this).attr('id').replace( /novy([0-9\-]+)?/, 'novy-'+nove_id ) ) });
					stara_nova.find(':input').each( function() { $(this).attr('name', $(this).attr('name').replace( /novy([0-9\-]+)?/, 'novy-'+nove_id ) ) });
					stara_nova.find('a').each( function() { $(this).attr('href', $(this).attr('href').replace( /novy([0-9\-]+)?/, 'novy-'+nove_id ) ) });
					stara_nova.removeClass('nesmazatelny');
				}

                vkladany.attr('id', vkladany.attr('id').replace( /-vzor/, '-novy' ) );
				vkladany.html( vkladany.html().replace( /vzor/g, 'novy' ) );
				vkladany.html( vkladany.html().replace( /\[\]/g, '['+polozka.substr( polozka.indexOf('-')+1 )+']' ) );

				// nove vkladana se vynuluje, vlozi na konec a presune se fokus na prvni policko
				//vkladany = $(this).closest('.pridatelna-skupina').find(':input[name*=novy\]]').eq(0).closest('.pridatelna-polozka');
				//alert( vkladany.length );
				vkladany.find('select').attr('selectedIndex',0);
				vkladany.find('input[type="text"]').val('');
				vkladany.insertBefore( this );
				vkladany.show();
				vkladany.find(':input:first').focus();

				// puvodni se ukaze odkaz pro smazani
				//stara_nova.addClass('oddel-vespod');

                $(this).attr('disabled', '');
				return false;
			})
			.each( function() {
				$(this).attr('value', '+ '+$(this).attr('value'));
			});
		});
	},

	mazaci_odkazy : function()
	{
		$('a.odstranit').live('click', function(e)
		{
			if( window.confirm("Opravdu si přeješ smazat tuto položku?") )
			{
				$(this).html('Maže se...');
				$(this).blur();
				$(this).closest('.soubor').addClass('maze-se');
				$(this).closest('.pridatelna-polozka').addClass('maze-se');
				// odkaz ke smazání neobsahuje id s hodnotou "novy" apod.
				if( $(this).attr('href').search("novy") == -1 )
				{
					$.ajax({
						type: "GET",
						url: $(this).attr('href'),
						data: 'ajax=1',
						dataType: 'json',
						success : function( odpoved ) {
							if( odpoved.smazano == 1 )
							{
								if( $('#'+odpoved.polozka).length != 0 )
								{
									$('#'+odpoved.polozka).fadeOut('normal', function() {
										$('#'+odpoved.polozka).remove();
									} );
								}
								else window.location = this.url+'&noajax=1';
							}
							else { window.location = this.url+'&noajax=1'; }
						},
						error : function() {
							window.location = this.url+'&noajax=1';
						}
					} );
				} else {
                    if( $(this).closest('.pridatelna-polozka') != null )
                    {
						$(this).closest('.pridatelna-polozka').fadeOut('normal', function(e) {
							$(this).remove();
						} );
					} else { window.location = this.url+'&noajax=1'; }
				}
			}
			return false;
		} );
	},
	
	ucasti_druzstev_odskrtnuti : function() {
		$('.ucasti_druzstev input[value!="0"]').change( function(e) {
			$('.ucasti_druzstev input[value="0"]').attr('checked', false);
		} );
	},

	pridani_fotografie : function() {
		$("#TB_window .fotogalerie a").click( function() {
   			$(".ui-dialog input.src").val( $(this).closest('.fotka').attr('id').substr(6) );
			tb_remove();
			return false;
		} );
	},
	
	pirazovani_fotografii : function() {
		$('#zdrojova-galerie input[type="checkbox"]').live( 'click', function(e) {
			if( $(this).attr('checked') == true )
			{
				var fotka = $(this).closest(".fotka");
				fotka.remove();
				fotka.insertAfter( '#cilova-galerie h3' );
			}
		} );
		$('#cilova-galerie input[type="checkbox"]').live( 'click', function(e) {
			if( $(this).attr('checked') == false )
			{
				var fotka = $(this).closest(".fotka");
				fotka.remove();
				fotka.insertAfter( '#zdrojova-galerie .fotogalerie h4' );
			}
		} );
	},
	
	serazovani : function()
	{
		$('.sortable').css('cursor','move');
		$('.sortable').sortable({ cursor: 'move' });
		$('.sortable').bind('sortupdate', function(event, ui)
		{
			$(this).children('div').each( function(i) { $(this).find('input[name*=poradi]').val(i+1); } );
			//$('.sortable .poradi').removeClass('hidden-js');
		});
	},
	
	hromadne_nahravani : function()
	{
		$('.oznac_vsechny_hromadne').show();

		$('.oznac_vsechny_hromadne').find('input#vsechny-hromadne').live( 'click', function()
		{
			$('.hromadne_nahrane .soubor input[type=checkbox]').attr('checked', $(this).attr('checked'));
		});
		
		$('#hromadne-nahrane-reload').live('click', function() {
			//$(this).css('disabled',true);
			$('#hromadne_nahrane .stav').text('Hledají se nové soubory...');
			$.get("/sprava/hromadne-nahrane-soubory.php", function(data) {
	            $('#hromadne_nahrane').html( data );
	        } );
	        //$(this).css('disabled',false);
	        return false;
		} );
	},
	
	datum_konce : function()
	{
		$('input[name*=konec\]]').focus( function()
		{
			if( $(this).val() == '' && $(this).closest('fieldset').find('input[name*=zacatek\]]').eq(0).val() != '' )
			{
				$(this).val( $(this).closest('fieldset').find('input[name*=zacatek\]]').eq(0).val() );
			}
		});
	},

	init : function()
	{
		this.mazaci_odkazy();
		this.pridavani_polozek();
		this.ucasti_druzstev_odskrtnuti();
		this.pirazovani_fotografii();
		this.serazovani();
		this.hromadne_nahravani();
		this.datum_konce();
	}

}

function swfupload() {

	var settings = {
		flash_url : "/etc/swfupload/swfupload/swfupload.swf",
		upload_url: "/sprava/ajax-nahravani-souboru.php",	// Relative to the SWF file
		post_params: {"PHPSESSID" : "<?php echo session_id(); ?>"},
				file_post_name: "fileupload",
				file_size_limit : "8 MB",
		file_types : "*.jpg;*.png;*.gif;*.doc;*.docx;*.xls;*.xlsx;*.zip;*.rar;*.ppt;*.pptx;*.pdf;*.txt",
		file_types_description : "Všechny soubory",
		file_upload_limit : 100,
		file_queue_limit : 0,
		custom_settings : {
			progressTarget : "fsUploadProgress",
			cancelButtonId : "btnCancel"
		},
		debug: false,

		// Button Settings
		button_image_url : "/etc/swfupload/XPButtonUploadText_61x22.png",	// Relative to the SWF file
		button_placeholder_id : "spanButtonPlaceholder",
		button_width: 61,
		button_height: 22,

		// The event handler functions are defined in handlers.js
		swfupload_loaded_handler : swfUploadLoaded,
		file_queued_handler : fileQueued,
		file_queue_error_handler : fileQueueError,
		file_dialog_complete_handler : fileDialogComplete,
		upload_start_handler : uploadStart,
		upload_progress_handler : uploadProgress,
		upload_error_handler : uploadError,
		upload_success_handler : uploadSuccess,
		upload_complete_handler : uploadComplete,
		queue_complete_handler : queueComplete	// Queue plugin event
	};

	swfu = new SWFUpload(settings);
}

$(document).ready(function() {

	$('.nasi-mali-pozarnici img').mouseover( function(e) {
		this.src = '/img/nasi-mali-pozarnici-hover.png';
	} ).mouseout( function(e) {
		this.src = '/img/nasi-mali-pozarnici.png';
	} );

	if( $("#eposta").html() != null ) {
		$("form").submit( function() {
			$("#email").val( $("#jmeno").val() );
		} );
	}
	
	if( $("form").length > 1 ) $("form").eq(0).find("select").change( function() {
		$("form").eq(0).submit();
	} );

	$.datepicker.setDefaults( { dayNamesMin: ['Ne', 'Po', 'Út', 'St', 'Čt', 'Pá', 'So'], monthNames: ['Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen', 'Červenec', 'Srpen', 'Září', 'Říjen', 'Listopad', 'Prosinec'], yearRange: '-0:+1', firstDay: 1, dateFormat: 'dd.mm.yy' } );
	$("#platnost_do").datepicker();
	$("#platnost_od").datepicker();
	$("#datum").datepicker();
	$("input.datum").datepicker();

	animovane_fotky.init();
	
	$('.sloupec + .sloupec').addClass('druhy-sloupec');
	
	$('a.lightbox').lightbox();
	
	$('#sprava textarea').texyla({
		toolbar: [
			'h2', 'h3', 'h4',
			null,
			'bold', 'italic',
			null,
			'center', ['left', 'right', 'justify'],
			null,
			'ul', 'ol',
			null,
			'link', 'img', 'table', 'emoticon',
			null,
			 'blockquote',
			null,
			['sup', 'sub', 'del', 'acronym', 'hr', 'notexy', 'web']
		],
		bottomRightPreviewToolbar: ['syntax'],
		tabs: false,
		baseDir: "/etc/texyla/texyla/",
		texyCfg: "admin",
		width: null,
		lng: "cs",
		buttonType: "span"
	});

	$('#kniha-hostu textarea').texyla({
		toolbar: [
			'bold', 'italic',
			null,
			'ul', 'ol',
			null,
			'link', 'emoticon',
			null,
			 'blockquote',
		],
		bottomRightPreviewToolbar: ['syntax'],
		tabs: false,
		baseDir: "/etc/texyla/texyla/",
		texyCfg: "admin",
		width: null,
		lng: "cs",
		buttonType: "span"
	});

	$.texyla("addWindow", "link", {
		dimensions: [570, 410],

		createContent: function () {
			return $(
				'<div><table><tbody><tr>' +
					'<th><label>' + this.lng.linkText + '</label></th>' +
					'<td><input type="text" class="link-text" value="' + this.texy.doTrimSelect().txt + '"></td>' +
				'</tr><tr>' +
					'<th><label>' + this.lng.linkUrl + '</label></th>' +
					'<td><input type="text" class="link-url"></td>' +
				'</tr><tr>' +
					'<th><label>Odkaz na položku</label></th>' +
					'<td id="hodnota_odkazu_na_polozky">' + $('#odkazy_na_polozky').html() +'</td>' +
				'</tr></tbody></table></div>'
			);
		},

		action: function (el) {
            var txt = el.find(".link-text").val();
			var odkaz = $('#hodnota_odkazu_na_polozky select').val();
			if( odkaz == null || odkaz == 0 ) odkaz = el.find(".link-url").val();
			txt = txt == '' ? '' : '"' + txt + '":';
			this.texy.replace(txt + odkaz);
			$('#odkazy_na_polozky select').attr('selectedIndex', 0);
		}
	});
	
	// Okno obrázku
	$.texyla("addWindow", "img", {
		createContent: function () {
			return $(
				'<div><p><a href="/sprava/vyber-fotografii.php?height=500&width=600&predmet=' + $('input[name=predmet]').val() + '&id=' + $('input[name=id]').val() + '" class="thickbox">Vybrat uloženou fotku v galerii</a></p>' +
				'<table><tbody><tr>' +
					// Adresa
					'<th><label>' + this.lng.imgSrc + '</label></th>' +
					'<td><input type="text" class="src"></td>' +
				'</tr><tr>' +
					// Alt
					'<th><label>' + this.lng.imgAlt + '</label></th>' +
					'<td><input type="text" class="alt"></td>' +
				'</tr><tr>' +
					// Zarovnání
					'<th><label>' + this.lng.imgAlign + '</label></th>' +
					'<td><select class="align">' +
						'<option value="*">' + this.lng.imgAlignNone + '</option>' +
						'<option value="<">' + this.lng.imgAlignLeft + '</option>' +
						'<option value=">">' + this.lng.imgAlignRight + '</option>' +
						'<option value="<>">' + this.lng.imgAlignCenter + '</option>' +
					'</select></td>' +
				'</tr></tbody></table></div>'
			);
		},

		action: function (el) {
			this.texy.img(
				el.find(".src").val(),
				el.find(".alt").val(),
				el.find(".align").val()
			);
		},

		dimensions: [350, 350]
	});
	
	mapa.init();
	
	sprava.init();

	anketa.init();

	$('.odpoved').children().click( function(e) {
		var cislo = $(this).attr('href').substr(-3);
		$('#odpoved').attr('value', cislo );
		$(this).attr('href','#');
	} );
	
	if( $('#hromadne-nahravani').length != 0 ) swfupload();
	
	$('#stalo-se,#ceka-nas,#posledni-zmeny,#loni').find('a:last').click( function()
	{
		$(this).closest('div').find('.blizke-dalsi').slideToggle('slow');
		$(this).remove();
		return false;
	});

});

$('body').unload(function() {
	GUnload();
});
