var wn,CMN=function(){var cmn,tO=function(v,type){var t=typeof v;if(t==="object"){if(!v){t="null";}else{if(typeof v.length==="number"&&(v.propertyIsEnumerable&&!v.propertyIsEnumerable("length"))&&typeof v.splice==="function"){t="array";}}}
return type?t===type:t;},pI=function(n){return parseInt(n,10);},getParams=function(j,d){var o={},dl=d.length,pr,roots=window.document.getElementsByTagName("html");d[-1]=["lang",roots[0].getAttribute("lang")||"cs"];for(var i=-1;i<dl;i++){pr=d[i][0];o[pr]=tO(j[pr],"undefined")?d[i][1]:j[pr];}
o.toString=function(){var pr,p="";for(pr in this){if(this.hasOwnProperty(pr)&&this[pr]!==arguments.callee){p+=(pr+": "+(tO(this[pr],"function")?"function...":this[pr])+"\n");}}
return p;};return o;},module=function(o,d,f){return function(j){var par=getParams((j||{}),d),M=function(){},m;M.prototype=o;M.prototype.getParams=function(){return par;};M.prototype.getParam=function(p){return par[p];};M.prototype.setParam=function(p,v){for(var prop in par){if(prop===p){par[prop]=v;return true;}}
return false;};M.prototype.name="module";M.prototype.toString=function(){return"CMN "+this.name+"\n\nParameters:\n"+this.getParams();};M.prototype.constructor=M;m=new M();if(tO(f,"function")){f.apply(m);}
return m;};},rm=[],gex=function(d){if(!d){return d;}
return function(s){var all=d.getElementsByTagName("*"),l=all.length,i,e;for(i=0;i<l;i++){e=all[i];if(e.hasAttribute("id")){if(e.getAttribute("id")===s){return e;}}}};},ge=function(s,doc){var g=gex(doc)||function(s){return window.document.getElementById(s);},el=tO(s,"string")?g(s)?g(s):null:s,rml=rm.length,c=el?tO(el.cmn,"undefined")?{}:el.cmn:{},i;if(!el){return el;}
if(c!==CMN){for(i=0;i<rml;i++){el[rm[i][0]]=rm[i][1];}
el.fE=el.firstEl=cmn.firstEl;el.lE=el.lastEl=cmn.lastEl;el.nE=el.nextEl=cmn.nextEl;el.pE=el.prevEl=cmn.prevEl;el.hC=el.hasClass=cmn.hasClass;el.aC=el.addClass=cmn.addClass;el.rC=el.removeClass=cmn.removeClass;el.aL=el.addListener=function(evtype,fc,capt){return cmn.addListener(this,evtype,fc,capt);};el.rL=el.removeListener=function(evtype,fc,capt){return cmn.removeListener(this,evtype,fc,capt);};el.cE=el.createEl=function(){var o=cmn.createEl.apply(null,arguments);if(tO(o,"array")){return o.append(this);}else{return this.appendChild(o);}};el.getElementsByTagNames=cmn.getElementsByTagNames;el.getElementsByClassName=function(cl,tg){return cmn.getElementsByClassName(this,cl,tg);};el.cmn=cmn;}
return el;},gc=function(a){if(!a){return a;}
var rml=rm.length,i,c=tO(a.cmn,"undefined")?{}:a.cmn,l=a.length;if(c!==CMN){for(i=0;i<rml;i++){a[rm[i][0]]=rm[i][1];}
a.aC=a.addClass=function(){var ag=[].splice.call(arguments,null),i;for(i=0;i<l;i++){cmn.addClass(a[i],ag);}
return a;};a.rC=a.removeClass=function(){var ag=[].splice.call(arguments,null),i;for(i=0;i<l;i++){cmn.removeClass(a[i],ag);}
return a;};a.aL=a.addListener=function(evtype,fc,capt){var i;for(i=0;i<l;i++){cmn.addListener(a[i],evtype,fc,capt);}
return a;};a.rL=a.removeListener=function(evtype,fc,capt){var i;for(i=0;i<l;i++){cmn.removeListener(a[i],evtype,fc,capt);}
return a;};a.execute=function(fc){var i;for(i=0;i<l;i++){fc.apply(a[i]);}
return a;};a.append=function(el){el=ge(el);var i;for(i=0;i<l;i++){el.appendChild(a[i]);}
return a;};a.cmn=cmn;}
return a;},regElM=function(fn,f){var sf=function(x){if(tO(x,"array")){var a=tO(x.cmn,"undefined")?{}:x.cmn,i,l;if(a!==CMN){x=gc(x);}
if(f){l=x.length;for(i=0;i<l;i++){f(x[i]);}}}else{x=ge(x);if(f){f(x);}}
return x;},nf=function(){var o=null,l=arguments.length,i,ao=[],c,e;if(l>1){for(i=0;i<l;i++){e=arguments[i];if(tO(e,"array")){ao.concat(sf(e));}else{ao.push(sf(e));}}
c=tO(ao.cmn,"undefined")?{}:ao.cmn;o=c===CMN?ao:gc(ao);}else if(l===1){o=sf(arguments[0]);}
return o;};if(f){cmn[fn]=nf;rm.push([fn,function(){return sf(this);}]);}else{return nf;}},dombuilt=false,onbuilt=[],built=function(){if(dombuilt){return;}
var i,l=onbuilt.length;for(i=0;i<l;i++){onbuilt[i]();}
dombuilt=true;},lsts=[];cmn={tO:tO,isMail:function(s){s=s||((this!==CMN)?this:false)||"";return(/^[_a-zA-Z0-9\.\-]+@[_a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$/).test(s);},trim:function(s){s=s||((this!==CMN)?this:false)||"";return s.replace(/^\s+|\s+$/g,"");},number_format:function(n,e,d,t){n=n||((this!==CMN)?this:false)||0;t=t||",";d=d||".";var c=isNaN(e)?2:e,sg=n<0?"-":"",i,j;n=Math.abs(+n||0).toFixed(c);i=pI(n)+"";j=i.length>3?i.length%3:0;return sg+(j?i.substr(0,j)+t:"")+i.substr(j).replace(/(\d{3})(?=\d)/g,"$1"+t)+(c?d+Math.abs(n-i).toFixed(c).slice(2):"");},extendTypes:function(){String.prototype.trim=this.trim;String.prototype.isMail=this.isMail;Number.prototype.number_format=this.number_format;},createEl:function(i){var ce=function(j){var par=getParams(j,[["tag","div"],["id",""],["className",""],["text",""],["style",null],["attrs",null],["doc",window.document]]),e=par.doc.createElement(par.tag);if(par.id!==""){e.id=par.id;}
if(par.className!==""){e.className=par.className;}
if(par.text!==""){e.appendChild(par.doc.createTextNode(par.text));}
if(par.style){for(var styleProp in par.style){if(par.style.hasOwnProperty(styleProp)&&!tO(par.style[styleProp],"function")){e.style[styleProp]=par.style[styleProp];}}}
if(par.attrs){for(var attrName in par.attrs){if(par.attrs.hasOwnProperty(attrName)&&!tO(par.attrs[attrName],"function")){e.setAttribute(attrName,par.attrs[attrName]);}}}
return e;},o=[],al=arguments.length,x,y,p,pl;for(x=0;x<al;x++){p=arguments[x];if(tO(p,"array")){pl=p.length;for(y=0;y<pl;y++){o.push(ce(p[y]));}}else{o.push(ce(p));}}
if(o.length===1){return ge(o[0]);}else if(o.length>1){return gc(o);}else{return null;}},browser:{isIE:!!(window.attachEvent&&!window.opera),isOpera:!!window.opera,isGecko:!!window.document.getAnonymousElementByAttribute,isWebKit:navigator.userAgent.indexOf("KHTML")>-1,toString:function(){var s="";for(var p in navigator){if(tO(navigator[p],"string")||tO(navigator[p],"number")){s+=(p+": "+navigator[p]+"\n");}}
return s;}},getViewportWidth:function(){if(window.innerWidth){return pI(window.innerWidth);}else{if(window.document.documentElement&&window.document.documentElement.clientWidth){return pI(document.documentElement.clientWidth);}else{if(window.document.body&&window.document.body.clientWidth){return pI(window.document.body.clientWidth);}}}},getViewportHeight:function(){if(window.innerHeight){return pI(window.innerHeight);}else{if(window.document.documentElement&&window.document.documentElement.clientHeight){return pI(window.document.documentElement.clientHeight);}else{if(window.document.body&&window.document.body.clientHeight){return pI(window.document.body.clientHeight);}}}},getCollection:function(){var o=null,l=arguments.length,i,ao=[],c,e;for(i=0;i<l;i++){e=arguments[i];if(tO(e,"array")){ao.concat(e);}else{ao.push(e);}}
c=tO(ao.cmn,"undefined")?{}:ao.cmn;o=c===CMN?ao:gc(ao);return o;},addClass:function(){var a0=arguments[0],c=this===CMN,el=c?tO(a0,"string")?window.document.getElementById(a0):a0:this,st=c?1:0,al=arguments.length,i,e,j,jl,n,ac=function(el,cl){var re=new RegExp("\\b"+cl+"\\b");if(!re.test(el.className)){el.className=(el.className?el.className:"")+" "+cl;}};for(i=st;i<al;i++){e=arguments[i];if(tO(e,"array")){jl=e.length;for(j=0;j<jl;j++){n=e[j];if(tO(n,"array")){CMN.addClass(el,n);}else{ac(el,n);}}}else{ac(el,e);}}
return ge(el);},removeClass:function(){var a0=arguments[0],c=this===CMN,el=c?tO(a0,"string")?window.document.getElementById(a0):a0:this,st=c?1:0,al=arguments.length,i,e,j,jl,n,rc=function(el,cl){var re=new RegExp("\\s*"+cl+"\\s*","g");el.className=el.className.replace(re,"");};for(i=st;i<al;i++){e=arguments[i];if(tO(e,"array")){jl=e.length;for(j=0;j<jl;j++){n=e[j];if(tO(n,"array")){CMN.removeClass(el,n);}else{rc(el,n);}}}else{rc(el,e);}}
return ge(el);},hasClass:function(){var a0=arguments[0],c=this===CMN,el=c?tO(a0,"string")?window.document.getElementById(a0):a0:this,s=[],st=c?1:0,al=arguments.length,re,e,i;for(i=st;i<al;i++){e=arguments[i];if(tO(e,"array")){s.concat(e);}else if(tO(e,"string")){s.push(e);}}
re=new RegExp("\\b("+s.join("|")+")\\b");return re.test(el.className);},getElementsByTagNames:function(){var a0=arguments[0],c=this===CMN,el=c?tO(a0,"string")?window.document.getElementById(a0):a0:this,st=c?1:0,o=[],al=arguments.length,e,i,j,jl,con=function(a,ae){var i,l=a.length,e=ae.length+l;for(i=l;i<e;i++){a[i]=ae[i-l];}
return a;};for(i=st;i<al;i++){e=arguments[i];if(tO(e,"array")){jl=e.length;for(j=0;j<jl;j++){o=con(o,el.getElementsByTagName(e[j]));}}else if(tO(e,"string")){o=con(o,el.getElementsByTagName(e));}}
return gc(o);},getElementsByClassName:function(el,cl,tg){var a,al,o=[],re,i;tg=tg||"*";el=tO(el,"string")?window.document.getElementById(el):el;a=CMN.getElementsByTagNames(el,tg);cl=tO(cl,"array")?cl.join("|"):tO(cl,"string")?cl:"";re=new RegExp("\\b("+cl+")\\b");al=a.length;for(i=0;i<al;i++){if(re.test(a[i].className)){o.push(a[i]);}}
return gc(o);},firstEl:function(el){el=el||this;if(tO(el,"string")){el=window.document.getElementById(el);}
if(el.firstChild){el=el.firstChild;if(el.nodeType===1){return ge(el);}
return CMN.nextEl(el);}
return null;},lastEl:function(el){el=el||this;if(tO(el,"string")){el=window.document.getElementById(el);}
if(el.lastChild){el=el.lastChild;if(el.nodeType===1){return ge(el);}
return CMN.prevEl(el);}
return null;},nextEl:function(el){el=el||this;if(tO(el,"string")){el=window.document.getElementById(el);}
while(el.nextSibling){el=el.nextSibling;if(el.nodeType===1){return ge(el);}}
return null;},prevEl:function(el){el=el||this;if(tO(el,"string")){el=window.document.getElementById(el);}
while(el.previousSibling){el=el.previousSibling;if(el.nodeType==1){return ge(el);}}
return null;},getPosX:function(el){el=tO(el,"string")?window.document.getElementById(el):el;var curleft=0;if(el.offsetParent){while(el.offsetParent){curleft+=el.offsetLeft;el=el.offsetParent;}}else if(el.x){curleft+=el.x;}
return pI(curleft);},getPosY:function(el){el=tO(el,"string")?window.document.getElementById(el):el;var curtop=0;if(el.offsetParent){while(el.offsetParent){curtop+=el.offsetTop;el=el.offsetParent;}}else if(el.y){curtop+=el.y;}
return pI(curtop);},getStyle:function(el,prop){el=tO(el,"string")?window.document.getElementById(el):el;var cs;if(window.document.defaultView&&window.document.defaultView.getComputedStyle){cs=el.ownerDocument.defaultView.getComputedStyle(el,"");if(!cs){return cs;}
return cs[prop];}
return el.currentStyle[prop];},getElementHeight:function(el){el=tO(el,"string")?window.document.getElementById(el):el;return pI(this.browser.isIE?el.offsetHeight:this.getStyle(el,"height"));},getElementWidth:function(el){el=tO(el,"string")?window.document.getElementById(el):el;return pI(this.browser.isIE?el.offsetWidth:this.getStyle(el,"width"));},addListener:function(el,evtype,fc,capt){var src,r,f;el=tO(el,"string")?window.document.getElementById(el):el;if(el===window&&evtype==="domready"){if(dombuilt){fc();return true;}
onbuilt.push(fc);if(CMN.browser.isIE&&document.readyState){if(!window.document.getElementById("ie_ready")){src=window.location.protocol==="https:"?"://0":((" java").substring(1)+"script:void(0)");window.document.write('<scr'+'ipt id="ie_ready" defer src="'+src+'"><\/script>');window.document.getElementById("ie_ready").onreadystatechange=function(){if(this.readyState==="complete"){built();}};}}else{if(CMN.browser.isGecko){window.document.addEventListener("DOMContentLoaded",built,false);}else{window.addEventListener("load",built,false);}}
return true;}else{if(el.addEventListener){el.addEventListener(evtype,fc,capt);}else if(el.attachEvent){f=function(){fc.apply(el,arguments);};r=el.attachEvent("on"+evtype,f,capt);if(r){lsts.push([fc,f]);}}
return ge(el);}},removeListener:function(el,evtype,fc,capt){var i,l=onbuilt.length,o=false,ll=lsts.length;el=tO(el,"string")?window.document.getElementById(el):el;if(el===window&&evtype==="domready"){for(i=0;i<l;i++){if(onbuilt[i]===fc){onbuilt.splice(i,1);o=true;}}
return o;}else{if(el.removeEventListener){el.removeEventListener(evtype,fc,capt);}else if(el.detachEvent){for(i=0;i<ll;i++){if(lsts[i][0]===fc){el.detachEvent("on"+evtype,lsts[i][1],capt);}}}
return ge(el);}},getEvent:function(e){e=e||window.event;if(tO(e.target,"undefined")){e.target=e.srcElement;}
if(tO(e.layerX,"undefined")){e.layerX=e.layerX=e.offsetX;}
if(tO(e.layerY,"undefined")){e.layerY=e.layerY=e.offsetY;}
if(tO(e.which,"undefined")){e.which=e.which=e.keyCode;}
if(tO(e.preventDefault,"undefined")){e.preventDefault=function(){e.returnValue=false;};}
return e;},createModule:function(n,d,f){cmn[n]=module({name:n},d,f);},xhr:function(j){var getRequest=function(){var req=null,MSXMLProgID=["Microsoft.XMLHTTP","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP"];try{req=new XMLHttpRequest();}catch(xX){for(var i=0;i<MSXMLProgID.length;i++){try{req=new window.ActiveXObject(MSXMLProgID[i]);break;}catch(xA){}}}finally{return req;}},req=getRequest();if(!req){throw{name:"FatalError",message:"Cannot initialize XHR object :("};}
var o=module({name:"xhr",response:{xml:null,text:"",json:null,status:0,json_error:null},onresponse:function(){}},[["url",""],["method","GET"],["params",""],["async",true],["timestamp",false],["onresponse",false]])(j),p=o.getParams(),setResult=function(){o.response.status=req.status;if(req.status===200){o.response.xml=req.responseXML;o.response.text=req.responseText;try{o.response.json=window.JSON?window.JSON.parse(req.responseText):eval("("+req.responseText+")");}catch(xJ){o.response.json_error=xJ;}}};if(tO(p.onresponse,"function")){o.onresponse=p.onresponse;}
if(p.async){req.onreadystatechange=function(){if(req.readyState==4){setResult();o.onresponse();}};}
o.send=function(){if(p.timestamp){p.params+=("&cmn_xhr_timestamp="+new Date().getTime());}
if(p.method.toUpperCase()==="POST"){req.open("POST",p.url,p.async);req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");if(req.overrideMimeType){req.setRequestHeader("Connection","close");}
req.send(p.params);}else{req.open("GET",p.url+"?"+p.params,p.async);req.send(null);}
if(!p.async){setResult();}};return o;},ani:function(j){var timer,ts,k,d=[["start",0],["end",0],["method",function(){}],["timestep",100],["duration",1000],["course","linear"]],o={name:"ani",x:0,y:0,running:false},onstart=[],onend=[],m=module(o,d)(j),p=m.getParams(),sgn=(p.end-p.start)<0,pas=function(){var end=sgn?p.start:p.end,r;m.x=new Date().getTime()-ts.getTime();switch(p.course){case"square":r=Math.ceil(Math.pow(m.x*k,2));break;case"cubature":r=Math.ceil(Math.pow(m.x*k,3));break;case"root":r=Math.ceil(Math.sqrt(m.x*k));break;case"linear":r=Math.ceil(m.x*k);break;}
m.y=p.start+Math.pow(-1,sgn)*r;

if(m.y>=end||m.x>p.duration){
  m.y=sgn?p.end:end;
  m.stop();
  p.method.apply(m);
  for(var i=0;i<onend.length;i++){
    if(tO(onend[i],"function")){
      onend[i].apply(m);
    }
  }
}else{p.method.apply(m);

  


}};m.onstart=function(f,a){if(tO(a,"undefined")||a){onstart.push(f);}else{for(var i=0;i<onstart.length;i++){if(onstart[i].toString()==f.toString()){onstart.splice(i,1);}}}};m.setParam=function(par,v){if(this.constructor.prototype.setParam(par,v)){sgn=(p.end-p.start)<0;}};m.onend=function(f,a){if(tO(a,"undefined")||a){onend.push(f);}else{for(var i=0;i<onend.length;i++){if(onend[i].toString()==f.toString()){onend.splice(i,1);}}}};m.run=function(){this.running=true;this.y=p.start;var sl=onstart.length,he=Math.pow(-1,sgn)*(p.end-p.start);switch(p.course){case"square":k=Math.sqrt(he)/p.duration;break;case"cubature":k=Math.pow(he,1/3)/p.duration;break;case"root":k=Math.pow(he,2)/p.duration;break;case"linear":k=he/p.duration;break;}
for(var i=0;i<sl;i++){if(tO(onstart[i],"function")){onstart[i].apply(this);}}
ts=new Date();timer=window.setInterval(pas,p.timestep);};m.stop=function(){this.running=false;window.clearInterval(timer);};m.reverse=function(){var start=this.getParam("start");this.setParam("start",this.getParam("end"));this.setParam("end",start);};return m;}};cmn.gE=cmn.getEl=ge;cmn.gC=cmn.getCollection;cmn.cE=cmn.createEl;cmn.fE=cmn.firstEl;cmn.lE=cmn.lastEl;cmn.nE=cmn.nextEl;cmn.pE=cmn.prevEl;cmn.gX=cmn.getPosX;cmn.gY=cmn.getPosY;cmn.gH=cmn.getElementHeight;cmn.gW=cmn.getElementWidth;cmn.aC=cmn.addClass;cmn.rC=cmn.removeClass;cmn.hC=cmn.hasClass;cmn.aL=cmn.addListener;cmn.rL=cmn.removeListener;regElM("setDN",function(el){el.style.display="none";});regElM("setDB",function(el){el.style.display=el.tagName.toLowerCase()==="tr"?"table-row":"block";});regElM("setDI",function(el){el.style.display="inline";});regElM("setVV",function(el){el.style.visibility="visible";});regElM("setVH",function(el){el.style.visibility="hidden";});regElM("swapDisplay",function(el){el.style.display=el.style.display==="none"?(el.tagName.toLowerCase()==="tr"?"table-row":"block"):"none";});regElM("swapVisibility",function(el){el.style.visibility=el.style.visibility==="hidden"?"visible":"hidden";});cmn.cC=cmn.createCollection=regElM();return cmn;}(),FRONT;



var showPic=function(el,filename,w,h){
  var pw=CMN.gE("picwin");
  pw.style.width=w+"px";
  pw.style.height=h+"px";
  pw.style.left="-100px";
  pw.style.top=CMN.getPosY(el)-CMN.getPosY("database")-35+"px";
  pw.innerHTML='<img src="/images/object/thumbnail/'+filename+'" width="'+w+'" height="'+h+'" />';
  pw.setDB();
  
};

var hidePic=function(){
  CMN.setDN("picwin");
};


CMN.createModule("ulightbox",[["container",null],["className",""],["animation",true]],function(){
  var self=this,p=this.getParams(),el=CMN.gE(p.container),thumbs=p.className===""?el.getElementsByTagNames("a"):el.getElementsByClassName(p.className,"a"),tl=thumbs.length,ind=0,doc=window.document.documentElement,doyle=window.document.getElementsByTagName("body"),bodie=doyle[0],darkness=bodie.appendChild(CMN.cE({className:"darkness"})),box=bodie.appendChild(CMN.cE({className:"ulb"})),img=box.appendChild(CMN.cE({tag:"img",attrs:{src:"images/ulightbox/empty.gif",alt:""}})),setOp=function(el,op){
    if(CMN.browser.isIE){
      el.style.filter="alpha(opacity="+op+")";
    }else{
      el.style.opacity=darkness.style["-moz-opacity"]=op/100;
    }
  },ani=function(j){
    return CMN.ani({timestep:2,duration:200,method:j.method,end:j.end,start:j.start || 0});
  },closebut=box.appendChild(CMN.cE({tag:"span",className:"ulbclose",text:this.getParam("lang")==="cs"?"":""})),nextbut=box.appendChild(CMN.cE({tag:"span",className:"ulbnext",text:this.getParam("lang")==="cs"?"":""})),prevbut=box.appendChild(CMN.cE({tag:"span",className:"ulbprev",text:this.getParam("lang")==="cs"?"":""})),counter=box.appendChild(CMN.cE({tag:"span",className:"ulbcount",text:" "})),count=function(){
    var pref=function(n){
      if(n>1 && n<5 || n===7 || n>99){return " ze ";}
      return " z ";
    };
    if(self.getParam("lang")==="cs"){
      counter.firstChild.data="Obrázek "+(ind+1)+pref(tl)+tl;
    }else{
      counter.firstChild.data="Picture "+(ind+1)+" of "+tl;    
    }
  },showControls=function(){
    CMN.setVV(closebut);
    if(tl>1){
      CMN.setVV(counter);
      if(ind>0){
        CMN.setVV(prevbut);
      }else{
        CMN.setVH(prevbut);      
      }
      
      if(ind<(tl-1)){
        CMN.setVV(nextbut);
      }else{
        CMN.setVH(nextbut);
      }
    }
    
  },hideControls=function(){
    CMN.setVH(closebut,nextbut,prevbut,counter);    
  },center=function(){
    var bh=CMN.getElementHeight(bodie),bw=CMN.getElementWidth(bodie),ww=CMN.getViewportWidth(),wh=CMN.getViewportHeight(),w=CMN.getElementWidth(box),h=CMN.getElementHeight(box),s=CMN.browser.isWebKit?bodie.scrollTop:doc.scrollTop;
    if(ww>w){
      box.style.marginLeft=-Math.round(w/2)+(CMN.browser.isIE?20:0)+"px";
      box.style.left="50%";
    }else{
      box.style.left=0;
      box.style.marginLeft=0;
      if(ww>bw){
        darkness.style.width=w+40+"px";
      }
    }
    if(wh>h){
      box.style.top=s+Math.round((wh-h)/2)+(CMN.browser.isIE?28:0)+"px";
      box.style.marginTop="0";
    }else{
      if(wh>bh){
        darkness.style.height=h+55+"px";
      }else if(h>wh){
        box.style.top=Math.round(bh/2)+"px";
        box.style.marginTop=-Math.round(h/2)+(CMN.browser.isIE?28:0)+"px";
      }
    }
  },stretch=function(){
  	var wh=CMN.getViewportHeight(),ww=CMN.getViewportWidth(),bh=CMN.getElementHeight(bodie),bw=CMN.getElementWidth(bodie);
    darkness.style.height=(wh>bh?wh:bh)+"px";
    darkness.style.width="100%";
    center();
  },resize=function(w,h,m){
    var a=[],bh=CMN.getElementHeight(bodie),sw=CMN.getElementWidth(box),sh=CMN.getElementHeight(box),r=w/h,wh=CMN.getViewportHeight(),s=CMN.browser.isWebKit?bodie.scrollTop:doc.scrollTop;
    if(p.animation){
      if(w>sw){
        a[0]=ani({start:sw,end:w,method:function(){
          box.style.width=this.y+"px";
          box.style.marginLeft=-Math.round(this.y/2)+"px";
        }});
      }else{
        a[0]=ani({start:0,end:sw-w,method:function(){
          box.style.width=sw-this.y+"px";
          box.style.marginLeft=-Math.round((sw-this.y)/2)+"px";
        }});
      }
      
      if(h>sh){
        a[1]=ani({start:sh,end:h,method:function(){
          box.style.height=this.y+"px";
          if(this.y>wh){
            box.style.top=Math.round(bh/2)+"px";
            box.style.marginTop=-Math.round(this.y/2)+"px";
          }else{
            box.style.top=s+(wh>this.y?Math.round((wh-this.y)/2):0)+"px";
            box.style.marginTop="0";	  
          }
        }});
      }else{
        a[1]=ani({start:0,end:sh-h,method:function(){
          var he=sh-this.y;
          box.style.height=he+"px";
          box.style.marginTop="0";	  
          box.style.top=s+((wh>he)?Math.round((wh-he)/2):0)+"px";
        }});
      }
      
      
      a[1].onend(function(){a[2].run();});
      a[0].onend(function(){a[1].run();});      
      a[2]=ani({end:100,method:function(){setOp(img,this.y);}});
      a[2].onstart(function(){
      img.style.left="0";
      });
      a[2].onend(function(){stretch();showControls();});
      a[(w===(sw-(CMN.browser.isIE?40:0)) && h===(sh-(CMN.browser.isIE?55:0)))?2:0].run();
    }else{
      box.style.width=w+"px";
      box.style.height=h+"px";
      stretch();
      setOp(img,100);
      img.style.left="0";
      showControls();
    }
  },onkey,day=function(){
  	var a=[];
    if(p.animation){
      a[0]=ani({end:100,method:function(){setOp(box,100-this.y);}});
      a[1]=ani({start:10,end:100,method:function(){setOp(darkness,100-this.y);}});
      a[1].onend(function(){CMN.setVH(darkness,box);setOp(img,0);img.style.left="-10000px";});
      a[0].onend(function(){a[1].run();});      
      a[0].run();
    }else{
      CMN.setVH(darkness,box);
    }
    CMN.rL(doc,"keydown",onkey);
    img.rL("load",function(){

     resize(this.width,this.height);
      

    });
    hideControls();
  },show=function(){
  	count();  
    img.src=thumbs[ind].href;
   
  },shift=function(i){
  	hideControls();
    setOp(img,0);
    img.style.left="-10000px";
    ind=ind+i;
    if(ind===0){prevbut.setVH();}else{prevbut.setVV();}
    if(ind===tl-1){nextbut.setVH();}else{nextbut.setVV();}
    show();
  },prev=function(){
    shift(-1);
  },next=function(){
    shift(1);
  },night=function(){
    var a=[];
    if(p.animation){
      CMN.setVV(darkness,box);
      a[0]=ani({end:90,method:function(){setOp(darkness,this.y);}});
      a[1]=ani({end:100,method:function(){setOp(box,this.y);}});
      a[1].onend(show);
      a[0].onend(function(){a[1].run();});      
      a[0].run();
    }else{
      setOp(darkness,90);
      setOp(box,100);
      CMN.setVV(darkness,box);
      show();
    }
    CMN.aL(doc,"keydown",onkey);
    img.aL("load",function(){
resize(this.width,this.height);
      

    });
  };
  
  onkey=function(e){
    e=CMN.getEvent(e);
    if(e.which===27){day();}
    if(e.which===37 && ind>0){prev();}
    if(e.which===39 && ind<tl-1){next();}
  };
  stretch();
  CMN.aL(window,"resize",stretch);
  CMN.aL(window,"scroll",center);
  thumbs.aL("click",function(e){
    var self=this,myIndex=function(){
      var i;
      for(i=0;i<tl;i++){
        if(thumbs[i]===self){
          if(i===0){
          //prevbut.setVH();
          }else{
       //   prevbut.setVV();
          }
          if(i===tl-1){
          // nextbut.setVH();
          }else{
        //  nextbut.setVV();
          }
          return i;
        }
      }
    };
    e=CMN.getEvent(e);
    ind=myIndex();
    night();
    e.preventDefault();
  });
  closebut.aL("click",day);
  prevbut.aL("click",prev);
  nextbut.aL("click",next);
});


FRONT={
  
  FormValidator:function(el){
    var lang=document.lang,RE=[],i,errClass="error",inps=[],labels=[];
    RE.mail=/^[_a-zA-Z0-9\.\-]+@[_a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,4}$/;
    RE.iso_date=/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/;
    RE.czech_date=/^([0-9]{1,2}\.\s*){2}\s*[0-9]{4}$/;
    RE.phone=/^(\+420)?(\s*\d\s*){9}$/;
    RE.int=/^[0-9]+$/;
    RE.nint=/^-?[0-9]+$/;
    RE.zip=/^[1-7][0-9]{2}\s*[0-9]{2}$/;
    el=CMN.gE(el);
    var labelEls=el.getElementsByTagNames("label");
    for(i=0;i<labelEls.length;i++){
      if(labelEls[i].htmlFor && labelEls[i].htmlFor!==""){
        labels[labelEls[i].htmlFor]=labelEls[i].firstChild.data;
      }
    }

    el.aL("submit",function(e){
      var emptys=[],invalids=[],usermessages=[],imess="Následující položky mají chybný formát:",emess="Následující položky nebyly vyplněny:",alrt="",i,j,el,mode,modes,type,typeRE,label;
      e=CMN.getEvent(e);
      for(i=0;i<inps.length;i++){
        if(CMN.tO(inps[i][4],"undefined") || eval(inps[i][4])){
          inps[i][0]=CMN.gE(inps[i][0]);
          el=inps[i][0];
          mode=inps[i][1].toLowerCase().replace(/\ /gi,"").split("&");
          modes=[];
          for(j=0;j<mode.length;j++){
            modes[mode[j]]=true;
          }
          type=inps[i][2];
          if(CMN.tO(type,"string") && CMN.trim(type)!==""){
            typeRE=RE[type];
          }else{
            typeRE=type;
          }
          label="";
          if(!CMN.tO(inps[i][3],"undefined") && !CMN.tO(inps[i][3],"null")){
            label=inps[i][3];
          }else if(!CMN.tO(labels[el.id],"undefined")){
            label=labels[el.id];
          }
          if(modes.require){
            if(CMN.trim(el.value)===""){
              emptys.push(label);
              el.aC(errClass);
            }
          }
          if(modes.validate){
            if(CMN.trim(el.value)!=="" && !typeRE.test(el.value)){
              invalids.push(label);
              el.aC(errClass);
            }
          }
        }
      }
      if(emptys.length>0 || invalids.length>0 || usermessages.length>0){
        if(emptys.length>0){
          alrt+=emess+"\n\n";
          for(i=0;i<emptys.length;i++){
            alrt+=emptys[i]+"\n";
          }
        }

        if(invalids.length>0){
          if(emptys.length>0){
            alrt+="\n\n";
          }
          alrt+=imess+"\n\n";
          for(i=0;i<invalids.length;i++){
            alrt+=invalids[i]+"\n";
          }
        }
        window.alert(alrt);
        e.preventDefault();
      }
    });

    this.registerInput=function(){
      var mode=arguments[1].toLowerCase().replace(/\ /gi,"").split("&"),j,type,typeRE,modes=[];

      for(j=0;j<mode.length;j++){
        modes[mode[j]]=true;
      }
     
      type=arguments[2];
      if(CMN.tO(type,"string") && CMN.trim(type)!==""){

        typeRE=RE[type];
      }else{
        typeRE=type;
      }

    
      if(modes["validate"]){
        CMN.gE(arguments[0]).aL("change",function(){
          if(typeRE.test(this.value)){
            this.rC(errClass);
          }
        });
      }
    
  
    
      if(modes["require"]){
        CMN.gE(arguments[0]).aL("change",function(){
          if(CMN.trim(this.value)!==""){
            if(modes.validate){
              if(typeRE.test(this.value)){
                this.rC(errClass);
              }
            }else{
              this.rC(errClass);
            }
          }
        });
      }
      
      
      inps.push(arguments);
    };
  },
  	  
  	  
  	  
  	  initMap:function(){
  	  
  	  
  	  var fce=   function(e){
  	       
  	       if((this.offer.value!="" && this.object!="") || (this.number.value!="" && this.number.value!="Číslo nemovitosti" )){

CMN.setVV("mapwait");
CMN.setDN("rescount");

if(this.number.value!="" && this.number.value!="Číslo nemovitosti"){
  var url="/vyhledavani.html";
  var params="output=ajax&code="+CMN.gE("number").value;
}else{


  	       var url="/ajax/";
  	       var params="";
  	       if(CMN.gE("offer").value=="L"){
  	         url+="pronajem/";
  	       }else{
  	         url+="prodej/";
  	       }
  	       
  	       if(CMN.gE("offer").value!=""){
  	         CMN.gE("offer").aC("active");
  	       }else{
  	        CMN.gE("offer").rC("active");
  	       }
  	       
  	        if(CMN.gE("object").value!=0){
  	         CMN.gE("object").aC("active");
  	       }else{
  	        CMN.gE("object").rC("active");
  	       }
  	       
  	       switch(CMN.gE("object").value){
  	         case "101": url+="byty.html";break;
  	         case "102": url+="rodinne-domy.html";break;
  	         case "103": url+="nebytove-prostory.html";break;
  	         case "140": url+="pokoje.html";break;
  	         	       
  	       }
  	       
  	       if(CMN.gE("locality").value!="0"){
  	         params="locality="+CMN.gE("locality").value;
  	         CMN.gE("locality").aC("active");
  	       }else{
  	         params="locality=0";
  	         CMN.gE("locality").rC("active");
  	       }
  	       
  	       
  	       if(CMN.gE("price").value!="0"){
  	        CMN.gE("price").aC("active");
  	         params+="&price="+CMN.gE("price").value;
  	       }else{
  	         params+="&price=0";
  	         CMN.gE("price").rC("active");
  	       }
  	       
  	       
  	       
  	       
}


  	       
  	       CMN.xhr({url:url,params:params,onresponse:function(){
  	         markers=[];
  	         var o=this.response.xml;
  	         var res=o.getElementsByTagName("result");
  	         if(res.length==0){
  	         	 CMN.gE("resc").innerHTML="0";
  	            if(manager) manager.clearMarkers();
  	         
  	           CMN.setVH("mapwait");
  	           CMN.setDB("rescount");
  	           return;
  	         }
  	         CMN.gE("resc").innerHTML=res.length;
  	         for(var i=0;i<res.length;i++){
  	           var marker = new google.maps.Marker({
      position: new google.maps.LatLng(res[i].getAttribute("map_n"),res[i].getAttribute("map_e")), 
      map: map
      
  }); 
  
  
(function(m,el){
  google.maps.event.addListener(m, 'click', function(){
     
     
     
     
     var infowindow = new google.maps.InfoWindow(
      { content: '<div class="loading2"></div>'
      });

     infowindow.open(map,m);
     
     
     CMN.xhr({url:"/ajax/detail.html",params:"object_id="+el.getAttribute("object_id"),onresponse:function(){
       
       var o=this.response.xml;
       
       var objects=o.getElementsByTagName("object");
       var obj=objects[0];
       
       var desc=obj.getElementsByTagName("description");
       var names=obj.getElementsByTagName("name");
        var photos=obj.getElementsByTagName("photo");
      
      var lnk="/";
      if(obj.getAttribute("business_type")=="L"){
        lnk+="pronajem/";
      }else{
        lnk+="prodej/";
      }
     
      switch(obj.getAttribute("object_type_id")){
  	         case "101": lnk+="byty/";break;
  	         case "102": lnk+="rodinne-domy/";break;
  	         case "103": lnk+="nebytove-prostory/";break;
  	         case "140": lnk+="pokoje/";break;
  	         	       
  	       }
      lnk+=obj.getAttribute("rewrite");
      	  lnk+=".html?popup=1";
      
       var content='<div class="inwin">';
         content+='<h3>'+names[0].firstChild.data+'</h3>';
         
         content+='<div class="inwc">';
         if(photos.length){
         content+='<span onclick="wn=window.open(\''+lnk+'\',\'win\',\'width=800,height=600,resizable=yes,scrollbars=yes\');setTimeout(function(){wn.focus();return false;},10)" href="'+lnk+'"><img src="/images/object/thumbnail/'+photos[0].getAttribute("filename")+'" width="'+photos[0].getAttribute("width")+'" height="'+photos[0].getAttribute("height")+'" alt="" /></span>';
         }
         content+=desc[0].firstChild.data;
         content+='</div>';
         content+='<span class="clearFix"></span>';
         content+='<p><span onclick="wn=window.open(\''+lnk+'\',\'win\',\'width=800,height=600,resizable=yes,scrollbars=yes\');setTimeout(function(){wn.focus();return false;},10)" >Otevřít detail</span></p>';	 
         	 
       content+='</div>';
       
       
       infowindow.setContent(content);
       
     }}).send();
     
     

  });
  
  
})(marker,res[i]);


  

  
  markers.push(marker);
  
  	         }
  	         
  	        
  	       if(manager) manager.clearMarkers();
  	         manager = new MarkerClusterer(map, markers);
			  
				  manager.resetViewport();
CMN.setVH("mapwait"); CMN.setDB("rescount");
  	       }}).send();
  	       
  	       if(e){
  	       e=CMN.getEvent(e);
  	       e.preventDefault();}
  	       return false;
  	     }
  	     };
  	     
  	     
  	     
  	     
  	     fce.call(CMN.gE("topform"));
  	     
  	  
  	  
  	     CMN.gE("topform").aL("submit",
  	     
  	     fce
  	     
  	     );
  	     
  	    var myOptions = {
      zoom: 12,
      center: new google.maps.LatLng(50.0833333333333333,14.4166666666666667),
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("bigmap"),     myOptions);
  
  var manager;
 


  
  	  }
  	  
  	  
  	  
  }




$(document).ready(function(){

if(CMN.gE("topform")){
 CMN.aL("topform","submit",function(e){

        e=CMN.getEvent(e);

        if((this.offer.value==="" || this.object==="") && (this.number.value==="" || this.number.value==="Číslo nemovitosti" )){

          window.alert("Zadejte, prosím, alespoň typ nabídky a objektu.");

          e.preventDefault();

        }

      });
}

function labelize(i,value){
i=CMN.gE(i);
        i.labelValue=value;
        
        i.aL("focus",function(){
          if(this.value==this.labelValue){this.value="";}
        });
        
        i.aL("blur",function(){
          if(this.value.trim()==""){this.value=this.labelValue;}
        });
}

if(CMN.gE("number"))labelize("number","Číslo nemovitosti");




var setLeftPriceOption=function(business_type,object_type){

var prsel=CMN.gE("lprice");
  prsel.options.length=1;
  
  
  eval("var filter="+CMN.gE("filter").value);
   
  if(business_type=="S"){
    prsel.options[prsel.options.length]=new Option("do 1.5 mil","1",filter.price==1,filter.price==1);
    prsel.options[prsel.options.length]=new Option("1.5 mil - 2 mil","2",filter.price==2,filter.price==2);
    prsel.options[prsel.options.length]=new Option("2 mil - 3 mil Kč","3",filter.price==3,filter.price==3);
    prsel.options[prsel.options.length]=new Option("3 mil a více","4",filter.price==4,filter.price==4);
  }else{
  
    if(object_type==140){
      prsel.options[prsel.options.length]=new Option("nerozhoduje","0");
    prsel.disabled=true;
    }else{
    prsel.disabled=false;
    }
    
    if(object_type==101 || object_type==103){
        prsel.options[prsel.options.length]=new Option("do 7 000","1",filter.price==1,filter.price==1);

            prsel.options[prsel.options.length]=new Option("7 000 - 10 000","2",filter.price==2,filter.price==2);

            prsel.options[prsel.options.length]=new Option("10 000 - 12 000","3",filter.price==3,filter.price==4);

            prsel.options[prsel.options.length]=new Option("12 000 - 15 000","4",filter.price==4,filter.price==4);

            prsel.options[prsel.options.length]=new Option("nad 15 000","5",filter.price==5,filter.price==5);
    }
  
  if(object_type==102){
      prsel.options[prsel.options.length]=new Option("do 20.000","1",filter.price==1,filter.price==1);

            prsel.options[prsel.options.length]=new Option("20.000 - 30.000","2",filter.price==2,filter.price==2);

            prsel.options[prsel.options.length]=new Option("nad 30.000","3",filter.price==3,filter.price==3);

  }
  
  }
  
  
  
  
  
};


var setLeftObjectTypeOption=function(business_type){
 var objsel=CMN.gE("lobject_type");
  objsel.options.length=1;
  
  eval("var filter="+CMN.gE("filter").value);
  
  
  if(business_type=="S"){
    objsel.options[objsel.options.length]=new Option("Byty","101",filter.object_type_id==101,filter.object_type_id==101);
    objsel.options[objsel.options.length]=new Option("Rodinné domy","102",filter.object_type_id==102,filter.object_type_id==102);
    
  }else{
  	   objsel.options[objsel.options.length]=new Option("Pokoje","140",filter.object_type_id==140,filter.object_type_id==140);
    objsel.options[objsel.options.length]=new Option("Byty","101",filter.object_type_id==101,filter.object_type_id==101);
         objsel.options[objsel.options.length]=new Option("Rodinné domy","102",filter.object_type_id==102,filter.object_type_id==102);
         objsel.options[objsel.options.length]=new Option("Nebytové prostory","103",filter.object_type_id==103,filter.object_type_id==103);
  }
  
  objsel.value=filter.object_type_id;
};



var setLeftDispositionOption=function(object_type){
  var lsel=CMN.gE("ldisp");
  lsel.options.length=1;
  
   eval("var filter="+CMN.gE("filter").value);
 
  
  
  if(object_type==140){
    lsel.options[lsel.options.length]=new Option("nerozhoduje","0");
    lsel.disabled=true;
  }else{
    lsel.disabled=false;
  }
  
  if(object_type==101 || object_type==102){
  	   if(object_type==101){
            lsel.options[lsel.options.length]=new Option("garsoniéra",211);
       }
                                      lsel.options[lsel.options.length]=new Option("1+kk",201,filter.disposition_id==201,filter.disposition_id==201);
                                      lsel.options[lsel.options.length]=new Option("1+1",202,filter.disposition_id==202,filter.disposition_id==202);
                                      lsel.options[lsel.options.length]=new Option("2+kk",203,filter.disposition_id==203,filter.disposition_id==203);
                                      lsel.options[lsel.options.length]=new Option("2+1",204,filter.disposition_id==204,filter.disposition_id==204);
                                      lsel.options[lsel.options.length]=new Option("3+kk",205,filter.disposition_id==205,filter.disposition_id==205);
                                      lsel.options[lsel.options.length]=new Option("3+1",206,filter.disposition_id==206,filter.disposition_id==206);
                                      lsel.options[lsel.options.length]=new Option("4+kk",207,filter.disposition_id==207,filter.disposition_id==207);
                                      lsel.options[lsel.options.length]=new Option("4+1",208,filter.disposition_id==208,filter.disposition_id==208);
                                      lsel.options[lsel.options.length]=new Option("5+kk a větší",209,filter.disposition_id==209,filter.disposition_id==209);
  }
  
  if(object_type==103){
 
                                

                          lsel.options[lsel.options.length]=new Option("obchod",212,filter.disposition_id==212,filter.disposition_id==212);  
                          lsel.options[lsel.options.length]=new Option("kancelář",213,filter.disposition_id==213,filter.disposition_id==213);
                          lsel.options[lsel.options.length]=new Option("garáž",214,filter.disposition_id==214,filter.disposition_id==214);
                          lsel.options[lsel.options.length]=new Option("sklad",215,filter.disposition_id==215,filter.disposition_id==215);

  }
  
  lsel.value=filter.disposition_id;
  
};


if(CMN.gE("lfrm")){
  setLeftObjectTypeOption(CMN.gE("business_type").value);
  setLeftDispositionOption(CMN.gE("lobject_type").value);
  setLeftPriceOption(CMN.gE("business_type").value,CMN.gE("lobject_type").value);

  CMN.gE("lobject_type").aL("change",function(){
    setLeftDispositionOption(CMN.gE("lobject_type").value);
    setLeftPriceOption(CMN.gE("business_type").value,CMN.gE("lobject_type").value);
  });
  
  
  CMN.gE("ldisp").aL("change",function(){
   setLeftPriceOption(CMN.gE("business_type").value,CMN.gE("lobject_type").value);

  });

  CMN.gE("lfrm").aL("submit",function(){
    var sel=this.getElementsByTagName("select");
    for(var i=0;i<sel.length;i++){
      sel[i].disabled=false;
    }
    
  });
  
 

}







var setTopObjectTypeOption=function(business_type){
  var objsel=CMN.gE("object");
  objsel.options.length=1;
  
   eval("var filter="+CMN.gE("filter").value);
 
  
  if(business_type=="S"){
    objsel.options[objsel.options.length]=new Option("Byty","101",filter.object_type_id==101,filter.object_type_id==101);
    objsel.options[objsel.options.length]=new Option("Rodinné domy","102",filter.object_type_id==102,filter.object_type_id==102);
    
  }else{
  	   objsel.options[objsel.options.length]=new Option("Pokoje","140",filter.object_type_id==140,filter.object_type_id==140);
    objsel.options[objsel.options.length]=new Option("Byty","101",filter.object_type_id==101,filter.object_type_id==101);
         objsel.options[objsel.options.length]=new Option("Rodinné domy","102",filter.object_type_id==102,filter.object_type_id==102);
         objsel.options[objsel.options.length]=new Option("Nebytové prostory","103",filter.object_type_id==103,filter.object_type_id==103);
  }
  
  objsel.value=filter.object_type_id;
  
}

var setTopPriceOption=function(business_type,object_type){
  
  var prsel=CMN.gE("price");
  prsel.options.length=1;
   
    eval("var filter="+CMN.gE("filter").value);
 
   
  if(business_type=="S"){
    prsel.options[prsel.options.length]=new Option("do 1.5 mil","1",filter.price==1,filter.price==1);
    prsel.options[prsel.options.length]=new Option("1.5 mil - 2 mil","2",filter.price==2,filter.price==2);
    prsel.options[prsel.options.length]=new Option("2 mil - 3 mil Kč","3",filter.price==3,filter.price==3);
    prsel.options[prsel.options.length]=new Option("3 mil a více","4",filter.price==4,filter.price==4);
  }else{
  
    if(object_type==140){
      prsel.options[prsel.options.length]=new Option("nerozhoduje","0");
    prsel.disabled=true;
    }else{
    prsel.disabled=false;
    }
    
    if(object_type==101 || object_type==103){
        prsel.options[prsel.options.length]=new Option("do 7 000","1",filter.price==1,filter.price==1);

            prsel.options[prsel.options.length]=new Option("7 000 - 10 000","2",filter.price==2,filter.price==2);

            prsel.options[prsel.options.length]=new Option("10 000 - 12 000","3",filter.price==3,filter.price==3);

            prsel.options[prsel.options.length]=new Option("12 000 - 15 000","4",filter.price==4,filter.price==4);

            prsel.options[prsel.options.length]=new Option("nad 15 000","5",filter.price==5,filter.price==5);
    }
  
  if(object_type==102){
      prsel.options[prsel.options.length]=new Option("do 20.000","1",filter.price==1,filter.price==1);

            prsel.options[prsel.options.length]=new Option("20.000 - 30.000","2",filter.price==2,filter.price==2);

            prsel.options[prsel.options.length]=new Option("nad 30.000","3",filter.price==3,filter.price==3);

  }
  
  }
  
  
  prsel.value=filter.price;
  
  
};


if(CMN.gE("topform")){

setTopObjectTypeOption(CMN.gE("offer").value);
setTopPriceOption(CMN.gE("offer").value,CMN.gE("object").value);

CMN.gE("offer").aL("change",function(){
  setTopObjectTypeOption(this.value);
  setTopPriceOption(this.value,CMN.gE("object").value);
});


CMN.gE("object").aL("change",function(){
  setTopPriceOption(CMN.gE("offer").value,this.value);
});


 CMN.gE("topform").aL("submit",function(){
    var sel=this.getElementsByTagName("select");
    for(var i=0;i<sel.length;i++){
      sel[i].disabled=false;
    }
    
  });

}

if(CMN.gE("ajaxbl")){
  CMN.gE("ajaxbl").aL("click",
    function(e){
    	
    	var inps=CMN.gE("database").getElementsByTagName("input");
    	var aloch=false;
    	var par="";
    	for(var i=0;i<inps.length;i++){
    	   if(inps[i].type=="checkbox"){
    	     if(inps[i].checked){
    	       aloch=true;
    	       par+=("&object_id[]="+inps[i].value);
    	     }
    	   
    	   }
    	}
    	
    	
    	if(aloch){
    	   CMN.xhr({url:"/ajax/board.html",params:"dummy"+par,onresponse:function(){
    	     var o=this.response.xml;
    	     var r=o.getElementsByTagName("result");
    	   CMN.gE("boardcount").innerHTML=r[0].getAttribute("board");  
    	     alert("Přidáno nových do schránky: "+r[0].getAttribute("new")+",celkem ve schránce: "+r[0].getAttribute("board"));
    	   
    	   }}).send();
    	   
    	   
    	}else{
    	  alert("Nevybrali jste žádnou položku");
    	}
    	
      e=CMN.getEvent(e);
      e.preventDefault();
      return false;
    }
  );
}



 if(CMN.gE("demform")){
        v=new FRONT.FormValidator("demform");
        v.registerInput("name","require",null,"Jméno");
        labelize("name","Jméno a příjmení (povinná položka)");
        
        v.registerInput("email","require&validate","mail","E-mail");
        labelize("email","Váš email (povinná položka)");
        
        v.registerInput("subject","require",null,"Předmět zprávy");
        labelize("subject","Předmět zprávy (povinná položka)");
        
        v.registerInput("message","require",null,"Obsah zprávy");
        labelize("message","Obsah zprávy (povinná položka)");
        
        labelize("phone","Telefon");
        
        m=CMN.gE("being").firstEl().firstChild.data.match(/^(\d+)[^\d]+(\d+)/);
        CMN.gE("f_being").value=parseInt(m[1],10)+parseInt(m[2],10);
        CMN.gE("being").setDN();
        
      }




//detail

  if(CMN.gE("thumbs") || CMN.gE("callbackform")){



if(CMN.gE("thumbs")){
        CMN.ulightbox({container:"photogallery",className:"lb"});

        CMN.gE("thumbs").getElementsByTagNames("a").aL("click",function(e){
          e=CMN.getEvent(e);
          CMN.getElementsByClassName("photogallery","lb").setDN();
          CMN.gE("prev"+this.id.substring(5)).setDB();
          window.focus(); window.location.href=window.location.href.replace(/#.*$/,"")+"#contentPanel";

          
         
          e.preventDefault();
        });
        
}
        
        
        
        var i=CMN.gE("callback");
        i.labelValue=i.value;
        
        i.aL("focus",function(){
          if(this.value==this.labelValue){this.value="";}
        });
        
        i.aL("blur",function(){
          if(this.value.trim()==""){this.value=this.labelValue;}
        });
        
        
        v=new FRONT.FormValidator("callbackform");
        v.registerInput("callback","require&validate","phone","Zadané telefonní číslo");
        m=CMN.gE("being").firstEl().firstChild.data.match(/^(\d+)[^\d]+(\d+)/);
        CMN.gE("f_being").value=parseInt(m[1],10)+parseInt(m[2],10);
        CMN.gE("being").setDN();
        
        
      }





























	// paging width
	var pagingWidth = 0;
	$('.paging a').each(function(i){
		pagingWidth +=( CMN.getElementWidth(this) + 14);
	});
		pagingWidth +=10;
	$('.paging').css({ width: pagingWidth + 'px' });
	
    jQuery("#slider").jcarousel({
		auto: 5,
        wrap: 'last',
		animation: 'slow',
		scroll: 1,
        initCallback: initialize,
		itemLoadCallback: change,
        // This tells jCarousel NOT to autobuild prev/next buttons
        buttonNextHTML: null,
        buttonPrevHTML: null
    });

});

function initialize(carousel) {
    jQuery('.slider-control a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });
};

function change(carousel) {
    for (var i = carousel.first; i <= carousel.last; i++) {
		$('.slider-control a').each(function(){
			if ($(this).html() == i){
				$(this).addClass('active');
			} else {
				$(this).removeClass('active');
			}
		});
    }
}
