/* DELEGATE: Copyright (c) 2008, Three Dub Media (http://threedubmedia.com)  */
(function(F){F.fn.delegate=function(I,H,J,K){return this.each(function(){F.event.delegate.add(this,I,H,J,K)})};F.fn.undelegate=function(I,H,J){return this.each(function(){F.event.delegate.remove(this,I,H,J)})};F.event.delegate={add:function(M,J,H,K,N){if(arguments.length<4){return }var I=B(H,A),L=F.data(M,"delegates")||F.data(M,"delegates",{});F.each(B(J,D),function(P,Q){var O=L[Q]||(L[Q]=[]);if(!O.length){F.event.add(M,Q,F.event.delegate.handle,L)}F.each(I,function(S,R){if(!R.length){return }O[O.length]={selector:R,handler:K,data:N}})})},remove:function(M,J,H,K){var I=B(H,A),L=F.data(M,"delegates")||{};if(M&&!J){F.each(L,function(N){F.event.remove(M,N,F.event.delegate.handle)});F.removeData(M,"delegates");return }F.each(B(J,D),function(N,O){if(H&&H.length){L[O]=F.grep(L[O]||[],function(Q,P){if(Q){F.each(I,function(S,R){if(Q.selector===R&&(!K||Q.handler===K)){return(P=false)}})}return(P!==false)});if(L[O].length){return }}F.event.remove(M,O,F.event.delegate.handle);delete L[O]})},handle:function(L){L.delegateParent=this;L.stopDelegation=function(){H=true};var M=L.target,K=arguments,J,H,I=(L.data||{})[L.type]||[];if(I.length){do{F.each(I,function(N,O){if(O&&F(M).matches(O.selector)){L.data=O.data;J=O.handler.apply(M,K);if(J===false||H===true){return false}}})}while(J!==false&&H!==true&&M!=this&&(M=M.parentNode))}return J}};F.fn.matches=function(J){if(typeof J!="string"){return false}var I=this,H;while(J.length&&I.length&&(H=E.exec(J))){I=I.setArray(F.filter(H[3],I).r);if(H[2]){I=I[G[H[2]]](H[1])}J=J.replace(H[0].substr(H[1]?H[1].length:0),"")}if(!C.test(J)&&!H){I=[]}return !!(I.length>0)};var E=(/(?:([^>+~\s]+)\s*([>+~\s])\s*)?([^>+~\s]+)\s*$/),D=(/\s+/),A=(/\s*,\s*/),C=(/^\s*$/),G={" ":"parents",">":"parent","+":"prev","~":"prevAll"};function B(I,H){return F.trim(I).split(H)}})(jQuery);

/* DIMENSIONS: Copyright (c) 2007 Paul Bakaus (paul.bakaus@googlemail.com) and Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * $LastChangedDate: 2007-12-20 08:43:48 -0600 (Thu, 20 Dec 2007) $
 * $Rev: 4257 $
 *
 * Version: 1.2
 *
 * Requires: jQuery 1.2+
 */
(function($){$.dimensions={version:'1.2'};$.each(['Height','Width'],function(i,name){$.fn['inner'+name]=function(){if(!this[0])return;var torl=name=='Height'?'Top':'Left',borr=name=='Height'?'Bottom':'Right';return this.is(':visible')?this[0]['client'+name]:num(this,name.toLowerCase())+num(this,'padding'+torl)+num(this,'padding'+borr);};$.fn['outer'+name]=function(options){if(!this[0])return;var torl=name=='Height'?'Top':'Left',borr=name=='Height'?'Bottom':'Right';options=$.extend({margin:false},options||{});var val=this.is(':visible')?this[0]['offset'+name]:num(this,name.toLowerCase())+num(this,'border'+torl+'Width')+num(this,'border'+borr+'Width')+num(this,'padding'+torl)+num(this,'padding'+borr);return val+(options.margin?(num(this,'margin'+torl)+num(this,'margin'+borr)):0);};});$.each(['Left','Top'],function(i,name){$.fn['scroll'+name]=function(val){if(!this[0])return;return val!=undefined?this.each(function(){this==window||this==document?window.scrollTo(name=='Left'?val:$(window)['scrollLeft'](),name=='Top'?val:$(window)['scrollTop']()):this['scroll'+name]=val;}):this[0]==window||this[0]==document?self[(name=='Left'?'pageXOffset':'pageYOffset')]||$.boxModel&&document.documentElement['scroll'+name]||document.body['scroll'+name]:this[0]['scroll'+name];};});$.fn.extend({position:function(){var left=0,top=0,elem=this[0],offset,parentOffset,offsetParent,results;if(elem){offsetParent=this.offsetParent();offset=this.offset();parentOffset=offsetParent.offset();offset.top-=num(elem,'marginTop');offset.left-=num(elem,'marginLeft');parentOffset.top+=num(offsetParent,'borderTopWidth');parentOffset.left+=num(offsetParent,'borderLeftWidth');results={top:offset.top-parentOffset.top,left:offset.left-parentOffset.left};}return results;},offsetParent:function(){var offsetParent=this[0].offsetParent;while(offsetParent&&(!/^body|html$/i.test(offsetParent.tagName)&&$.css(offsetParent,'position')=='static'))offsetParent=offsetParent.offsetParent;return $(offsetParent);}});function num(el,prop){return parseInt($.curCSS(el.jquery?el[0]:el,prop,true))||0;};})(jQuery);

/* BGIFRAME Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * $LastChangedDate: 2007-07-21 18:45:56 -0500 (Sat, 21 Jul 2007) $
 * $Rev: 2447 $
 *
 * Version 2.1.1
 */
(function($){$.fn.bgIframe=$.fn.bgiframe=function(s){if($.browser.msie&&/6.0/.test(navigator.userAgent)){s=$.extend({top:'auto',left:'auto',width:'auto',height:'auto',opacity:true,src:'javascript:false;'},s||{});var prop=function(n){return n&&n.constructor==Number?n+'px':n;},html='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+'style="display:block;position:absolute;z-index:-1;'+(s.opacity!==false?'filter:Alpha(Opacity=\'0\');':'')+'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+'"/>';return this.each(function(){if($('> iframe.bgiframe',this).length==0)this.insertBefore(document.createElement(html),this.firstChild);});}return this;};})(jQuery);

/**
 * jGlycy
 * (c) 2008 Semooh (http://semooh.jp/)
 * 
 */
(function($, prefix, jg){$[jg] = $({});$[jg].extend({invoke: function(nodes) {nodes.each(function(){var node = this;var funcs = $(node).attr(prefix).split(',');$(funcs).each(function(){var arg = $(node).attr(prefix + ":" + this);if(arg) {eval('var options = {' + arg + '}');} else {var options = {};}if($.fn[this]) {$(node)[this](options);}});});},invokeElement: function(node) {$[jg].invoke($("*[" + prefix + "]", node));}});$(document).ready(function(){$[jg].invokeElement(document);});})(jQuery, "jg", "jg");


/*
 * jQuery Tooltip plugin 1.3
 *
 * http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/
 * http://docs.jquery.com/Plugins/Tooltip
 *
 * Copyright (c) 2006 - 2008 Jörn Zaefferer
 *
 * $Id: jquery.tooltip.js 5741 2008-06-21 15:22:16Z joern.zaefferer $
 * 
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */;(function($){var helper={},current,title,tID,IE=$.browser.msie&&/MSIE\s(5\.5|6\.)/.test(navigator.userAgent),track=false;$.tooltip={blocked:false,defaults:{delay:200,fade:false,showURL:true,extraClass:"",top:15,left:15,id:"tooltip"},block:function(){$.tooltip.blocked=!$.tooltip.blocked;}};$.fn.extend({tooltip:function(settings){settings=$.extend({},$.tooltip.defaults,settings);createHelper(settings);return this.each(function(){$.data(this,"tooltip",settings);this.tOpacity=helper.parent.css("opacity");this.tooltipText=this.title;$(this).removeAttr("title");this.alt="";}).mouseover(save).mouseout(hide).click(hide);},fixPNG:IE?function(){return this.each(function(){var image=$(this).css('backgroundImage');if(image.match(/^url\(["']?(.*\.png)["']?\)$/i)){image=RegExp.$1;$(this).css({'backgroundImage':'none','filter':"progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='"+image+"')"}).each(function(){var position=$(this).css('position');if(position!='absolute'&&position!='relative')$(this).css('position','relative');});}});}:function(){return this;},unfixPNG:IE?function(){return this.each(function(){$(this).css({'filter':'',backgroundImage:''});});}:function(){return this;},hideWhenEmpty:function(){return this.each(function(){$(this)[$(this).html()?"show":"hide"]();});},url:function(){return this.attr('href')||this.attr('src');}});function createHelper(settings){if(helper.parent)return;helper.parent=$('<div id="'+settings.id+'"><h3></h3><div class="body"></div><div class="url"></div></div>').appendTo(document.body).hide();if($.fn.bgiframe)helper.parent.bgiframe();helper.title=$('h3',helper.parent);helper.body=$('div.body',helper.parent);helper.url=$('div.url',helper.parent);}function settings(element){return $.data(element,"tooltip");}function handle(event){if(settings(this).delay)tID=setTimeout(show,settings(this).delay);else
show();track=!!settings(this).track;$(document.body).bind('mousemove',update);update(event);}function save(){if($.tooltip.blocked||this==current||(!this.tooltipText&&!settings(this).bodyHandler))return;current=this;title=this.tooltipText;if(settings(this).bodyHandler){helper.title.hide();var bodyContent=settings(this).bodyHandler.call(this);if(bodyContent.nodeType||bodyContent.jquery){helper.body.empty().append(bodyContent)}else{helper.body.html(bodyContent);}helper.body.show();}else if(settings(this).showBody){var parts=title.split(settings(this).showBody);helper.title.html(parts.shift()).show();helper.body.empty();for(var i=0,part;(part=parts[i]);i++){if(i>0)helper.body.append("<br/>");helper.body.append(part);}helper.body.hideWhenEmpty();}else{helper.title.html(title).show();helper.body.hide();}if(settings(this).showURL&&$(this).url())helper.url.html($(this).url().replace('http://','')).show();else
helper.url.hide();helper.parent.addClass(settings(this).extraClass);if(settings(this).fixPNG)helper.parent.fixPNG();handle.apply(this,arguments);}function show(){tID=null;if((!IE||!$.fn.bgiframe)&&settings(current).fade){if(helper.parent.is(":animated"))helper.parent.stop().show().fadeTo(settings(current).fade,current.tOpacity);else
helper.parent.is(':visible')?helper.parent.fadeTo(settings(current).fade,current.tOpacity):helper.parent.fadeIn(settings(current).fade);}else{helper.parent.show();}update();}function update(event){if($.tooltip.blocked)return;if(event&&event.target.tagName=="OPTION"){return;}if(!track&&helper.parent.is(":visible")){$(document.body).unbind('mousemove',update)}if(current==null){$(document.body).unbind('mousemove',update);return;}helper.parent.removeClass("viewport-right").removeClass("viewport-bottom");var left=helper.parent[0].offsetLeft;var top=helper.parent[0].offsetTop;if(event){left=event.pageX+settings(current).left;top=event.pageY+settings(current).top;var right='auto';if(settings(current).positionLeft){right=$(window).width()-left;left='auto';}helper.parent.css({left:left,right:right,top:top});}var v=viewport(),h=helper.parent[0];if(v.x+v.cx<h.offsetLeft+h.offsetWidth){left-=h.offsetWidth+20+settings(current).left;helper.parent.css({left:left+'px'}).addClass("viewport-right");}if(v.y+v.cy<h.offsetTop+h.offsetHeight){top-=h.offsetHeight+20+settings(current).top;helper.parent.css({top:top+'px'}).addClass("viewport-bottom");}}function viewport(){return{x:$(window).scrollLeft(),y:$(window).scrollTop(),cx:$(window).width(),cy:$(window).height()};}function hide(event){if($.tooltip.blocked)return;if(tID)clearTimeout(tID);current=null;var tsettings=settings(this);function complete(){helper.parent.removeClass(tsettings.extraClass).hide().css("opacity","");}if((!IE||!$.fn.bgiframe)&&tsettings.fade){if(helper.parent.is(':animated'))helper.parent.stop().fadeTo(tsettings.fade,0,complete);else
helper.parent.stop().fadeOut(tsettings.fade,complete);}else
complete();if(settings(this).fixPNG)helper.parent.unfixPNG();}})(jQuery);

// my own code for enabling tooltips
$(function(){
	$(".tooltip").tooltip({ 
	    bodyHandler: function() {
			return $(this).html();
	    } 
	}); 
});

//my own code for enabling text labels
$(function(){
	$("[textlabel]").each(function(){
		var input = $(this);
		var textLabel = input.attr("textlabel");
		
		var add = function(){
			var value = input.val();
			if(value.length == 0 || value == textLabel){
				input.val(textLabel);
				input.addClass("has-text-label");
			}
		}
		var remove = function(){
			if(input.hasClass("has-text-label")){
				input.removeClass("has-text-label");
				input.val("");
			}
		}
		input.focus(remove).blur(add);
		add();
	}) 
});

/**
 * jQuery Spin 1.1.1
 *
 * Copyright (c) 2009 Naohiko MORI
 * Dual licensed under the MIT and GPL licenses.
 *
 **/
(function($){
  var calcFloat = {
    get: function(num){
      var num = num.toString();
      if(num.indexOf('.')==-1) return[0, eval(num)];
      var nn = num.split('.');
      var po = nn[1].length;
      var st = nn.join('');
      var sign = '';
      if(st.charAt(0)=='-'){
        st = st.substr(1);
        sign = '-';
      }
      for(var i=0; i<st.length; ++i) if(st.charAt(0)=='0') st=st.substr(1, st.length);
      st = sign + st;
      return [po, eval(st)];
    },
    getInt: function(num, figure){
      var d = Math.pow(10, figure);
      var n = this.get(num);
      var v1 = eval('num * d');
      var v2 = eval('n[1] * d');
      if(this.get(v1)[1]==v2) return v1;
      return(n[0]==0 ? v1 : eval(v2 + '/Math.pow(10, n[0])'));
    },
    sum: function(v1, v2){
      var n1 = this.get(v1);
      var n2 = this.get(v2);
      var figure = (n1[0] > n2[0] ? n1[0] : n2[0]);
      v1 = this.getInt(v1, figure);
      v2 = this.getInt(v2, figure);
      return eval('v1 + v2')/Math.pow(10, figure);
    }
  };
  $.extend({
    spin: {
      interval: 1,
      max: 10000,
      min: 1,
      timeInterval: 500,
      timeBlink: 200,
      btnClass: "spinner",
      upClass: "spinner-up",
      downClass: "spinner-down",
      btnCss: {cursor: 'pointer', verticalAlign: 'middle', cssFloat: 'left'},
      txtCss: {marginRight: 0, paddingRight: 0, verticalAlign: 'middle', cssFloat: 'left', fontSize: '12px', padding: '5px'},
      lock: false,
      decimal: null,
      beforeChange: null,
      changed: null,
      buttonUp: null,
      buttonDown: null
    }
  });
  $.fn.extend({
    spin: function(o){
      return this.each(function(){
				o = o || {};
				var opt = {};
				$.each($.spin, function(k,v){
					opt[k] = (typeof o[k]!='undefined' ? o[k] : v);
				});
        
        var txt = $(this);
        
        var btn = $(document.createElement('span'));

        btn.append("&nbsp;");
        btn.addClass(opt.btnClass);
        if(opt.btnCss) btn.css(opt.btnCss);
        if(opt.txtCss) txt.css(opt.txtCss);
        
        txt.after(btn);
		if(opt.lock){
					txt.focus(function(){txt.blur();});
        }
        
        function spin(vector){
          var val = txt.val();
          var org_val = val;
          if(opt.decimal) val=val.replace(opt.decimal, '.');
          if(!isNaN(val)){
            val = calcFloat.sum(val, vector * opt.interval);
            if(opt.min!==null && val<opt.min) val=opt.min;
            if(opt.max!==null && val>opt.max) val=opt.max;
            if(val != txt.val()){
              if(opt.decimal) val=val.toString().replace('.', opt.decimal);
              var ret = ($.isFunction(opt.beforeChange) ? opt.beforeChange.apply(txt, [val, org_val]) : true);
              if(ret!==false){
                txt.val(val);
                if($.isFunction(opt.changed)) opt.changed.apply(txt, [val]);
                txt.change();
                addClass = (vector > 0 ? opt.upClass : opt.downClass);
                btn.addClass(addClass);
                btn.removeClass(opt.btnClass);
                if(opt.timeBlink<opt.timeInterval){ 
                	with({c : addClass}){
                		setTimeout(function(){btn.addClass(opt.btnClass);btn.removeClass(c);}, opt.timeBlink);
                	}
                }
              }
            }
          }
          if(vector > 0){
            if($.isFunction(opt.buttonUp)) opt.buttonUp.apply(txt, [val]);
          }else{
            if($.isFunction(opt.buttonDown)) opt.buttonDown.apply(txt, [val]);
          }
        }
        
        btn.mousedown(function(e){
          var pos = e.pageY - btn.offset().top;
          var vector = (btn.height()/2 > pos ? 1 : -1);
          (function(){
            spin(vector);
            var tk = setTimeout(arguments.callee, opt.timeInterval);
            $(document).one('mouseup', function(){
              clearTimeout(tk); btn.removeClass(opt.upClass); btn.removeClass(opt.downClass); btn.addClass(opt.btnClass);
            });
          })();
          return false;
        });
      });
    }
  });
})(jQuery);
/* Czech initialisation for the jQuery UI date picker plugin. */
jQuery(function($){if($.datepicker){$.datepicker.regional['cs']={closeText:'Zavřít',prevText:'&#x3c;Dříve',nextText:'Později&#x3e;',currentText:'Nyní',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'],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'],weekHeader:'Týd',dateFormat:'dd.mm.yy',firstDay:1,isRTL:false,showMonthAfterYear:false,yearSuffix:''};$.datepicker.setDefaults($.datepicker.regional['cs'])}});
