/*------------------------------------- 
 スクロール 
-------------------------------------*/  
jQuery(document).ready(function(){  
	jQuery('a[href*=#]').click(function() {  
		if(location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname){  
			 var $target = jQuery(this.hash);  
			$target = $target.length && $target || jQuery('[name=' + this.hash.slice(1) +']');
				if($target.length){
					var targetOffset = $target.offset().top;  
					jQuery('html,body').animate({ scrollTop: targetOffset }, 500);
					return false;  
				} 
			} 
		});  
});

//********************************************************************* 画像先読み込み
/*
jQuery.fn.extend({
	preloadImages:function(options){
		conf = jQuery.extend({
			images : [0,0,0,0]
		}, options);
		for(var i = 0; i<arguments.length; i++)
		{
			jQuery('<img>').attr('src', arguments[i]);
		}
	}
});
*/
//********************************************************************* テーブルデザイン(色)
jQuery.fn.extend({
	tableDesign: function(options){
		conf = jQuery.extend({
			thColor  : '#fff',
			thBgColor: '#21343a',
			border   : '1px #fff solid',
			tdOdd    : '#fcc',
			tdEven   : '#fee',
			tdHover  : '#080',
			tdClick  : '#00a',
			boxName  : '',
			boxEq    : 0,
			hoverStyle : 1
		}, options);
		jQuery('th', this)
			.css('color', conf.thColor)
			.css('background-color', conf.thBgColor);
		jQuery('th', this).css('border', conf.border);
		jQuery('td', this).css('border-bottom', conf.border);
		jQuery('tr:odd',  this).css('background-color',  conf.tdOdd);
		jQuery('tr:even', this).css('background-color', conf.tdEven);
		if (conf.hoverStyle) {
			jQuery('tbody tr', this).hover(function(){
				jQuery('td', this).css('background-color', conf.tdHover);
				if (checkBox(this, conf.boxName)) {
					jQuery('td', this).css('background-color', conf.tdClick);
				}
			}, function(){
				jQuery('td', this).css('background-color', '');
				if (checkBox(this, conf.boxName)) {
					jQuery('td', this).css('background-color', conf.tdClick);
				}
			});
		}
		function checkBox(selector, boxName) {
			var check = jQuery('td :checkbox.' + boxName, selector).attr('checked');
			return check;
		}
	}
});
//********************************************************************* IE6用にpng24をpng8 切り替え
jQuery.fn.extend({
	pngIE6: function(options){
		set = jQuery.extend({
			png : 'IE6'
		}, options);
		var ua = navigator.userAgent;
		if (ua.match(/IE 6/)) {
			this.each(function(){
				var img = $(this).attr('src');
				var png  = img.substring(0, img.length - 4) + set.png + img.substr(img.length - 4, 4 );
				$(this).attr('src',png);
			});
		}
	}
});

//********************************************************************* ロールオーバー画像を指定
jQuery.fn.extend({
	imgRollOver: function(options){
		set = jQuery.extend({
			rText : 'on'
		}, options);
		this.each(function(){
			var out = $(this).attr('src');
			var on  = out.substring(0, out.length - 4) + set.rText + out.substr(out.length - 4, 4 );
			$('<img />').attr('src', on);
			$(this).hover(
				function(){ $(this).attr('src',on) },
				function(){ $(this).attr('src',out) }
			);
		});
	}
});

//********************************************************************* FireFox2にWordBreak適用
jQuery.fn.extend({
	wordBreak: function(){
		var ua = navigator.userAgent;
		if(ua.match(/IE/)) {
			this.css('word-break', 'break-all');
		} else {
			this.each(function(){
				if(navigator.userAgent.indexOf('Firefox/2') != -1) {
					$(this).html($(this).text().split('').join('<wbr />'));
				} else {
					$(this).html($(this).text().split('').join(String.fromCharCode(8203)));
				}
			});
		}
	}
});

//********************************************************************* UA取得
function getUserAgent(){
	var ua = navigator.userAgent;
	if (ua.match(/IE 6/)) {
		return true;
	}
	return false;
}

//********************************************************************* get time()
function getTime(){
	var t = new Date();
	return t.getTime();
}

//********************************************************************* regix
function regMatch(patern, str){
	var reg = new RegExp(patern,"ig");
	if (str.match(reg)) {
		return true;
	}
	return false;
}

//********************************************************************* get FormObj
function getSendData(selector){
	var data = {};
	jQuery(selector)
	.each(function(i){
		var name = jQuery(this).attr('name');
		var val  = jQuery(this).val();
		if (jQuery(this).is(':checkbox')) {
			if($(this).is(':checked')){
				if( !data[name] ) data[name] = [];
				data[name].push(val);
			}
		} else if (jQuery(this).is(':radio')) {
			if($(this).is(':checked')){
				if( !data[name] ) data[name] = [];
				data[name].push(val);
			}
		} else {
			data[name] = val;
		}
	});
	return data;
}

//********************************************************************* モーダルウィンドウ
/*
jQuery.fn.extend({
	modalWindow: function(options){
		conf = jQuery.extend({
			text  : '',
			color : '#fff',
			bgLayer : '#000'
		}, options);
		var ie6 = (typeof document.body.style.maxHeight == 'undefined') ? 1 : 0;
		this.append(conf.text);
		$('#modalWrap td').html('');
		$('div#modalLayer').remove();
		$('iframe#modalIf').remove();
		$('table#modalWrap').remove();
		$('body').append('<div id="modalLayer"></div><table id="modalWrap"><tr><td></td></tr></table>');
		$('#modalWrap td').html(this);
		if (ie6) {
			$('#modalLayer').before('<iframe id="modalIf"></iframe>');
			$('#modalLayer, #modalWrap, #modalIf').css('position','absolute');
			$('#modalLayer, #modalIf').width($('body').width());
			$(window).scroll(function(){
				$('#modalLayer').css('top', $(document).scrollTop());
				$('#modalWrap').css('top', ($(document).scrollTop()+$(window).height()/2) + 'px');
			});
		} else {
			$('#modalLayer, #modalWrap, #modalIf').css('position','fixed');
			$('#modalLayer, #modalIf').width('100%');
		}
		$('#modalIf')
			.css('top', '0')
			.css('left', '0')
			.css('height', '100%')
			.css('opacity', '0')
			.css('filter', 'alpha(opacity=0)')
			.css('z-index', '9997');
		$('div#modalLayer')
			.css('top', '0')
			.css('left', '0')
			.css('height', '100%')
			.css('background-color', conf.bgLayer)
			.css('opacity', '0.60')
			.css('filter', 'alpha(opacity=60)')
			.css('z-index', '9998');
		$('#modalWrap')
			.css('top', '50%')
			.css('left', '50%')
			.css('margin-top', -(this.height()/2))
			.css('margin-left', -(this.width()/2))
			.css('opacity', '0.60')
			.css('filter', 'alpha(opacity=60)')
			.css('z-index', '9999')
			.css('color', conf.color);
	}
});
*/

