$(document).ready(function(){
	$("#g_navi li").hover(
		function(){
			$("ul", this).fadeIn("fast");
			ulHeight = $("ul", this).height() - 5;
			$("iframe", this).height(ulHeight);
			$("iframe", this).fadeIn("fast");
		}, 
		function(){
			$("ul", this).fadeOut("fast");
			$("iframe", this).fadeOut("fast");
		} 
	);
	if (document.all){
		$("#g_navi li").hoverClass ("sfHover");
	}
});

$.fn.hoverClass = function(c){
	return this.each(function(){
		$(this).hover( 
			function(){$(this).addClass(c);},
			function(){$(this).removeClass(c);}
		);
	});
};
$(function(){
	//チェックボックスにクリックイベントを設定
	$("input:checkbox[name^='itemchk']").click(function(){
		//チェックされている数を取得
		cnum = $("input:checkbox[name^='itemchk']:checked").length;
		//チェック上限を３つに設定
		if(cnum > 3){
		//チェックを入れても外してもイベントが発生するので
		//現在チェックが入っている場合のみアラートを表示（チェックを入れた場合）
		if (this.checked){
			alert('資料請求は一度に3商品までになります');
			return false;
		}else{
			return true;
		}
	}
	return true;
	});
	
	//クエスチョン用のツールチップ
	$('a.qtip').qtip({
		content: '<p>別ウィンドウで開きます</p>',
		show: 'mouseover',
		hide: 'mouseout',
		style:{
			border:{
				color: '#999'
			}
		}
	});
	
//	if(document.all){
//		viewHeight = document.body.clientHeight;
//	} else if(document.layers || document.getElementById){
//		viewHeight = innerHeight;
//	}
//	
//	alert(viewHeight);
});

function cldiv(target){
	$(target).hide();
};

function opdiv(target){
	$(target).show();
}

function numchk(){
	if( $(".numchk").val().match(/[^0-9]+/) ){
		window.alert('数字以外が入力されています。');
	} else if( $(".numchk").val() == "" && $(".sexchk").val() == "" ){
		window.alert('年齢・性別が入力されていません。');
	} else if( $(".numchk").val() == "" ){
		window.alert('年齢が入力されていません。');
	} else if( $(".sexchk").val() == "" ){
		window.alert('性別が入力されていません。');
	} else{
		return true;
	};
	return false;
}

//new window
$(function(){
	$(".open_win").click(function(){
		var url = $(this).attr("href");
		window.open(url,'window','');return false;
	});
});

//new window 個別商品
$(function(){
	$(".open_win1").click(function(){
		var url = $(this).attr("href");
		window.open(url,'window1','toolbar=no,location=no,dirctory=no,status=yes,menubar=no,scrollbars=yes,resizable,width=665,height=475');return false;
	});
});

//new window 会社情報
$(function(){
	$(".open_win2").click(function(){
		var url = $(this).attr("href");
		window.open(url,'window2','toolbar=no,location=no,dirctory=no,status=yes,menubar=no,scrollbars=yes,resizable,width=665,height=500');return false;
	});
});

//new window 規約関連
$(function(){
	$(".open_win3").click(function(){
		var url = $(this).attr("href");
		window.open(url,'window3','toolbar=no,location=no,dirctory=no,status=yes,menubar=no,scrollbars=yes,resizable,width=680,height=475');return false;
	});
});

//new window 一分診断
$(function(){
	$(".open_win4").click(function(){
		var url = $(this).attr("href");
		window.open(url,'window4','toolbar=no,location=no,dirctory=no,status=no,menubar=no,scrollbars=no,resizable,width=380,height=370');return false;
	});
});

//new window 詳細診断
$(function(){
	$(".open_win5").click(function(){
		var url = $(this).attr("href");
		window.open(url,'window5','toolbar=no,location=no,dirctory=no,status=yes,menubar=no,scrollbars=yes,resizable,width=700,height=500');return false;
	});
});

$(function(){
	$(".open_win6").click(function(){
		var url = $(this).attr("href");
		window.open(url,'window6','toolbar=no,location=no,dirctory=no,status=yes,menubar=no,scrollbars=yes,resizable,width=770,height=542');return false;
	});
});

$(function(){
	$(".pop_link").click(function(){
		var url = $(this).attr("href");
		if(!window.opener || window.opener.closed){
			window.alert('操作元ウィンドウが存在しないため、ウィンドウ内で遷移します');
			window.location.href = url;
		} else{
			window.opener.location.href = url;
			window.close();
		}
		return false;
	});
});

