$(document).ready(function() {

  //////////////////////////////////////////////////////////////// add dividers to navigation elements
  $('ul.corp-header-nav li:not(:first)').before('<li><img src="/images/corporate/header-nav-leaf.jpg"/></li>');
  $('#header ul.supernav li').last().addClass('last');
  
  $("a.button").click(function () {
    $("#selection ul").slideToggle('300');
    $("#selection ul a").toggle('fast');
    return false;
  });

  /////////////////////////////////////////////////////////////// jquery accordion
	$('#accordion').accordion({
		autoHeight: false,
		navigation: true,
		header: 'h4',
		collapsible: true,
		active: false,
    animated: 'size'
	});
	
  ///// add feature button style to corporate home page features
	$('#corporate-features .feature').each(function(){
    $(this).children().last().addClass('feature-button');
  });
  
  //Booking widget
  // $('form#resmarkForm input.date-pick').datepicker({
  //   showOn: 'both',
  //   buttonImage: '/images/calendar.png',
  //   buttonImageOnly: true,
  //   changeMonth: true,
  //  changeYear: true
  // });
  // 
  // $('form#resmarkForm').submit(function() {
  //   var start = $('form#resmarkForm input#startDate').val();
  //   $('form#resmarkForm input#endDate').val(start);
  // });
  
 // causes book it div to slide 

 $('.interior #book-it').hide();
 
  $('a#show-book').click(function() {
    // $('.interior #book-it').toggle("fast");
    $('.interior #book-it').slideToggle(300);
    return false;
  });
  
  /////////////////////////////////////////////////////////// fancybox for gallery
  $(".flickr-gallery a").fancybox({
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'titlePosition'		: true,
		'titlePosition'		: 'inside',
		'overlayColor'		: '#000',
		'overlayOpacity'	: 0.88,
		'showNavArrows'   : true,
		'showCloseButton' : true
  });
  
  $("a.watch").fancybox({
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'titlePosition'		: true,
		'titlePosition'		: 'inside',
		'overlayColor'		: '#000',
		'overlayOpacity'	: 0.88,
		'showNavArrows'   : true,
		'showCloseButton' : true
  });
  
  //  wrap images in a div for frame background
  // $("img#left").each(function(i){
  //   $(this).wrap("<div id='frame-left'></div>");
  // });
  // $("img#right").wrap("<div id='frame-right'></div>");
  
  // $("img#left").wrap("<div></div>");
  // $("img#right").wrap("<div></div>");

  // dropdowns
  $('#main-nav ul li').each(function() {
    $(this).hover(function() {
      $(this).addClass('nav-on');
    }, function() {
      $(this).removeClass('nav-on');
    });
  });
  
  // $('#main-nav ul li.main:not(:first)').before('<li><img src="/images/asheville/mainnav_leaf.gif" /></li>');
  
  // bind an onClick event for this second Flash container
	$("#clickhere").click(function() {
	  
	  var params = {
        menu: "false",
        wmode: "transparent"
    };
	  
		//append the full screen div to the page so we can embed flash in it
    $("body").append('<div id="konami-overlay" style="position:fixed;top:0;left:0;background:#000;width:100%;height:100%;z-index:600;opacity: 0;"></div>');
  	$("body").append('<div id="konami-code" style="position:fixed;top:0;left:0;width:100%;height:100%;z-index:610;"><div id="konami-flash-embed"></div></div>');
  	
  	$("#konami-overlay").animate({ opacity: 0.7 }, 1000, "swing", function(){
    	//embed the easter egg
    	swfobject.embedSWF("/swf/easter-egg.swf", "konami-flash-embed", "1100", "100%","9.0.0", "", {}, params, {});
  	});
  	
  	//hide the flash objects on the page
  	$("object").hide();
  	$("embed").hide();
  	
    setTimeout(function() {
      $('#konami-overlay').remove();
      $('#konami-code').remove();
      //show the flash objects on the page
    	$("object").show();
    	$("embed").show();
    }, 13000);
    
    return false;

	});

  $("#startDate").datepicker({
    showOn: 'both',
    buttonImage: '/images/calendar.png',
    buttonImageOnly: true,
    changeMonth: true,
  	changeYear: true,
  	onSelect: function(dateText, inst){
  	  $("#endDate").val(dateText);
  	}
  });
  
  // function removeEasterEgg() {
  //    $(function(){
  //       //remove konami code html
  //       $("#konami-overlay").remove();
  //       $("#konami-code").remove();
  // 
  //       //show the flash objects on the page
  //      $("object").show();
  //    });
  // }
	
  
  /////////////////////////////////////////////////////////////// home page tabs for video
  $(function() {
    //$("#video-tabs").tabs();
  });
  
  // form validation
  //$("#guestbook").validate();

}); //end document.ready
