$(document).ready(function(){
 $('a').focus(function(){$(this).blur();});
 $('.confirm',$(this)).each(function(i){
  $(this).click(function(){
   return confirm('Potvrďte prosím tuto operaci.');
  });
 });
 $("span.checkbox",$(this)).each(function(i){
  $(this).click(function(){
   val=$(this).children('input').val();
   $(this).children('span.chck').removeClass('chck-'+val);
   $(this).children('input').val((val==0?1:0));
   $(this).children('span.chck').addClass('chck-'+(val==0?1:0));
  });
 });
});

$(document).ready(function(){
	$('div.poll').each(function(i){
		pollId = $(this).attr('id').substr(5);
		$('div.pollItem a',$(this)).each(function(){
			$(this).click(function(){
			  answerId = $(this).attr('id').substr($(this).attr('id').lastIndexOf('-') + 1);
				$.get('/js/CMSPoll.js',
					{ pollId: pollId, answerId: answerId },
					function(data){
					  $('#poll-'+pollId).html(data);
					}
				);
			});
		});
	});
});

$(document).ready(function(){
 if(self.location.href.indexOf('/admin/')==-1){
  CSBfleXcroll('left-scr');
  CSBfleXcroll('content-scr');
 }
});

function pic_popup(src,w,h){
 window.open('/graphics/news/?src='+src+'&w='+w+'&h='+h,'picture','width='+w+',height='+h+',resizable=no,scrollbars=no,toolbar=no,status=no,menubar=no')
}

function obj(o){return document.getElementById(o);}

function ajax_handle_generic(){
 if(xmlhttp.readyState==4){
		if(xmlhttp.status==200){
   var response=xmlhttp.responseText;
   if(response.indexOf('|')!=-1){
    var update=new Array();
    update=response.split('|');
    if(obj(update[0]).innerHTML!=null){
     obj(update[0]).innerHTML=response.substr((update[0].length+1));
    }
   }
		}
 }
}

function ajax_poll(id,answerId,width){
 xmlhttp.open('get','/js/CMSPoll.js?id='+id+'&answerId='+answerId+'&width='+width);
 xmlhttp.onreadystatechange=ajax_handle_generic;
 xmlhttp.send(null);
}
