
 var ajaxOff = !window.XMLHttpRequest;
 var loadSpol = false;
 var last_id=0;
 var show_id=0;

 $(function() {
	afterload();
	$(window).bind('resize', function() { $('body').css("display","none"); $('body').css("display","block"); $(document).pngFix(); });
 });

function afterload() {
 	$('.imgREPLACE').each(function (i) { if($(this).attr('class')!='') {
 		imgname=$(this).attr('class').split(" ")[1];
 		img=imgname.split("*");
 		if(img.length==1) {	$(this).html('<img src="img/'+img[0]+'.png" alt="'+$(this).html()+'"/>'); }
 		if(img.length==3) {	$(this).html('<img src="img/'+img[0]+'.png" style="width:'+img[1]+'px;height:'+img[2]+'px" alt="'+$(this).html()+'"/>'); }
 	}});
 	if(!ajaxOff) {
 		$('.ajax').each(function (i) { $(this).click(ajaxifikace); });
	 	$('.ajaxFade').each(function (i) { $(this).click(ajaxifikaceFade); }); 
 	} 
 	DD_belatedPNG.fix('.png_bg, img, *');
	$('a.lightbox').lightBox({fixedNavigation:true});
	$.datepicker.setDefaults($.datepicker.regional['cs']);
	$('input.datepicker').datepicker({showOn: 'button', buttonImage: '/img/calendar.gif', buttonImageOnly: true});
	$('.spol span').mouseenter(function () { tmp=$(this).parent().attr('class').split(" "); $(this).parent().children('.timer').animate({ width: '100%' },800,function() { $(this).css('width','0px'); }); loadSpol=setTimeout("detailspol("+tmp[1]+");",800); });
	$('.spol span').mouseleave(function () { tmp=$(this).parent().attr('class').split(" "); $('.timer:animated').stop().css('width','0px'); clearTimeout(loadSpol); });
}

function ajaxifikace() { 
	$(this).attr('onclick');
	tmp=$(this).attr('class').split(" ");
	i=1; while(tmp[i-1]!='ajax'&&i<tmp.length) i=i+1; 
	for(;i<tmp.length;i++) {
			if($('#'+tmp[i]).has('.content').length>0) temp='#'+tmp[i]+' > .content'; else temp='#'+tmp[i];
			$(temp).html('<span class="preload">... probíhá načítání ...<img src="/img/preload.gif" alt="preloader" class="preloader"/></span>').load('/null.php?trg='+tmp[i]+'&get='+$(this).attr('href'),{},function () {	afterload(); }); 			
	}
	if($('body').scrollTop()>270) $('html, body').scrollTop(180);
	return false; 
}

function ajaxifikaceFade() { 
	var anchor=$(this);
	$(this).attr('onclick');
	tmp=$(this).attr('class').split(" ");
	i=1; while(tmp[i-1]!='ajaxFade'&&i<tmp.length) i=i+1;
	for(;i<tmp.length;i++) {
			if($('#'+tmp[i]).has('.content').length>0) temp='#'+tmp[i]+' > .content'; else temp='#'+tmp[i];
			var trg=tmp[i];
			$(temp).fadeOut(500,function() {
				if($(this).has('.content').length>0) temp='#'+$(this).attr('id')+' > .content'; else temp='#'+$(this).attr('id');
				$(temp).load('null.php?trg='+trg+'&get='+anchor.attr('href'),{},function () { $(this).fadeIn(2000);  afterload(); }); }); 			
	}
	if($('body').scrollTop()>270) $('html, body').scrollTop(180);
	return false; 
}

function detailspol(id) {
	if(id<=0 || id==show_id) return false;
	$('#novinky').hide();
 	$('#detailspol').hide().load('/null.php?zobraz=spol&id='+id,function(){ $('#detailspol').fadeIn(1000); });
 	show_id=id;
	return true; 
 }
 

