/*昭和科学*/



//デバッグ時のエラー回避（IE6～8、もしかしたら9も）
if (!window.console) {
	window.console = {
		log : function () {},
		info : function () {},
		warn : function () {},
		error : function () {},
		time : function () {},
		timeEnd : function () {}
	};
};



jQuery(function() {
	
	//ノーマルロールオーバー
	jQuery('.swapimg').each(function() {
		this.oSrc = jQuery(this).attr('src');
		if (this.oSrc.indexOf('_on.') > -1) {
			this.rSrc = this.oSrc;
		} else {
			this.rSrc = this.oSrc.replace(/^(.+)(\.[a-z]+)$/, '$1_on$2');
			jQuery('<img>').attr('src', this.rSrc); //プリロード
		}
	}).hover(function() {
			this.src = this.rSrc;
	},function() {
			this.src = this.oSrc;
	});
	
	//ページ内スクロール
	jQuery('.scroll_to').click(function() {
		jQuery.scrollTo(jQuery(this).attr('href'), 400, {margin:true});
		return false;
	});
	
	
	
	//トップページswf読み込み
	if (jQuery('body.home #header2_image_swf')[0]) {
		swfobject.embedSWF(
			'img/header2_mainimage.swf',
			'header2_image_swf',
			'960',
			'220',
			'10.0.0',
			null,
			null,
			{
				quality: 'high',
				menu: 'false',
				scale: 'exactfit',
				allowscriptaccess: 'always'
			},
			null
		);
	}
	
	
	
	//FAQ表示・非表示
	jQuery('.qa .A_box').css('display', 'none');
	jQuery('.qa .Q_box').click(function() {
		jQuery('.A_box', jQuery(this).parent('.qa')[0]).slideToggle(300);
	});
	
	
	
	//cookieにテキストを保存
	jQuery('.js_textsend a').click(function() {
		jQuery.cookie('js_text', jQuery(this).text());
	});
	if (jQuery('.js_textreceive')[0]) {
		jQuery('.js_textreceive').text(jQuery.cookie('js_text'));
	}
	
});



//ページ読み込み完了後に実行
jQuery(window).load(function() {
		
	//このファイル置いてあるディレクトリを調べる
	var this_dir;
	this_dir = jQuery('script[src$="/basic.js"]')[0].src;
	this_dir = this_dir.slice(0, this_dir.lastIndexOf('/') + 1);
	
	//住所自動入力読み込み
	if (location.href.indexOf('/form/') > -1) {
		jQuery.ajax({
			type: 'get',
			url: this_dir + 'ajaxzip2.js',
			dataType: 'script',
			scriptCharset: 'utf-8',
			success: function() {
				AjaxZip2.JSONDATA = this_dir + 'address_data';
			}
		});
	}
	
	//AjaxZip2をバインドする
	//jQuery('.ajaxzip').bind('keyup', function() {
	//	AjaxZip2.zip2addr(this, 'f_address', 'f_address');
	//});
	jQuery('.ajaxzip').bind({
		focus: function() {
			//console.info(this);
			this.val = jQuery(this).val();
			//console.info(this.val);
		},
		blur: function() {
			if (this.val != jQuery(this).val()) {
				AjaxZip2.zip2addr(this, 'f_address', 'f_address');
			}
		},
		keyup: function() {
			AjaxZip2.zip2addr(this, 'f_address', 'f_address');
		}
	});
	
});







