$(function() {
	$("a.anchorLink").anchorAnimate()
});

jQuery.fn.anchorAnimate = function(settings) {

 	settings = jQuery.extend({
		speed : 600
	}, settings);	
	
	return this.each(function(){
		var caller = this
		$(caller).click(function (event) {	
			event.preventDefault()
			var locationHref = window.location.href
			var elementClick = $(caller).attr("href")
			
			var destination = $(elementClick).offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
				window.location.hash = elementClick
			});
		  	return false;
		})
	})
}	


$(function(){
		$('#gallery').slides({
			preload: true,
			preloadImage: '/images/loading.gif',
			effect: 'fade',
			crossfade: true,
			slideSpeed: 350,
			fadeSpeed: 1000,
			generateNextPrev: true,
			generatePagination: false,
			play: 4000,
			pause: 1500
			});
	});

	$(function(){
		$('#slides').slides({
			preload: true,
			preloadImage: '/images/loading.gif',
			play: 5000,
			pause: 2500,
			crossfade: true,
			slideSpeed: 350,
			fadeSpeed: 500,
			hoverPause: true,
			effect: 'slide, fade'				
		});
	});


 $(function(){
      $(".tweet").tweet({
        join_text: "auto",
        username: "eastmanhawaii",
        avatar_size: 32,
        count: 3,
        loading_text: "loading tweets..."
      });
    });		
		
$(function() {
	
	$(".dropdown h3").click(function () {
		$(this).siblings(".hidden").slideToggle("fast");
	});
	
	$(".agentpdf").click(function () {
		$(this).siblings(".hiddenstuff").slideToggle("slow");
	});
		
    $("#navsub h2").click(function () {
	$(this).siblings("ul").slideToggle("fast");
    });

	$('<span style="display:none;" class="show">閉じる</span>').appendTo(".hiding h4.one");
    $(".hiding h4.one").click(function () {
	$(".hiding .showme.one").slideToggle("fast");
	$(".hiding h4.one span").toggle();
    });
	
	$('<span style="display:none;" class="show">閉じる</span>').appendTo(".hiding h4.two");
    $(".hiding h4.two").click(function () {
	$(".hiding .showme.two").slideToggle("fast");
	$(".hiding h4.two span").toggle();
    });
	
	$('<span style="display:none;" class="show">閉じる</span>').appendTo(".hiding h4.three");
    $(".hiding h4.three").click(function () {
	$(".hiding .showme.three").slideToggle("fast");
	$(".hiding h4.three span").toggle();
    });
	
	$('<span style="display:none;" class="show">閉じる</span>').appendTo(".hiding h4.four");
    $(".hiding h4.four").click(function () {
	$(".hiding .showme.four").slideToggle("fast");
	$(".hiding h4.four span").toggle();
    });
	
	$('<span style="display:none;" class="show">閉じる</span>').appendTo(".hiding h4.five");
    $(".hiding h4.five").click(function () {
	$(".hiding .showme.five").slideToggle("fast");
	$(".hiding h4.five span").toggle();
    });
	
	$('<span style="display:none;" class="show">閉じる</span>').appendTo(".hiding h4.six");
    $(".hiding h4.six").click(function () {
	$(".hiding .showme.six").slideToggle("fast");
	$(".hiding h4.six span").toggle();
    });
	
	$('<span style="display:none;" class="show">閉じる</span>').appendTo(".hiding h4.seven");
    $(".hiding h4.seven").click(function () {
	$(".hiding .showme.seven").slideToggle("fast");
	$(".hiding h4.seven span").toggle();
    });
	
	$('<span style="display:none;" class="show">閉じる</span>').appendTo(".hiding h4.eight");
    $(".hiding h4.eight").click(function () {
	$(".hiding .showme.eight").slideToggle("fast");
	$(".hiding h4.eight span").toggle();
    });

	$('<span style="display:none;" class="show">閉じる</span>').appendTo(".hiding h4.nine");
    $(".hiding h4.nine").click(function () {
	$(".hiding .showme.nine").slideToggle("fast");
	$(".hiding h4.nine span").toggle();
    });


	$('<span style="display:none;" class="show">閉じる</span>').appendTo(".hiding h4.ten");
    $(".hiding h4.ten").click(function () {
	$(".hiding .showme.ten").slideToggle("fast");
	$(".hiding h4.ten span").toggle();
    });

	$('<span style="display:none;" class="show">閉じる</span>').appendTo(".hiding h4.accommodation");
    $(".hiding h4.accommodation").click(function () {
	$(".hiding .showme.accommodation").slideToggle("fast");
	$(".hiding h4.accommodation span").toggle();
    });

	$('<span style="display:none;" class="show">閉じる</span>').appendTo(".kiyaku h4.regulations");
    $(".kiyaku h4.regulations").click(function () {
	$(".kiyaku .showme.regulations").slideToggle("fast");
	$(".kiyaku h4.regulations span").toggle();
    });
	
	$(".hiding h4 span.show:even").after('<img src="/images/button-arrow.png" width="30" height="30" align="absbottom" style="margin-right:12px;" >');	 
	$(".kiyaku h4 span.show:even").after('<img src="/images/button-arrow.png" width="30" height="30" align="absbottom" style="margin-right:12px;" >');	 
 
    $(".hovermestars, .hovermehouse, .hovermeroom").click(function () {
	$(this).siblings(".tip").toggle("fast");
    });
	$('body').click(function() {
	$(".tip").hide("fast");
	 });
	$('.hovermestars, .hovermehouse, .hovermeroom').click(function(event){
     event.stopPropagation();
	 });
	 
/*    $(".hovermehouse").click(function () {
	$(".housetype").toggle("fast");});
	$('.hovermehouse').click(function(event){
     event.stopPropagation();
	 });

    $(".hovermeroom").click(function () {
	$(".roomtype").toggle("fast");
    });
	$('.hovermeroom').click(function(event){
     event.stopPropagation();
	 });
	 
	 
   $(".hovermestars").click(
	  function() { $(".stars").show("fast"); }, 
	  function() { $(".stars").hide("fast"); }
		)	


    $(".hovermehouse").click(
	  function() { $(".housetype").show("fast"); }, 
	  function() { $(".housetype").hide("fast"); }
		)	

    $(".hovermeroom").click(
	  function() { $(".roomtype").show("fast"); }, 
	  function() { $(".roomtype").hide("fast"); }
		)	
*/

			
    $("#dorm").hide();
    $("#homestay").hide();
    $(".showmorecontent").hide();


    $('#packagestay').change(function(){
        if ($(this).val() == 'condo') {
            $("#condo").slideDown("slow");
        } else {
            $("#condo").hide();
        }
    });  

    $('#packagestay').change(function(){
        if ($(this).val() == 'dorm') {
            $("#dorm").slideDown("slow");
        } else {
            $("#dorm").hide();
        }
    });  

    $('#packagestay').change(function(){
        if ($(this).val() == 'homestay') {
            $("#homestay").slideDown("slow");
        } else {
            $("#homestay").hide();
        }
    });  

	$(".showmorebutton").click(function () {
		$(this).hide();
		$(this).siblings(".hidebutton").show();
		$(this).siblings(".showmorecontent").slideToggle("fast");
		});

	$(".hidebutton").click(function () {
		$(this).hide();
		$(this).siblings(".showmorebutton").show();
		$(this).siblings(".showmorecontent").slideToggle("fast");
		});

});


