$(function(){

	new Image().src = 'http://tatsuwa.com/images/map_tokyo.gif';
	new Image().src = 'http://tatsuwa..com/images/map_kanagawa.gif';

	// scroll
	$('a[href^=#]').click(function() {
		var t = jQuery(this.hash);//not use "$" but "jQuery". It's because loading more than two jquery files...
		if (this.hash.length > 1 && t.length) {
			jQuery.scrollTo(t, 400);
			return false;
		}
	});

	$('#header a, .idTabs > a').unbind('click');

	$('#fontSwitch').show();
	var $alt_css = $('link[rel=alternate stylesheet]');
	var setCss = function(title) {
		var $css = $alt_css.filter('[title=' + title + ']');
		if ($css.length) {
			$alt_css.attr('disabled', 'disabled');
			$css.removeAttr('disabled');
			var date = new Date();
			date.setTime(date.getTime() + (365 * 24 * 60 * 60 * 1000));
			$.cookie('css', title, {path: '/', expires: date});
		}
	};
	
	// default css
	setCss($.cookie('css'));
	$('#fontSwitch a').click(function() {
		var fontsize = $(this).attr('href').replace(/^#/, '');
		setCss(fontsize);
		return false;
	});

	// rollover
	$('.imgover').each(function(){
		this.osrc = $(this).attr('src');
		this.rollover = new Image();
		this.rollover.src = this.osrc.replace(/(\.gif|\.jpg|\.png)/, "_o$1");
	}).hover(function(){
		$(this).attr('src',this.rollover.src);
	},function(){
		$(this).attr('src',this.osrc);
	});

	// set input placeholder
	$('input.placeholder, textarea.placeholder').each(function() {
		if (!$(this).val() || $(this).val() == $(this).attr('title')) {
			$(this).val($(this).attr('title')).addClass('empty');
		}
	}).focus(function() {
		if ($(this).val() == $(this).attr('title')) {
			$(this).val('').removeClass('empty');
		}
	}).blur(function() {
		if (!$(this).val().length) {
			$(this).val($(this).attr('title')).addClass('empty');
		}
	}).parents('form').submit(function() {
		$(this).find('input.placeholder').each(function() {
				if ($(this).val() == $(this).attr('title')) {
					$(this).val('');
				}
		});
	});
	
	//table
	//$('.dateList dd').filter(':even').addClass('even');
	$('.dateList').each(function() {
		$(this).find('> dd:even').addClass('even');
	
	});
});


