
var g_main_site_url='http://www.rcunion.pl/';var MavSelectBox=new Class({Implements:[Options,Events],options:{allowSplit:true,altClass:'select-box-alt',alternate:false,alternateOdd:false,attachResize:true,container:null,disableClass:'disabled',elem:null,filter:null,fxOptions:{},groupClass:'select-box-options-group',maxShow:null,minShow:3,optionClass:'select-box-opt',selectboxClass:'select-box',selectClass:'selected',selectmenuClass:'select-box-options',separator:'--',showStyles:false,size:1,template:'<span>%s</span>',tmplt_regex:null,useFx:true,onHide:$empty(),onOver:$empty(),onSelect:$empty(),onShow:$empty()},isCrolling:false,container:null,element:null,focused:null,length:0,selected:null,selectedIndex:0,showing:false,textSearch:'',version:'0.5.5',initialize:function(_options){this.boundShow=this.show.bind(this);this.boundKey_option=this.key_option.bind(this);this.boundHide=this.hide.bind(this);var opts=($type(_options)!='object'?{'elem':_options}:_options);if(!$defined(opts.elem))return;this.setOptions(opts);if(this.options.filter){this.filter=this.options.filter;}
this.element=$(this.options.elem);this.elementCopy=this.element.clone().set({'id':this.element.get('id'),'name':this.element.get('name')});if(!$defined(this.options.container)||(this.container=$(this.options.container))==null){this.container=null;}
this.optClass='li[class*='+this.options.optionClass+']';this.create_select();if(this.options.attachResize){window.addEvent('resize',function(){if(this.showing){this.show();}}.bind(this));}},destroy:function(_revert){if(_revert){if(this.selected&&$defined(this.selected.retrieve('value'))){$each(this.elementCopy.options,function(_elem){if(_elem.value==this.selected.retrieve('value')){_elem.selected=true;}},this);}
this.elementCopy.replaces($(this.element.get('id')));}
this.remove_events();this.elementSelect.destroy();},ieFocus:function(){this.isCrolling=true;},create_select:function(){var wh=this.element.getSize();this.eid=this.element.get('id');this.elementSelect=new Element('div',{'class':this.options.selectboxClass,'styles':{'width':wh.x,'height':wh.y}}).inject(this.element,'after');this.elementDisplay=new Element('a',{'href':'javascript:void(0)'}).inject(this.elementSelect,'top');if(this.elementCopy.get('tabindex')!=0){this.elementDisplay.set('tabindex',this.elementCopy.get('tabindex'));}
this.elementDisplay.setStyles({'height':(wh.y-5),'line-height':(wh.y-5)});this.add_events();this.elementOptions=new Element('ul',{'styles':{'width':wh.x},'opacity':(this.options.useFx?0:1),'class':this.options.selectmenuClass}).inject(this.elementSelect);if(Browser.Engine.trident){this.boundIeFocus=this.ieFocus.bind(this);this.elementOptions.addEvent('mousedown',this.boundIeFocus);}
this.fx=this.options.useFx?new Fx.Tween(this.elementOptions,$merge({'duration':'200','link':'cancel'},this.options.fxOptions)):null;$each(this.element.getChildren(),this.create_option.bind(this));if(this.options.alternate){this.elementOptions.getElements(this.optClass+':'+(this.options.alternateOdd?'odd':'even')).addClass(this.options.altClass);}
(this.selected=this.elementOptions.getElement('li.'+this.options.selectClass)).removeClass(this.options.selectClass);this.selectedIndex=this.selected.retrieve('idx');this.elementDisplay.set({'html':this.selected.get('html'),'class':(this.options.showStyles?this.selected.get('class'):''),'style':(this.options.showStyles?this.selected.get('style'):'')});this.elementOptions.store('coords',this.elementOptions.getCoordinates()).setStyles({'visibility':'','display':'none'});this.element=new Element('input',{'type':'hidden','value':this.element.get('value'),'id':this.element.get('id'),'name':this.element.get('name')}).replaces(this.element).set('id',this.eid);},create_option:function(_opt,_idx,_group){var val=_opt.get('value'),selected=!!(_opt.selected);var text=(_opt.get('label')?_opt.get('label'):(_opt.get('text')||'&nbsp;'));var opt_class=(_opt.get('tag')=='optgroup'?' optgroup unselectable':' '+this.options.optionClass)+(selected&&!_opt.disabled?' '+this.options.selectClass:'')+
(_opt.disabled?' '+this.options.disableClass:'');var new_option=new Element('li',{'id':this.eid+'_opt'+_idx,'html':this.filter(text,this.options.tmplt_regex,this.options.template),'style':_opt.get('style'),'class':_opt.get('class')+opt_class}).store('value',_opt.get('value')).store('idx',(_opt.get('tag')!='optgroup'?(++this.length):'')).addEvents({'mouseover':this.over.bind(this),'mousedown':this.select.bind(this)}).inject(($(_group)||this.elementOptions));new_option.store('coords',new_option.getCoordinates());if(_opt.get('tag')=='optgroup'){var optgroup=new Element('ul',{'class':this.options.groupClass}).inject(new_option);$each(_opt.getChildren(),function(_sopt,_sidx){this.create_option(_sopt,(_idx+''+_sidx),optgroup);},this);}
if(this.options.allowSplit&&text.match(new RegExp(this.options.separator))){text=text.split(this.options.separator);this.elementOptions.lastChild.set('html','<span><span class="goleft">'+text[0].trim()+'</span><span class="goright">'+text[1].trim()+'</span><br style="clear:both" /></span>');}},filter:function(_str,_regx,_tmplt){return _tmplt.replace(/\%s/i,_str);},inject:function(_option,_where){},dispose:function(_elem){},add_events:function(){this.elementDisplay.addEvents({'click':this.boundShow,'keydown':this.boundKey_option,'blur':this.boundHide});},remove_events:function(){this.elementOptions.removeEvent(this.boundIeFocus);this.elementDisplay.removeEvents({'click':this.boundShow,'keydown':this.boundKey_option,'blur':this.boundHide});},key_option:function(e){e=new Event(e);if(e.key!='tab'){e.stop();switch(e.key){case'esc':this.hide();break;case'enter':this.select(this.selected);case'tab':this.hide();break;case'up':case'down':if(e.alt){this.show();}
this.select(e.key);break;case'shift':case'control':case'alt':break;default:this.search(e.key);}}},search:function(_key,_retrying){this.textSearch+=_key;var option_elems=this.get_options(),str_found=false,elem=false;for(var i=0;i<option_elems.length;i++){var elem=option_elems[i]
if((elem.get('text')).match(new RegExp('^'+this.textSearch,'i'))){if(this.selected!=elem){this.select(elem);}
str_found=true;break;}}
if(str_found===false){this.textSearch='';if(!_retrying){this.search(_key,true);}}},get_options:function(_selector){return this.elementOptions.getElements((_selector||this.optClass));},determine:function(_elem){var elem=($type(_elem)=='element'?(_elem.get('tag')!='li'?_elem.getParent('li'):_elem):this.get_options());if($type(_elem)!='element'){var fromIdx=((this.focused&&this.focused!=this.selected)?this.focused:this.selected).retrieve('idx');elem=elem.filter(function(_el){return(!$(_el).hasClass(this.options.disableClass)&&((_elem=='up'&&$(_el).retrieve('idx')<fromIdx)||(_elem=='down'&&$(_el).retrieve('idx')>fromIdx)));},this);elem=elem[0]?(_elem=='up'?elem.reverse():elem)[0]:elem;}
return elem;},over:function(e){e=new Event(e);var elem=($(e.target).get('tag')!='li'?$(e.target).getParent('li'):$(e.target));if(!elem.hasClass(this.options.disableClass)&&!elem.hasClass('unselectable')){if($type(this.focused)=='element'){this.focused.removeClass(this.options.selectClass);}
(this.focused=elem).addClass(this.options.selectClass);this.fireEvent('over');}},select:function(_elem,fire_event){var elem=($type(_elem)=='event'?new Event(_elem).target:_elem);elem=this.determine(elem);if(elem&&!elem.hasClass(this.options.disableClass)&&!elem.hasClass('unselectable')){if(this.focused){this.focused.removeClass(this.options.selectClass);}
if(this.showing===true){(this.focused=this.selected=elem).addClass(this.options.selectClass);this.scroll();}else{this.selected=elem;}
this.element.set('value',this.selected.retrieve('value'));this.selectedIndex=this.selected.retrieve('idx');this.elementDisplay.set({'html':this.selected.get('html'),'class':(this.options.showStyles?this.selected.get('class'):'')}).removeClass(this.options.selectClass).removeClass(this.options.altClass);if(fire_event==null)
this.fireEvent('select',this.selected);if(Browser.Engine.trident){this.isCrolling=false;this.hide();}}},scroll:function(){var sElem=this.elementOptions.getCoordinates();var selElem=this.selected.getCoordinates();var elScrollTop=this.elementOptions.scrollTop;if((elScrollTop+sElem.height)<(selElem.top-sElem.top+5)){this.elementOptions.scrollTop=(selElem.top-sElem.top-sElem.height+selElem.height);}
else if((selElem.top-sElem.top+selElem.height)<(elScrollTop+5)){this.elementOptions.scrollTop=(selElem.top-sElem.top);}},show:function(){var coords=this.elementOptions.retrieve('coords');var sElem=this.elementSelect.getCoordinates(),sElem_top=(sElem.top+sElem.height);if(this.container){sElem_top-=this.container.getStyle('top');sElem.left-=this.container.getStyle('left');}
var h=((window.getSize().y+window.getScroll().y)-sElem_top);var height=(coords.height>=h?0:'auto'),showing=0;if(coords.height>=h){$each(this.get_options(),function(_elem){var eH=_elem.retrieve('coords').height;if(height<h&&(height+eH)<h){height+=eH;showing++;}},this);if(showing<this.options.minShow){height=(sElem.top<coords.height?sElem.top-10:coords.height);sElem_top=sElem.top-height-1;}}
this.elementOptions.setStyles({'display':'','height':height,'top':sElem_top,'left':sElem.left,'margin':0});this.scroll();this.showing=true;this.focused=this.selected;this.focused.addClass(this.options.selectClass);this.fireEvent('show');if(this.options.useFx){this.fx.start('opacity',0,1);}
this.elementDisplay.focus();},hide:function(e){if(this.isCrolling){this.isCrolling=false;this.elementDisplay.focus();}
else if(this.showing){if(this.options.useFx){this.fx.start('opacity',1,0).chain(function(){this.elementOptions.scrollTop=0;this.elementOptions.setStyle('display','none');if(this.focused){this.focused.removeClass(this.options.selectClass);}
this.showing=this.focused=false;}.bind(this));}else{this.elementOptions.setStyle('display','none');if(this.focused){this.focused.removeClass(this.options.selectClass);}
this.showing=this.focused=false;}
this.fireEvent('hide');}
this.textSearch='';}});window.addEvent('domready',function(){var f_box=$('features-box');if(f_box){var a_tab=f_box.getElement('li.tab-active');if(a_tab){var c_box_id=a_tab.getElement('a.tab-link').getProperty('rel');$(c_box_id).setStyle('display','block');}
f_box.getElements('a.tab-link').addEvent('click',function(e){e.stop();var box_id=this.getProperty('rel');var a_tab=f_box.getElement('li.tab-active');var c_box_id=a_tab.getElement('a.tab-link').getProperty('rel');a_tab.removeClass('tab-active');this.getParent('li.tab').addClass('tab-active');$(c_box_id).set('tween',{'duration':250});$(c_box_id).get('tween').start('opacity',0).chain(function(){$(c_box_id).setStyle('display','none');$(box_id).set('tween',{'duration':250});$(box_id).setStyles({'display':'block','opacity':0});$(box_id).get('tween').start('opacity',1);}.bind(this));});}});var noobSlide=new Class({initialize:function(params){this.items=params.items;this.mode=params.mode||'horizontal';this.modes={horizontal:['left','width'],vertical:['top','height']};this.size=params.size||240;this.box=params.box.setStyle(this.modes[this.mode][1],(this.size*this.items.length)+'px');this.button_event=params.button_event||'click';this.handle_event=params.handle_event||'click';this.onWalk=params.onWalk||null;this.currentIndex=null;this.previousIndex=null;this.nextIndex=null;this.interval=params.interval||5000;this.autoPlay=params.autoPlay||false;this._play=null;this.handles=params.handles||null;if(this.handles){this.addHandleButtons(this.handles);}
this.buttons={previous:[],next:[],play:[],playback:[],stop:[]};if(params.addButtons){for(var action in params.addButtons){this.addActionButtons(action,$type(params.addButtons[action])=='array'?params.addButtons[action]:[params.addButtons[action]]);}}
this.fx=new Fx.Tween(this.box,$extend((params.fxOptions||{duration:500,wait:false}),{property:this.modes[this.mode][0]}));this.walk((params.startItem||0),true,true);},addHandleButtons:function(handles){for(var i=0;i<handles.length;i++){handles[i].addEvent(this.handle_event,this.walk.bind(this,[i,true]));}},addActionButtons:function(action,buttons){for(var i=0;i<buttons.length;i++){switch(action){case'previous':buttons[i].addEvent(this.button_event,this.previous.bind(this,[true]));break;case'next':buttons[i].addEvent(this.button_event,this.next.bind(this,[true]));break;case'play':buttons[i].addEvent(this.button_event,this.play.bind(this,[this.interval,'next',false]));break;case'playback':buttons[i].addEvent(this.button_event,this.play.bind(this,[this.interval,'previous',false]));break;case'stop':buttons[i].addEvent(this.button_event,this.stop.bind(this));break;}
this.buttons[action].push(buttons[i]);}},previous:function(manual){this.walk((this.currentIndex>0?this.currentIndex-1:this.items.length-1),manual);},next:function(manual){this.walk((this.currentIndex<this.items.length-1?this.currentIndex+1:0),manual);},play:function(interval,direction,wait){this.stop();if(!wait){this[direction](false);}
this._play=this[direction].periodical(interval,this,[false]);},stop:function(){$clear(this._play);},walk:function(item,manual,noFx){if(item!=this.currentIndex){this.currentIndex=item;this.previousIndex=this.currentIndex+(this.currentIndex>0?-1:this.items.length-1);this.nextIndex=this.currentIndex+(this.currentIndex<this.items.length-1?1:1-this.items.length);if(manual){this.stop();}
if(noFx){this.fx.cancel().set((this.size*-this.currentIndex)+'px');}else{this.fx.start(this.size*-this.currentIndex);}
if(manual&&this.autoPlay){this.play(this.interval,'next',true);}
if(this.onWalk){this.onWalk((this.items[this.currentIndex]||null),(this.handles&&this.handles[this.currentIndex]?this.handles[this.currentIndex]:null));}}}});window.addEvent('domready',function(){var nl_overlay,nl_center;nl_center=$('newsletter-box');$(document.body).adopt(nl_overlay=new Element("div",{id:"fullscreen-overlay",'events':{'click':close_newsletter}}).setStyle("display","none"),nl_center);var fx_overlay=new Fx.Tween(nl_overlay,{property:"opacity",'duration':'short'});$('newsletter-link').addEvent('click',function(e){e.stop();var middle=window.getScrollTop()+(window.getHeight()/2);var centerWidth=316;var centerHeight=214;nl_center.setStyles({top:Math.max(0,middle-(centerHeight/2)),width:centerWidth,height:centerHeight,marginLeft:-centerWidth/2});var scroll=window.getScroll(),size=window.getSize();nl_center.setStyle("left",scroll.x+(size.x/2));fx_overlay.set(0).start(0.50).chain(function(){nl_center.setStyle('display','block');});nl_overlay.setStyle('display','block');});function close_newsletter()
{nl_center.setStyle('display','none');fx_overlay.start(0);}
$('nletter-close').addEvent('click',function(e){e.stop();close_newsletter();});$('newsletter-del-a').addEvent('click',function(e){e.stop();$('newsletter-action').value='del';var req=new Request.JSON({url:g_main_site_url+'nl.php',onSuccess:function(res){if(res.error==1)
$('newsletter-message-txt').removeClass('message-ok').addClass('message-err');else
$('newsletter-message-txt').removeClass('message-err').addClass('message-ok');$('newsletter-message-txt').set('text',res.msg);}}).post($('newsletter-form'));return;});$('newsletter-add-a').addEvent('click',function(e){e.stop();$('newsletter-action').value='add';var req=new Request.JSON({url:g_main_site_url+'nl.php',onSuccess:function(res){if(res.error==1)
$('newsletter-message-txt').removeClass('message-ok').addClass('message-err');else
$('newsletter-message-txt').removeClass('message-err').addClass('message-ok');$('newsletter-message-txt').set('text',res.msg);}}).post($('newsletter-form'));return;});});
