jQuery(function(){
	if (document.URL.match(/localhost(.*)PC/)) {
		s_root = document.URL.replace(/(.*?\/)design\/.*/, '$1www/html/');
	}
	else if (document.URL.match('/localhost/')) {
		s_root = document.URL.replace(/(.*?\/html\/).*/, '$1');
	}
	else {
		s_root = '/';
	}
	
	
	//IE6.0のみpingfix
	if ($.browser.version == '6.0') {
		$("img[src*='.png'], input[type='image'][src*='.png']")
			.css('behavior', 'url("' + s_root + 'js/iepngfix.htc")')
		;
		
//		$("div , h1 , h2 , h3 , h4 , h5 , p , ul , li , dl , dt , dd , table , th , td")
		$("div , h1 , h2 , h3 , h4 , h5 , p , ul , li , dl , dt , dd , table , th , td")
			.each(
				function () {
					if ($(this).css('background-image').match('\.png')) {
						$(this)
							.css('behavior', 'url("' + s_root + 'js/iepngfix.htc")')
						;
					}
				}
			)
		;
	}
	//ホバー関連
	$("img[src*='/off/'], input[type='image'][src*='/off/']")
		.hover(
			function () {
				$(this).attr("src", $(this).attr("src").replace('/off/', '/on/'));
			},
			function () {
				$(this).attr("src", $(this).attr("src").replace('/on/', '/off/'));
			}
		)
	;
	//背景画像のホバー
	$(".bg-hover")
		.hover(
			function () {
				$(this).css("background-image", $(this).css("background-image").replace('/off/', '/on/'));
			},
			function () {
				$(this).css("background-image", $(this).css("background-image").replace('/on/', '/off/'));
			}
		)
	;
	
	//登録フォームのやつ
	$("input[value*='メールアドレスを入力してください']")
		.focus(
			function () {
				$(this).val('');
			}
		)
	;
	
	//フッターリンクのポップアップ
	$("#footer ul li a, .subsizePopup, .check a")
		.click(
			function() {
				if ($(this).attr('title') == 'HOME') {
					return true;
				}
				//uriを取得
				var uri = $(this).attr("href");
				
				//ウインドウを立ち上げる
				obj = window.open(uri, "subsize", "directories=0,location=0,menubar=0,status=0,toolbar=0,resizeable=0,width=530,height=680");
				obj.focus();
				return false;
			}
		)
	;
	
	//サブサイズ閉じるボタン
	$(".subsize img[alt='閉じる']")
		.css("cursor","pointer")
		.click(
			function () {
				window.close();
			}
		)
	;
	
	//--------------------------------------------------------------------------------
	// メールアドレス入力テキストフィールド用処理
	//--------------------------------------------------------------------------------
	
	//初期値の場合はグレーアウト
	if ($("input:text[name='u[email]']").val() == 'メールアドレスを入力して下さい') {
		$("input:text[name='email']").css('color', '#999');
	}
	//登録テキストフィールド初期化処理
	$("input:text[name='u[email]']")
		.focus(
			function () {
				if ($(this).val() == 'メールアドレスを入力して下さい') {
					$(this).val('');
				}
			}
		)
		.blur(
			function() {   
				if ($(this).val()=='') {
					$(this).val('メールアドレスを入力して下さい')
				}   
			}
		)
	;
	//登録テキストフィールド初期化処理
	$("input:text[name='c[email]']")
		.focus(
			function () {
				if ($(this).val() == 'メールアドレスを入力して下さい') {
					$(this).val('');
				}
			}
		)
		.blur(
			function() {   
				if ($(this).val()=='') {
					$(this).val('メールアドレスを入力して下さい')
				}   
			}
		)
	;
	// 外部リンクのアンカーが押された場合新規ウインドウ
	$("* a")
		.click(
			function () {
				if ($(this).attr('title') == 'HOME') {
					return true;
				}
				//URLを取得
				var uri = $(this).attr("href").match(/^https?:\/\/.*$/);
				//もし外部リンクの場合はポップアップ
				if (uri) {
					obj = window.open(uri, "_blank");
					obj.focus();
					return false;
				}
				else {
					return true;
				}
			}
		)
	;

	// regist input
	$("body#index #regist dd.registBtn input")
		.hover(
			function () {
				$(this).attr("src", 'img/index/regist_btn_on.png');
			},
			function () {
				$(this).attr("src", 'img/index/regist_btn.png');
			}
		)
	;
	
	
		$("body.subsize #footer p img")
		.hover(
			function () {
				$(this).attr("src", 'img/subsize/close_btn_on.gif');
			},
			function () {
				$(this).attr("src", 'img/subsize/close_btn.gif');
			}
		)
	;
	
		$("body#contact #contents dd input")
		.hover(
			function () {
				$(this).attr("src", 'img/subsize/contact_btn_on.gif');
			},
			function () {
				$(this).attr("src", 'img/subsize/contact_btn.gif');
			}
		)
	;

});

