/**
 * 数値を3桁区切りでカンマを入れる
 */
function number_format(input)
{
	var num = new String(input).replace(/,/g, '');
	while (num != (num = num.replace(/^(-?\d+)(\d{3})/, '$1,$2')));

	return num;
}

/*ロールオーバー*/
/*
	Standards Compliant Rollover Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/
function initRollovers()
{
	if (!document.getElementById) return;

	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_o'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);

			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;

			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}

			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

/**
 * jQuery拡張
 */
(function($){$.fn.extend({
	// プルダウン
	hoverClass: function(c)
	{
		return this.each(function(){
			$(this).hover(function() {
				$(this).addClass(c);
			},function() {
				$(this).removeClass(c);
			});
		});
	}
});})(jQuery);

// 読み込み完了後
jQuery(document).ready(function($){
	/**
	 * プルダウン
	 */
	$('#navi li').hover(function(){
		$('ul', this).fadeIn('fast');
	}, function() {
		$('ul', this).fadeOut('fast');
	});
	if (document.all) {
		$('#navi li').hoverClass('sfHover');
	}

	// 各種プレースホルダー
	$('[placeholder]').placeholder();

	initRollovers();
});
