$(document).ready(function(){
  
  /// Home page slide show
  $('#slider').nivoSlider({
      effect:'boxRandom',    
      animSpeed:600,
      pauseTime:4500,
      boxCols: 10, 
      boxRows: 4, 
      controlNav: false,
      directionNav: false
  });
 
  
  // Menu dropdown Script
  $("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav
    
  $("ul.topnav li").mouseenter(function() { //When trigger is clicked...
    
    //Following events are applied to the subnav itself (moving subnav up and down)
    if (!$(this).find("ul.subnav").is(':visible'))
      $(this).find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click

    $(this).hover(function() {
    }, function(){  
      $(this).find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
    });

    //Following events are applied to the trigger (Hover events for the trigger)
    }).hover(function() {
      $(this).addClass("subhover"); //On hover over, add class "subhover"
    }, function(){  //On Hover Out
      $(this).removeClass("subhover"); //On hover out, remove class "subhover"
  });
  
  
  // Slide panel for login 
  // Expand Panel
  $("#open").click(function(){
    $("div#panel").slideDown("slow");
  
  });  
  
  // Collapse Panel
  $("#close").click(function(){
    $("div#panel").slideUp("slow");  
  });    
  
  // Switch buttons from "Log In | Register" to "Close Panel" on click
  $("#toggle a").click(function () {
    $("#toggle a").toggle();
  }); 
  
  $(".testimonial a").click(function(event) {
      event.preventDefault(); 
    });
  
  $(".testimonial a").click(function(){
      //Set Variables
      var imgTitle = $(this).attr("href"); //Get Main Image URL
    
      $("#testimonialcycle").attr('src',imgTitle); //Switch the main image (URL + alt tag)
         
      //Show active list-item
      $(".testimonial a").removeClass('active');
      $(this).addClass('active');  
    
      $(".testimonial").removeClass('active');
      $(this).parent().addClass('active');
 
  }) 
    
  $("#open_main").click(function(){
    if ($("div#panel").is(":hidden")) {
      $("div#panel").slideDown("slow");
      $("#toppanel .AspNet-Login").slideDown("slow");
      $("#toggle a").toggle();
    }
  }); 


});
