function Button(type){ this.type = type; var self = { baseUrl : 'http://ida2.km-union.ru/kmsites/button/', type : this.type, btn : null, panel : null, init : function(){ // add css file this.addCssStyle(); // create button and add events this.createButton(); // create navigation panel this.createNavigationPanel(); }, addCssStyle : function(){ $('head').append(''); }, createButton : function(){ /* render button */ $('body').append(''); this.btn = $('div#navigationButton'); if ($.browser.msie) { this.btn.hover( function(){ $(this).addClass('hover'); }, function(){ $(this).removeClass('hover'); } ); } var self = this; this.btn.click( function(){ var el = $(this); if (!el.hasClass('active')) { el.addClass('active'); self.showNavigationPanel(); }else{ el.removeClass('active'); self.hideNavigationPanel(); } } ); }, createNavigationPanel : function(){ var html = ''; $('body').append(html); this.panel = $('div#navigationPanel'); }, showNavigationPanel : function(){ this.panel.css('display', 'block').animate( { opacity:1, filter:'alpha(opacity=100)' }, 250, 'swing', function() { /* ok */ } ); }, hideNavigationPanel : function(){ this.panel.animate( { opacity:0, filter:'alpha(opacity=0)' }, 250, 'swing', function() { /* ok */ $(this).css('display', 'none'); } ); } } self.init(); return self; } function encode_utf8(s){ return unescape(encodeURIComponent(s)); } function decode_utf8(s){ return decodeURIComponent(escape(s)); }