function calcTotal(){

	base = removeComma(document.form1.txtBase.value);
	topBanner = removeComma(document.form1.txtTopBanner.value);
	flash = removeComma(document.form1.txtFlash.value);
	menu = removeComma(document.form1.txtMenu.value);
	menuIcon = removeComma(document.form1.txtMenuIcon.value);
	interview = removeComma(document.form1.txtInterview.value);
	page = removeComma(document.form1.txtPage.value);
	pageNum = removeComma(document.form1.optPage.value);
	background = removeComma(document.form1.txtBackground.value);
	icon = removeComma(document.form1.txtIcon.value);
	iconNum = removeComma(document.form1.optIcon.value);

	total = eval(base);

	if (document.form1.chkTopBanner.checked) {
		total = total + eval(topBanner);
	}

	if (document.form1.chkFlash.checked) {
		total = total + eval(flash);
	}

	if (document.form1.chkMenu.checked) {
		total = total + eval(menu);
	}

	if (document.form1.chkMenuIcon.checked) {
		total = total + eval(menuIcon);
	}

	if (document.form1.chkInterview.checked) {
		total = total + eval(interview);
	}

	if (document.form1.chkPage.checked) {
		total = total + (eval(page) * eval(pageNum));
	}

	if (document.form1.chkBackground.checked) {
		total = total + eval(background);
	}

	if (document.form1.chkIcon.checked) {
		total = total + (eval(icon) * eval(iconNum));
	}

	document.form1.txtTotal.value = addComma(total);
	document.form1.txtTax.value = addComma(total * 0.05);
	document.form1.txtTotalTax.value = addComma(total * 1.05);
}

function addComma(value){
    var i;
		value = ""+value;
    for(i = 0; i < value.length/3; i++){
        value = value.replace(/^([+-]?\d+)(\d\d\d)/,"$1,$2");
    }
    return value;
}

function removeComma(value) {
    return value.split(",").join("");
}

function changeTopBanner(){

	if (!document.form1.chkTopBanner.checked) {
		document.form1.chkFlash.checked = false;
	}
}

function changeFlash(){

	if (document.form1.chkFlash.checked) {
		document.form1.chkTopBanner.checked = true;
	}
}

function changeMenu(){

	if (!document.form1.chkMenu.checked) {
		document.form1.chkMenuIcon.checked = false;
	}
}

function changeMenuIcon(){

	if (document.form1.chkMenuIcon.checked) {
		document.form1.chkMenu.checked = true;
	}
}

function changePage(){

	document.form1.chkPage.checked = true;
}

function changeIcon(){

	document.form1.chkIcon.checked = true;
}

function checkInput(){

	if (document.form1.txtTotalTax.value == ""){

		alert("お申し込み内容を選択してください。");
		return false;
	}

	if (document.form1.userName.value == ""){

		alert("お名前を入力してください。");
		document.form1.userName.focus();
		return false;
	}

	if (document.form1.userEmail.value == ""){

		alert("メールアドレスを入力してください。");
		document.form1.userEmail.focus();
		return false;
	}

	if (!confirm("申し込みメールを送信します。よろしいですか？\n\n※この申し込みで契約が確定するわけではありません。")){
		return false;
	}

	return true;
}

