/*
Donvoan Mueller following the inscrutable exhortations of his soul.
donovan@rhinointernet.com
http://rhinointernet.com
*/

jQuery(document).ready(function(){
   slideshow.initialize(jQuery('.slideshow').eq(0));
   collapsables.initialize(jQuery('.relatedlinks'));
   
   $('div.searchbox #searchsubmit').attr('value', ' ');
   
   chartsengrafs();
   
});

var slideshow = {
   SlideDur:    5000, //Slide duration
   TransTime:   1000,  //Transition animation time
   activeSlide: 0,    //Initial slide, then current slide
   
   initialize: function(viewport) {
      var _this     = this;
      this.viewport = viewport;
      this.items    = viewport.find('.items li');
      
      this.viewport.css('overflow', 'hidden');
      this.items.hide();
      this.items.eq(this.activeSlide).show();
      
      setInterval(function(){ _this.next() }, this.SlideDur);
   }, //initialize()
   
   next: function() {
      var _this = this;
      
      var next = this.activeSlide + 1;
      if (next >= this.items.length) {
         next = 0;
      }
      
      this.items.fadeOut(this.TransTime);
      
      setTimeout(function(){
         _this.items.eq(next).fadeIn(this.TransTime);   
      }, this.TransTime + 500);
      
      this.activeSlide = next;
   } //next()

}; //slideshow{}


/*==( Collapsables )=========================================================*/

var collapsables = {
   items:   null,
   headers: null,

   initialize: function(items) {
      var _this    = this;
      this.items   = items;
      this.headers = this.items.children('.header');
      
      // setup
      this.items.children(':not(.header)').hide();
      this.headers.css('cursor', 'pointer');

      // add hover effect
      this.headers.hover(
         function() { // mouseover
            $(this).css('color', '#8ca18f');
         },
         function() { // mouseout
            $(this).css('color', '#2B3C2D');
         }
      );
      
      // toggle contents on header click
      this.headers.click(function(){
         var contents = $(this).parent().children(':not(.header)');
         var visible  = contents.filter(':visible');
         if (visible.length > 0) {
            // we need to hide things
            contents.slideUp();
         } else {
            contents.slideDown();
         } // if
      }); // headers.click

      // check URL hash for initial content to display
      if (window.location.hash.length > 1) {
         setTimeout(function(){
            _this.items.filter(window.location.hash).children().slideDown();
         }, 300); // delay animation for a nicer feel
      }
   } // initialize()
}; // collapsable{}




/*==( Chartsengrafs. )=========================================================*/

function chartsengrafs(){

$('center').find('map').next('img').addClass('chartimage');


}; //chartsengrafs









