/**
 * @author dudee
 */
function ladujZdjecie(id, adres, iter, typ, gal) {
	var zdjecia = $('[id^=numerZdjecia_'+gal+'_]');

	if ( iter < zdjecia.length && iter >= 0 ) {
		//var htmlFoto = '<div class="galleryPhotoBorder"><a id="glowneLink" href="'+adres+'" class="thickbox"><img id="glowne" src="'+adres+'" alt="" title="" /></a></div>';
		var htmlFLV = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="400" height="300" id="video" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="false" /><param name="movie" value="'+adres+'" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="'+adres+'" quality="high" bgcolor="#ffffff" width="400" height="300" name="video" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
		//alert(gal);
		
		if (typ == 'foto') {
			$('#glowneLink_'+gal).attr('href',adres);
			$('#glowne_'+gal).attr('src',adres);
			$('#galleryPhoto_'+gal).hide();
			$('#galleryPhoto2_'+gal).show();
		}
		else if (typ == 'flv') {
			$('#galleryPhoto_'+gal).html(htmlFLV);
			$('#galleryPhoto2_'+gal).hide();
			$('#galleryPhoto_'+gal).show();
		}
		//alert(gal);
		//$('#galleryPhoto').html('fffggffgfg');
		$('#glowneLink_'+gal).attr('href',adres);
		$('#glowne_'+gal).attr('src',adres);
		zdjecia.attr('class', 'galleryItemsUnselected');
		$('#numerZdjecia_'+gal+'_' + iter).attr('class', 'galleryItemsSelected');
		
		iterPop = iter-1;
		adres = $('#adres_'+gal+'_' + iterPop).attr('value');
		typ = $('#typ_'+gal+'_' + iterPop).attr('value');
		$('#linkZdjeciePop_'+gal).bind('click',{id: id, adres: adres, iter: iterPop, typ: typ, gal: gal, opis: opis}, ladujZdjecie2 );
		
		iterNast = iter+1;
		adres = $('#adres_'+gal+'_' + iterNast).attr('value');
		typ = $('#typ_'+gal+'_' + iterNast).attr('value');
		$('#linkZdjecieNast_'+gal).bind('click',{id: id, adres: adres, iter: iterNast, typ: typ, gal: gal, opis: opis}, ladujZdjecie2 );
		
		if (opis[gal] != undefined) $('#photoDescription_'+gal).html(opis[gal][id]);
	}
}

function ladujZdjecie2(event) {
	gal = event.data.gal;
	iter = event.data.iter;
	adres = event.data.adres;
	id = event.data.id;
	typ = event.data.typ;
	opis = event.data.opis;
	ladujZdjecie(id, adres, iter, typ, gal);
}

