
window.addEvent('domready', function() {
      
   var toggles = $$('h1.toggler');
   var elements = $$('p.element');
   var first_toggle=toggles.getFirst();
   var backlink = $('back');
   if(first_toggle.length != 0){
    if(!$('accordeon')){ 
        var count = 0;
          var parent = new Element('div',{id:'accordion'});
          parent.inject($('cont'));
          toggles.each(function(el){
             el.inject(parent);
             elements[count].inject(parent);
             count++;
          });
          for(i=count;i<elements.length;i++) 
                elements[i].set('class','noElement');
      }
      if(backlink!=null) parent.grab(backlink);
     var myAccordion = new Accordion($('accordion'), 'h1.toggler', 'p.element', {
                  opacity: false,
                  onActive: function(toggler, element){
                        toggler.setStyle('color', '#000000');
                  },
                  onBackground: function(toggler, element){
                        toggler.setStyle('color', '#0069B3');
                  }
            });
    }
    
   if($('tabber')!=null && $('blogpage') !=null){
      var tabs = new SimpleTabs('blogpage' , {selector: 'h6'});


      $('tabmen').inject($('blogpage'));
   }
    
    
    if($('myGallery')) startGallery($('myGallery'));
    $('body').erase('class');
    
    //var menMorph = new Fx.Morph(leftel, { 'duration': 2000 });
    //myMorph.start({'height':300});
    $$('li.on ul').each(function(el){el.set('class','on')});

    var morphers = $$('#menu li ul.off');
    var switches = morphers.getParent('li');
//    menMorph = new Fx.Morph(morphers, { 'duration': 1000 });
    morphers.setStyle('opacity','0');
      switches.each(function(el){
         el.addEvent('mouseover', function(e){
                      var t = el.getElement('ul').setStyles({
                        'position':'absolute',
                        'z-index' :'12000'
                        }).fade(.8);
               });
         el.addEvent('mouseout', function(e){
               var t = el.getElement('ul').fade(0);
               });      
      })
});

/**
*
*  URL encode / decode
*  http://www.webtoolkit.info/
*
**/
 
var Url = {
 
      // public method for url encoding
      encode : function (string) {
            return escape(this._utf8_encode(string));
      },
 
      // public method for url decoding
      decode : function (string) {
            return this._utf8_decode(unescape(string));

      },
 
      // private method for UTF-8 encoding
      _utf8_encode : function (string) {
            string = string.replace(/\r\n/g,"\n");
            var utftext = "";
 
            for (var n = 0; n < string.length; n++) {
 
                  var c = string.charCodeAt(n);
 
                  if (c < 128) {
                        utftext += String.fromCharCode(c);
                  }
                  else if((c > 127) && (c < 2048)) {
                        utftext += String.fromCharCode((c >> 6) | 192);
                        utftext += String.fromCharCode((c & 63) | 128);
                  }
                  else {
                        utftext += String.fromCharCode((c >> 12) | 224);
                        utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                        utftext += String.fromCharCode((c & 63) | 128);
                  }
 
            }
 
            return utftext;
      },
 
      // private method for UTF-8 decoding
      _utf8_decode : function (utftext) {
            var string = "";
            var i = 0;
            var c = c1 = c2 = 0;
 
            while ( i < utftext.length ) {
 
                  c = utftext.charCodeAt(i);
 
                  if (c < 128) {
                        string += String.fromCharCode(c);
                        i++;
                  }
                  else if((c > 191) && (c < 224)) {
                        c2 = utftext.charCodeAt(i+1);
                        string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                        i += 2;
                  }
                  else {
                        c2 = utftext.charCodeAt(i+1);
                        c3 = utftext.charCodeAt(i+2);
                        string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                        i += 3;
                  }
 
            }
 
            return string;
      }
 
}

