
// SPOLECNE - skryvani formu pro prihlaseni
var login = {
    init: function ()
    {
        if( typeof($('#ppri_toggle'))!='object')
            return false;
       
       $('#ppri_toggle').click(function(){ login.toggle(); return false; });
       if(!$('#prihl_pravy p.error').attr('class'))
       {
           $('#ppri_he').toggle();
           $('#ppri_jm').toggle();
       }
       //$('#pprihlas').click( function(){ this.checkdata; return false; } ); 
       $('#prihl_pravy').bind('submit', function(){ return login.checkdata(); });
    },
    toggle: function ()
    {     
        $('#ppri_he').toggle();
        $('#ppri_jm').toggle(); 
        $('#ppri_toggle').toggle();
    },
    checkdata: function()
    {
        if( $('#pjmeno').attr('value') && $('#pheslo').attr('value') )
        {                
            $('#prihl_pravy').unbind('submit');
            $('#prihl_pravy').submit(); 
            return true;  
        }
        else
        {                                            
            alert('Zadejte uživatelské jméno a heslo.');
            return false;
        }
    }
};

// SPOLECNE - akce hlavniho menu 
var mainmenu = {
    init: function()
    {
        $('#hlavicka li').bind('mouseover',function(){ $(this).addClass('hover') }).bind('mouseout', function(){ $(this).removeClass('hover') });
        $('a#m2').click(function(){ return false });
    }
};
      
// REKLAMA - zarazeni v katalogu
var tmenu = {
    //maximalni pocet zatrzenych checkboxu
    maxChecked: 0,
    init: function()
    {
        if( typeof($('#zarkat')) != 'object') return false;
        
        if( $('#zarkat').hasClass('zarkat_rbannery') )
        {
            this.maxChecked = 0;
            this.bannery = true;
        }
        if( $('#zarkat').hasClass('zarkat_rkatalog') )
            this.maxChecked = 0;
        
        
                
        $('#temp_zarazeno').after('<input type="hidden" name="temp_zarazeno_sys" id="temp_zarazeno_sys" value="" />');  

            
        this.countChecked($(this));
        this.hideall();
        $('#sbalitvse').click(function(){ tmenu.hideall(); return false; });
        $('#rozbalitvse').click(function(){ tmenu.showall(); return false; });
        
        $('#zarkat>li>span,ul.lev1>li>span').click(function(){ tmenu.toggleChild(this); });
        $('ul.lev2>li>span').click(function(){ tmenu.toggleCheck(this); });
        
        if(this.bannery)
          $('#zarkat input').click(function(){ tmenu.countChecked($(this)); });
        else
          $('input.treeCheck').click(function(){ tmenu.countChecked($(this)); });
          
        
    },
    hideall: function()
    {
        $('ul.lev1,ul.lev2').hide();    
        $('ul#zarkat span').removeClass('opened');              
    },
    showall: function()
    {
        $('ul.lev1,ul.lev2').show();
        $('ul#zarkat span').addClass('opened');
    },
    //rozbaleni 2 poslednich urovni
    toggleChild: function(e)
    {
        var subul =  $(e).next();
        if( subul.attr('class') == 'lev1' || subul.attr('class') == 'lev2' )
        {
            subul.toggle();
        }
        $(e).toggleClass('opened');
    },
    //prepnuti checkboxu v posledni urovni
    toggleCheck: function(e)
    {
        if(typeof(e)=='object')
            var check = $(e).prev();
        else
            var check = $('#'+e);
        if( check.attr('type') == 'checkbox' )    
        {
            if(check.attr('checked'))
                check.removeAttr('checked');
            else
                check.attr('checked','checked');
        }
        tmenu.countChecked(check);
    },
    inCats: '',
    //pocitani zatrhlych
    countChecked: function(e)
    {
        if( tmenu.maxChecked && ($('input.treeCheck:checked').length > tmenu.maxChecked ))
        {
            e.removeAttr('checked');
            alert('Dosáhli jste maximálního počtu zařazení.\nPro zařazení do této kategorie musíte zrušit zařazení v jiné kategorii.');
        }
        tmenu.inCats = '';
        tmenu.inCatsSys = '';
        if(tmenu.bannery)
          var checked = $('ul#zarkat input:checked');
        else
          var checked = $('input.treeCheck:checked');
          
        checked.each(function(){  
            var path = '';
            //level 1
            if( $(this).parent('span').parent('li').parent('ul#zarkat').length )
            {
              path += $(this).parent('span').text();
              pathSys = path+'#';
              path = '<li>'+path+' <a href="#" onclick="tmenu.toggleCheck(\''+$(this).attr('id')+'\');return false;">vyřadit</a></li>'; 
              tmenu.inCats += path;
              
              tmenu.inCatsSys += pathSys;
            }
            //level 2
            if( $(this).parent('span').parent('li').parent('ul').parent('li').parent('ul#zarkat').length )
            {
              path += $(this).parent('span').parent('li').parent('ul').prev('span').text()+' / ';
              path += $(this).parent('span').text();
              pathSys = path+'#';
              path = '<li>'+path+' <a href="#" onclick="tmenu.toggleCheck(\''+$(this).attr('id')+'\');return false;">vyřadit</a></li>'; 
              tmenu.inCats += path;
              
              tmenu.inCatsSys += pathSys;
               
            }
            //level 3 
            else if($(this).next('span').length)
            {
              thiss = $(this).next('span');                                     
              path = thiss.parent('li').parent('ul').parent('li').parent('ul').prev('span').text()+' / ';
              path +=  thiss.parent('li').parent('ul').prev('span').text()+' / ';
              path += thiss.text();
              path = path.replace(/( \/  \/ )/,""); // remove double slash
              path = path.replace(/^( \/ )/,""); // remove first slash
              pathSys = thiss.text()+'#';//'<li>'+path+'</li>';
              path = '<li>'+path+' <a href="#" onclick="tmenu.toggleCheck(\''+thiss.prev('input').attr('id')+'\');return false;">vyřadit</a></li>'; 
              tmenu.inCats += path;
              
              pathSys = pathSys.replace(" \/  \/ ","");
              tmenu.inCatsSys += pathSys;
            }
            
            //tmenu.inCats = tmenu.inCats.replace('li\>\/ ','li\>');
            //tmenu.inCatsSys = tmenu.inCatsSys.replace('li\>\/ ','li\>');

        });
        $('#temp_zarazeno').attr('value','<ol>'+tmenu.inCats+'</ol>');
        tmenu.inCatsSys = tmenu.inCatsSys.replace(/#$/,'');
        $('#temp_zarazeno_sys').attr('value',tmenu.inCatsSys);
        
        
        if(tmenu.maxChecked)
        	remaining = '<p class="celkem">Zbývá možnost zařazení v '+(this.maxChecked-checked.length)+' kategoriích.</p>';
        else
        	remaining = '';
        	
        $('#treeSum').html(
            '<p class="vybrane">Vybraná zařazení v katalogu firem:</p>'+
            '<ol>'+tmenu.inCats+'</ol>'+
            remaining+
            '<p class="celkem">Celkem zařazeno v '+checked.length+' kategoriích.</p>'
            );
    }
    

};


//datepicker
var tptemp_od,tptemp_do;
function showCal(idod,iddo,minlength,maxlength)
{
	tptemp_do = idod;
	tptemp_od = iddo;
	
	jQuery(function($){
			$.datepicker.regional['cs'] = {clearText: 'Vymazat', clearStatus: 'Vymaže zadané datum',
				closeText: 'Zavřít',  closeStatus: 'Zavře kalendář beze změny',
				prevText: '&#x3c;Dříve', prevStatus: 'Přejít na předchozí měsí',
				nextText: 'Později&#x3e;', nextStatus: 'Přejít na další měsíc',
				currentText: 'Nyní', currentStatus: 'Přejde na aktuální měsíc',
				monthNames: ['leden','únor','březen','duben','květen','červen',
						'červenec','srpen','září','říjen','listopad','prosinec'],
				monthNamesShort: ['led','úno','bře','dub','kvě','čer',
				'čvc','srp','zář','říj','lis','pro'],
				monthStatus: 'Přejít na jiný měsíc', yearStatus: 'Přejít na jiný rok',
				weekHeader: 'Týd', weekStatus: 'Týden v roce',
				dayNames: ['neděle', 'pondělí', 'úterý', 'středa', 'čtvrtek', 'pátek', 'sobota'],
				dayNamesShort: ['ne', 'po', 'út', 'st', 'čt', 'pá', 'so'],
				dayNamesMin: ['ne','po','út','st','čt','pá','so'],
				dayStatus: 'Nastavit DD jako první den v týdnu', dateStatus: '\'Vyber\' DD, M d',
				dateFormat: 'dd.mm.yy', firstDay: 1, 
				initStatus: 'Vyberte datum', isRTL: false};
			$.datepicker.setDefaults($.datepicker.regional['cs']);
	});

		
	$('#'+idod+',#'+iddo).datepicker({ 
			//minDate: new Date(),
			onSelect: function(){ 
			          
			          // today
                var date_tdo = new Date();
                tnewdate = date_tdo.getDate();
                tnewdate+= '.';
                tnewdate+= date_tdo.getMonth()+1;
                tnewdate+= '.';
                tnewdate+= date_tdo.getFullYear();
                
                // "from" isnt filled
                if(!$('#'+idod).attr('value'))
                {
                    // fill with today
                    $('#'+idod).attr('value', tnewdate);
                }
                
                // parse and create "from" date
                minr = $('#'+idod).attr('value').split('.');
                var mint = new Date();
                mint.setFullYear(minr[2],minr[1]-1,minr[0]);
                
                // "from" < today
                if( mint < date_tdo)
                {
                    // set "from" to today
                    $('#'+idod).attr('value', tnewdate);
                }
                
		          
			          // if "to" date is not set
                if( ! $('#'+iddo).attr('value') )
                {
                    // set "to" date to "from" date
                    $('#'+iddo).attr('value', $('#'+idod).attr('value') ); //auto select 'to' date
                }
                    
                    
                if(minlength)
                {
                    //split dates to array
                    dod = $('#'+idod).attr('value').split('.');
                    ddo = $('#'+iddo).attr('value').split('.');
                    //var dates
                    var date_od = new Date();
                    var date_do = new Date();
                    //parse input dates to object
                    date_od.setFullYear(dod[2],dod[1]-1,dod[0]);
                    date_do.setFullYear(ddo[2],ddo[1]-1,ddo[0]);
                    //count difference between dates
                    var diff = (date_do - date_od)/(1000*60*60*24);      

                    if( diff < minlength )
                    {   
                    
                        // set new "to" date same as "from" date
                        date_do.setFullYear(dod[2],dod[1]-1,dod[0]);                    
                        // set mimimal end date from begin date and minimal length
                        date_do.setDate(date_do.getDate()+minlength);  
               
                        //make date string                    
                        newdate = date_do.getDate();
                        newdate+= '.';
                        newdate+= date_do.getMonth()+1;
                        newdate+= '.';
                        newdate+= date_do.getFullYear();

                        $('#'+iddo).attr('value',newdate);

                    }
                }
                
                if(maxlength)
                {
                    //split dates to array
                    dod = $('#'+idod).attr('value').split('.');
                    ddo = $('#'+iddo).attr('value').split('.');
                    //var dates
                    var date_od = new Date();
                    var date_do = new Date();
                    //parse input dates to object
                    date_od.setFullYear(dod[2],dod[1]-1,dod[0]);
                    date_do.setFullYear(ddo[2],ddo[1]-1,ddo[0]);
                    //count difference between dates
                    var diff = (date_do - date_od)/(1000*60*60*24);      
                    //set mimimal end date from begin date and minimal length
                    date_do.setDate(date_od.getDate()+maxlength);                              
                    //make date string                    
                    newdate = date_do.getDate();
                    newdate+= '.';
                    newdate+= date_do.getMonth()+1;
                    newdate+= '.';
                    newdate+= date_do.getFullYear();
                    
                    if( diff > maxlength || diff<0 )
                    {                      
                       $('#'+iddo).attr('value',newdate);
                    }
                }

			}
	}); 
	

}	


var filtr = {
		init: function()
		{
			$('#toggle_hledani').hide();
			$('#toggle_hledani_ctrl').click(function(){ $('#toggle_hledani').toggle(); $(this).toggleClass('act') });
            $('#toggle_filtr').hide();
            $('#toggle_filtr_ctrl').click(function(){ $('#toggle_filtr').toggle(); $(this).toggleClass('act') });
		}
}


function periodical( fn, time ) {
    fn();
    if (time > 0) return setInterval( fn, time );
} 

var tcounter = {
		//limity
		limits: { 
				rclankynadpis: 105,
				rclankyperex: 315,
                
				rzpravynadpis: 160,
				rzpravyperex: 260,
				rzpravytext: 0,
                
        rvideapopis: 450,
        
        rkatalogpopis: 420
		},
		//doporucene hodnoty
		doporu: { 
				aclankyperex: 315,
				aclankynadpis: 105,
                
        azpravynadpis: 105,
        azpravyperex: 315
		},
		init: function(type,jqtid/*,limit,doporuc*/){
			periodical( function(){tcounter.count(jqtid,tcounter.limits[type],tcounter.doporu[type])}, 100 );
		},
		count: function(jqtid,limit,doporuc)
		{
			jqt = $('#'+jqtid);
			if(!jqt.prev('span').hasClass('txtstatus'))
				jqt.before('<span class="txtstatus" id="status_'+jqtid+'"></span>');
			jqs = $('#status_'+jqtid);
			var jqtext = jqt.attr('value');
			var diff = jqtext.length;
			//pokud je nastaven limit
			if(limit>0) {
				//rozdil max a aktualniho
				diff = limit - diff;
				if(diff<0){
					//pokud prekrocime limit, orez text
					jqt.attr('value', jqtext.substring(0,limit) );
				}
				if(diff<=0)
					diff = '<b>Dosáhli jste maximálního počtu znaků</b>';
				else
					diff = 'Zbývá '+diff+' znaků.';
			}
			else {
				//bez podorucene hodnoty
				if(!doporuc){
					diff = 'Napsáno '+diff+' znaků.';
				}
				//s doporucenou hodnotou
				else {
					diff = doporuc - diff;
					diff = 'Zbývá '+diff+' znaků do doporučené hodnoty.';
				}
			}
			jqs.html(diff);
			}
}

 // MEDIA - AKCE - filtr 
 var mfiltr = {
        init: function()
        {
            $('select#fobdrok,select#fobdmes').change(function(){
                if($('select#fobdrok').attr('value')=='0')
                {
                    $('select#fobdmes').attr('value',0);
                }
            });
        }
 }


// ODKAZY - tree menu
var odkazy = {
    init: function()
    {                                
        odkazy.init_backend(); 
        if( typeof($('div.odkazy'))!='object' )
                return false;
        
        $('div.odkazy h2,div.odkazy h3').click(function(){ 
                if( $(this).next().hasClass('sub_odkazy') || $(this).next().hasClass('sub_odkazy1') )
                {
                    $(this).next().toggle();     
                    $(this).toggleClass('closed');
                    if( $(this).next().css('display')=='none' )
                    {
                        $(this).next().children('div').hide();
                        $(this).next().children('h3').addClass('closed');
                    }
                }
        });
        
        $('div.sub_odkazy,div.sub_odkazy1').hide();
        $('div.odkazy h2,div.odkazy h3').addClass('closed');
    },
    init_backend: function()
    {                                                     
        $('div#zarkat div > span').click(function(){
            $($(this).nextAll('div').get(0)).toggle(); 
        }); 
        if( ! $('div#zarkat').hasClass('odkazy_back') )
        this.hideall();                                         
    },
    hideall: function()
    {
        $('div#zarkat div.lev1,div#zarkat div.lev3').hide();
    },
    showall: function()
    {
        $('div#zarkat div.lev1,div#zarkat div.lev3').show();
    }

};

// SPOLECNE - auto switch obrazku
autoswi_images = new Array();
preloaded = new Array();
var autoswi = {
    init: function()
    {
        $('*[src*=-hp-]')
            .bind('mouseover',function(){ $(this).attr('src', $(this).attr('src').replace('-hp-','-ha-') ) })
            .bind('mouseout',function(){ $(this).attr('src', $(this).attr('src').replace('-ha-','-hp-') ) })
            .each(function(){ autoswi_images[autoswi_images.length] = $(this).attr('src').replace('-hp-','-ha-'); });
        for (var i = 0; i < autoswi_images.length; i++){
           preloaded[i] = document.createElement('img');
           $(preloaded[i]).attr('src',autoswi_images[i]);
        };
    }
}


function tcul(element, thisEl){
    if($(element) && $(thisEl))  
    {
        var tosave;
        if($(element).hasClass('hidden')){
            $(element).removeClass('hidden');
            $(thisEl).addClass('opened');
        }
        else {
            $(element).addClass('hidden');
            $(thisEl).removeClass('opened');
        }
    }
}
function tculall(direction){
    if(direction)
        $('.lev3','.lev2','.lev1').each(function(){
            $(this).removeClass('hidden');
            $(this).addClass('opened');
        });
    else
        $('.lev3','.lev2','.lev1').each(function(){
            $(this).addClass('hidden');
            $(this).removeClass('opened');
        });
}

//objednavka bannery
function checkdat()
{
    if($('#bezobrod').attr('value')&&$('#bezobrdo').attr('value')&& $('#obj_proklik').attr('value'))
    {
        $('#obj_proklik').attr('disabled',true);
        $('#bezobrod').attr('disabled',false); 
         $('#bezobrdo').attr('disabled',false); 
        
        if( confirm('Není možné kombonivat počet prokliků s datumem.\nChcete nastavit počet prokliků namísto data?') )
        {
          $('#bezobrod').attr('value','');
          $('#bezobrdo').attr('value','');
          $('#obj_proklik').attr('disabled',false);
          $('#bezobrod').attr('disabled',true); 
          $('#bezobrdo').attr('disabled',true);  
          $('#obj_proklik').focus(); 
        }
    }
    else
    {
         $('#obj_proklik').attr('disabled',false);
    }


}
function switchblocks()
{                     
   if($('#zar_vedlejsi').attr('checked'))
      $('#zarvedlejsi').show();
   else
                    $('#zarvedlejsi').hide();
                
   if($('#zar_vedlejsi').attr('checked') && $('#zar_media').attr('checked'))    
                    $('#zarmedia').show();
   else
                    $('#zarmedia').hide();
  //prepinani zobrazeni stromu a dalsi jeho udalosti
  if( $('#zar_katalog').attr('checked') ){
    $('#zarkatalog').show()
  }
  else {
    $('#zarkatalog').hide()
  }
}


// uzivatelsky admin - zmena typu uctu
function fzmuzucet()
{
    if($('#zmuzucet').attr('value')=='odbornik')
    {
        $('.t_klient').hide();
        $('.t_odbornik').show();
    }
    else if($('#zmuzucet').attr('value')=='klient')
    {
        $('.t_odbornik').hide();
        $('.t_klient').show();
    }
    else
    {
       $('.t_odbornik').hide();
       $('.t_klient').hide(); 
    }                                           
}

clankyDiskuze = {
   autofocus: function()
   {
        if( $('form#novyp textarea').length )  {
            $('form#novyp textarea').focus();            
        }    
   }
}

vamiddle = {
   init: function(count)
   {
      if( ! $('.fotb').length || count < 0 ) return false;
      if(jQuery.browser.msie)
        var offset = -2;
      else
        var offset = 0;
      $('.fotb').each(function(){
        var box_height = parseInt($(this).children('div').children('a').height());
        var img_height = parseInt($(this).children('div').children('a').children('img').height());
        var margin_top = Math.floor( ( box_height - img_height ) / 2 ) + offset;
        //if(margin_top>0)
        //{
          $(this).children('div').children('a').children('img').css('margin-top', margin_top+'px' );
      //console.log(margin_top)
        //}
      });
      count -= 1;
      setTimeout('vamiddle.init('+count+')', 1000);
      //console.log(count)
   }
}

 
$(document).ready(function(){ 
   

   // SPOLECNE - auto switch obrazku
   autoswi.init();

   //tooltip init
   if(typeof(leviTip)=='object')
		 $('.tooltip').leviTip({ closeDelay: 200 });
   
   // SPOLECNE - skryvani formu pro prihlaseni 
   login.init();
   
   // SPOLECNE - akce hlavniho menu 
   mainmenu.init();
   
   // ODKAZY - tree menu
   odkazy.init();
   
   // REKLAMA - zarazeni v katalogu
   tmenu.init();
  
   // ADMIN - SPOLECNE
   filtr.init();
   
   // MEDIA - AKCE - filtr
   mfiltr.init();
   
   // CLANKY - autofocus na textarea v diskuzi
   clankyDiskuze.autofocus();
	 
	 // KATALOG - detail - fotky
	 vamiddle.init(30);

   //nyroModal init
   $('a[rel*=lightbox],a[class*=lightbox]').nyroModal(
   {
      width: null, 
      height: null, 
      minWidth: null,
      minHeight: null,
      css: { // Default CSS option for the nyroModal Div. Some will be overwritten or updated when using IE6
        bg: {
          zIndex: 10000,
          position: 'fixed',
          top: 0,
          left: 0,
          height: '100%',
          width: '100%'
        },
        wrapper: {
          zIndex: 10100,
          position: 'fixed',
          top: '50%',
          left: '50%'
        },
        wrapper2: {
        },
        content: {
          overflow: 'auto'
        },
        loading: {
          zIndex: 10200,
          position: 'fixed',
          top: '50%',
          left: '50%',
          marginTop: '-50px',
          marginLeft: '-50px'
        }
      }
  
   });

	 
});
 
if(typeof(tinyMCE)=='object')
{
    tinyMCE.init({
                        mode: "specific_textareas",
                        editor_selector : "mce_simple",
                        theme : "advanced",
                        plugins : "advimage,style,table,inlinepopups,insertdatetime,media,searchreplace,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager",
                        theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright, justifyfull,separator,bullist,numlist,separator,forecolor,separator,formatselect,fontsizeselect",            //,styleselect
                        theme_advanced_buttons2 : "insertimage,image,link,unlink,separator,pasteword,template,separator,tablecontrols,separator,code,removeformat,fullscreen,separator,undo,redo",
                        theme_advanced_buttons3 : "",
                        theme_advanced_toolbar_location : "top",
                        theme_advanced_toolbar_align : "center",
                        theme_advanced_statusbar_location : "bottom",
                        theme_advanced_resizing : true,
                        theme_advanced_resize_horizontal: false,   
                        imagemanager_path : "../../../../../"+AM_FOLDER,
                        imagemanager_rootpath : "../../../../../"+AM_FOLDER,
                        theme_advanced_text_colors : "7B7B7B,717E87,364E5F,A71F3F,C42E51,FFFFFF,000000,FF0000,3ABF23,2330BF",
                        width : "675",
                        height : "500",
                        content_css : "/css/mce_content.css",
                        relative_urls : false
    });   
	tinyMCE.init({
						mode: "specific_textareas",
						editor_selector : "mce",
						theme : "advanced",
						plugins : "advimage,style,table,inlinepopups,insertdatetime,media,searchreplace,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager",
						theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright, justifyfull,separator,bullist,numlist,separator,forecolor,separator,formatselect,fontsizeselect",             //styleselect,
						theme_advanced_buttons2 : "insertimage,image,link,unlink,separator,pasteword,template,separator,tablecontrols,separator,code,removeformat,fullscreen,separator,undo,redo",
						theme_advanced_buttons3 : "",
						theme_advanced_toolbar_location : "top",
						theme_advanced_toolbar_align : "center",
						theme_advanced_statusbar_location : "bottom",
						theme_advanced_resizing : true,
						
						imagemanager_path : "../../../../../"+AM_FOLDER,
						imagemanager_rootpath : "../../../../../"+AM_FOLDER,
						theme_advanced_resize_horizontal: false,
            theme_advanced_text_colors : "7B7B7B,717E87,364E5F,A71F3F,C42E51,FFFFFF,000000,FF0000,3ABF23,2330BF",
            width : "675",
            height : "500",
            content_css : "/css/mce_content.css",
            relative_urls : false 
	});  
}

/*
function ajaxfilemanager(field_name, url, type, win) {
			var ajaxfilemanagerurl =  WEBPATH+"/tinymce/jscripts/tiny_mce/plugins/ajaxfilemanager/ajaxfilemanager.php?editor=tinymce&mfolder="+AM_FOLDER;
			switch (type) {
				case "image":
					break;
				case "media":
					break;
				case "flash": 
					break;
				case "file":
					break;
				default:
					return false;
			}
            tinyMCE.activeEditor.windowManager.open({
                url: WEBPATH+"/tinymce/jscripts/tiny_mce/plugins/ajaxfilemanager/ajaxfilemanager.php?editor=tinymce&mfolder="+AM_FOLDER,
                width: 782,
                height: 440,
                inline : "yes",
                close_previous : "no"
            },{
                window : win,
                input : field_name
            });
        }
          */  /*
function ajaxfilemanager(field_name, url, type, win) {
					var ajaxfilemanagerurl = WEBPATH+"/tinymce/jscripts/tiny_mce/plugins/ajaxfilemanager/ajaxfilemanager.php?editor=tinymce&mfolder="+AM_FOLDER;
					switch (type) {
						case "image":
							break;
						case "media":
							break;
						case "flash": 
							break;
						case "file":
							break;
						default:
							return false;
					}
					
					var fileBrowserWindow = new Array();
					fileBrowserWindow["file"] = ajaxfilemanagerurl;
					fileBrowserWindow["title"] = "Ajax File Manager";
					fileBrowserWindow["width"] = "782";
					fileBrowserWindow["height"] = "440";
					fileBrowserWindow["close_previous"] = "no";
					tinyMCEPopup.openWindow(fileBrowserWindow, {
						window : win,
						input : field_name,
						resizable : "yes",
						inline : "yes",
						editor_id : tinyMCEPopup.getWindowArg("editor_id","editor_id")
					});
					return false;
                    
}*/


function cpy(from,to){
    for(i=0;i<from.length;i++)
    {
        $('#'+to[i]).attr('value', $('#'+from[i]).attr('value') )
    }
}

var flashVer = {
    //minimum
    major: 9,
    minor: 0,
    release: 28,
    test: function()
    {
       if( 

          (
           (swfobject.getFlashPlayerVersion().major >= this.major)
/*           + 
           (swfobject.getFlashPlayerVersion().minor >= this.minor)
           + 
           (swfobject.getFlashPlayerVersion().release >= this.release)
*/           
          ) 
          != 1
       
       )

         document.write('<p class="flashold">Verze Vašeho <a href="http://www.adobe.com/products/flashplayer/">Flash Playeru</a> je zastaralá. <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=shockwaveFlash">Nainstalujte si novou verzi</a>, abyste mohli využít všech funkcí přehrávače.</p>') 
        
    }
}

