//Adjust heights created by Michal Matuška (fireball_)
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('$.y.z=9(e){e=A.B({j:[],6:\'f\',q:r},e);$(1).l(9(){k b=0;k c=0;k d={m:e.j.C};D(k i=0;i<d.m;i++){b=0;c=0;$(\'\'+e.j[i]+\'\',1).l(9(){7(e.q==r){$(1).8(\'g\',\'E\')}$(\'.3-4-5\',1).8(\'h-f\',\'0\');7(e.6==\'n\'|e.6==\'o\'&&$(\'.3-4-5\',1).m()==0){$(1).F(\'<s G="3-4-5"></s>\');$(\'.3-4-5\',1).8({\'H\':\'I\',\'J\':\'0\',\'h\':\'0\'})}});$(\'\'+e.j[i]+\'\',1).l(9(){b=b>$(1).g()?b:$(1).g()});$(\'\'+e.j[i]+\'\',1).l(9(){7(e.q==r){$(1).g(b)}7(e.6==\'n\'||e.6==\'o\'){7($(\'t\',1).m()>0){k a=$(1);$(K L()).M(9(){c=$(\'.3-4-5\',a).g();7(e.6==\'n\'){$(\'.3-4-5\',a).8(\'h-f\',(b-c)/2+\'p\')}7(e.6==\'o\'){$(\'.3-4-5\',a).8(\'h-f\',u.v(b-c)+\'p\')}}).w(\'x\',$(\'t\',1).w(\'x\'))}N{c=$(\'.3-4-5\',1).g();7(e.6==\'n\'){$(\'.3-4-5\',1).8(\'h-f\',(b-c)/2+\'p\')}7(e.6==\'o\'){$(\'.3-4-5\',1).8(\'h-f\',u.v(b-c)+\'p\')}}}})}})};',50,50,'|this||js|ah|help|vAlign|if|css|function||||||top|height|padding||elements|var|each|size|center|bottom|px|adjust|true|span|img|Math|floor|attr|src|fn|adjustHeights|jQuery|extend|length|for|auto|wrapInner|class|display|block|margin|new|Image|load|else'.split('|'),0,{}));
(function($){$.fn.fontSizeListener=function(element,callback){var el=$(element);var h=el.height();var listen=function(){var newH=el.height();if(newH!=h){h=newH;if(callback&&typeof callback=='function'){callback()}}};var fontSizeInterval=setInterval(function(){listen()},200)}})(jQuery);
// Jquery Form
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}(';(5($){$.D.T=5(u){2(!3.J){P(\'T: 2O C 2P - 2Q 2R 1d\');6 3}2(U u==\'5\')u={V:u};4 v=$.2S(3.16(\'1e\'));2(v){v=(v.2T(/^([^#]+)/)||[])[1]}v=v||1f.2U.2V||\'\';u=$.1p({1g:v,H:3.16(\'1u\')||\'1S\'},u||{});4 w={};3.L(\'E-1T-1U\',[3,u,w]);2(w.1V){P(\'T: C 1W 1q E-1T-1U L\');6 3}2(u.1v&&u.1v(3,u)===I){P(\'T: C 1h 1q 1v 1X\');6 3}4 a=3.1w(u.2W);2(u.K){u.Q=u.K;M(4 n 1x u.K){2(u.K[n]2X 17){M(4 k 1x u.K[n])a.9({7:n,8:u.K[n][k]})}F a.9({7:n,8:u.K[n]})}}2(u.1y&&u.1y(a,3,u)===I){P(\'T: C 1h 1q 1y 1X\');6 3}3.L(\'E-C-1Y\',[a,3,u,w]);2(w.1V){P(\'T: C 1W 1q E-C-1Y L\');6 3}4 q=$.1z(a);2(u.H.2Y()==\'1S\'){u.1g+=(u.1g.2Z(\'?\')>=0?\'&\':\'?\')+q;u.K=G}F u.K=q;4 x=3,Y=[];2(u.1A)Y.9(5(){x.1A()});2(u.1B)Y.9(5(){x.1B()});2(!u.18&&u.19){4 y=u.V||5(){};Y.9(5(a){$(u.19).30(a).R(y,1Z)})}F 2(u.V)Y.9(u.V);u.V=5(a,b){M(4 i=0,W=Y.J;i<W;i++)Y[i].31(u,[a,b,x])};4 z=$(\'N:32\',3).1a();4 A=I;M(4 j=0;j<z.J;j++)2(z[j])A=S;4 B=I;2(u.1C||A||B){2(u.20)$.33(u.20,1D);F 1D()}F $.34(u);3.L(\'E-C-35\',[3,u]);6 3;5 1D(){4 h=x[0];2($(\':N[7=C]\',h).J){36(\'37: 38 21 39 22 3a 3b "C".\');6}4 i=$.1p({},$.23,u);4 s=$.1p(S,{},$.1p(S,{},$.23),i);4 j=\'3c\'+(1E 3d().3e());4 k=$(\'<1C 3f="\'+j+\'" 7="\'+j+\'" 24="25:26" />\');4 l=k[0];k.3g({3h:\'3i\',27:\'-28\',29:\'-28\'});4 m={1h:0,1b:G,1i:G,3j:0,3k:\'n/a\',3l:5(){},2a:5(){},3m:5(){},3n:5(){3.1h=1;k.16(\'24\',\'25:26\')}};4 g=i.2b;2(g&&!$.1F++)$.1j.L("3o");2(g)$.1j.L("3p",[m,i]);2(s.2c&&s.2c(m,s)===I){s.2b&&$.1F--;6}2(m.1h)6;4 o=0;4 p=0;4 q=h.X;2(q){4 n=q.7;2(n&&!q.1k){u.Q=u.Q||{};u.Q[n]=q.8;2(q.H=="Z"){u.Q[7+\'.x\']=h.11;u.Q[7+\'.y\']=h.12}}}1l(5(){4 t=x.16(\'19\'),a=x.16(\'1e\');h.1m(\'19\',j);2(h.2d(\'1u\')!=\'2e\')h.1m(\'1u\',\'2e\');2(h.2d(\'1e\')!=i.1g)h.1m(\'1e\',i.1g);2(!u.3q){x.16({3r:\'2f/E-K\',3s:\'2f/E-K\'})}2(i.1G)1l(5(){p=S;13()},i.1G);4 b=[];2g{2(u.Q)M(4 n 1x u.Q)b.9($(\'<N H="3t" 7="\'+n+\'" 8="\'+u.Q[n]+\'" />\').2h(h)[0]);k.2h(\'1n\');l.2i?l.2i(\'2j\',13):l.3u(\'2k\',13,I);h.C()}3v{h.1m(\'1e\',a);t?h.1m(\'19\',t):x.3w(\'19\');$(b).2l()}},10);4 r=2m;5 13(){2(o++)6;l.2n?l.2n(\'2j\',13):l.3x(\'2k\',13,I);4 c=S;2g{2(p)3y\'1G\';4 d,O;O=l.2o?l.2o.2p:l.2q?l.2q:l.2p;2(O.1n==G||O.1n.2r==\'\'){2(--r){o=0;1l(13,2s);6}P(\'3z 22 3A 1C 3B 3C 2m 3D.\');6}m.1b=O.1n?O.1n.2r:G;m.1i=O.2t?O.2t:O;m.2a=5(a){4 b={\'3E-H\':i.18};6 b[a]};2(i.18==\'3F\'||i.18==\'3G\'){4 f=O.2u(\'1H\')[0];m.1b=f?f.8:m.1b}F 2(i.18==\'2v\'&&!m.1i&&m.1b!=G){m.1i=2w(m.1b)}d=$.3H(m,i.18)}3I(e){c=I;$.3J(i,m,\'2x\',e)}2(c){i.V(d,\'V\');2(g)$.1j.L("3K",[m,i])}2(g)$.1j.L("3L",[m,i]);2(g&&!--$.1F)$.1j.L("3M");2(i.2y)i.2y(m,c?\'V\':\'2x\');1l(5(){k.2l();m.1i=G},2s)};5 2w(s,a){2(1f.2z){a=1E 2z(\'3N.3O\');a.3P=\'I\';a.3Q(s)}F a=(1E 3R()).3S(s,\'1I/2v\');6(a&&a.2A&&a.2A.1r!=\'3T\')?a:G}}};$.D.3U=5(c){6 3.2B().2C(\'C.E-1s\',5(){$(3).T(c);6 I}).R(5(){$(":C,N:Z",3).2C(\'2D.E-1s\',5(e){4 a=3.E;a.X=3;2(3.H==\'Z\'){2(e.2E!=14){a.11=e.2E;a.12=e.3V}F 2(U $.D.2F==\'5\'){4 b=$(3).2F();a.11=e.2G-b.29;a.12=e.2H-b.27}F{a.11=e.2G-3.3W;a.12=e.2H-3.3X}}1l(5(){a.X=a.11=a.12=G},10)})})};$.D.2B=5(){3.2I(\'C.E-1s\');6 3.R(5(){$(":C,N:Z",3).2I(\'2D.E-1s\')})};$.D.1w=5(b){4 a=[];2(3.J==0)6 a;4 c=3[0];4 d=b?c.2u(\'*\'):c.21;2(!d)6 a;M(4 i=0,W=d.J;i<W;i++){4 e=d[i];4 n=e.7;2(!n)1J;2(b&&c.X&&e.H=="Z"){2(!e.1k&&c.X==e){a.9({7:n,8:$(e).2J()});a.9({7:n+\'.x\',8:c.11},{7:n+\'.y\',8:c.12})}1J}4 v=$.1a(e,S);2(v&&v.1t==17){M(4 j=0,2K=v.J;j<2K;j++)a.9({7:n,8:v[j]})}F 2(v!==G&&U v!=\'14\')a.9({7:n,8:v})}2(!b&&c.X){4 f=$(c.X),N=f[0],n=N.7;2(n&&!N.1k&&N.H==\'Z\'){a.9({7:n,8:f.2J()});a.9({7:n+\'.x\',8:c.11},{7:n+\'.y\',8:c.12})}}6 a};$.D.3Y=5(a){6 $.1z(3.1w(a))};$.D.3Z=5(b){4 a=[];3.R(5(){4 n=3.7;2(!n)6;4 v=$.1a(3,b);2(v&&v.1t==17){M(4 i=0,W=v.J;i<W;i++)a.9({7:n,8:v[i]})}F 2(v!==G&&U v!=\'14\')a.9({7:3.7,8:v})});6 $.1z(a)};$.D.1a=5(a){M(4 b=[],i=0,W=3.J;i<W;i++){4 c=3[i];4 v=$.1a(c,a);2(v===G||U v==\'14\'||(v.1t==17&&!v.J))1J;v.1t==17?$.40(b,v):b.9(v)}6 b};$.1a=5(b,c){4 n=b.7,t=b.H,1c=b.1r.1K();2(U c==\'14\')c=S;2(c&&(!n||b.1k||t==\'1o\'||t==\'41\'||(t==\'1L\'||t==\'1M\')&&!b.1N||(t==\'C\'||t==\'Z\')&&b.E&&b.E.X!=b||1c==\'15\'&&b.1O==-1))6 G;2(1c==\'15\'){4 d=b.1O;2(d<0)6 G;4 a=[],1P=b.42;4 e=(t==\'15-2L\');4 f=(e?d+1:1P.J);M(4 i=(e?d:0);i<f;i++){4 g=1P[i];2(g.1d){4 v=g.8;2(!v)v=(g.1Q&&g.1Q[\'8\']&&!(g.1Q[\'8\'].43))?g.1I:g.8;2(e)6 v;a.9(v)}}6 a}6 b.8};$.D.1B=5(){6 3.R(5(){$(\'N,15,1H\',3).2M()})};$.D.2M=$.D.44=5(){6 3.R(5(){4 t=3.H,1c=3.1r.1K();2(t==\'1I\'||t==\'45\'||1c==\'1H\')3.8=\'\';F 2(t==\'1L\'||t==\'1M\')3.1N=I;F 2(1c==\'15\')3.1O=-1})};$.D.1A=5(){6 3.R(5(){2(U 3.1o==\'5\'||(U 3.1o==\'46\'&&!3.1o.47))3.1o()})};$.D.48=5(b){2(b==14)b=S;6 3.R(5(){3.1k=!b})};$.D.1d=5(b){2(b==14)b=S;6 3.R(5(){4 t=3.H;2(t==\'1L\'||t==\'1M\')3.1N=b;F 2(3.1r.1K()==\'2N\'){4 a=$(3).49(\'15\');2(b&&a[0]&&a[0].H==\'15-2L\'){a.4a(\'2N\').1d(I)}3.1d=b}})};5 P(){2($.D.T.4b&&1f.1R&&1f.1R.P)1f.1R.P(\'[4c.E] \'+17.4d.4e.4f(1Z,\'\'))}})(4g);',62,265,'||if|this|var|function|return|name|value|push|||||||||||||||||||||||||||||submit|fn|form|else|null|type|false|length|data|trigger|for|input|doc|log|extraData|each|true|ajaxSubmit|typeof|success|max|clk|callbacks|image||clk_x|clk_y|cb|undefined|select|attr|Array|dataType|target|fieldValue|responseText|tag|selected|action|window|url|aborted|responseXML|event|disabled|setTimeout|setAttribute|body|reset|extend|via|tagName|plugin|constructor|method|beforeSerialize|formToArray|in|beforeSubmit|param|resetForm|clearForm|iframe|fileUpload|new|active|timeout|textarea|text|continue|toLowerCase|checkbox|radio|checked|selectedIndex|ops|attributes|console|GET|pre|serialize|veto|vetoed|callback|validate|arguments|closeKeepAlive|elements|not|ajaxSettings|src|about|blank|top|1000px|left|getResponseHeader|global|beforeSend|getAttribute|POST|multipart|try|appendTo|attachEvent|onload|load|remove|50|detachEvent|contentWindow|document|contentDocument|innerHTML|100|XMLDocument|getElementsByTagName|xml|toXml|error|complete|ActiveXObject|documentElement|ajaxFormUnbind|bind|click|offsetX|offset|pageX|pageY|unbind|val|jmax|one|clearFields|option|skipping|process|no|element|trim|match|location|href|semantic|instanceof|toUpperCase|indexOf|html|apply|file|get|ajax|notify|alert|Error|Form|must|be|named|jqFormIO|Date|getTime|id|css|position|absolute|status|statusText|getAllResponseHeaders|setRequestHeader|abort|ajaxStart|ajaxSend|skipEncodingOverride|encoding|enctype|hidden|addEventListener|finally|removeAttr|removeEventListener|throw|Could|access|DOM|after|tries|content|json|script|httpData|catch|handleError|ajaxSuccess|ajaxComplete|ajaxStop|Microsoft|XMLDOM|async|loadXML|DOMParser|parseFromString|parsererror|ajaxForm|offsetY|offsetLeft|offsetTop|formSerialize|fieldSerialize|merge|button|options|specified|clearInputs|password|object|nodeType|enable|parent|find|debug|jquery|prototype|join|call|jQuery'.split('|'),0,{}));
// Jquery History
(function($){function History(){this._curHash='';this._callback=function(hash){}};$.extend(History.prototype,{init:function(callback){this._callback=callback;this._curHash=location.hash;if($.browser.msie){if(this._curHash==''){this._curHash='#'}$("body").prepend('<iframe id="jQuery_history" style="display: none;"></iframe>');var iframe=$("#jQuery_history")[0].contentWindow.document;iframe.open();iframe.close();iframe.location.hash=this._curHash}else if($.browser.safari){this._historyBackStack=[];this._historyBackStack.length=history.length;this._historyForwardStack=[];this._isFirst=true;this._dontCheck=false}this._callback(this._curHash.replace(/^#/,''));setInterval(this._check,100)},add:function(hash){this._historyBackStack.push(hash);this._historyForwardStack.length=0;this._isFirst=true},_check:function(){if($.browser.msie){var ihistory=$("#jQuery_history")[0];var iframe=ihistory.contentDocument||ihistory.contentWindow.document;var current_hash=iframe.location.hash;if(current_hash!=$.history._curHash){location.hash=current_hash;$.history._curHash=current_hash;$.history._callback(current_hash.replace(/^#/,''))}}else if($.browser.safari){if(!$.history._dontCheck){var historyDelta=history.length-$.history._historyBackStack.length;if(historyDelta){$.history._isFirst=false;if(historyDelta<0){for(var i=0;i<Math.abs(historyDelta);i++)$.history._historyForwardStack.unshift($.history._historyBackStack.pop())}else{for(var i=0;i<historyDelta;i++)$.history._historyBackStack.push($.history._historyForwardStack.shift())}var cachedHash=$.history._historyBackStack[$.history._historyBackStack.length-1];if(cachedHash!=undefined){$.history._curHash=location.hash;$.history._callback(cachedHash)}}else if($.history._historyBackStack[$.history._historyBackStack.length-1]==undefined&&!$.history._isFirst){if(location.hash.indexOf('#')>=0){$.history._callback(location.hash.split('#')[1])}else{$.history._callback('')}$.history._isFirst=true}}}else{var current_hash=location.hash;if(current_hash!=$.history._curHash){$.history._curHash=current_hash;$.history._callback(current_hash.replace(/^#/,''))}}},isKonqueror:function(){return/KHTML|Konqueror/.test(navigator.userAgent)},load:function(hash){var newhash;if($.browser.safari){newhash=hash}else{newhash=(this.isKonqueror()?'':'#')+hash;location.hash=newhash}this._curHash=newhash;if($.browser.msie){var ihistory=$("#jQuery_history")[0];var iframe=ihistory.contentWindow.document;iframe.open();iframe.close();iframe.location.hash=newhash;this._callback(hash)}else if($.browser.safari){this._dontCheck=true;this.add(hash);var fn=function(){$.history._dontCheck=false};window.setTimeout(fn,200);this._callback(hash);location.hash=newhash}else{this._callback(hash)}}});$(document).ready(function(){$.history=new History()})})(jQuery);
// TABS
$.fn.pdTabs=function(option){option=jQuery.extend({tabSelector:'.tab-fragment',tabNameSelector:'.tab-name',defTab:0,tabPosition:'top',hideTabClass:'hide-tab',activeTabClass:'active',callFunction:function(){},prefix:'hi_'},option);var helpHash='';var sdiak="áäčďéěíĺľ?ôöŕšťúůüýřž?ČĎÉĚÍĹĽŇÓÔÖŔ ŤÚŮÜÝ?/";var bdiak="aacdeeillnooorstuuuyrzAACDEEILLNOOORSTUUUYRZ.";function bezdiak(str){var tx="";var txt=str;for(p=0;p<txt.length;p++){if(sdiak.indexOf(txt.charAt(p))!=-1){tx+=bdiak.charAt(sdiak.indexOf(txt.charAt(p)))}else tx+=txt.charAt(p)}return tx};$(this).each(function(){var element=$(this);$(element).addClass('js');var tabConstruct={name:function(){var i=0;var arr=[];$(''+option.tabSelector,element).each(function(){var size=$(''+option.tabNameSelector,this).size();if(size>0){if($(''+option.tabNameSelector+':eq(0)',this).attr('title')!=''){arr[i]=$(''+option.tabNameSelector+':eq(0)',this).attr('title')}else{arr[i]=$(''+option.tabNameSelector+':eq(0)',this).text()}}else{var j=i+1;arr[i]='Tab '+j}i++});return arr},id:function(){var arr=this.name();for(var i=0;i<arr.length;i++){arr[i]=bezdiak(arr[i].toLowerCase());arr[i]=arr[i].replace(/\s/g,"-").replace(/[-]{2,}/g,"-").replace(/\.|\{|\}|\(|\)|\[|\]|\\|@|:|\d/g,"").replace(/^-/,"").replace(/-$/,"")}return arr},size:$(''+option.tabSelector,element).size(),tabList:function(){var arrName=tabConstruct.name();var arrId=tabConstruct.id();var list='<ul class="tab-list">';for(var i=0;i<this.size;i++){list+='<li class="tab-'+(i+1)+' tab-'+arrId[i]+'"><a href="#'+arrId[i]+'"><span>'+arrName[i]+'</span></a></li>'}list+='</ul>';return list}};if(option.tabPosition=='bottom'){$(element).append(tabConstruct.tabList());$('.tab-list a').each(function(){$(this).attr('href','#'+$(this).attr('href').split('#')[1])})}else{$(element).prepend(tabConstruct.tabList());$('.tab-list a').each(function(){$(this).attr('href','#'+$(this).attr('href').split('#')[1])})}var i=0;var arrId=tabConstruct.id();$(''+option.tabSelector,element).each(function(){$(this).attr('id',arrId[i]);i++});function makeTabByHash(hash){if(typeof hash!='undefined'){var hash=hash}else{var hash=''}if(hash!=''){var onlyHash=hash;hash=option.prefix+hash}else{hash=window.location.hash.slice(1)}if(hash==''&&helpHash==''){var index=typeof option.defTab=='number'?option.defTab:0;$(''+option.tabSelector,element).eq(index).removeClass(option.hideTabClass);$(''+option.tabSelector,element).not(':eq('+index+')').addClass(option.hideTabClass);$('.tab-list li',element).not(':eq('+index+')').removeClass(option.activeTabClass);$('.tab-list li',element).eq(index).addClass(option.activeTabClass)}else{if($('#'+hash,element).is(option.tabSelector)==true){$('#'+hash,element).filter('.hide-tab').removeClass(option.hideTabClass);$(''+option.tabSelector,element).not('#'+hash+'').addClass(option.hideTabClass);var index=$(''+option.tabSelector,element).index($('#'+hash));$('.tab-list li',element).not(':eq('+index+')').removeClass(option.activeTabClass);$('.tab-list li',element).eq(index).addClass(option.activeTabClass);helpHash=hash}else if($(''+option.tabSelector+' #'+hash,element).size()>0||$(''+option.tabSelector+' #'+onlyHash,element).size()>0){if($(''+option.tabSelector+' #'+hash,element).size()>0){var index=$(''+option.tabSelector,element).index($('#'+hash).parents(''+option.tabSelector))}else{var index=$(''+option.tabSelector,element).index($('#'+onlyHash).parents(''+option.tabSelector))}$(''+option.tabSelector,element).eq(index).removeClass(option.hideTabClass);$(''+option.tabSelector,element).not(':eq('+index+')').addClass(option.hideTabClass);$('.tab-list li',element).not(':eq('+index+')').removeClass(option.activeTabClass);$('.tab-list li',element).eq(index).addClass(option.activeTabClass);helpHash=$(''+option.tabSelector+' #'+hash,element).parents(''+option.tabSelector).attr('id')}else{if(helpHash==''){var index=typeof option.defTab=='number'?option.defTab:0}else{var index=$(''+option.tabSelector,element).index($('#'+helpHash))}$(''+option.tabSelector,element).not(':eq('+index+')').addClass(option.hideTabClass);$('.tab-list li',element).not(':eq('+index+')').removeClass(option.activeTabClass);$('.tab-list li',element).eq(index).addClass(option.activeTabClass)}option.callFunction();if($(''+option.tabSelector+' #'+hash,element).size()>0){var top=$('#'+hash).offset().top;$('html, body').scrollTop(top)}}};$('a[href^="#"]').each(function(){var hash=$(this).attr('href').split('#');hash=hash[hash.length-1];if(hash!=''&&$('#'+hash,element).size()){$('#'+hash).each(function(){this.id=option.prefix+this.id});$('label[for="'+hash+'"]').each(function(){this.htmlFor=option.prefix+this.htmlFor});$(this).click(function(){$.history.load(hash);return false})}});$.history.init(makeTabByHash);var hash=window.location.hash;hash=hash.replace(/^.*#/,'');if(hash!=''){$.history.load(hash)}else{makeTabByHash()}})};
// Checkbox filter
$.fn.sortCheckbox=function(option){option=jQuery.extend({name:'all'},option);$(this).each(function(){var el=$(this);$(':checkbox',this).click(function(){if($(this).hasClass(option.name)){el.find(":checkbox."+option.name).attr('checked',true);el.find(":checkbox").not('.'+option.name).attr('checked',false)}else if(el.find(":checkbox").not('.'+option.name).filter(':checked').size()>0){el.find(":checkbox."+option.name).attr('checked',false)}else{el.find(":checkbox."+option.name).attr('checked',true)}})})};
// PDBox, Copyright (c) 2007 PeckaDesign (www.peckadesign.cz)
jQuery.fn.pdBox=function(options){var o=jQuery.extend({minWidth:540},options);var allLinks=this;var groupLinks=null;var thisLink=null;var numbers=null;var boxWidth=540;var langcode=$('html').attr('lang')||'cs';var langs={cs:{close:"Zavřít",prev:"předchozí",next:"další"},en:{close:"Close",prev:"previous",next:"next"},de:{close:"Zumachen",prev:"vorige",next:"folgend"},es:{close:"Vaer",prev:"previo",next:"siguiente"},fr:{close:"Fermer",prev:"précédant",next:"suivant"},it:{close:"Chiudere",prev:"previo",next:" veniente"},ru:{close:"закрыть",prev:"пред??в?щий",next:"по?ед?щий"}};var imgPreloader=null;return this.each(function(){jQuery(this).bind('click',function(){if(navigator.appName!='Konqueror'){showOverlay()}showBox();initGroup(this);return false});function showBox(){if(!document.getElementById("TB_window")){jQuery("body").append("<div id='TB_window'></div>");var html="<div id='pd-box-top'>"+"<div id='pd-box-bottom'>"+"<div id='pd-box-left'>"+"<div id='pd-box-right'>"+"<div id='pd-content'>"+"<div id='TB_secondLine'>"+"<div id='prevnext'>"+"<a href='#' id='TB_prev' rel=''>"+langs[langcode]["prev"]+"</a>"+"<a href='#' id='TB_next' rel=''>"+langs[langcode]["next"]+"</a>"+"</div>"+"<div id='TB_pages'></div>"+"</div>"+"<div class='break'></div>"+"<h2 id='TB_caption'></h2>"+"<div id='TB_desc'></div>"+"<a href='' id='TB_ImageOff' title='"+langs[langcode]["close"]+"'></a>"+"</div>"+"</div>"+"</div>"+"</div>"+"</div>"+"<div id='TB_closeWindow'>"+"<a href='#' id='TB_closeWindowButton' title='"+langs[langcode]["close"]+"'> "+langs[langcode]["close"]+"</a>"+"</div>"+"<div id='pd-box-top-left'>&nbsp;</div>"+"<div id='pd-box-top-right'>&nbsp;</div>"+"<div id='pd-box-bottom-left'>&nbsp;</div>"+"<div id='pd-box-bottom-right'>&nbsp;</div>";jQuery("#TB_window").append(html);jQuery("#TB_closeWindowButton").bind('click',hideBox);positionBox()}};function hideBox(){if(o.onHide){o.onHide.call($('#TB_window'))}hideOverlay();jQuery(document).unbind('keyup');return false};function initGroup(elem){var group=jQuery(elem).attr('rel');if(group&&group!='nofollow'){groupLinks=allLinks.filter('a[rel="'+group+'"]');var htmlPages='';groupLinks.each(function(i){htmlPages+=" <a href='"+this.href+"'>"+(i+1)+"</a> "});jQuery("#TB_pages").append(htmlPages);numbers=jQuery("#TB_pages a");jQuery("#TB_prev").bind('click',function(){jQuery('#TB_pages .active').prev().trigger('click');return false});jQuery("#TB_next").bind('click',function(){jQuery('#TB_pages .active').next().trigger('click');return false});jQuery(document).bind('keyup',function(e){var keycode;if(!e){var e=window.event}if(e.keyCode){keycode=e.keyCode}else if(e.which){keycode=e.which}var key=String.fromCharCode(keycode).toLowerCase();if((key=='x')||(key=='c')||(keycode==27)){jQuery("#TB_closeWindowButton").trigger('click')}else if((key=='p')||(keycode==37)){jQuery("#TB_prev:visible").trigger('click')}else if((key=='n')||(key=='d')||(keycode==39)){jQuery("#TB_next:visible").trigger('click')}});if(numbers.size()==1){jQuery("#TB_prev, #TB_next, #TB_pages").addClass('hidden')}jQuery("#TB_pages a").bind('click',clickNumber).eq(groupLinks.index(elem)).trigger('click')}else{groupLinks=jQuery(elem);jQuery("#TB_prev, #TB_next, #TB_pages").addClass('hidden');preloadContent(elem.href,elem)}};function clickNumber(){numbers.removeClass('active');jQuery(this).addClass('active');var index=numbers.index(this);if(index==0){jQuery("#TB_prev").addClass("hidden")}else{jQuery("#TB_prev").removeClass("hidden")}if(index==numbers.size()-1){jQuery("#TB_next").addClass("hidden")}else{jQuery("#TB_next").removeClass("hidden")}thisLink=groupLinks.eq(index);preloadImage(this.href);return false};function preloadContent(href,elem){var regexp=/\.jpg|\.png|\.gif$/;if(href.search(regexp)!==-1){$('#pdb-caption, #pdb-desc, #pdb-image-anchor').removeClass('hidden');$("#pdb-content").addClass('hidden');preloadImage(href)}else{$("#pdb-content").removeClass('hidden').addClass('loader');$('#pdb-caption, #pdb-desc, #pdb-image-anchor').addClass('hidden');preloadHtml(href,elem)}};function preloadHtml(href,elem){ioff=$('#pdb-image-anchor');href=elem.pathname+elem.search;var s='?';var re1=/\?/;if(href.search(re1)!=-1)s='&';$("img",ioff).remove();$("#TB_secondLine").remove();$("#TB_ImageOff").html();var hashUrl=false;var hash=$(elem).attr('href').split('#')[1];if($('#'+hash).size()>0){hashUrl=true;var hashContent=$('#'+hash).html()}if(hashUrl){$('#TB_caption').html($(elem).attr('title'));jQuery("#TB_ImageOff").remove();$("#TB_desc").html(hashContent);$('#pd-box-bottom-left, #pd-box-bottom-right').css('position','absolute');if(o.onLoad){o.onLoad.call($('#TB_window'))}$('.closeBox').bind('click',hideBox)}else{$("#TB_desc").load(href+s+"ajax=true",null,function(){jQuery("#TB_ImageOff").remove();$('#pd-box-bottom-left, #pd-box-bottom-right').css('position','absolute');$("#formDoporucte #BDmessage").append($("#odeslat").attr('title'));if(o.onLoad){o.onLoad.call($('#TB_window'))}$('.closeBox').bind('click',hideBox)})}if(boxWidth<o.minWidth)boxWidth=o.minWidth;positionBox()};function preloadImage(href){ioff=jQuery('#TB_ImageOff');if(ioff.size()==1){ioff.height(ioff[0].offsetHeight+"px")}jQuery("img",ioff).remove();imgPreloader=document.createElement('img');jQuery(imgPreloader).bind('load',showImage);jQuery(imgPreloader).attr('src',href)};function showImage(e){this.onload=null;var pagesize=getPageSize();var x=pagesize[0]-150;var y=pagesize[1]-150;var imageWidth=this.width;var imageHeight=this.height;var jqimg=jQuery('img',thisLink);var caption=jqimg.attr('alt');var desc=jqimg.attr('title');var longdesc=jqimg.attr('longdesc');var enhdesc=desc?desc+'':'';if(longdesc)enhdesc+=', <a href="'+longdesc+'">'+longdesc+'</a>';if(caption)jQuery("#TB_caption").removeClass("hidden").html(caption);else jQuery("#TB_caption").addClass("hidden").empty();jQuery("#TB_desc").addClass("hidden").empty();boxWidth=imageWidth+2*17+2*17;if(boxWidth<o.minWidth)boxWidth=o.minWidth;positionBox();this.alt=caption;if(desc)this.title=desc;ioff.height("auto").empty().append(this).bind('click',hideBox);jQuery("#TB_window").css({display:"block"})};function positionBox(){var arrayPageScroll=getPageScrollTop();var pagesize=getPageSize();jQuery("#TB_window").css({marginLeft:'-'+parseInt(boxWidth/2)+'px',width:boxWidth+'px',top:(arrayPageScroll[1]+40)+"px"})};function getPageSize(){var de=document.documentElement;var w=window.innerWidth||self.innerWidth||(de&&de.clientWidth)||document.body.clientWidth;var h=window.innerHeight||self.innerHeight||(de&&de.clientHeight)||document.body.clientHeight;arrayPageSize=new Array(w,h);return arrayPageSize};function getPageScrollTop(){var yScrolltop;if(self.pageYOffset){yScrolltop=self.pageYOffset}else if(document.documentElement&&document.documentElement.scrollTop){yScrolltop=document.documentElement.scrollTop}else if(document.body){yScrolltop=document.body.scrollTop}arrayPageScroll=new Array('',yScrolltop);return arrayPageScroll};function showOverlay(){if(!document.getElementById("TB_HideSelect")){jQuery("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div>");jQuery("#TB_overlay").bind('click',hideBox);sizeOverlay()}};function sizeOverlay(){if(window.innerHeight&&window.scrollMaxY){var yScroll=window.innerHeight+window.scrollMaxY}else if(document.body.scrollHeight>document.body.offsetHeight){var yScroll=document.body.scrollHeight}else{var yScroll=document.body.offsetHeight}jQuery("#TB_overlay").css("height",yScroll+10+"px");jQuery("#TB_HideSelect").css("height",yScroll+"px")};function hideOverlay(){jQuery('#TB_window, #TB_overlay, #TB_HideSelect').remove()}})};
// Cookie
jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options=$.extend({},options);options.expires=-1}var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000))}else{date=options.expires}expires='; expires='+date.toUTCString()}var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('')}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break}}}return cookieValue}};
// FB CLICK
function fb_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&amp;t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}

jQuery.fn.extend(
{
    /**
     * 
     */
    kHoverBox: function(o) {
        return this.each(function(i) {
            new jQuery.kHoverBox(this, o, i);
        });
    }
});

var positionLeft = false;

jQuery.extend(
{   
    kHoverBox: function(e, o, i) 
    {
        var publ = this;
        

        // Private methods/variables
        var priv = 
        {
            o: 
            {
            	loadContent: function(){},
				timeOut: 300,
				timeOutOut: 500      	
            },
            isMouseInBox: false,
            isMouseInLink: false,
            timeOut: false,

            init: function(e, o) 
            {
                if(o) jQuery.extend(priv.o, o);

				jQuery(e).bind('mouseover', function(event)
				{
					
					width = jQuery(document).width();										
					
					var left = event.pageX;
					var top =  event.pageY;
					
					
					priv.isMouseInLink = true;
					
					if(!priv.timeOut)
					setTimeout(function()
					{						
						if(priv.isMouseInLink)
						{
							jQuery('#kHoverBox').remove();
							jQuery('body').append('<div id="kHoverBox" class="kHoverBox'+i+'"></div>');
							var khb = jQuery('#kHoverBox');							
							khb.hide()
							.bind('mouseover', function(event){
								priv.isMouseInBox = true;
							})
							.bind('mouseout', function(event){
								priv.isMouseInBox = false;
								priv.hide();								
							});
							
							priv.o.loadContent(e, left, top);
							khb.css({ position: 'absolute', left: '0', top: '0', display: 'block', visibility: 'hidden'});
							
							// pripadne posunuti doleva, kdyz vpravo neni misto
							if (left + 215 > jQuery(document).width()) {
								khb
                                    .css({ position: 'absolute', left: (left - 200) + 'px', display: 'none', visibility: 'visible'})
                                    .show()
                                    .css('top', (top - khb.outerHeight()) +'px');
								positionLeft = true;
							}							
							else {
								khb
                                    .css({ position: 'absolute', left: left + 'px', display: 'none', visibility: 'visible'})
								    .show()
                                    .css('top', (top - khb.outerHeight()) +'px');
								positionLeft = false;
							}
																											
						}
					} , priv.o.timeOut);
					return false;
				});
				
				
				jQuery(e).bind('mouseout', function()
				{	
					priv.isMouseInLink = false;	
					priv.hide();				
					return false;
				});
				
            },
            
			hide: function() 
			{
				priv.timeOut = true;
				setTimeout(function()
				{
					priv.timeOut = false;
					if(!priv.isMouseInLink && !priv.isMouseInBox)
					{
						jQuery('.kHoverBox'+i).remove();
					}
				} , priv.o.timeOutOut);
			}

        };

        // Initialize
        priv.init(e, o);
    }
});

function loadComents(e, left, top)
{
	$.ajax({
		type: "GET",
		url: "/tpl/ajax/getComments.php",
		data: "prodID="+$('#prodID').attr('title')+"&comment="+$(e).text(),
		success: function(xml){
			var html = xml;
			var khb = $('#kHoverBox');
			khb
                .html('<div class="hoverbox"><div id="corner"></div>' + html + '</div>')
                .css('top', (top - khb.outerHeight()) +'px');
		}		
	});
};



$(document).ready(function(){
    
    //
    $('.comments-list .adlink a').kHoverBox({loadContent: loadComents});
		
    // Init pdBox
    $('.thickbox').pdBox({});
    $('.guide').pdBox({minWidth: 810});
            
    $('.att-links .blank').attr('target', 'blank');
    
    $('.products-crossroad tbody tr').hover(
    	function(){
    		$(this).addClass('hover');
    	},
    	function(){
    		$(this).removeClass('hover');
    	}
    );
            
    $('.ajaxPrebasket').pdBox({
    	minWidth: 800,
    	onLoad: function(){
    		var $this = $(this);
    		var $par = $('.accessories-list', this);
    		
    		$('ul', $par).adjustHeights({ 
                elements : ['h3 .name'],
                vAlign : 'top'
            });
    		
    		$('li', $par).each(function(){
    			var $box = $(this);
    			var $btn = $('.price a', $box);
    			
    			$btn.click(function(){
    				var href = $(this).attr('href');
    				$.ajax({ 
              			type: "GET",
              			url: href.split('?')[0],
              			data: href.split('?')[1]+'&ajax=true',
              			//dataType: 'xml',
              			success: function(responseXML)
              			{
              				var $html = $('<div></div>')
              					$html.append(responseXML)
              				
              				$('.col-h-r', $this).replaceWith($('.col-h-r', $html))
              				
              				$box.fadeOut(200, function(){ 
              					// Odstranění boxu pokud už nejsou produkty k přidání
                  				if(!$('li:visible', $par).size())
                  				{
                  					$par.remove()
                  				}
                  				var $ul = $box.parent()
                  				if(!$('li:visible', $ul).size())
                  				{
                  					$ul.remove()
                  				}
                  				else{
                                    $('li:visible', $ul).eq(0).addClass('first');
                                }
              				});
              				
          				 }
      				});
      				return false;
    			});
    		});
    	},
    	onHide: function(){
    		var replace1 = $('#ajaxReplace .basket').clone();
    		$('body #tool-menu .basket').replaceWith(replace1);
    	}
	});
	
    $('.compareAjax').pdBox({
    	minWidth: 800,
    	onLoad: function(){
    		var $par = $('.accessories-list', this);
    		var $this = $(this);
    		$('li', $par).each(function(){
    			var $box = $(this);
    			var $btn = $('.info a', $box);
    			
    			$btn.click(function(){
    				var href = $(this).attr('href');
    				$.ajax({ 
              			type: "GET",
              			url: href.split('?')[0],
              			data: href.split('?')[1]+'&ajax=true',
              			//dataType: 'xml',
              			success: function(responseXML)
              			{
              				var $html = $('<div></div>')
              					$html.append(responseXML)
              				
              				$('.message', $this).replaceWith($('.message', $html))
              				
              				$box.fadeOut(200, function(){ 
              					// Odstranění boxu pokud už nejsou produkty k přidání
                  				if(!$('li:visible', $par).size())
                  				{
                  					$par.remove()
                  				}
                  				var $ul = $box.parent()
                  				if(!$('li:visible', $ul).size())
                  				{
                  					$ul.remove()
                  				}
                  				else{
                                    $('li:visible', $ul).eq(0).addClass('first');
                                }
              				});                  				
                        }
      				});
      				return false;
    			});
    		});
    	}
    });
            
            // FILTER BOX
            $('.filter-box, .filter-box-grey').each(function(){
            	/*var $btn = $('#filter-button', this),
            		$box = $('.box', this),
            		url = location.host + location.pathname;
            	if($btn.is('.open')){
            		$box.show();
        		}
            	else{$box.hide();}
            	
            	$btn.click(function(){
            		if(!$btn.is('.open')){
            			$(this).addClass('open');
            			if(!/peckadesign/.test(url))
            			{
            				pageTracker._trackEvent('Parametrické filtrování - vím přesně co hledám', 'open-box', location.host + location.pathname)	
            			}
            			$box.show();
            		}
            		else{
            			$box.hide();
            			if(!/peckadesign/.test(url))
            			{
            				pageTracker._trackEvent('Parametrické filtrování - vím přesně co hledám', 'close-box', location.host + location.pathname)	
            			}
            			$btn.removeClass('open');	
            		}
            	});
            	
            	$('label a', $box).click(function(){
            		$(this).parent().prev().trigger('click').attr('checked', true);
            		$('#paramSend').click();
            		return false;
            	});
            	
            	$('.right a', $box).click(function(){
            		var param = $(this).attr('href').split('?')[1];
            		var loc = window.location.search.substr(1);
            		var s = loc == '' ? '' : '&';
					if (loc.indexOf(param)!=-1){
						 param = '';
						 s = '';
					}
            		
            		//console.log(loc+s+param)
            		window.location.search = loc+s+param;
            		return false;
            	});
            	
            	//Zaškrtávání inputů
    			$('p', $box).sortCheckbox();*/
    			
    			var $this = $(this);
    			
    			if ( $('.next-params .spc', $this).text()!='' ) {
	    			$('.control', $this).show().each(function(){					
						if ($.cookie('filter')) {
							$('.filter-box-grey .next-params .spc').show();			
							$(this).css('background-image', 'url("/img/bg/filter-controls-up.png")').text('Méně kritérií výběru');	
						}
						else {
							$('.filter-box-grey .next-params .spc').hide();
							$(this).css('background-image', 'url("/img/bg/filter-controls-down.png")').text('Více kritérií výběru');
						}
					}).click(function(){    				
	    				if ($.cookie('filter')) {
	    					if ( $.browser.msie && $.browser.version<8) {
	    						$(this).hide();
	    					}
	    					$('.next-params .spc', $this).slideUp('slow', function(){
								$('.control', $this).show();
							});
							$(this).css('background-image', '').text('Více kritérií výběru');
	    					$.cookie('filter', null, {path: '/', expires: date, domain: ''});
	    				}
	    				else{
	    					if ( $.browser.msie && $.browser.version<8) {
	    						$(this).hide();
	    					}
							$('.next-params .spc', $this).slideDown('slow', function(){
								$this.css('position', 'relative'); 
								$('.control', $this).show();
							});
							$(this).css('background-image', '').text('Méně kritérií výběru');
							var date = new Date();
		                    date.setTime(date.getTime() + (24 * 60 * 60 * 1000));
		                    $.cookie('filter', 'true', {path: '/', expires: date, domain:''});
		                    pageTracker._trackEvent('Filtr produktů', 'Více kritérií výběru', location.host + location.pathname);
						}					
					});
				}
				else {
					$('.next-params', $this).remove();
				}
    			
    			$('p:not(".brands-inputs") label a', $this).click(function(){
            		$(this).parent().prev().trigger('click').attr('checked', true);
            		$('#paramSend').click();
            		return false;
            	});
            	
    			$('p', $this).sortCheckbox();
            });
            
            // Content help
            $('.content .blockem').append('<span class="cor cor-l"></span><span class="cor cor-r"></span><span class="cor cor-bl"></span><span class="cor cor-br"></span>')
            $('.content table tr:even').addClass('even');
            $('.table-list tr, .basket thead tr').each(function(){
            	var back = 0;
	            $('td, th' , this).each(function(i){
	            	var $box = $(this);
	            	var x = $box.outerWidth() % 3;
	            	if($.browser.mozilla && i!=0){back-=1;}
	            	$box.css('background-position', (back) +'px 100%');
	            	back = x;
	            });
	        });

			// Kroky objednávky
	        $('.step-list').each(function(){
	        	var $step = $('li.prev, li.next', this);
	        	var $prev = $('li.prev', this);
	        	var $next = $('li.next', this);
	        	
	        	$next.click(function(){
	        		$('#order .buttons .r input').trigger('click');
	        	});
	        	$prev.click(function(){
	        		$('#order .buttons .l input').trigger('click');
	        	});
	        	$step.hover(function(){$(this).addClass('hover')}, function(){$(this).removeClass('hover')})
	        });
	        
	        // Proklik na celý box
	        $('#header-contact .tab-fragment').slice(0, 2).each(function(){
                $(this).css('cursor', 'pointer');
                $(this).hover(
                	function(){
                		$(this).addClass('hover');
                	},
                	function(){
                		$(this).removeClass('hover');
                	}
            	)
                $(this).click(function(){
                    window.location = $('.l a', this).attr('href');
                    return false;
                });
            });
            $('.help .phone').click(function(){
                window.location = $('a', this).attr('href');
                return false;
            }).css('cursor', 'pointer');
            
            // Sort form
            $('.sort-box .l select').each(function(i){
            	var index = i;
            	$(this).change(function(){
            		if(i==0 && this.value==''){
            			$('select', this.form).each(function(){
            				this.removeAttribute('name');
            			});
            		}
            		else if(this.value==''){
            			this.removeAttribute('name');	
            		}
            		this.form.submit()
            	});
        	});
            
            // Payment and transport
            var Order = function(){
                this.box = {
                    $pay: $('.payment-box'),
                    $trans: $('.transport-box')
                };
                this.check = function(c){
                    $('.item:not(.'+c+')', this.box.$pay).hide().attr('checked', false);
                    $('.item.'+c, this.box.$pay).filter(':hidden').show();        
                };
                var that = this;
                this.init = function(){
                    $('.radio:checked', this.box.$trans).each(function(){
                        var id = $(this).attr('id');
                        that.check(id);      
                    });
                    $('.radio', this.box.$trans).click(function(){
                        var id = $(this).attr('id');
                        that.check(id);      
                    });
                };
                this.init();
            };
            var order = new Order();
            
            // SERVICES CONTROL
            var services = function(){
				if ( $('#transport3').is(':checked') ) {
					$('.services-list').each(function(){
						$('input', this).attr('disabled', false);	
					});
				}
				else {
					$('.services-list').each(function(){
						$('input', this).attr('disabled', true);	
					});				
				}
			};
            services();
            $('.transport-box input').click(function(){
				services();
			});
			$('.services-list #services1, .services-list #services2').click(function(){
				if($(this).is('#services1') && $(this).is(':checked')){
					$('.services-list #services2').attr('checked', false);
				}
				else if($(this).is('#services2') && $(this).is(':checked')){
					$('.services-list #services1').attr('checked', false);	
				}
			});
		
            
            // Open box
	        $('.open-box').each(function(){
	            var $this = $(this);
	            var $chck = $('h2 input', this);
	            var $box = $('.box', $this);
	            var attr = $chck.attr('checked')
	            var size = 0;
	            $('.box :input', $this).each(function(){
	                if($(this).is(':text') && $(this).val() != '')
	                {
	                    size++;
	                }
	                else if($(this).attr('checked'))
	                {
	                    size++;
	                }
	            });
	            if(attr || size != 0)
	            {
	                $chck.attr('checked', true);
	                $this.data('status', true);
	            }
	            else
	            {
	                $box.hide();
	                $this.data('status', false);
	            }
	            $('h2 input', $this).click(function(){
	                if($this.data('status'))
	                {
	                    $chck.attr('checked', false);
	                    $box.slideUp('fast');
	                    $this.data('status', false);
	                }
	                else
	                {
	                    $chck.attr('checked', true);
	                    $box.slideDown('fast');
	                    $this.data('status', true);
	                }
	            });
	        });
	        $('.order-list li').each(function(){
	        	var $box = $(this);
	        	var $openBox = $('.box', $box);
	        	var $btn = $('<span class="arr"></span>');
	        	var open = false;
	        	
	        	$openBox.hide().after($btn);
	        	$btn = $('.arr, h3', $box);
            	
	        	$btn.click(function(){
	        		if(!open)
	        		{
	        			$openBox.show();
	        			$box.addClass('open');
		        		/* POSITIONED CORNER IE 6 RECALCULATE */
	                	$('.cor', $box).css('position','relative').css('position','absolute');	
	        			open = true;
	        		}
	        		else
	        		{
	        			$openBox.hide();
	        			$box.removeClass('open');
		        		/* POSITIONED CORNER IE 6 RECALCULATE */
	                	$('.cor', $box).css('position','relative').css('position','absolute');
	        			open = false;
	        		}
	        	});
	        	
	        	
	        });
	        
             // Focus
        	$('input#q').each(function(){
        		var $this = $(this);
        		var $form = $($this.get(0).form);
        		var btntext = $(this).attr('value');
        		
        		$(this).blur().bind('focus', function(){
        			$(this).addClass('focus');
        			var text = $(this).attr('value');
        			if( text == btntext ){
        				$(this).attr('value', '');
        			}
        		}).bind('blur', function(){
        			$(this).removeClass('focus');
        			var text2 = $(this).attr('value');
        			if( text2 == '' || text2 == undefined ){
        				$(this).attr('value', btntext);
        			}
        		});
        		$form.bind('submit', function(){
        			var text = $this.attr('value');
        			if( text == btntext ){
        				$this.attr('value', '');
        			}		
        		});
        	});
                   	
        	$('#main-menu').each(function(){
        		var $box = $(this);
        		var $li = $('li.submenu', $box);
        		
        		$li.each(function(){
        			var $this = $(this);
        			var $sub = $('.box', this);
        				$sub.show()
        			var height = $sub.height();
        				$sub.hide()
        			var speed = /*Math.ceil(height*1.4)*/300;
        			var time = null
        			
        			$sub.css('margin-top', -height+'px');
        			
        			$this.hover(
	        			function(){
	        				$('#q').trigger('blur');
	        				//time = setTimeout(function(){
	        					$this.addClass('hover');
		        				$sub.show().stop().animate({
		        					marginTop: 0+'px'
		        					
		        				}, speed);
		        				$this.find('.item span').css('padding-bottom', '20px');		
	        				//}, 100);
	        			},
	        			function(){
	        				//time = clearTimeout(time);
	        				$sub.stop().animate({
	        					marginTop: -height+'px'
	        				}, speed, function(){
	        						$(this).hide()
	        						$this.removeClass('hover');
	    					});	
	    					$this.find('.item span').css('padding-bottom', '')
	        			}
	    			);
        		});
        	});
        	
        	$('#home-crossroad').each(function(){
        		var $box = $(this);
        		var $li = $('li', $box);
        		var subS = '.box';
        		var hoverable = true;
        		var time = null;
        		
        		$li.filter(':has('+subS+')').hover(
        			function(){
        				var $this = $(this);
        				time = setTimeout(function(){
	        				if(hoverable)
	        				{
	        					$('#q').trigger('blur');
		        				$('h3 a', $this).css('z-index', '5');
		        				$(subS, $this).css('z-index', '4').show();
		        				$this.addClass('hover');
		        				$('.illust').css('position', 'absolute');
		        				$('.cat-list ul', $this).adjustHeights({
				                    elements : ['.name'],
				                    vAlign : 'top'
				                });
	        				}
	        			}, 100);
        			},
        			function(){
        				time = clearTimeout(time);
        				$('h3 a', this).css('z-index', '3');
        				$(subS, this).css('z-index', '2').hide();
                 		$(this).removeClass('hover');
        			}	
        		).each(function(){
        			var $this = $(this);
        			var $subBox = $(subS, $this)
        			$subBox.append('<a href="#" class="closeBtn"></a>')
        			$subBox.find('.closeBtn').click(function(){
        				hoverable = false;
        				setTimeout(function(){hoverable = true;}, 400)
        				
        				$('h3 a', $this).css('z-index', '3');
        				$subBox.css('z-index', '2').hide();
        				$this.removeClass('hover')
        				return false;
        			})
        		});
        	});
        	
        	// Tool menu
        	$('#tool-menu').each(function(){
        		var $box = $(this);
        		var time = null;
        		$box.find('.shop').hover(
        			function(){
        				var $this = $(this);
        				time = setTimeout(function(){
        					$('#q').trigger('blur');
		        			$this.addClass('hover');
		        			$('.box', $this).slideDown(150, function(){
	                 			$this.addClass('hover');	
                 			});
             			}, 100);
        			},
        			function(){
        				time = clearTimeout(time);
        				var $this = $(this);
                 		$('.box', this).slideUp(150, function(){
                 			$this.removeClass('hover');	
                 		});
        			}	
        		);
            });
            
            /* Regovat - !!musí být před záložkama!! */
            $('.comments-list li').each(function(){
                var number = $('.num', this).text().split('.')[0],
                    $btn = $('.r a', this),
                    $target = $($btn.attr('hash')),
                    $text = $target.find('textarea');
                    
                $btn.click(function(){
                    $text
                        .val($text.val()+' ['+number+'] ')
                        .focus()
                        // oprava - webkit při focusu skočí na začátek textu
                        .attr({
                            'selectionStart': $text.val().length,
                            'selectionEnd': $text.val().length
                        });
                });
            });
            
            // Volaní záložek
            $('.tabs-box').pdTabs({callFunction: function(){init()}});
			
            // Adjust heights
            function init(){
                $('.accessories-list ul').adjustHeights({
                    elements : ['h3 .name'],
                    vAlign : 'top'
                });
                $('#home-crossroad ul').adjustHeights({
                    elements : ['h3 .name'],
                    vAlign : 'bottom'
                });
                $('.category-crossroad ul').adjustHeights({
                    elements : ['.name','.spc'],
                    vAlign : 'top'
                });
                $('.products-crossroad ul, .accessories-list ul').adjustHeights({
                    elements : ['.name', '.spc', '.review'],
                    vAlign : 'top'
                });
                $('.action-crossroad').adjustHeights({
                    elements : ['.info', '.name', '.small'],
                    vAlign : 'top'
                });
                $('.compare table').adjustHeights({
                    elements : ['h2'],
                    vAlign : 'top'
                });
                
                /* POSITIONED CORNER IE 6 RECALCULATE */
                $('.cor, .illust').css('position','absolute');
                
            }
            init();
            
            // FONT SIZE
            $(document).fontSizeListener('#main-menu', function(){init()});
			
			// PRODUCT LIST HOVER & CLICK
			$('.products-crossroad li').hover(
				function(){
					if ( !$.browser.msie || ($.browser.msie && $.browser.version>6) ) {
						$(this).addClass('hover');
					}
					$(this).css('cursor', 'pointer');
				},
				function(){
					$(this).removeClass('hover');
					$(this).css('cursor', 'default');		
				}
			).click(function(){
				window.location = $('h3 a', this).attr('href');
			});
            
            
            // JS HELP
           $('.js-help').each(function(){
            	
            	var $this = $(this),
            		text = $this.attr('title'),
            		title = this.previousSibling.nodeValue,
            		cons = {
	            		top: 12,
	            		left: 12	
            		},
            		time = null,
            		$box = $('<div class="pdTool"><div class="spc"><h4></h4><p></p><span></span></div></div>');
            	
            	$this.attr('title', '').find('img').attr('alt', '');
            	$box.css({'position':'absolute', 'z-index':'10'});
            	
            	$this.bind('mouseenter', function(e){
            		$('.pdTool').remove();
					
					time = setTimeout(function(){
            			$box.css({'opacity':'0'}).appendTo('body').find('p').text(text).end().find('h4').text(title);
            			
            			var top = e.clientY < $box.outerHeight() ? $this.offset().top + $this.height() + cons.top : $this.offset().top - $box.outerHeight() - (cons.top / 2);
						var left = $this.offset().left - (cons.left / 2);
						
						e.clientY < $box.outerHeight() ? $box.removeClass('reverse') : $box.addClass('reverse');
						
            			$box.css({'top': top, 'left': left});
            			$box.css({'opacity':''}).show();
            		}, 500);
            		
            		return false;
            	});
            	$this.bind('mouseleave', function(e){
            		time = clearTimeout(time);
            		$('.pdTool').hide().remove()
            	
            	});
            });        
			
		// AJAX ORDER Login
        $('.loginOrderForm').each(function(){
            var $this = $(this),
                $pass = $('#pwdLogin', $this),
                $name = $('#loginname', $this),
                $btn = $('.btn input', $this);
                
            $pass.add($name).keypress(function(e){
                if(e.keyCode == '13'){
                    $btn.trigger('click');
                    return false;
                }
            })
            
            $btn.click(function(e){
                  $.ajax({ 
              			type: "POST",
              			url: '/uzivatel?ajax=true&xml=true',
              			data: 'loginname='+$name.val()+'&password='+$pass.val()+'&btnLoginSubmit=Login',
              			dataType: 'xml',
              			success: function(responseXML)
              			{
    		        		//var elements = $('user',responseXML).children();
    			        	$('*', $('user',responseXML)).each(function() {
    			        		$('#order'+this.tagName).val($(this).text()).parent().removeClass('fix-int-error');					
    						}); 
    						
    						// HL? KY
    						$('.message').remove();
    						var mType = $('messages',responseXML).children()[0].tagName;
    						var mText = $('message',responseXML).text();
    						var mHead = $('messageHead',responseXML).text();
    						var message = $('<div class="message '+ mType +'-message"></div>');
    					        message.append('<div class="spc"><p></p><span class="illust" style="position: absolute;"/><span class="cor cor-l" style="position: absolute;"/><span class="cor cor-r" style="position: absolute;"/><span class="cor cor-bl" style="position: absolute;"/><span class="cor cor-br" style="position: absolute;"/></div>');
    					        message.find('p').html('<strong>'+mHead+'</strong>'+mText);
                            $this.parents('form:first').prepend(message);
                            
                            // VYPNUTNÍ AJAXU
                            if (mType=='ok'){
                                $pass.add($name).parent().removeClass('fix-int-error');
                                $this.hide();
                            }
                            else if(mType=='error'){
                                $pass.add($name).parent().addClass('fix-int-error');
                            }
                             
                            // ROZKLIKAVANI CHECKBOXŮ  
                            $('.open-box').each(function(){
                                var $this = $(this);
                                var size = 0;
                                $('.box :input', $this).each(function(){
                                    if($(this).val() != '')
                                    {
                                        size++;
                                    }
                                });
                                if(size != 0 && !$this.data('status'))
                                {
                                    $(':checkbox', this).trigger('click');
                                }   
                            });      
              			}
                  });
                  e.preventDefault();
              });

        }); 
        
        
        // Našeptávač
        $('#search-box').each(function(){
        	var $box = $(this);
        	var $inp = $('.int-text', $box);
        		$inp.attr('autocomplete', 'off');
        	var data = $inp.attr('name')+'=';
        	var time = null;
        	var blur = true;
        	var suggest = {
        		el: '.suggest-box',
        		item: 'li',
        		hClass : 'active'
        	};

        	var ajax = function(){
        		var aData = $inp.attr('name')+'='+$inp.val();
        		if(data != aData && $inp.val().length > 1 )
        		{
        			data = aData;
        			$inp.css('background', '');
	        		$.ajax({
						type: "GET",
						url: '/ajax/suggest',
						data: $inp.attr('name')+'='+$inp.val(),
						success: function(xml){
							$inp.css('background', '');
							$(suggest.el).hide().remove();
		        			$box.append(xml);
		        			
		        			$(suggest.el).find(suggest.item).mouseover(function(){
				        		$(suggest.el).find(suggest.item+'.'+suggest.hClass).removeClass(suggest.hClass);
				        		$(this).addClass(suggest.hClass);
				        		blur = false;
				        	}).mouseout(function(){blur = true;})
				        	
				        	$(suggest.el).find('.more').mouseover(function(){blur = false;}).mouseout(function(){blur = true;})
		    			}
		    		});	
		    	}
		    	else if($inp.val().length <= 1)
		    	{
		    		$(suggest.el).hide().remove();	
		    	}
		    	else
		    	{
		    		
		    	}
        	}
        	$inp
        		.bind('keydown keyup', function(e){
	        		if(e.keyCode == 40 && e.type == 'keydown')
	        		{
	        			if($(suggest.el).find(suggest.item+'.'+suggest.hClass).size() == 0 || $(suggest.el).find(suggest.item+'.'+suggest.hClass).is(':last-child'))
	        			{
	        				$(suggest.el).find(suggest.item+'.'+suggest.hClass).removeClass(suggest.hClass);
	        				$(suggest.el).find(suggest.item+':first-child').addClass(suggest.hClass);	
	        			}
	        			else
	        			{
	        				$(suggest.el).find(suggest.item+'.'+suggest.hClass).removeClass(suggest.hClass).next().addClass(suggest.hClass);			
	        			}
	        			return false;
	        		}
	        		
	        		else if(e.keyCode == 38 && e.type == 'keydown')
	        		{
		        		if($(suggest.el).find(suggest.item+'.'+suggest.hClass).size() == 0 || $(suggest.el).find(suggest.item+'.'+suggest.hClass).is(':first-child'))
		        		{
		        			$(suggest.el).find(suggest.item+'.'+suggest.hClass).removeClass(suggest.hClass);
		        			$(suggest.el).find(suggest.item+':last-child').addClass(suggest.hClass);
		        		}
		        		else
		        		{
		        			$(suggest.el).find(suggest.item+'.'+suggest.hClass).removeClass(suggest.hClass).prev().addClass(suggest.hClass);	
		        		}
		        	}
		        	else if(e.keyCode == 13)
		        	{
		        		if($(suggest.el).find(suggest.item+'.'+suggest.hClass).size())
		        		{
		        			window.location = $(suggest.el).find(suggest.item+'.'+suggest.hClass+' a:first').attr('href');
		        			e.preventDefault();
		        			return false;
		        		}
	        		}
	        		else if(e.keyCode == 9)
		        	{
		        		blur = true;			
		        	}
	        	})
        		.bind('focus', function(){
        			time = setInterval(ajax, 750);	
        		})
        		.bind('blur', function(){
        			if(blur)
        			{
		        		$(suggest.el).hide().remove();
		        		time = clearInterval(time);	
		        	}
        		});
        });
        
        
        
         // JS HELP
       $('.availabilityOK').each(function(){
        	
        	var $this = $(this),
        		text = $this.next().html(),
        		cons = {
            		top: 8,
            		left: 12	
        		},
        		time = null,
        		$box = $('<div class="pdTool pdAvailability"><div class="spc"></div></div>');
        	
        	
        	$box.css({'position':'absolute', 'z-index':'10'});
        	$box.css({'opacity':'0'}).appendTo('body').find('.spc').html(text);
        	
        	$this.bind('mouseenter', function(e){
        		$box.css({'opacity':'0'});
				
				time = setTimeout(function(){
				    
				    var scrollTop = $('body').scrollTop() || $('html').scrollTop();
				    var screenHeight = $(window).height();
				    var boxHeight = $box.height();
				    
				    var top1 = $this.offset().top + $this.height() + (cons.top / 2);
				    var top2 = $this.offset().top - boxHeight - (cons.top / 2);
				    var viewRelHeight = $this.offset().top - scrollTop + $this.height() + (cons.top / 2) + boxHeight;
        			
        			var top = viewRelHeight < screenHeight ? top1 : top2;
					var left = $this.offset().left; //+ ($this.width() / 2) - (   cons.left/2);
					
					//e.clientY < $box.outerHeight() ? $box.removeClass('reverse') : $box.addClass('reverse');
					
        			$box.css({'top': top, 'left': left});
        			$box.css({'opacity':''}).show();
        		}, 500);
        		
        		return false;
        	});
        	$this.bind('mouseleave', function(e){
        		time = clearTimeout(time);
        		$('.pdTool').hide();
        	
        	});
        });  
        
        
        
});
