clearCookie("part");
setCookie("part","yakumo");


function setCookie(key, val, tmp) {
    tmp = key + "=" + escape(val) + "; ";
    tmp += "path=" + "/script/psi/" + "; ";
    tmp += "expires=Fri, 31-Dec-2030 23:59:59; ";
    document.cookie = tmp;
}

function getCookie(key,  tmp1, tmp2, xx1, xx2, xx3) {
    tmp1 = " " + document.cookie + ";";
    xx1 = xx2 = 0;
    len = tmp1.length;
    while (xx1 < len) {
        xx2 = tmp1.indexOf(";", xx1);
        tmp2 = tmp1.substring(xx1 + 1, xx2);
        xx3 = tmp2.indexOf("=");
        if (tmp2.substring(0, xx3) == key) {
            return(unescape(tmp2.substring(xx3 + 1, xx2 - xx1 - 1)));
        }
        xx1 = xx2 + 1;
    }
    return("");
}

function clearCookie(key) {
    document.cookie = key + "=;expires=1-Jan-1997 00:00:00;";
    return true;
}


function keisan(){
count = 0;
point = 0;

count_x = 0;
point_x = 0;


ck1 = 0;
ck2 = 0;
ck3 = 0;

insi = 1100;
tester = 6300;
kousin = 5250;
syaken = 10290;

if(document.myFORM.elements[0].checked){
jibai = 18980;
jyuryo = 8800;
car_type = "1";
}
if(document.myFORM.elements[1].checked){
jibai = 22470;
jyuryo = 25200;
car_type = "2";
}
if(document.myFORM.elements[2].checked){
jibai = 22470;
jyuryo = 37800;
car_type = "3";
}
if(document.myFORM.elements[3].checked){
jibai = 22470;
jyuryo = 50400;
car_type = "4";
}
if(document.myFORM.elements[4].checked){
jibai = 22470;
jyuryo = 25200;
car_type = "5";
syaken = 13440;
}
if(document.myFORM.elements[5].checked){
jibai = 22470;
jyuryo = 37800;
car_type = "6";
syaken = 13440;
}
if(document.myFORM.elements[6].checked){
jibai = 22470;
jyuryo = 50400;
car_type = "7";
syaken = 13440;
}

basic_total = insi + tester + kousin + syaken + jibai + jyuryo;
price = 0;

if(document.myFORM.set1.checked){
count_x = count_x + 1;
point_x = point_x + 20;
price = price + 0;
ck1 = 1;
}

if(document.myFORM.set2.checked){
count_x = count_x + 1;
point_x = point_x + 15;
price = price + 0;
ck2 = 1;
}

if(document.myFORM.set3.checked){
count_x = count_x + 1;
point_x = point_x + 10;
price = price + 0;
ck3 = 1;
}

if(document.myFORM.set4.checked){
count = count + 1;
point = point + 1;
price = price + 4000;
}

if(document.myFORM.set5.checked){
count = count + 1;
point = point + 2;
if(car_type == "1"){
price = price + 2500;
}
if((car_type == "2") || (car_type == "5")){
price = price + 3000;
}
if((car_type == "3") || (car_type == "6")){
price = price + 3500;
}
if((car_type == "4") || (car_type == "7")){
price = price + 4000;
}
}

if(document.myFORM.set6.checked){
count = count + 1;
point = point + 1;
if(car_type == "1"){
price = price + 2000;
}
if((car_type == "2") || (car_type == "5")){
price = price + 2500;
}
if((car_type == "3") || (car_type == "6")){
price = price + 3500;
}
if((car_type == "4") || (car_type == "7")){
price = price + 4500;
}
}

if(document.myFORM.set7.checked){
count = count + 1;
point = point + 1;
if(car_type == "1"){
price = price + 2500;
}
if((car_type == "2") || (car_type == "5")){
price = price + 3000;
}
if((car_type == "3") || (car_type == "6")){
price = price + 3500;
}
if((car_type == "4") || (car_type == "7")){
price = price + 4000;
}
}

if(document.myFORM.set8.checked){
count = count + 1;
point = point + 1;
if(car_type == "1"){
price = price + 4800;
}
if((car_type == "2") || (car_type == "5")){
price = price + 6800;
}
if((car_type == "3") || (car_type == "6")){
price = price + 7500;
}
if((car_type == "4") || (car_type == "7")){
price = price + 9500;
}
}

if(document.myFORM.set9.checked){
count = count + 1;
point = point + 1;
price = price + 2400;
}

if(document.myFORM.set10.checked){
count = count + 1;
point = point + 1;
price = price + 4500;
}

if(document.myFORM.set11.checked){
count = count + 1;
point = point + 1;
price = price + 2400;
}

if(document.myFORM.set12.checked){
count = count + 1;
point = point + 1;
price = price + 3600;
}

if(document.myFORM.set13.checked){
count = count + 1;
point = point + 2;
if(car_type == "1"){
price = price + 11000;
}
if((car_type == "2") || (car_type == "5")){
price = price + 13000;
}
if((car_type == "3") || (car_type == "6")){
price = price + 13000;
}
if((car_type == "4") || (car_type == "7")){
price = price + 16000;
}
}

if(document.myFORM.set14.checked){
count = count + 1;
point = point + 2;
if(car_type == "1"){
price = price + 10000;
}
if((car_type == "2") || (car_type == "5")){
price = price + 11000;
}
if((car_type == "3") || (car_type == "6")){
price = price + 13000;
}
if((car_type == "4") || (car_type == "7")){
price = price + 14000;
}
}

if(document.myFORM.set15.checked){
count = count + 1;
point = point + 2;
if(car_type == "1"){
price = price + 11000;
}
if((car_type == "2") || (car_type == "5")){
price = price + 12000;
}
if((car_type == "3") || (car_type == "6")){
price = price + 13000;
}
if((car_type == "4") || (car_type == "7")){
price = price + 14000;
}
}

if(document.myFORM.set16.checked){
count = count + 1;
point = point + 2;
if(car_type == "1"){
price = price + 9000;
}
if((car_type == "2") || (car_type == "5")){
price = price + 12000;
}
if((car_type == "3") || (car_type == "6")){
price = price + 15000;
}
if((car_type == "4") || (car_type == "7")){
price = price + 19000;
}
}




if((ck1 == 1) && (ck2 == 1)){
alert("車検予約はどちらか一つをお選び下さい。");
return false();
}

if((ck2 == 1) && (ck3 == 1)){
alert("車検予約はどちらか一つをお選び下さい。");
return false();
}

if((ck1 == 1) && (ck3 == 1)){
alert("車検予約はどちらか一つをお選び下さい。");
return false();
}

waribiki = 0;
waribiki = count * point * 100 + count_x * point_x * 100;
document.myFORM.discount.value = waribiki;
document.myFORM.jibai.value = jibai;
document.myFORM.jyuryo.value = jyuryo;
document.myFORM.insi.value = insi;
document.myFORM.tester.value = tester;
document.myFORM.kousin.value = kousin;
document.myFORM.syaken.value = syaken;
document.myFORM.total.value = basic_total;
document.myFORM.set_price.value = price;
price = basic_total + price - waribiki;
document.myFORM.sototal.value = price;

}