"; calcboxHTML += "\n"; calcboxHTML += "\n"; calcboxHTML += "\n"; calcboxHTML += "\n"; calcboxHTML += "\n noEnrolmentFeePromotion = new Array(); noEnrolmentFeePromotion["Barcelona"] = false; noEnrolmentFeePromotion["Madrid"] = false; noEnrolmentFeePromotion["Seville"] = false; noEnrolmentFeePromotion["Valencia"] = false; noEnrolmentFeePromotion["Malaga"] = false; noEnrolmentFeePromotion["Buenos Aires"] = false; noEnrolmentFeePromotion["Playa del Carmen"] = false; noEnrolmentFeePromotion["Turrialba"] = false; noEnrolmentFeePromotion["Playa Dominical"] = false; noEnrolmentFeePromotion["Arenal"] = false; noEnrolmentFeePromotion["Tamarindo"] = false; promotionDiscountPercent = new Array(); promotionDiscountPercent["INT"] = {'Barcelona':'0' , 'Madrid':'0' , 'Seville':'0' , 'Valencia':'0'}; promotionDiscountPercent["I20"] = {'Barcelona':'0' , 'Madrid':'0' , 'Seville':'0' , 'Valencia':'0'}; promotionDiscountPercent["SIN"] = {'Barcelona':'0' , 'Madrid':'0' , 'Seville':'0' , 'Valencia':'0'}; xmlHttp = null; courseData = new Object; dates = new Array(); allBoxes = new Array("destinationBox", "courseBox", "signupBox"); courseCodes = new Array("INT", "I20", "SIN", "SAL", "FLM", "EE2", "EE3", "INM", "I05", "I10", "DLP", "EVN", "TNG", "DLX", "IND", "DNC", "MUS"); accommodationCodes = new Array("FBF", "FHB", "FHD", "SRD", "SNG", "DBL", "SPV", "SSH", "SPL", "APT"); currencySymbols = new Object; currencySymbols["EUR"] = "€"; currencySymbols["USD"] = "$"; currencySymbols["GBP"] = "£"; currencySymbols["CAD"] = "c$"; currencySymbols["CHF"] = "Sfr"; currencySymbols["SEK"] = "kr"; currencySymbols["BRL"] = "R$"; currencySymbols["JPY"] = "¥"; months = new Array(); months[1] = "January"; months[2] = "February"; months[3] = "March"; months[4] = "April"; months[5] = "May"; months[6] = "June"; months[7] = "July"; months[8] = "August"; months[9] = "September"; months[10] = "October"; months[11] = "November"; months[12] = "December"; epcLocation = ""; epcLocationText = ""; currencySymbol = currencySymbols["EUR"]; coursePrice = new Object(); courseTotal = 0; enrolmentFee = 0; accommodationTotal = 0; placementFee = 0; totalPrice = 0; advDisc3moPerc = 3; advDisc4moPerc = 6; advDisc5moPerc = 10; bulkDisc12wksPerc = 15; bulkDisc20wksPerc = 15; dlpHardQuantity = 3; evnHardQuantity = 4; rowDelim = "|"; colDelim = "^"; idIdx = 0; codeIdx = 1; nameIdx = 2; familyIdx = 3; currencyIdx = 4; priceIdx = 5; hasInnerText = (document.getElementsByTagName("body")[0].innerText != undefined) ? true : false; /*************************** Data functions ***************************/ // Reference http://www.w3schools.com/ajax/ajax_example_suggest.asp function getXmlHttpObject() { try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } function setCourseData(doUpdateCourseForm, doUpdateCurrencyPrices) { var courseStringData = ""; var rows = new Array(); var cols = new Array(); var row = ""; var epcCode; var epcCodeStrIdx = 0; var idStrIdx = 1; var codeStrIdx = 2; var nameStrIdx = 3; var familyStrIdx = 4; var currencyStrIdx = 5; var priceStrIdx = 6; var locationStrIdx = 7; if (xmlHttp.readyState==4) { courseStringData=xmlHttp.responseText; rows = courseStringData.split(rowDelim); courseData = new Object; // Clear any previous data if (rows.length > 0) { for (i in rows) { row = rows[i]; cols = row.split(colDelim); if (cols.length > 0 && isNaN(cols[epcCodeStrIdx])) { epcCode = cols[epcCodeStrIdx]; courseData[epcCode] = new Array(cols[idStrIdx], cols[codeStrIdx], cols[nameStrIdx], cols[familyStrIdx], cols[currencyStrIdx], cols[priceStrIdx]); } } if (doUpdateCourseForm) { updateCourseForm(); updateAccommodationOptions(); if (document.epcForm.is_beginner.selectedIndex > 0) { updateDates(document.epcForm.is_beginner.options[document.epcForm.is_beginner.selectedIndex].value); } /* if (epcLocation == "Barcelona" || epcLocation == "Seville" || epcLocation == "Valencia" || epcLocation == "Madrid") { document.getElementById("adv-disc-box").style.display = ""; } else { document.getElementById("adv-disc-box").style.display = "none"; } */ } if (doUpdateCurrencyPrices) { updateCurrencyPrices(); } } } } function updateCourseData(currency, doUpdateCourseForm, doUpdateCurrencyPrices) { var url = ""; xmlHttp = getXmlHttpObject(); if (xmlHttp == null) { return; } url = "epc_course_data.php?location=" + epcLocation + "¤cy=" + currency; //document.getElementById("test").innerHTML = "" + url + ""; xmlHttp.onreadystatechange=function() { setCourseData(doUpdateCourseForm, doUpdateCurrencyPrices); } xmlHttp.open("GET",url,true); xmlHttp.send(null); } function setDates() { var dateStringData = ""; if (xmlHttp.readyState==4) { dateStringData=xmlHttp.responseText; dates = dateStringData.split(","); updateDateOptions(); } } function updateDates(isBeginnerNum) { var url = ""; var codesArray = new Array(); var i = 0; xmlHttp = getXmlHttpObject(); if (xmlHttp == null) { return; } for (var code in coursePrice) { codesArray[i++] = code; } url = "epc_dates.php?location=" + epcLocation + "&is_beginner=" + isBeginnerNum + "&epc_codes=" + codesArray.join(","); xmlHttp.onreadystatechange=setDates; xmlHttp.open("GET",url,true); xmlHttp.send(null); } /*************************** Calculating functions ***************************/ function updateCourseTotal(code, quantity, subtotal) { courseTotal = 0; if (quantity == null || quantity == 0 || quantity == "" || subtotal == 0) { if (coursePrice[code]) delete coursePrice[code]; } else { coursePrice[code] = new Array(quantity, subtotal); } for (var i in coursePrice) { courseTotal += (+coursePrice[i][1]); } updateEnrolmentFee(); } function updateEnrolmentFee() { if (courseTotal > 0) { if (noEnrolmentFeePromotion[epcLocation]) { enrolmentFee = 0; } else { try { enrolmentFee = courseData["ENR"][priceIdx]; if (isNaN(enrolmentFee) || enrolmentFee == null || enrolmentFee <= 0) enrolmentFee = 0; } catch (e) { enrolmentFee = 0; } } enrolmentFee = (+enrolmentFee); document.getElementById("calcboxRow-ENR").style.display = ""; document.getElementById("subtotal-ENR").innerHTML = currencySymbol + " " + currencyFormat(enrolmentFee); } else { enrolmentFee = 0; document.getElementById("calcboxRow-ENR").style.display = "none"; document.getElementById("subtotal-ENR").innerHTML = "0.00"; } } function updatePlacementFee() { if (accommodationTotal > 0) { try { placementFee = courseData["PLC"][priceIdx]; placementFee = (+placementFee); document.getElementById("calcboxRow-PLC").style.display = ""; document.getElementById("subtotal-PLC").innerHTML = currencySymbol + " " + currencyFormat(placementFee); } catch (e) {} } else { placementFee = 0; document.getElementById("calcboxRow-PLC").style.display = "none"; document.getElementById("subtotal-PLC").innerHTML = "0.00"; } } function updateDiscounts() { // Begin Promotion and Bulk Discounts var thisCourseTotal = 0; var baseCourses = new Array("INT","I20","SIN"); var baseCoursesQuantityTotal = 0; var total20BulkDiscount5pct = 0; var total20BulkDiscount = 0; var total12BulkDiscount = 0; var totalPromotionDiscount = 0; var discountTotal = 0; var isDiscountedLocation = false; var isIntOrSinCourse = false; for (var i in baseCourses) { try { // For now, exclude I20 from any discounts. remove this if statement when done. // if (baseCourses[i] != 'I20') { baseCoursesQuantityTotal += +coursePrice[baseCourses[i]][0]; // } } catch (e) {} } for (var i in baseCourses) { var thisCourse = baseCourses[i]; var thisCoursePromoDiscountPercent = promotionDiscountPercent[thisCourse][epcLocation]; thisCourseTotal = 0; try { thisCourseTotal = +coursePrice[thisCourse][1]; } catch (e) {} // if (thisCourseTotal == 0 || thisCourse == 'I20') { // For now, exclude I20 from any discounts. remove this if statement when done. if (thisCourseTotal == 0) { continue; } if (epcLocation == "Barcelona" || epcLocation == "Seville" || epcLocation == "Valencia" || epcLocation == "Madrid") { isDiscountedLocation = true; } else { isDiscountedLocation = false; } if (thisCourse == 'INT' || thisCourse == 'SIN') { isIntOrSinCourse = true; } else { isIntOrSinCourse = false; } if (isDiscountedLocation && thisCourse == 'I20' && baseCoursesQuantityTotal >= 20 && 5 > thisCoursePromoDiscountPercent) { bulkDiscount = (+thisCourseTotal) * 5 / 100; totalPrice += (-bulkDiscount); total20BulkDiscount5pct += (+bulkDiscount); discountTotal += (+bulkDiscount); } else if (isDiscountedLocation && isIntOrSinCourse && baseCoursesQuantityTotal >= 20 && bulkDisc20wksPerc > thisCoursePromoDiscountPercent) { bulkDiscount = (+thisCourseTotal) * bulkDisc20wksPerc / 100; totalPrice += (-bulkDiscount); total20BulkDiscount += (+bulkDiscount); discountTotal += (+bulkDiscount); } else if (isDiscountedLocation && isIntOrSinCourse && baseCoursesQuantityTotal >= 12 && bulkDisc12wksPerc > thisCoursePromoDiscountPercent) { bulkDiscount = (+thisCourseTotal) * bulkDisc12wksPerc / 100; totalPrice += (-bulkDiscount); total12BulkDiscount += (+bulkDiscount); discountTotal += (+bulkDiscount); } else if (baseCoursesQuantityTotal > 0 && thisCoursePromoDiscountPercent) { promotionDiscount = (+thisCourseTotal) * thisCoursePromoDiscountPercent / 100; totalPrice += (-promotionDiscount); totalPromotionDiscount += (+promotionDiscount); discountTotal += +(promotionDiscount); } /* Original, before isDiscoutedLocation specific change if (baseCoursesQuantityTotal >= 20 && bulkDisc20wksPerc > thisCoursePromoDiscountPercent) { bulkDiscount = (+thisCourseTotal) * bulkDisc20wksPerc / 100; totalPrice += (-bulkDiscount); total20BulkDiscount += (+bulkDiscount); discountTotal += (+bulkDiscount); } else if (baseCoursesQuantityTotal >= 12 && bulkDisc12wksPerc > thisCoursePromoDiscountPercent) { bulkDiscount = (+thisCourseTotal) * bulkDisc12wksPerc / 100; totalPrice += (-bulkDiscount); total12BulkDiscount += (+bulkDiscount); discountTotal += (+bulkDiscount); } else if (baseCoursesQuantityTotal > 0 && thisCoursePromoDiscountPercent) { promotionDiscount = (+thisCourseTotal) * thisCoursePromoDiscountPercent / 100; totalPrice += (-promotionDiscount); totalPromotionDiscount += (+promotionDiscount); discountTotal += +(promotionDiscount); } */ } // End for baseCourses document.getElementById("subtotal-bulk-disc-20-5pct").innerHTML = "0.00"; document.getElementById("calcboxRow-bulk-disc-20-5pct").style.display = "none"; document.getElementById("subtotal-bulk-disc-20").innerHTML = "0.00"; document.getElementById("calcboxRow-bulk-disc-20").style.display = "none"; document.getElementById("subtotal-bulk-disc-12").innerHTML = "0.00"; document.getElementById("calcboxRow-bulk-disc-12").style.display = "none"; document.getElementById("subtotal-promotion").innerHTML = "0.00"; document.getElementById("calcboxRow-promotion").style.display = "none"; if (total20BulkDiscount5pct > 0) { document.getElementById("subtotal-bulk-disc-20-5pct").innerHTML = currencySymbol + " -" + currencyFormat(bulkDiscount); document.getElementById("calcboxRow-bulk-disc-20-5pct").style.display = ""; } if (total20BulkDiscount > 0) { document.getElementById("subtotal-bulk-disc-20").innerHTML = currencySymbol + " -" + currencyFormat(total20BulkDiscount); document.getElementById("calcboxRow-bulk-disc-20").style.display = ""; } if (total12BulkDiscount > 0) { document.getElementById("subtotal-bulk-disc-12").innerHTML = currencySymbol + " -" + currencyFormat(total12BulkDiscount); document.getElementById("calcboxRow-bulk-disc-12").style.display = ""; } if (totalPromotionDiscount > 0) { document.getElementById("subtotal-promotion").innerHTML = currencySymbol + " -" + currencyFormat(totalPromotionDiscount); document.getElementById("calcboxRow-promotion").style.display = ""; } // End Promotion and Bulk Dicounts // **************************************** // Begin Advanced Dicounts /* Disable Advanced Discounts var advDisc3mo = ""; var advDisc4mo = ""; var advDisc5mo = ""; var today = new Date(); var currYear = today.getFullYear(); var currMonth = today.getMonth() + 1; var currDay = today.getDate(); var startDate = document.epcForm.start_date.options[document.epcForm.start_date.selectedIndex].value; var dateArray = new Array(); var startYear = 0; var startMonth = 0; var startDay = 0; var monthDiff = 0; if (epcLocation != "Barcelona" && epcLocation != "Seville" && epcLocation != "Valencia" && epcLocation != "Madrid") return false; if (totalPrice <= 0) { document.getElementById("adv-disc-3mo").innerHTML = ""; document.getElementById("adv-disc-4mo").innerHTML = ""; document.getElementById("adv-disc-5mo").innerHTML = ""; return; } // Discount only applied to tuition advDisc3mo = ( (+courseTotal) - (+discountTotal) ) * advDisc3moPerc / 100; advDisc4mo = ( (+courseTotal) - (+discountTotal) ) * advDisc4moPerc / 100; advDisc5mo = ( (+courseTotal) - (+discountTotal) ) * advDisc5moPerc / 100; document.getElementById("subtotal-adv-disc-3mo").innerHTML = currencySymbol + " -" + currencyFormat(advDisc3mo); document.getElementById("subtotal-adv-disc-4mo").innerHTML = currencySymbol + " -" + currencyFormat(advDisc4mo); document.getElementById("subtotal-adv-disc-5mo").innerHTML = currencySymbol + " -" + currencyFormat(advDisc5mo); document.getElementById("calcboxRow-adv-disc-3mo").style.display = "none"; document.getElementById("calcboxRow-adv-disc-4mo").style.display = "none"; document.getElementById("calcboxRow-adv-disc-5mo").style.display = "none"; if (startDate == null || startDate == "") return; dateArray = startDate.split("-"); startYear = dateArray[0]; startMonth = dateArray[1]; startDay = dateArray[2]; monthDiff = ((startYear - currYear) * 12) + (startMonth - currMonth) - (startDay < currDay ? 1 : 0); if (monthDiff >= 5) { document.getElementById("calcboxRow-adv-disc-5mo").style.display = ""; totalPrice += (-advDisc5mo); } else if (monthDiff >= 4) { document.getElementById("calcboxRow-adv-disc-4mo").style.display = ""; totalPrice += (-advDisc4mo); } else if (monthDiff >= 3) { document.getElementById("calcboxRow-adv-disc-3mo").style.display = ""; totalPrice += (-advDisc3mo); } */ // End Advance Discount disable // End Advanced Dicounts } function updatePromotion() { if (!promotionDiscountPercent[epcLocation]) return false; var intensiveQuantity = 0; var superIntensiveQuantity = 0; var intensiveTotal = 0; var superIntensiveTotal = 0; var baseCoursesQuantityTotal = 0; var baseCoursesTotal = 0; var promotionDiscount = 0; document.getElementById("subtotal-promotion").innerHTML = "0.00"; document.getElementById("calcboxRow-promotion").style.display = "none"; try { intensiveQuantity = coursePrice["INT"][0]; intensiveTotal = coursePrice["INT"][1]; } catch (e) {} try { superIntensiveQuantity = coursePrice["SIN"][0]; superIntensiveTotal = coursePrice["SIN"][1]; } catch (e) {} baseCoursesQuantityTotal = (+intensiveQuantity) + (+superIntensiveQuantity); baseCoursesTotal = (+intensiveTotal) + (+superIntensiveTotal); document.getElementById("subtotal-promotion").innerHTML = "0.00"; document.getElementById("calcboxRow-promotion").style.display = "none"; if (baseCoursesQuantityTotal > 0) { promotionDiscount = (+baseCoursesTotal) * promotionDiscountPercent[epcLocation] / 100; document.getElementById("subtotal-promotion").innerHTML = currencySymbol + " -" + currencyFormat(promotionDiscount); document.getElementById("calcboxRow-promotion").style.display = ""; totalPrice += (-promotionDiscount); } } function updateCancellationInsurance() { var cancelInsFormVal = document.epcForm.CIN.options[document.epcForm.CIN.selectedIndex].value; var cancelIns = 0; if (cancelInsFormVal == null || cancelInsFormVal == "" || cancelInsFormVal == 0) { document.getElementById("calcboxRow-CIN").style.display = "none"; document.getElementById("subtotal-CIN").innerHTML = "0.00"; return; } cancelIns = totalPrice * 0.04; totalPrice += (+cancelIns); document.getElementById("calcboxRow-CIN").style.display = ""; document.getElementById("subtotal-CIN").innerHTML = currencySymbol + " " + currencyFormat(cancelIns); } function updateTotalPrice() { totalPrice = (+courseTotal) + (+enrolmentFee) + (+accommodationTotal) + (+placementFee); updateDiscounts(); updateCancellationInsurance(); document.getElementById("totalPrice").innerHTML = currencySymbol + " " + currencyFormat(totalPrice); document.epcSignup.total_price.value = totalPrice; updateMinDeposit(); updateSignupForm(); } /*************************** Main functions ***************************/ function locationSelected(locationValue, locationText) { if (epcLocation != null && epcLocation != "") { resetForm(); } epcLocation = locationValue; epcLocationText = locationText; document.getElementById("destinationDisplay").innerHTML = "Destination: " + epcLocationText; document.getElementById("promotion-label").innerHTML = "Promotion Discount"; updateCourseData(document.epcForm.currency.options[document.epcForm.currency.selectedIndex].value, true, false); // Exception for Salamanca: no airport pickup if (epcLocation == "Salamanca") { document.getElementById("courses4-box").style.display = "none"; } adjustSelectOptions(); } function locationMapSelected(locationValue, locationText) { var locLength = document.epcForm.location.length; for (var i = 0; i < locLength; i++) { if (document.epcForm.location[i].value == locationValue) { document.epcForm.location[i].checked = true; } } } function courseSelected(code, quantity) { var quantityObj = null; var subtotal; var displayVal = ""; var hrspwk = ""; var wks = "" var isBeginnerNum = null; if (!checkLevelCompat()) { return; } if (code == "IND_units") code = "IND"; quantityObj = document.getElementById("quantity-" + code); if (quantityObj) { if (code == "IND") { hrspwk = document.epcForm.IND_units.options[document.epcForm.IND_units.selectedIndex].value; wks = document.epcForm.IND.options[document.epcForm.IND.selectedIndex].value quantityObj.innerHTML = "(" + hrspwk + "/" + wks + ")"; } else if (code == "DLP") { // For DELE, the quantity and displayed differ, so hard code the display quantityObj.innerHTML = "(" + dlpHardQuantity + ")"; } else if (code == "EVN") { // For EVN, the quantity and displayed differ, so hard code the display quantityObj.innerHTML = "(" + evnHardQuantity + ")"; } else { quantityObj.innerHTML = "(" + quantity + ")"; } } subtotal = quantity * courseData[code][priceIdx]; if (subtotal == null || subtotal <= 0) { displayVal = "none"; subtotal = 0; } document.getElementById("subtotal-" + code).innerHTML = currencySymbol + " " + currencyFormat(subtotal); document.getElementById("calcboxRow-" + code).style.display = displayVal; updateCourseTotal(code, quantity, subtotal); updateTotalPrice(); // A few courses are have date restrictions. // Run after updateCourseTotal, since updateDate relies // on the coursePrice array, which is updated in updateCourseTotal. isBeginnerNum = document.epcForm.is_beginner.options[document.epcForm.is_beginner.selectedIndex].value; if ( isBeginnerNum != null && isBeginnerNum != "" && !(isNaN(isBeginnerNum)) ) { updateDates(isBeginnerNum); } } function accommodationSelected(code, quantity) { var epcCode = ""; var subtotal; for (i in accommodationCodes) { epcCode = accommodationCodes[i]; document.getElementById("subtotal-" + epcCode).innerHTML = "0.00"; document.getElementById("calcboxRow-" + epcCode).style.display = "none"; } try { subtotal = quantity * courseData[code][priceIdx]; } catch (e) {} if (subtotal != null && subtotal > 0) { document.getElementById("subtotal-" + code).innerHTML = currencySymbol + " " + currencyFormat(subtotal); document.getElementById("quantity-" + code).innerHTML = "(" + quantity + ")"; document.getElementById("calcboxRow-" + code).style.display = ""; } else { subtotal = 0; } accommodationTotal = subtotal; updatePlacementFee(); updateTotalPrice(); } function currencySelected(currency) { currencySymbol = currencySymbols[currency]; updateCourseData(currency, false, true); } function levelSelected(isBeginnerNum) { if (!checkLevelCompat()) { return; } if (isBeginnerNum == null || isBeginnerNum == "" || isNaN(isBeginnerNum)) { resetStartDate(); } else { updateDates(isBeginnerNum); } } function dateSelected(startDate) { updateTotalPrice(); } function cancelInsSelected() { updateTotalPrice(); } /*************************** Supporting functions ***************************/ function resetStartDate() { document.epcForm.start_date.options[0] = new Option("Select level", ""); document.epcForm.start_date.selectedIndex = 0; document.epcForm.start_date.length = 1; dates = new Array(); } function resetForm() { var formObj = null; for (i in courseCodes) { epcCode = courseCodes[i]; formObj = document.getElementsByName(epcCode); formObj[0].selectedIndex = 0; document.getElementById("product-" + epcCode).style.display = "none"; document.getElementById("quantity-" + epcCode).innerHTML = ""; document.getElementById("subtotal-" + epcCode).innerHTML = "0.00"; document.getElementById("calcboxRow-" + epcCode).style.display = "none"; } for (i in accommodationCodes) { epcCode = accommodationCodes[i]; document.getElementById("quantity-" + epcCode).innerHTML = ""; document.getElementById("subtotal-" + epcCode).innerHTML = "0.00"; document.getElementById("calcboxRow-" + epcCode).style.display = "none"; } resetStartDate(); document.epcForm.is_beginner.selectedIndex = 0; document.epcForm.IND_units.selectedIndex = 0; document.epcForm.accommodation_code.selectedIndex = 0; document.epcForm.accommodation_quantity.selectedIndex = 0; document.epcForm.APK.selectedIndex = 0; document.epcForm.CIN.selectedIndex = 0; document.getElementById("calcboxRow-ENR").style.display = "none"; document.getElementById("subtotal-ENR").innerHTML = "0.00"; document.getElementById("calcboxRow-PLC").style.display = "none"; document.getElementById("subtotal-PLC").innerHTML = "0.00"; document.getElementById("calcboxRow-promotion").style.display = "none"; document.getElementById("subtotal-promotion").innerHTML = "0.00"; document.getElementById("calcboxRow-bulk-disc-12").style.display = "none"; document.getElementById("subtotal-bulk-disc-12").innerHTML = "0.00"; document.getElementById("calcboxRow-bulk-disc-20-5pct").style.display = "none"; document.getElementById("subtotal-bulk-disc-20-5pct").innerHTML = "0.00"; document.getElementById("calcboxRow-bulk-disc-20").style.display = "none"; document.getElementById("subtotal-bulk-disc-20").innerHTML = "0.00"; document.getElementById("calcboxRow-adv-disc-3mo").style.display = "none"; document.getElementById("subtotal-adv-disc-3mo").innerHTML = "0.00"; document.getElementById("calcboxRow-adv-disc-4mo").style.display = "none"; document.getElementById("subtotal-adv-disc-4mo").innerHTML = "0.00"; document.getElementById("calcboxRow-adv-disc-5mo").style.display = "none"; document.getElementById("subtotal-adv-disc-5mo").innerHTML = "0.00"; document.getElementById("calcboxRow-APK").style.display = "none"; document.getElementById("subtotal-APK").innerHTML = "0.00"; document.getElementById("calcboxRow-CIN").style.display = "none"; document.getElementById("subtotal-CIN").innerHTML = "0.00"; document.getElementById("totalPrice").innerHTML = "0.00"; coursePrice = new Object(); courseTotal = 0; enrolmentFee = 0; accommodationTotal = 0; placementFee = 0; totalPrice = 0; } function checkLevelCompat() { var level = ""; var intensive = 0; var superIntensive = 0; try { level = document.epcForm.is_beginner.options[document.epcForm.is_beginner.selectedIndex].value; intensive = document.epcForm.INT.options[document.epcForm.INT.selectedIndex].value; superIntensive = document.epcForm.SIN.options[document.epcForm.SIN.selectedIndex].value; } catch (e) {} if ( !isNaN(superIntensive) && superIntensive > 0 && (isNaN(intensive) || intensive == 0 ) && level == "1" ) { alert("Please note that the super-intensive course is not available for absolute beginners."); try { document.epcForm.is_beginner.selectedIndex = 0; document.epcForm.SIN.selectedIndex = 0; if (coursePrice["SIN"]) delete coursePrice["SIN"]; resetStartDate(); document.getElementById("subtotal-SIN").innerHTML = "0.00"; document.getElementById("calcboxRow-SIN").style.display = "none"; updateCourseTotal(); updateTotalPrice(); } catch (e) {} return false; } else { return true; } } function currencyFormat(n) { var result = ""; var nLength = 0; var position = 0; if (n == null || isNaN(n)) { return n; } n = (+n).toFixed(2); nLength = n.length; if (nLength <= 6) { return n; } for (var i = nLength; i > (nLength -3); i--) { result = n.charAt(i-1) + result; } for (var i = (nLength - 3); i > 0; i--) { position = nLength - 2 - i; if ( ((position-1) % 3) == 0 && i != (nLength-3)) { result = "," + result; } result = n.charAt(i-1) + result; } return result; } function toggleVisible(elementId) { var isBeginner = document.epcForm.is_beginner.options[document.epcForm.is_beginner.selectedIndex].value; var startDate = document.epcForm.start_date.options[document.epcForm.start_date.selectedIndex].value; if (elementId == "signupBox") { if (courseTotal == null || courseTotal == 0) { alert("Please choose at least one course."); return; } if (isBeginner == null || isBeginner == "") { alert("Please choose a level."); return; } if (startDate == null || startDate == "") { alert("Please choose a start date."); return; } } if (elementId == "courseBox") { if (epcLocation == null || epcLocation == "") { alert("Please select a destination."); return; } } for (i in allBoxes) { if (allBoxes[i] == elementId) { document.getElementById(elementId).style.display = ""; } else { document.getElementById(allBoxes[i]).style.display = "none"; } } return false; } function updateCourseForm() { var displayVal = "none"; var epcCode; var objByNameArray = new Array(); var accommodationCode = ""; if (courseData == null || courseData.length == 0) { return; } for (i in courseCodes) { epcCode = courseCodes[i]; displayVal = "none"; if (courseData[epcCode] != null && courseData[epcCode][priceIdx] > 0) { displayVal = ""; } document.getElementById("product-" + epcCode).style.display = displayVal; } } function updateAccommodationOptions() { var i = 1; var epcCode = ""; var currentSelectedCode = document.epcForm.accommodation_code.options[document.epcForm.accommodation_code.selectedIndex].value; // remember index 0 is the empty option document.epcForm.accommodation_code.length = 1; for (j in accommodationCodes) { epcCode = accommodationCodes[j]; if (courseData[epcCode]) { if (courseData[epcCode][priceIdx] > 0) { document.epcForm.accommodation_code.options[i] = new Option(courseData[epcCode][nameIdx], epcCode); if (epcCode == currentSelectedCode) { document.epcForm.accommodation_code.options[i].selected = true; } i++; } } } } function updateDateOptions() { var thisDate = ""; var dateArray = new Array(); var localMonth = ""; var displayDate = ""; var currentSelectedDate = document.epcForm.start_date.options[document.epcForm.start_date.selectedIndex].value; var isBeginnerNum = document.epcForm.is_beginner.options[document.epcForm.is_beginner.selectedIndex].value; if (dates.length <= 0) return; document.epcForm.start_date.length = 0; document.epcForm.start_date.options[0] = new Option("Please Select...", ""); for (var i = 0; i < dates.length; i++) { thisDate = dates[i]; dateArray = thisDate.split("-"); localMonth = months[(+dateArray[1])]; displayDate = dateArray[2] + " " + localMonth + " " + dateArray[0]; document.epcForm.start_date.options[i+1] = new Option(displayDate, thisDate); if (thisDate == currentSelectedDate) { document.epcForm.start_date.options[i+1].selected = true; } } } function updateCurrencyPrices() { courseTotal = 0; for (var code in coursePrice) { try { coursePrice[code][1] = (+coursePrice[code][0]) * courseData[code][priceIdx]; courseTotal += (+coursePrice[code][1]); document.getElementById("subtotal-" + code).innerHTML = currencySymbol + " " + currencyFormat(coursePrice[code][1]); } catch (e) {} } accommodationSelected(document.epcForm.accommodation_code.options[document.epcForm.accommodation_code.selectedIndex].value, document.epcForm.accommodation_quantity.options[document.epcForm.accommodation_quantity.selectedIndex].value); updateEnrolmentFee(); updatePlacementFee(); updateTotalPrice(); } function updateMinDeposit() { var maxDays = 28; //maximum number of days where a full deposit is required var oneDay = 1000*60*60*24; var today = new Date(); var startDate = document.epcForm.start_date.options[document.epcForm.start_date.selectedIndex].value; var startDateArray = new Array(); var startDateObj = new Date(); var dayDiff = 0; var minDeposit = 0; if (startDate == null || startDate == "") return; startDateArray = startDate.split("-"); startDateObj = new Date(startDateArray[0], (startDateArray[1]-1), startDateArray[2]); dayDiff = Math.ceil( (startDateObj.getTime() - today.getTime()) / oneDay ); if ( dayDiff < maxDays ) { minDeposit = totalPrice; } else { minDeposit = totalPrice / 2; } document.getElementById("minDeposit").innerHTML = currencySymbol + " " + currencyFormat(minDeposit); document.epcSignup.cc_charge.value = currencyFormat(minDeposit); document.epcSignup.min_deposit.value = currencySymbol + " " + currencyFormat(minDeposit); } String.prototype.escapeHTML = function () { return( this.replace(/&/g,'&'). replace(/>/g,'>'). replace(/"; var cell1Text = ""; var cell2Text = ""; document.getElementById("signupFormCurrencySymbol").innerHTML = currencySymbol; document.epcSignup.currency_symbol.value = currencySymbol; for (var i = 0; i < calcboxRows.length - 1; i++) { //Skip the last row, the currency drop down if (calcboxRows[i].style.display != "none") { if (i == (calcboxRows.length - 3)) { calcboxHTML += "\n
"; } else { calcboxCells = calcboxRows[i].getElementsByTagName("td"); if (hasInnerText) { cell1Text = calcboxCells[0].innerText; cell2Text = calcboxCells[1].innerText; } else { cell1Text = calcboxCells[0].textContent; cell2Text = calcboxCells[1].textContent; } // euro, pound, and yen symbols are garbled cell2Text = currencySymbol + cell2Text.substring(cell2Text.indexOf(" ")); calcboxHTML += "\n " + cell1Text + " " + cell2Text + " "; } } } calcboxHTML += "\n Destination: " + epcLocationText + " "; calcboxHTML += "\n Level: " + document.epcForm.is_beginner.options[document.epcForm.is_beginner.selectedIndex].text + " "; calcboxHTML += "\n Start Date: " + document.epcForm.start_date.options[document.epcForm.start_date.selectedIndex].text + " "; calcboxHTML += "\n"; document.getElementById("signupCalcbox").innerHTML = calcboxHTML; document.epcSignup.calc_box_code.value = calcboxHTML.escapeHTML(); } function adjustSelectOptions() { var selectElements = new Array("INT", "I20", "SIN", "SAL", "FLM", "EE2", "EE3", "INM", "I05", "I10", "DLP", "EVN", "TNG", "DLX", "IND", "DNC", "MUS"); var currSelect; // Exception for Cuba locations and Salamanca: minimum 2 week options if ( epcLocation == "Santiago de Cuba" || epcLocation == "Havana" || epcLocation == "Trinidad" || epcLocation == "Salamanca" ) { for (i in selectElements) { currSelect = document.epcForm[selectElements[i]]; if ( currSelect.options[1] !== undefined && currSelect.options[1].value == 1 ) { currSelect.remove(1); } } } else { // In case the user selected a Cuba location, // then goes back and selects a different location // add back the option for 1 week if necessary var opt; for (i in selectElements) { currSelect = document.epcForm[selectElements[i]]; if ( currSelect.options[1] === undefined || currSelect.options[1].value == 2 ) { opt = document.createElement("option"); opt.text = "1 week"; opt.value = "1"; currSelect.insertBefore(opt, currSelect.options[1]); } } } }