$(document).ready(function(){

     /* Begin Availability Panel Control */
     $("#availability").toggle(function() {
     $("#availabilityBar").show();
     $("#availabilityBar").animate({width:"250px"});
     $("#availability").animate({left:"250px"});
     $("#facebook").animate({left:"250px"});
     },function(){
     $("#availability").animate({left:"0px"});
     $("#facebook").animate({left:"0px"});
     $("#availabilityBar").animate({width:"0px"},function(){
     $("#availabilityBar").hide();
     });
     });
     /* End Availability Panel Control */

     /* Begin Testimonials Panel Control */
     $("#testimonials").toggle(function() {
     $("#testimonialsBar").show();
     $("#testimonialsBar").animate({height:"350px"});
     $("#page-wrap").css("position","relative");
     $("#page-wrap").animate({top:"350px"});
     },function(){
     $("#page-wrap").animate({top:"0px"});
     $("#page-wrap").css("position","statc");
     $("#testimonialsBar").animate({height:"0px"},function(){

     $("#testimonialsBar").hide();
     });
     });
     /* End Testimonials Panel Control */
     });


     /*menus*/

     function initMenus() {
   $('ul.menu ul').hide();
   $.each($('ul.menu'), function(){
   $('#' + this.id + '.expandfirst ul:first').show();
   });
   $('ul.menu li a').click(
   function() {
   var checkElement = $(this).next();
   var parent = this.parentNode.parentNode.id;

  if($('#' + parent).hasClass('noaccordion')) {
  $(this).next().slideToggle('normal');
  return false;
  }
  if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
  if($('#' + parent).hasClass('collapsible')) {
  $('#' + parent + ' ul:visible').slideUp('normal');
  }
  return false;
  }
 if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
   $('#' + parent + ' ul:visible').slideUp('normal');
  checkElement.slideDown('normal');
  return false;
   }
   }
  );
   }
   $(document).ready(function() {initMenus();});


/*sliding divs*/


function slideSwitch() {
    var $active = $('#slideshow DIV.active');

    if ( $active.length == 0 ) $active = $('#slideshow DIV:last');

    // use this to pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow DIV:first');

    // uncomment below to pull the divs randomly
    //var $sibs  = $active.siblings();
    //var rndNum = Math.floor(Math.random() * $sibs.length );
    //var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active')


        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});
