﻿$(document).ready(function() {
	$(".checklist input:checked").parent().addClass("selected");
	$(".checklist .checkbox-select").click(
		function(event) {
			event.preventDefault();
			var context=$(this).parent().addClass("selected");
			$(this).parent().find(":checkbox").attr("checked","checked");

			/* 画像の切替 */
			if($(this).parent().find(":checkbox").attr("id") =='1'){
				$("#1st").attr("src","img/btn/Demand_1_select.png");
				$("#arrow_1st").attr("src","img/btn/Demand_arrow_on.png");
			}else if($(this).parent().find(":checkbox").attr("id") =='2'){
				$("#2nd").attr("src","img/btn/Demand_2_select.png");
				$("#arrow_2nd").attr("src","img/btn/Demand_arrow_on.png");
			}else if($(this).parent().find(":checkbox").attr("id") =='3'){
				$("#3rd").attr("src","img/btn/Demand_3_select.png");
				$("#arrow_3rd").attr("src","img/btn/Demand_arrow_on.png");
			}else if($(this).parent().find(":checkbox").attr("id") =='4'){
				$("#4th").attr("src","img/btn/Demand_4_select.png");
				$("#arrow_4th").attr("src","img/btn/Demand_arrow_on.png");
			}
			cnum = $("input:checkbox[@name='check']:checked").length;
			if(cnum==4){
				var timestamp = new Date().getTime();
				$("#checkDemand1").attr("src","img/btn/DemandPage_on.png")+'?'+timestamp;
				$("#checkDemand2").attr("src","img/btn/DemandPage_on.png")+'?'+timestamp;
				$("#checkDemand1").mouseover(function(){
					this.style.cursor="hand";
				});
				$("#checkDemand2").mouseover(function(){
					this.style.cursor="hand";
				});
			}
		}
	);
	$(".onDemand").click(
		function(event) {
			cnum = $("input:checkbox[@name='check']:checked").length;
			if(cnum==4){
				window.location=("contents/demand.html");
			}
		}
		
	);
	$(".Demand_off").click(
		function(event) {
			cnum = $("input:checkbox[@name='check']:checked").length;
			if(cnum==4){
				window.location=("contents/demand.html");
			}else{
				if(confirm("お手数ですが４つのチェック項目をクリックしてから\nお申込みフォームへお進み下さい")){
					window.location=("index.html#move_point");
				}
			}
		}
	);
/*
	$(".checklist .checkbox-deselect").click(
		function(event) {
			event.preventDefault();
			$(this).parent().removeClass("selected");
			$(this).parent().find(":checkbox").removeAttr("checked");
			cnum = $("input:checkbox[@name='check']:checked").length;
			if(cnum!=4){
				$("#checkDemand1").attr("src","img/btn/Disable_DemandPage.png");
				$("#checkDemand2").attr("src","img/btn/Disable_DemandPage.png");
			}
		}
	);
*/
	
});
