/**
 * general.js - for yura-kankou.com
 * @requires jQuery v1.4.2
 *
 * Copyright (c) 2010 kuuchuu.org
 * $Date: 2010.6.30
 *
 */


/**
 *	Initialization
 */
$(document).ready(function(){
	for (module in kuuchuu) {
		if (kuuchuu[module].init){
			kuuchuu[module].init();
		}
	}
});


var kuuchuu = {};


/**
 *	tipTip plugin init
 */
kuuchuu.tipTip = {
	init: function() {
		$('img','.thumbnails').tipTip({
			defaultPosition: "top",
			delay:"0"
		});
	}
}


/**
 *	externalLinks (add target _blank)
 */
kuuchuu.externalLinks = {
	init: function() {
		$('a[rel=external]').attr("target","_blank");
	}
};

/**
 *	pagetop scroll
 */
kuuchuu.pagetop = {
	init: function() {
		$('a[href*=#]').click(function() {
			if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')&& location.hostname == this.hostname) {
				var $target = $(this.hash);
				$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
				if ($target.length) {
					var targetOffset = $target.offset().top;
					$('html,body').animate({scrollTop: targetOffset}, 500);
					return false;
				}
			}
		});	
	 }
};


/**
 *	simple photo gallery
 */
kuuchuu.simplegallery = {
	init:function(){
		this.setup('#cruise-main');
		this.setup('#restaurant-main');
		this.setup('#store-main');
		this.setup('#store-items');
	},
	setup:function(sectionID){
		if(!$(sectionID)) return false;
		var self = this;
		var photo = $('.photo', sectionID);
		var thumb = $('.thumbnails', sectionID);
		var tgt = $('img', photo);
		$('li a', thumb).click(function(){
			var p = $(this).attr('href');
			var alt = $('img', this).attr('alt');
			tgt.attr('src', p);
			tgt.attr('alt', alt);
			self.photoUpdate(photo);
			return false;
		});
		self.photoUpdate(photo);
	},
	photoUpdate:function(photo){
		var cap = $('img', photo).attr('alt');
		$('.caption', photo).empty().append(cap);
	}
}




