// JavaScript Document
if (document.domain.match(/192.168/i) === null) {
	var webroot = "";
} else {
	var webroot = "/pp";	
}
$(function() {
	// ロールオーバー
	$(".rollover").rollover();
	$("#headerMenu img").rollover();
	// フォーム装飾
	$(':text, :password, textarea').addClass('formInputDecoration');
	// templateA装飾
	$('.templateA table.form tr:last').attr("style", "border: none;");
	// colorbox(ポップアップウィンドウ)
	$("a.colorbox").colorbox({
		close:"閉じる",
		speed:500
	});
	// colorbox(iframe)
	$("a.iframe").colorbox({
		width:"760",
		height:"80%",
		iframe:true
	});
	//　ヘッダログイン 
	
	// ツールチップ
	// トップ
	$('#headerLinkTop').qtip({
		content: '<div class="tooltip">ぴよぴよプラザ<br />トップページへのリンクです。</div>',
		position: {
			corner: {
				target: "topMiddle",
				tooltip: "bottomMiddle"
			}
		},
		style: {
			border: {
				radius: 4,
				color: "#FFAF36"
			},
			tip: "bottomMiddle"
		},
		show: 'mouseover',
		hide: 'mouseout'
	});
	// お試し作成
	$('#headerLinkDemo').qtip({
		content: '<div class="tooltip">お子様の写真やお好きなメッセージを登録して、実際のご注文と同じように赤ちゃんプリントのデザインをお試しいただけます。<br />お気に入りのデザインができるまで何度もお試しいただけるうえ、お試しのデザインでそのままご注文することも可能です。</div>',
		position: {
			corner: {
				target: "topMiddle",
				tooltip: "bottomMiddle"
			}
		},
		style: {
			border: {
				radius: 4,
				color: "#FFAF36"
			},
			tip: "bottomMiddle"
		},
		show: 'mouseover',
		hide: 'mouseout'
	});
	// お買い物ガイド
	$('#headerLinkShoppingGuide').qtip({
		content: '<div class="tooltip">赤ちゃんプリントのお買い物の方法をステップごとに、お客様の操作手順にしたがって解説しております。</div>',
		position: {
			corner: {
				target: "topMiddle",
				tooltip: "bottomMiddle"
			}
		},
		style: {
			border: {
				radius: 4,
				color: "#FFAF36"
			},
			tip: "bottomMiddle"
		},
		show: 'mouseover',
		hide: 'mouseout'
	});
	// ご購入の前にお読みください
	$('#headerLinkBeforePurchase').qtip({
		content: '<div class="tooltip">ご購入いただく前にあらかじめお知らせしたいことが書いてあります。<br />こちらのページからも赤ちゃんプリントをお買い求めいただけます。</div>',
		position: {
			corner: {
				target: "topMiddle",
				tooltip: "bottomMiddle"
			}
		},
		style: {
			border: {
				radius: 4,
				color: "#FFAF36"
			},
			tip: "bottomMiddle"
		},
		show: 'mouseover',
		hide: 'mouseout'
	});
	// よくいただくご質問
	$('#headerLinkFaq').qtip({
		content: '<div class="tooltip">お客様からよくいただくご質問をＱ＆Ａ形式でご紹介しております。<br />ご希望の回答がない場合にはお問い合わせフォームへのリンク、または専用フリーダイヤルの番号を記載しておりますのでお気軽にお問い合わせください。</div>',
		position: {
			corner: {
				target: "topMiddle",
				tooltip: "bottomMiddle"
			}
		},
		style: {
			border: {
				radius: 4,
				color: "#FFAF36"
			},
			tip: "bottomMiddle"
		},
		show: 'mouseover',
		hide: 'mouseout'
	});
	// 送料・配送方法について
	$('#headerLinkDelivery').qtip({
		content: '<div class="tooltip">都道府県別の送料一覧、配送時間について解説しております。</div>',
		position: {
			corner: {
				target: "topMiddle",
				tooltip: "bottomMiddle"
			}
		},
		style: {
			border: {
				radius: 4,
				color: "#FFAF36"
			},
			tip: "bottomMiddle"
		},
		show: 'mouseover',
		hide: 'mouseout'
	});
	//お問い合わせ
	$('#headerLinkInquiry').qtip({
		content: '<div class="tooltip">当店へのお問い合わせフォームです。マイページにログインすると入力項目のお客様情報が自動的に入力されるので便利です。</div>',
		position: {
			corner: {
				target: "topMiddle",
				tooltip: "bottomMiddle"
			}
		},
		style: {
			border: {
				radius: 4,
				color: "#FFAF36"
			},
			tip: "bottomMiddle"
		},
		show: 'mouseover',
		hide: 'mouseout'
	});
	// table.roundedForm tr.hoverに色付
	$("table.roundedForm tr").hover(
		function(){
			$(this).addClass("hover");
		},
		function(){
			$(this).removeClass("hover");
		}
	);
});

/* 関数群
--------------------------------------------------*/
/**
 * [関数名] isNum
 * [機　能] 数値チェック（文字コードでチェック）
 * [説　明] 数値（0-9）かどうか文字コードで調べる
 * [引　数]
 * @param obj テキストボックスオブジェクト
 * [返り値]
 * @return true(含まれていない) | false(含まれている)
*/
function isNum(str){
	for(var i=0 ; i<str.length; i++){
		var code=str.charCodeAt(i);
		if ((48>code || code>57)){
			/* 数値（0-9）以外の文字コード範囲 */
			return false;
		}
	}
	return true;
}

// 文字列 str 中に含まれる半角数字を全角に。
function toZenkaku(str) {
	return str.replace(/\d/g, function(str){return String.fromCharCode(str.charCodeAt(0)+65248);});
}
// 文字列 str 中に含まれる全角数字を半角に。
function toHankaku(str) {
	return str.replace(/[０-９]/g, function(str){return String.fromCharCode(str.charCodeAt(0)-65248);});
}