
var OLToppanel = new Class({	
initialize: function(element, options) {
this.options = $extend({
modulenid: '',
duration: 1000,
auto: 0,
delay: 0,
overlay: 0,
cookie_suffix: 'oltoppanel_'
}, options || {});

this.el = $(element);
this.el.getParent().getParent().setStyle('position', 'relative');
this.el.getParent().getParent().getParent().setStyle('position', 'relative');
this.panel = this.el.getElement('div.ol-tp-panels');
this.wraper = this.el.getElement('div.ol-tp-wraper');

this.content = this.el.getElement('div.ol-tp-content');
this.button = $('ol-tp-kuti-wraper-'+this.options.modulenid);
if($('ol-tp-Overlay')==null){
this.overlay = new Element('div', {'id': 'ol-tp-Overlay'});	
this.overlay.inject($(document.body));
}
else{
this.overlay = $('ol-tp-Overlay');
}
this.overlay.setStyles({'display':'block', 'visibility':'hidden'});

this.el.setStyle('display', 'block');
this.button.getElement('div.ol-tp-kuti-subwap').setStyle('left', this.panel.offsetWidth/2 - this.button.getElement('div.ol-tp-kuti-subwap').offsetWidth/2);

if (!this.myslider) {
this.myslider = new Fx.Slide(this.wraper, {duration: this.options.duration, open:true});
}		
this.myslider.hide ();

if(!this.overlayFx  && this.options.overlay){
this.overlayFx = new Fx.Morph(this.overlay, {duration: 500});
}


if(this.options.auto){
$clear(this.timer);
this.timmer = this.openPanel.delay(this.options.delay, this);
}

this.button.getElement('div.ol-tp-kuti-subwap').addEvent('click', function(){
this.myslider.toggle();

this.controlButtonDontshowagain($('ol-tp-kuti-subwap-'+this.options.modulenid));						

if(this.options.overlay){
if(this.overlay.getStyle('visibility')=='hidden'){
this.overlayFx.start({
'height': [0, window.getScrollSize()['y'] + this.content.offsetHeight],
'opacity': [0, 0.7]
});
}
else{
this.overlayFx.start({
'height': [this.overlay.offsetHeight, 0],
'opacity': [0.7, 0]
});
}			
}
}.bind(this));

/*this.close = this.content.getElement('span.ol-tp-close');
if(this.close!=null){
this.close.addEvent('click', function(){
this.myslider.slideOut();
this.myslider.slideIn();

if(this.options.overlay){
this.overlayFx.start({
'height': [this.overlay.offsetHeight, 0],
'opacity': [0.7, 0]
});
}
}.bind(this));
}*/

},

openPanel: function(){
this.myslider.slideIn();
this.myslider.slideOut();
if(this.options.overlay){
this.overlayFx.start({
'height': [0, window.getScrollSize()['y'] + this.content.offsetHeight],
'opacity': [0, 0.7]
});
}
}


});
