function calculateFees() { var regForm = document.forms["registration"]; var isInvitedSpeaker = ( regForm["contribution"].selectedIndex == 0 ); // --- people --- var peopleCount = 1; peopleCount += regForm["accompanying"].selectedIndex; if ( isInvitedSpeaker ) { peopleCount -= 1; } var regFee = 380 * peopleCount; // EUR // --- days --- var dayCount = { "smolenice" : 0, "bratislava": 0 }; if ( regForm["smolenice25"].checked ) { ++dayCount["smolenice"]; } if ( regForm["smolenice26"].checked ) { ++dayCount["smolenice"]; } if ( regForm["smolenice27"].checked ) { ++dayCount["smolenice"]; } if ( regForm["smolenice28"].checked ) { ++dayCount["smolenice"]; } // --- rooms --- var roomFees = { "smolenice" : 0, "bratislava": 0 }; // smolenice room fee switch ( regForm["accommodation"].selectedIndex ) { // suite case 1: if ( isInvitedSpeaker ) { var peopleCountTmp = (peopleCount + 1); if ( peopleCountTmp >= 2 ) { // 1+1 for 40, rest for 80 roomFees["smolenice"] = 40 + Math.ceil(Math.max(0, (peopleCountTmp - 2)) / 2) * 120; } else { roomFees["smolenice"] = 0; } } else { roomFees["smolenice"] = Math.ceil(peopleCount / 2) * 120; } break; // double bed room case 2: roomFees["smolenice"] = peopleCount * 35; break; // 3 bed room case 3: roomFees["smolenice"] = peopleCount * 30; break; } roomFees["smolenice"] *= dayCount["smolenice"]; // bratislava room fee switch ( regForm["accommodation_ba"].selectedIndex ) { // suite case 1: if ( isInvitedSpeaker ) { var peopleCountTmp = (peopleCount + 1); if ( peopleCountTmp >= 2 ) { // 1+1 for 40, rest for 80 roomFees["bratislava"] = 40 + Math.ceil(Math.max(0, (peopleCountTmp - 2)) / 2) * 75; } else { roomFees["bratislava"] = 0; } } else { roomFees["bratislava"] = Math.ceil(peopleCount / 2) * 75; } break; // double bed room case 2: roomFees["bratislava"] = peopleCount * 37.5; break; } // --- summary --- payment = regFee + (roomFees["smolenice"] + roomFees["bratislava"]); // debugging info // alert( // "people count: " + peopleCount // + "\nroom fee: smolenice-" + roomFees["smolenice"] + ", bratislava-" + roomFees["bratislava"] // + "\ndays: smolenice-" + dayCount["smolenice"] + ", bratislava-" + dayCount["bratislava"] // + "\nregistration fee: " + regFee // + "\ntotal: " + payment); regForm["sum"].value = payment; }