function GenerateCustomFckGallery(files_array)
{
		var result="";
		result+="<div class='bodyGallery-env'>";		
		
		for (var a=0;a<files_array.length;a++){
			result+="<a class='bodyGallery' href=\""+files_array[a].path+"\" rel=\"lightbox[gallery]\"><img alt=\"\" src=\""+files_array[a].thumb+"\" /></a>";
		}
		
		result+="<div class='cleaner'></div></div>";
		return result;
}

$(function() {
	$.fn.nyroModal.settings.processHandler = function(settings) {
		var from = settings.from;
		if (!settings.type && from && from.href) {
			/*alert(
				'type should be image: '+settings.type + '\n'
				+ "need to determine if image manually");*/
			var arr = from.href.split('?');
			//if carrying extra stuff
			if(arr.length>1){
				var newArr=arr[0].split('.');
				var newType=settings.type;
				//alert('extension is: ' + newArr[newArr.length-1]);
				switch(newArr[newArr.length-1].toUpperCase()){
					case 'IMG':
					case 'JPG':
					case 'JPEG':
					case 'PNG':
					case 'GIF':
					case 'ASPX':
						newType='image';
						break;
					default:
						newType=settings.type;
				}
				//alert("new type is " + newType);
				$.nyroModalSettings({
					type: newType
				});
			}
		}
	};
	
});

$(document).ready(function(){

	$("a[rel=lightbox]").nyroModal({galleryCounts: false});

  	// otevreni odkazu do noveho okna	
  	$("a.nw").attr("title", "Tento odkaz se otevře do nového okna");
  
      $('a.nw').click( function() {
          window.open( $(this).attr('href') );
          return false;
      });
      
    // validace formularu
    $("#form").ndFormValidator();
    
	function genPrednasejici(val){
		$("#seznamPrednasejicich").remove();
				
		var seznam = jQuery('<table class="form" id="seznamPrednasejicich"></table>');
		
		for(i=1; i<=val; i++){
			id = "prednasejici" + i;		
			var el = jQuery('<tr><th><label for="'+ id +'">Jméno a Příjmení</label></th><td><input class="required" title="Přednášející '+ i +'"type="text" name="'+ id +'" id="'+ id +'" type="text" /><strong class="star">*</strong></td></tr>');
			seznam.append(el);
		}
		
		$("#prednasejiciForm").after(seznam);		
	}
	
	genPrednasejici(1);
	
	$("#pocet").change(function(){ 
		var val = $(this).val();
		genPrednasejici(val);		
	});    
																												
});

