//
//Copyright (C) 2006 Aifer Web Service,Inc.
//
var aRequestCount=315;
var aOptionCategory=210;
var aOptionKeyword=315;
var aOptionYahoo=210;
var aOptionAffiliate=105;
function calculate(){
	formDisable();
	var count=document.F.requestCount.value;
	{
		var sc=document.getElementById("requestCountSC");
		sc.innerHTML="<span style=\"color:red;font-size:12pt;font-weight:bold;\">"+calcRequestCount()+"</span>円";
	}
	{
		var rc=document.getElementById("optionCategoryRC");
		rc.innerHTML="<span style=\"color:red\">"+count+"</span>件×"+aOptionCategory+"円";
		var sc=document.getElementById("optionCategorySC");
		sc.innerHTML="<span style=\"color:red;font-size:12pt;font-weight:bold;\">"+calcOptionCategory()+"</span>円";
	}
	{
		var rc=document.getElementById("optionKeywordRC");
		rc.innerHTML="<span style=\"color:red\">"+count+"</span>件×"+aOptionKeyword+"円";
		var sc=document.getElementById("optionKeywordSC");
		sc.innerHTML="<span style=\"color:red;font-size:12pt;font-weight:bold;\">"+calcOptionKeyword()+"</span>円";
	}
	{
		var rc=document.getElementById("optionYahooRC");
		rc.innerHTML="<span style=\"color:red\">"+count+"</span>件×"+aOptionYahoo+"円";
		var sc=document.getElementById("optionYahooSC");
		sc.innerHTML="<span style=\"color:red;font-size:12pt;font-weight:bold;\">"+calcOptionYahoo()+"</span>円";
	}
	{
		var rc=document.getElementById("optionAffiliateRC");
		rc.innerHTML="<span style=\"color:red\">"+count+"</span>件×"+aOptionAffiliate+"円";
		var sc=document.getElementById("optionAffiliateSC");
		sc.innerHTML="<span style=\"color:red;font-size:12pt;font-weight:bold;\">"+calcOptionAffiliate()+"</span>円";
	}
	{
		var sc=document.getElementById("discountQuestionnaireSC");
		sc.innerHTML="<span style=\"color:red;font-size:12pt;font-weight:bold;\">"+calcDiscountQuestionnaire()+"</span>円";
	}
	{
		var sc=document.getElementById("discountToplinkSC");
		sc.innerHTML="<span style=\"color:red;font-size:12pt;font-weight:bold;\">"+calcDiscountToplink()+"</span>円";
	}
	{
		var sc=document.getElementById("calculateAllPriceSC");
		sc.innerHTML="金額合計　<span style=\"color:red;font-size:16pt;font-weight:bold;\">"+alltotal()+"</span> 円";
	}
	document.F.calculateAllPrice.value=alltotal();
}
function formDisable(){
	var keywordlength=document.F.optionKeyword1.value.length+document.F.optionKeyword2.value.length+document.F.optionKeyword3.value.length+document.F.optionKeyword4.value.length+document.F.optionKeyword5.value.length;
	if(keywordlength != 0 && document.F.optionCategory.selectedIndex != 0){
		alert("カテゴリ指定とキーワード指定は同時にお選び頂くことはできません\nカテゴリ指定とキーワード指定の内容をリセットします");
		document.F.optionCategory.selectedIndex=0;
		document.F.optionKeyword1.value="";
		document.F.optionKeyword2.value="";
		document.F.optionKeyword3.value="";
		document.F.optionKeyword4.value="";
		document.F.optionKeyword5.value="";
	}
}
function calcRequestCount(){
	return parseInt(document.F.requestCount.value)*aRequestCount;
}
function calcOptionCategory(){
	if(document.F.optionCategory.value == ""){
		return 0;
	}else{
		return parseInt(document.F.requestCount.value)*aOptionCategory;
	}
}
function calcOptionKeyword(){
	var keywordlength=document.F.optionKeyword1.value.length+document.F.optionKeyword2.value.length+document.F.optionKeyword3.value.length+document.F.optionKeyword4.value.length+document.F.optionKeyword5.value.length;
	if(keywordlength == 0){
		return 0;
	}else{
		return parseInt(document.F.requestCount.value)*aOptionKeyword;
	}
}
function calcOptionYahoo(){
	if(document.F.optionYahoo[1].checked){
		return parseInt(document.F.requestCount.value)*aOptionYahoo;
	}else{
		return 0;
	}
}
function calcOptionAffiliate(){
	if(document.F.optionAffiliate[1].checked){
		return parseInt(document.F.requestCount.value)*aOptionAffiliate;
	}else{
		return 0;
	}
}
function calcOptionServiceTotal(){
	//2008.10.24 仮設置
	var calc=0;
	if(document.F.optionService[1].checked){
		calc+=52500;
		var sc=document.getElementById("optionServiceSC1");
		sc.innerHTML="<span style=\"color:red;font-size:12pt;font-weight:bold;\">52500</span>円";
	}else{
		var sc=document.getElementById("optionServiceSC1");
		sc.innerHTML="<span style=\"color:red;font-size:12pt;font-weight:bold;\">0</span>円";
	}
	
	if(document.F.optionService[2].checked){
		calc+=21000;
		var sc=document.getElementById("optionServiceSC2");
		sc.innerHTML="<span style=\"color:red;font-size:12pt;font-weight:bold;\">21000</span>円";
	}else{
		var sc=document.getElementById("optionServiceSC2");
		sc.innerHTML="<span style=\"color:red;font-size:12pt;font-weight:bold;\">0</span>円";
	}
	
	if(document.F.optionService[3].checked){
		calc+=31500;
		var sc=document.getElementById("optionServiceSC3");
		sc.innerHTML="<span style=\"color:red;font-size:12pt;font-weight:bold;\">31500</span>円";
	}else{
		var sc=document.getElementById("optionServiceSC3");
		sc.innerHTML="<span style=\"color:red;font-size:12pt;font-weight:bold;\">0</span>円";
	}
	return calc;
}

function subtotal(){
	return calcRequestCount()+calcOptionCategory()+calcOptionKeyword()+calcOptionYahoo()+calcOptionAffiliate()+calcOptionServiceTotal();
}
function calcDiscountQuestionnaire(){
	if(document.F.discountQuestionnaire.checked){
		return parseInt(-subtotal()*0.05);
	}else{
		return -0;
	}
}
function calcDiscountToplink(){
	if(document.F.discountToplink.checked){
		return parseInt(-subtotal()*0.15);
	}else{
		return -0;
	}
}
function alltotal(){
	return subtotal()+calcDiscountQuestionnaire()+calcDiscountToplink();
}

