function pagination_preloader(id,url,page_detail){
	  
}


function filebrowser_preloader() {
	el=$('filebrowser_preloader').style;
	el.display=(el.display == 'block')?'none':'block';

}

// hide newsletter box
function hide_newsletters(){
$('cancel_newsletters_form').fade('hide');

$('cancel_newsletter_link').addEvent('click', function(e) {
	new Event(e).stop();
	$('newsletters_form').fade(0);
	$('cancel_newsletters_form').fade(1);
});

$('newsletters_link').addEvent('click', function(e) {
	new Event(e).stop();
	$('cancel_newsletters_form').fade(0);
	$('newsletters_form').fade(1);
});
}


function addSearchEngine($cesta,$title,$desc) {
  if ((typeof window.sidebar == "object") &&
      (typeof window.sidebar.addSearchEngine == "function")) {

    window.sidebar.addSearchEngine(
      $cesta+"/search-ff.src",
      //$cesta+"/articles/search_addon",
      $cesta+"/css/fastest/icons/favicon.ico",
      $title,
      $desc);

  } else
    alert("Váš prohlížeč nepodporuje tuto funkci. Zkuste Mozillu.");

}

 function html_entity_decode (string, quote_style) {
        var hash_map = {}, symbol = '', tmp_str = '', entity = '';
        tmp_str = string.toString();
        
        if (false === (hash_map = this.get_html_translation_table('HTML_ENTITIES', quote_style))) {
            return false;
        }
    
        delete(hash_map['&']);
        hash_map['&'] = '&amp;';
    
        for (symbol in hash_map) {
            entity = hash_map[symbol];
            tmp_str = tmp_str.split(entity).join(symbol);
        }
        tmp_str = tmp_str.split('&#039;').join("'");
        
        return tmp_str;
    }

// tooltips
function footer_tooltips(){
window.addEvent('domready', function(){
	var Tips_help = new Tips($$('.tip_win'),{
			showDelay: 400,
			hideDelay: 8500,
			className: 'tip_win',
			offsets: {'x': -149, 'y': -80},
			fixed: true
	});
	new SmoothScroll({
		 links: '.scroll_moo',
		duration:700 
	},window);
	
	if ($('doporuceni_link')){
		$('doporuceni_link').addEvent('click',function(e){
			new Event(e).stop();
			doporuceni_win('<?php echo lang_doporucte_tuto_stranku?>');
		});
	}
	
});
}
// skryvani zapomenuteho hesla
function hide_lost_password(){
$('forgot_passwords_form').fade('hide');
$('forgot_password_link').addEvent('click', function(e) {
	new Event(e).stop();
	$('logins_form').fade(0);
	$('forgot_passwords_form').fade(1);
});

$('login_link').addEvent('click', function(e) {
	new Event(e).stop();
	$('forgot_passwords_form').fade(0);
	$('logins_form').fade(1);
});
}

// doporuceni domwin
function doporuceni_win(title){
	domwin.newWindow({
		id			: 'doporuceni_win',
		sizes		: [500,220],
		scrollbars	: false,
		defined_lang: ['cz'],
		languages	: false,
		title		: title,
		ajax_url	: '/doporucenis/',
		closeConfirm: false,
		max_minBtn	: false,
		modal_close	: true
	}); 
}

// minimalni delka search pole
function min_delka_search(id,text,alert_text,lang){
	
	if (($(id).value == text) || ($(id).value.length < 3))
		alert(alert_text);
	else
		window.location.href =  lang + '/search/' + id.value;
			
}



function getHighestIndex(){				
		var allElems = document.getElementsByTagName?document.getElementsByTagName("*"): document.all; 
		var maxZIndex = 0;
		for(var i=0;i<allElems.length;i++) {
			var elem = allElems[i];
			var cStyle = null;
			if (elem.currentStyle) {cStyle = elem.currentStyle;
			} else if (document.defaultView && document.defaultView.getComputedStyle){
				cStyle = document.defaultView.getComputedStyle(elem,"");
			}
			var sNum;
			if (cStyle) {
				sNum = Number(cStyle.zIndex);
			} else {
				sNum = Number(elem.style.zIndex);
			}
			if (!isNaN(sNum)) {
				maxZIndex = Math.max(maxZIndex,sNum);
			}
		}
		return maxZIndex;
} 

Element.implement({
	inputLimit: function(){
		if (this.hasClass('float')){
			this.addEvent('keypress',function(e){
				var event = new Event(e); 
				var allow_key = ['1','2','3','4','5','6','7','8','9','0',',','backspace','left','right','tab','f5'];	
				if (allow_key.indexOf(event.key) != -1) 
					return true; 
				else 
					return false;			
			});
		} else if (this.hasClass('integer')){
			this.addEvent('keypress',function(e){
				var event = new Event(e); 
				var allow_key = ['1','2','3','4','5','6','7','8','9','0','backspace','left','right','tab','f5'];	
				if (allow_key.indexOf(event.key) != -1) 
					return true; 
				else 
					return false;			
			});
		}
	},
	
	ajaxLoad: function(url, children){
		var empty_value = '--- Zvolte hodnotu ---'
		this.addEvent('change', function(){
			new Request.JSON({
				url: url + this.value,
				onComplete: (function(json){
					children.each(function(obj){
						$(obj).empty();
						new Element('option', {title:empty_value, value:''}).setHTML(empty_value).inject($(obj));
					});
					child = children[0];
					$each(json, function(value, id){
						new Element('option', {title:value, value:id}).setHTML(value).inject($(child));
					}, this);
				}).bind(this)
			}).send();
		});
	},
	
	getOptionText: function(){
		return this.options[this.selectedIndex].getHTML();
	}
});
String.implement({
	camelCase2: function(){
		return this.replace(/_\D/g, function(match){
			return match.charAt(1).toUpperCase();
		});
	}
});

function tisk(){
window.print();
return false;
}

function button_preloader(id){
		id.addClass('button_preloader');
		id.setProperty('disabled');
}

function button_preloader_disable(id){
		id.removeClass('button_preloader');
		id.removeProperty('disabled');
}

// zmena pisma ve clankach
function init_font_changer(){
	Cookie.get("fontType");
	switchFont(Cookie.get("fontType"));

	if ($('switch_f1'))$('switch_f1').addEvent('click',function(e){new Event(e).stop();switchFont(1);setFontSize(1)})
	if ($('switch_f2'))$('switch_f2').addEvent('click',function(e){new Event(e).stop();switchFont(2);setFontSize(2)})
	if ($('switch_f3'))$('switch_f3').addEvent('click',function(e){new Event(e).stop();switchFont(3);setFontSize(3)})



	function switchFont(typ)
	{
		if (typ==1){
		
		$('obal').getElements('.article_text').removeClass('large_font').addClass('small_font');
		$('obal').getElements('.article_anotace').removeClass('large_font').addClass('small_font');				
		$('obal').getElements('.f1').addClass('active');				
		$('obal').getElements('.f2').removeClass('active');				
		$('obal').getElements('.f3').removeClass('active');				
		}
		
		if (typ==2){
		$('obal').getElements('.article_text').removeClass('small_font').removeClass('large_font');				
		$('obal').getElements('.article_anotace').removeClass('small_font').removeClass('large_font');				
		$('obal').getElements('.f1').removeClass('active');				
		$('obal').getElements('.f2').addClass('active');				
		$('obal').getElements('.f3').removeClass('active');				
		}

		if (typ==3){
		$('obal').getElements('.article_text').removeClass('small_font').addClass('large_font');
		$('obal').getElements('.article_anotace').removeClass('small_font').addClass('large_font');				
		$('obal').getElements('.f1').removeClass('active');				
		$('obal').getElements('.f2').removeClass('active');				
		$('obal').getElements('.f3').addClass('active');				
		}
		

	  }
	function setFontSize(typ){
		Cookie.remove('fontType');
		var myCookie  =  Cookie.set('fontType', typ,{path: '/'});

	}
}
