1$(document).ready(function() 2{ 3 $(".onlyEng").on("keypress", function(event) 4 { 5 var allow = /[A-Za-z0-9 ]/g; 6 7 var key = String.fromCharCode(event.which); 8 9 // keyCode == 8 is backspace 10 // keyCode == 37 is left arrow 11 // keyCode == 39 is right arrow 12 if (event.keyCode == 8 || event.keyCode == 37 || event.keyCode == 39 || allow.test(key)) 13 { 14 return true; 15 } 16 17 return false; 18 }); 19 20 $(".onlyHeb").on("keypress", function(event) 21 { 22 var allow = /[×-ת0-9 ]/g; 23 24 var key = String.fromCharCode(event.which); 25 26 // keyCode == 8 is backspace 27 // keyCode == 37 is left arrow 28 // keyCode == 39 is right arrow 29 if (event.keyCode == 8 || event.keyCode == 37 || event.keyCode == 39 || allow.test(key)) 30 { 31 return true; 32 } 33 34 return false; 35 }); 36 37 $(".onlyNumbers").on("keypress", function(event) 38 { 39 var allow = /[0-9 ]/g; 40 41 var key = String.fromCharCode(event.which); 42 43 // keyCode == 8 is backspace 44 // keyCode == 37 is left arrow 45 // keyCode == 39 is right arrow 46 if (event.keyCode == 8 || event.keyCode == 37 || event.keyCode == 39 || allow.test(key)) 47 { 48 return true; 49 } 50 51 return false; 52 }); 53 54}); 55 56var xmlRequest = new xmlObj(false); 57 58var saveHtmlCode; 59var global_reloadPage = ""; 60 61/* -------------------------------------------------------------------------------------------------------------------- */ 62/* diving_openPopup */ 63/* -------------------------------------------------------------------------------------------------------------------- */ 64function diving_openPopup (popupName) 65{ 66 saveHtmlCode = $("#" + popupName).html(); 67 $("#" + popupName).html(""); 68 69 var addToClose = ""; 70 71 if (global_reloadPage != "") 72 { 73 $.fancybox(saveHtmlCode, {padding: 20, showCloseButton: true, onClosed: function() {window.location.href=global_reloadPage}}); 74 } 75 else 76 { 77 $.fancybox(saveHtmlCode, {padding: 20, showCloseButton: true, onClosed: function() {$("#" + popupName).html(saveHtmlCode)} }); 78 } 79} 80 81/* ------------------------------------------------------------------------------------------------------------ */ 82/* diving_submitContactForm */ 83/* ------------------------------------------------------------------------------------------------------------ */ 84function diving_submitContactForm () 85{ 86 var formName = "contactForm"; 87 88 var formValidator = new Validator(formName); 89 90 formValidator.clearAllValidations (); 91 92 formValidator.addValidation("fullname", "required", myTailJS["fullname-required"]); 93 formValidator.addValidation("email", "required", myTailJS["email-required"]); 94 formValidator.addValidation("email", "email", myTailJS["email-invalid"]); 95 96 if (formValidator.validate ()) 97 { 98 //e.preventDefault(); 99 grecaptcha.ready(function() { 100 grecaptcha.execute('6Ld5LqUZAAAAAIGM07QX_15iFONPtfU-nmZEO1Q_', {action: 'submit'}).then(function(token) { 101 $('#'+formName+' input[name=g-recaptcha-response]').val(token); 102 $('#'+formName).attr("onsubmit", "").submit(); 103 }); 104 }); 105 } 106 107 return false; 108} 109 110/* ------------------------------------------------------------------------------------------------------------ */ 111/* diving_submitNewsLetterForm */ 112/* ------------------------------------------------------------------------------------------------------------ */ 113function diving_submitNewsLetterForm () 114{ 115 var formValidator = new Validator("newsLetterForm"); 116 117 formValidator.clearAllValidations (); 118 119 formValidator.addValidation("newsletter_username", "required", myTailJS["required-fullname"], "×©× ×¤×¨×× ××שפ××"); 120 formValidator.addValidation("newsletter_email", "required", myTailJS["required-email"], "××××××"); 121 formValidator.addValidation("newsletter_email", "email", myTailJS["invalid-email"], "××××××"); 122 123 return formValidator.validate (); 124} 125 126/* ------------------------------------------------------------------------------------------------------------ */ 127/* diving_submitOrderPackageForm */ 128/* ------------------------------------------------------------------------------------------------------------ */ 129function diving_submitOrderPackageForm () 130{ 131 if (document.getElementById("packageId") == 43) 132 diving_checkTz (""); 133 134 var packageType = $("form#orderPackageForm input#packageType").val(); 135 var packageSubType = $("form#orderPackageForm input#packageSubType").val(); 136 137/* if (packageType == "memberPlus") // check insurance date 138 { 139 for (i = 0; i <= 6; i++) 140 { 141 if (i == 0 || (document.getElementById('tz' + i) != undefined && document.getElementById('tz' + i).value != '')) 142 { 143 var index = ((i == 0) ? "" : i); 144 145 var today = new Date(); 146 147 var year = $("#insuranceYear" + index).val(); 148 var month = $("#insuranchMonth" + index).val(); 149 var day = $("#insurancDay" + index).val(); 150 151 var today = new Date(); 152 var checkDate = new Date(year + "-" + month + "-" + day); 153 154 var diff = parseInt((checkDate.getTime() - today.getTime()) / (24*3600*1000)); 155 156 if (diff < 0) 157 { 158 alert ("×ש ××××ר ת×ר×× ×¢×ª×××"); 159 return false;
160 } 161 162 if (diff > 90) 163 { 164 alert ("× ××ª× ××××ר ת×ר×× ××××× ×¢× 90 ××× ×§××××"); 165 return false; 166 } 167 } 168 } 169 } 170*/ 171 var formValidator = new Validator("orderPackageForm"); 172 173 formValidator.clearAllValidations (); 174 175 var packId = document.getElementById("packageId"); 176 177 if (packId.value == "") 178 { 179 alert ("×ש ××××ר ××××× ××רש×××"); 180 $("#packageId").focus(); 181 return false; 182 } 183 184 if (globalLang == "ENG") 185 { 186 if ($("input#firstname").val() == "") 187 $("input#firstname").val($("input#firstnameEng").val()); 188 189 if ($("input#lastname").val() == "") 190 $("input#lastname").val($("input#lastnameEng").val()); 191 } 192 193 formValidator.addValidation ("tz", "required", myTailJS["required-tz"]); 194 formValidator.addValidation ("firstname", "required", myTailJS["required-firstname"]); 195 formValidator.addValidation ("lastname", "required", myTailJS["required-lastname"]); 196 formValidator.addValidation ("firstnameEng", "required", myTailJS["required-firstnameEng"]); 197 formValidator.addValidation ("firstnameEng", "onlyeng", myTailJS["onlyEnglish"]); 198 formValidator.addValidation ("lastnameEng", "required", myTailJS["required-lastnameEng"]); 199 formValidator.addValidation ("lastnameEng", "onlyeng", myTailJS["onlyEnglish"]); 200 formValidator.addValidation ("gender", "required", myTailJS["required-gender"]); 201 formValidator.addValidation ("degreeId", "required", myTailJS["required-degreeId"]); 202 formValidator.addValidation ("city", "required", myTailJS["required-city"]); 203// formValidator.addValidation ("street", "required", myTailJS["required-street"]); 204// 205 if (packageSubType != "offline") 206 { 207 formValidator.addValidation ("email", "required", myTailJS["required-email"]); 208 formValidator.addValidation ("email", "email", myTailJS["invalid-email"]); 209 210 if (packageType != "issue") 211 formValidator.addValidation ("company", "required", myTailJS["required-company"]); 212 } 213 214 if (globalLang == "HEB" && packageSubType != "offline") 215 { 216 formValidator.addValidation ("phone", "required", myTailJS["required-phone"]); 217 } 218 219 formValidator.addValidation ("birthYear", "required", myTailJS["required-birthYear"]); 220 formValidator.addValidation ("birthMonth", "required", myTailJS["required-birthMonth"]); 221 formValidator.addValidation ("birthDay", "required", myTailJS["required-birthDay"]); 222 223 if ($("input#hoger").length > 0) 224 formValidator.addValidation ("hoger", "required", myTailJS["required-hoger"]); 225 226 if ($("input#ccNumber").length > 0) 227 { 228 formValidator.addValidation ("ccNumber", "required", myTailJS["required-ccNumber"]); 229 formValidator.addValidation ("ccExpireYear","required", myTailJS["required-ccExpireYear"]); 230 formValidator.addValidation ("ccExpireMonth","required", myTailJS["required-ccExpireMonth"]); 231 formValidator.addValidation ("ccCvv", "required", myTailJS["required-ccCvv"]); 232 } 233 234 var additionalInsurants = 0; 235 for (i=1; i <= 10; i++) 236 { 237 if (document.getElementById('tz' + i) != undefined && document.getElementById('tz' + i).value != '') 238 { 239 240 if (globalLang == "ENG") 241 { 242 $("input#firstname" + i).val($("input#firstnameEng" + i).val()); 243 $("input#lastname" + i).val($("input#lastnameEng" + i).val()); 244 } 245 246 additionalInsurants++; 247 248/* formValidator.addValidation("tz" + i, "minlen=8", myTailJS["invalid-tz"]); 249 formValidator.addValidation("tz" + i, "maxlen=9", myTailJS["invalid-tz"]);*/ 250 formValidator.addValidation("tz" + i, "numeric", myTailJS["only-numbers"]); 251 formValidator.addValidation ("firstname" + i, "required", myTailJS["required-firstname"]); 252 formValidator.addValidation ("lastname" + i, "required", myTailJS["required-lastname"]); 253 formValidator.addValidation ("firstnameEng" + i, "required", myTailJS["required-firstnameEng"]); 254 formValidator.addValidation ("firstnameEng" + i, "onlyeng", myTailJS["onlyEnglish"]); 255 formValidator.addValidation ("lastnameEng" + i, "required", myTailJS["required-lastnameEng"]); 256 formValidator.addValidation ("lastnameEng" + i, "onlyeng", myTailJS["onlyEnglish"]); 257 formValidator.addValidation ("gender" + i, "required", myTailJS["required-gender"]); 258// formValidator.addValidation ("street" + i, "required", myTailJS["required-street"]); 259 formValidator.addValidation ("city" + i, "required", myTailJS["required-city"]); 260 261 if (globalLang == "HEB") 262 { 263 formValidator.addValidation ("phone" + i, "required", myTailJS["required-phone"]); 264 } 265 266 formValidator.addValidation ("email" + i, "required", myTailJS["required-email"]); 267 formValidator.addValidation ("email" + i, "email", myTailJS["invalid-email"]); 268 formValidator.addValidation ("birthYear" + i, "required", myTailJS["required-birthYear"]); 269 formValidator.addValidation ("birthMonth" + i, "required", myTailJS["required-birthMonth"]); 270 formValidator.addValidation ("birthDay" + i, "required", myTailJS["required-birthDay"]); 271 formValidator.addValidation ("degreeId" + i, "required", myTailJS["required-degreeId"]); 272 formValidator.addValidation ("company" + i, "required", myTailJS["required-company"]); 273 } 274 } 275 276 if ($("#diffInvoiceDetails").prop ("checked")) 277 { 278 formValidator.addValidation ("invoiceName", "required", myTailJS["required-invoiceName"]); 279 formValidator.addValidation ("invoiceAddress", "required", myTailJS["required-invoiceAddress"]); 280 formValidator.addValidation ("invoicePhone", "required", myTailJS["required-invoicePhone"]); 281 } 282 283 if (formValidator.validate ()) 284 { 285 if (packageType != "renew" && packageType != "issue" && packId.value != 12/*CMAS diploma*/) 286 { 287 for (i = 0; i <= 10; i++) 288 { 289 if (i == 0 || (document.getElementById('tz' + i) != undefined && document.getElementById('tz' + i).value != '')) 290 { 291 var index = ((i == 0) ? "" : i); 292
293 var validateMsg = diving_validateBirthDate($("#birthYear" + index).val(), 294 $("#birthMonth" + index).val(), 295 $("#birthDay" + index).val()); 296 297 if (validateMsg != "") 298 { 299 alert (validateMsg); 300 $("#birthYear" + index).focus(); 301 return false; 302 } 303 } 304 } 305 } 306 307 if ($("input#ccNumber").length > 0) 308 { 309 var today = new Date(); 310 311 if ($("select#ccExpireYear").val() == today.getFullYear() && $("select#ccExpireMonth").val() < today.getMonth()+1) 312 { 313 alert (myTailJS["invalid-ccExpire"]); 314 return false; 315 } 316 } 317 318 var oField = document.getElementById("termsAgree"); 319 if (packageSubType != "offline" && packageType != "instructor" && oField != undefined && oField.checked != true && oField.value != "on") 320 { 321 alert(myTailJS["termsAgree"]); 322 oField.focus(); 323 return false; 324 } 325 326 if (packageSubType != "offline" && packageType != "instructor" && $("#healthAgree").length && !$("#healthAgree").prop ("checked")) 327 { 328 alert(myTailJS["healthAgree"]); 329 $("#healthAgree").focus(); 330 return false; 331 } 332 333 if (packageSubType != "offline" && packageType != "instructor" && $("#coronaTerms").length && !$("#coronaTerms").prop ("checked")) 334 { 335 alert(myTailJS["coronaAgree"]); 336 $("#coronaTerms").focus(); 337 return false; 338 } 339 340 if ($("#instructorAgree").length && !$("#instructorAgree").prop ("checked")) 341 { 342 alert(myTailJS["instructorAgree"]); 343 $("#instructorAgree").focus(); 344 return false; 345 } 346 347 if (document.getElementById("minInsurants") != undefined) 348 { 349 var minInsurants = document.getElementById("minInsurants").value; 350 351 if (additionalInsurants < (minInsurants - 1)) 352 { 353 alert(myTailJS["wrong-InsurantsNo"]); 354 packId.focus(); 355 return false; 356 } 357 } 358 359 if (packageType == "issue") 360 { 361 var selected = false; 362 363 $('input.cert').each(function() 364 { 365 if ($(this).is(":checked")) 366 { 367 selected = true; 368 } 369 }); 370 371 if (!selected) 372 { 373 alert (myTailJS["certs-choose"]); 374 return false; 375 } 376 } 377 378 var toSubmit = true; 379 380 if (additionalInsurants != 0) 381 { 382 if (duplicateValues("firstname") || duplicateValues("lastname") || duplicateValues("firstnameEng") || duplicateValues("lastnameEng")) 383 { 384 toSubmit = false; 385 386 if (confirm("××©× × ××××××× ×× ××תר ×ש ×©× ×××. ××× ×ª×¨×¦× ×××ש×× ××× ××ת?")) 387 { 388 toSubmit = true; 389 } 390 } 391 } 392 393 if (toSubmit) 394 { 395 $('#submitOrderBtn').prop('disabled', true).html(myTailJS["sending"]); 396 397 if (globalLang == "HEB" && packageSubType != "offline" && packageType != "instructor") 398 diving_askForTruma('orderPackageForm'); 399 else 400 document.forms["orderPackageForm"].submit(); 401 } 402 403 return false; 404 } 405 406 return false; 407} 408 409function duplicateValues (fieldName) 410{ 411 var duplicate = false; 412 413 var values = new Array(); 414 415 values.push ($("input#" + fieldName).val()); 416 417 for (i=1; i <= 10; i++) 418 { 419 if (document.getElementById('tz' + i) != undefined && document.getElementById('tz' + i).value != '') 420 { 421 var value = $("input#" + fieldName + i).val(); 422 423 if (values.indexOf(value) == -1) 424 { 425 values.push (value); 426 } 427 else 428 { 429 duplicate = true; 430 } 431 } 432 } 433 434 return duplicate; 435} 436 437 438/* ------------------------------------------------------------------------------------------------------------ */ 439/* diving_validateBirthDate */ 440/* ------------------------------------------------------------------------------------------------------------ */ 441function diving_validateBirthDate (year, month, day) 442{ 443 var birthDate = diving_getBirthDate (year, month, day); 444 445 if (birthDate == "") 446 { 447 return myTailJS["invalid-birthDate"]; 448 } 449 450 var today = new Date(); 451 var age = today.getFullYear() - year; 452 453 if (today.getMonth()+1 < month*1 || (today.getMonth()+1 == month*1 && today.getDate() < day*1)) 454 { 455 age--; 456 } 457 458 if (today.getMonth()+1 > month*1 || (today.getMonth()+1 == month*1 && today.getDate() > day*1)) 459 { 460 age++; 461 } 462 463 if (age < 12) 464 { 465 return myTailJS["min-age"]; 466 } 467 468 if (age >= 75) 469 { 470 return myTailJS["max-age"]; 471 } 472 473 return ""; 474} 475 476/* -------------------------------------------------------------------------------------------------------------------- */ 477/* diving_getBirthDate */ 478/* -------------------------------------------------------------------------------------------------------------------- */ 479function diving_getBirthDate (year, month, day) 480{ 481 var birthDate = ""; 482 483 if (year != "" || month != "" || day != "") 484 { 485 var dayobj = new Date(year, month-1, day) 486 if ((dayobj.getMonth()+1 != month) || (dayobj.getDate() != day) || (dayobj.getFullYear() != year)) 487 { 488 return false;
489 } 490 491 birthDate = year + "-" + month + "-" + day; 492 } 493 494 return birthDate; 495} 496 497/* ------------------------------------------------------------------------------------------------------------ */ 498/* diving_toggleInvoice */ 499/* ------------------------------------------------------------------------------------------------------------ */ 500function diving_toggleInvoice () 501{ 502 if ($("#diffInvoiceDetails").prop ("checked")) 503 { 504 $(".invoiceDetails").each (function () { $(this).show () }); 505 } 506 else 507 { 508 $(".invoiceDetails").each (function () { $(this).hide () }); 509 } 510} 511 512/* ------------------------------------------------------------------------------------------------------------ */ 513/* diving_askForTruma */ 514/* ------------------------------------------------------------------------------------------------------------ */ 515function diving_askForTruma(formName) 516{ 517// if (formName == "orderPackageForm") 518// { 519// action = "diving_orderMagazine()"; 520// } 521// else 522// { 523 action = "document.forms[\"" + formName + "\"].submit()"; 524// } 525 526 if (formName == "eventRegisterForm") 527 var text = "×רש××ª× ×××ר××¢"; 528 else 529 var text = "××××ש ××× ×××ר ×××××××"; 530 531 $.fancybox("<div style='width:300px;height:250px;text-align:center'><br /><strong>תר×× ××××עת ××× ×©××× ××צ×רת ××ª×¨× ×¦××××!</strong><br /><br />"+ 532 "×¢× " + text + " ×ש ××פשר×ת×<br />×תר×× ××§×¨× ×פ×ת×× ××ª×¨× ×¦××××<br />××ס×××¢ ××××עת ×ספ×× × ××××!<br /><br />"+ 533 "×רצ×× × ×תר×× <select onchange='setTruma(this.value)' id='trumaSums'><option value='0'>××ר ס×××</option><option value='10'>10 ש\"×</option>"+ 534 "<option value='20'>20 ש\"×</option><option value='50'>50 ש\"×</option><option value='100'>100 ש\"×</option></select><br /><br />"+ 535 "<button class='btn btn-orange' onclick='" + action + "'>××ש×</button>", {padding: 20}); 536} 537 538/* ------------------------------------------------------------------------------------------------------------ */ 539/* diving_orderMagazine */ 540/* ------------------------------------------------------------------------------------------------------------ */ 541function diving_orderMagazine () 542{ 543 $.fancybox("<div style='width:300px;height:200px;text-align:center'>" + 544 "<br /><strong>×××××× ××××× ×©× ××××× \"צ××××\"</strong><br/><br/>××××× 50 ×©× × ××ת××××ת,<br/>" + 545 "×× ××©× ×¢×ר-××××-עת××,<br/>××××¨× ××ת××××ת ת××רת ××× ×ש××× ×××× (15 âª).<br /><br />" + 546 "<button id='submitMagazinBtn' class='btn btn-orange' onclick='setMagazine(15)'>××××</button> " + 547 "<button class='btn btn-orange' onclick='document.forms[\"orderPackageForm\"].submit()'>××, ת×××</button>" + 548 "</div>", {padding: 20}); 549} 550 551/* ------------------------------------------------------------------------------------------------------------ */ 552/* diving_submitOrderProductsForm */ 553/* ------------------------------------------------------------------------------------------------------------ */ 554function diving_submitOrderProductsForm () 555{ 556 557 var formValidator = new Validator("shopProductsForm"); 558 559 formValidator.clearAllValidations (); 560 561 formValidator.addValidation ("firstname", "required", myTailJS["required-firstname"]); 562 formValidator.addValidation ("lastname", "required", myTailJS["required-lastname"]); 563 formValidator.addValidation ("street", "required", myTailJS["required-street"]); 564 formValidator.addValidation ("city", "required", myTailJS["required-city"]); 565 formValidator.addValidation ("email", "required", myTailJS["required-email"]); 566 formValidator.addValidation ("email", "email", myTailJS["invalid-email"]); 567 568 if (formValidator.validate ()) 569 { 570 $("form#shopProductsForm input#amount").val (parseFloat($("#cartTotalAmount").html ())); 571 572 var shipment = $("span#shipment" + $("select#shipment").val ()).html(); 573 574 var underlinePos = document.getElementById("custom").value.indexOf("_"); 575 if (underlinePos == -1) 576 document.getElementById("custom").value += "_" + shipment; 577 else 578 document.getElementById("custom").value = document.getElementById("custom").value.substring(0,underlinePos+1) + shipment; 579 580 return true; 581 } 582 583 return false;
584} 585 586function setTruma(value) 587{ 588 document.getElementById('truma').value = value; 589 document.getElementById('sum').value = (document.getElementById('sum').value * 1) + parseInt(value); 590} 591 592function setMagazine(value) 593{ 594 document.getElementById('magazine').value = value; 595 document.getElementById('sum').value = (document.getElementById('sum').value * 1) + parseInt(value); 596 597 $('#submitMagazinBtn').prop('disabled', true).html(myTailJS["sending"]); 598 document.forms["orderPackageForm"].submit(); 599} 600 601/* ------------------------------------------------------------------------------------------------------------ */ 602/* diving_checkUniqueMember */ 603/* ------------------------------------------------------------------------------------------------------------ */ 604function diving_checkUniqueMember () 605{ 606 oForm = document.getElementById("registerForm"); 607 608 var xml = "<data>" + 609 "<command>private.checkUniqueMember</command>" + 610 "<username>" + oForm.tz.value + "</username>" + 611 "<email>" + oForm.email.value + "</email>" + 612 "</data>"; 613 614 xmlRequest.init (xml); 615 xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "diving_checkUniqueMember_response"); 616 return false; 617} 618 619function diving_checkUniqueMember_response (i) 620{ 621 xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText)); 622 623 try 624 { 625 var isUnique = xmlRequest.getValue("isUnique"); 626 627 oForm = document.getElementById("orderPackageForm"); 628 629 if (isUnique == "1") 630 { 631 oForm.submit (); 632 } 633 else 634 { 635 alert (myTailJS["not-unique"]); 636 oForm.username.focus (); 637 return false; 638 } 639 } 640 catch (e) 641 { 642 alert ("AJAX Error"); 643 return false; 644 } 645 646 return false; 647} 648 649/* ------------------------------------------------------------------------------------------------------------ */ 650/* diving_submitLoginForm */ 651/* ------------------------------------------------------------------------------------------------------------ */ 652function diving_submitLoginForm () 653{ 654 var oForm = document.getElementById("loginForm"); 655 656 var formValidator = new Validator("loginForm"); 657 658 formValidator.clearAllValidations (); 659 660 formValidator.addValidation("username", "required", myTailJS["required-tz"]); 661 formValidator.addValidation("password", "required", myTailJS["required-password"]); 662 663 if (formValidator.validate ()) 664 { 665 var xml = "<data>" + 666 "<command>private.checkLogin</command>" + 667 "<username><![CDATA[" + oForm.username.value + "]]></username>" + 668 "<password><![CDATA[" + oForm.password.value + "]]></password>" + 669 "</data>"; 670 671 xmlRequest.init (xml); 672 xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "diving_afterCheckLogin"); 673 } 674 675 return false; 676} 677 678/* -------------------------------------------------------------------------------------------------------------------- */ 679/* diving_afterCheckLogin */ 680/* -------------------------------------------------------------------------------------------------------------------- */ 681function diving_afterCheckLogin (i) 682{ 683 xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText)); 684 685 var oForm = document.getElementById("loginForm"); 686 687 try 688 { 689 var returnCode = xmlRequest.getValue("returnCode"); 690 691 if (returnCode == "OK") 692 { 693 var username = xmlRequest.getValue("username"); 694 695 $("input#username").val (username); 696 697 oForm.submit(); 698 699 return false; 700 } 701 else if (returnCode == "WRONG_USERNAME_OR_PASSWORD") 702 { 703 alert (myTailJS["wrong-login"]); 704 return false; 705 } 706 } 707 catch (e) 708 { 709 } 710 711 return false; 712} 713 714/* ------------------------------------------------------------------------------------------------------------ */ 715/* diving_showPasswordForm */ 716/* ------------------------------------------------------------------------------------------------------------ */ 717function diving_showPasswordForm () 718{ 719 $("#loginPopup").hide (); 720 721 if ($("#loginForm input#username").val() != "") 722 $("#passwordForm input#username").val($("#loginForm input#username").val()); 723 724 $("#passwordPopup").show (); 725} 726 727/* ------------------------------------------------------------------------------------------------------------ */ 728/* diving_backToLogin */ 729/* ------------------------------------------------------------------------------------------------------------ */ 730function diving_backToLogin () 731{ 732 $("#passwordPopup").hide (); 733 $("#loginPopup").show (); 734} 735 736/* ------------------------------------------------------------------------------------------------------------ */ 737/* diving_submitPasswordForm */ 738/* ------------------------------------------------------------------------------------------------------------ */ 739function diving_submitPasswordForm () 740{ 741 var oForm = document.getElementById("passwordForm"); 742 743 var formValidator = new Validator("passwordForm"); 744 745 formValidator.clearAllValidations (); 746 747 formValidator.addValidation("username", "required", myTailJS["required-tz"]); 748 749 if (formValidator.validate ()) 750 { 751 var xml = "<data>" + 752 "<command>private.sendPassword</command>" + 753 "<username><![CDATA[" + oForm.username.value + "]]></username>" + 754 "</data>"; 755 756 xmlRequest.init (xml); 757 xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "diving_afterSendPassword"); 758 } 759 760 return false;
761} 762 763/* -------------------------------------------------------------------------------------------------------------------- */ 764/* diving_afterSendPassword */ 765/* -------------------------------------------------------------------------------------------------------------------- */ 766function diving_afterSendPassword (i) 767{ 768 xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText)); 769 770 try 771 { 772 var returnCode = xmlRequest.getValue("returnCode"); 773 774 if (returnCode == "OK") 775 { 776 alert ("×ס×ס×× × ×©××× ××ת××ת ××××××× ×©××"); 777 778 $("#loginForm input#username").val($("#passwordForm input#username").val()); 779 780 diving_backToLogin (); 781 } 782 else 783 { 784 alert ("×× ×צ×× × ×ת פר××× ××תר!"); 785 } 786 } 787 catch (e) 788 { 789 } 790 791 return false; 792} 793 794/* ------------------------------------------------------------------------------------------------------------ */ 795/* diving_forgotPassword */ 796/* ------------------------------------------------------------------------------------------------------------ */ 797function diving_forgotPassword () 798{ 799 oForm = document.getElementById("loginForm"); 800 801 if (oForm.username.value == "") 802 { 803 alert (myTailJS["required-tz"]); 804 oForm.username.focus (); 805 return false; 806 } 807 808 oPassForm = document.getElementById("passForm"); 809 810 oPassForm.username.value = oForm.username.value; 811 812 oPassForm.submit (); 813} 814 815function isNumber(n) { 816 return !isNaN(parseFloat(n)) && isFinite(n); 817} 818function PadDigits(n, totalDigits) 819{ 820 var pd = ''; 821 for (i=0; i < (totalDigits-n.length); i++) 822 pd += '0'; 823 return pd + n.toString(); 824} 825 826/* ------------------------------------------------------------------------------------------------------------ */ 827/* diving_submitChoicesForm */ 828/* ------------------------------------------------------------------------------------------------------------ */ 829function diving_submitChoicesForm (e, formName, tzField, yearField) 830{ 831 // Add leading zeroes to short TZ 832 var tz = $("input#" + tzField).val (); 833 834 empty = ""; 835 836 if (formName == "checkForm" && tz == myTailJS["enter-tz"]) 837 { 838 empty = myTailJS["enter-tz"]; 839 tz = ""; 840 } 841 842 if (isNumber(tz) && tz.length < 8) 843 $("input#" + tzField).val (PadDigits(tz, 8)); 844 845 var formValidator = new Validator(formName); 846 847 formValidator.clearAllValidations (); 848 849 formValidator.addValidation(tzField, "required", myTailJS["required-tz"], empty); 850 formValidator.addValidation(yearField, "required", myTailJS["required-year"], empty); 851// formValidator.addValidation(tzField, "numeric", myTailJS["only-numbers"], empty); 852 853 if (formValidator.validate ()) 854 { 855 e.preventDefault(); 856 grecaptcha.ready(function() { 857 grecaptcha.execute('6Ld5LqUZAAAAAIGM07QX_15iFONPtfU-nmZEO1Q_', {action: 'submit'}).then(function(token) { 858 $('#'+formName+' input[name=g-recaptcha-response]').val(token); 859 $('#'+formName).attr("onsubmit", "").submit(); 860 }); 861 }); 862 } 863 else 864 return false; 865} 866 867/* ------------------------------------------------------------------------------------------------------------ */ 868/* diving_emptyCart */ 869/* ------------------------------------------------------------------------------------------------------------ */ 870function diving_emptyCart () 871{ 872 // don't allow order submit until cart update is done 873 $('#sendOrderBtn').prop('disabled', true); 874 875 if (confirm(myTailJS["confirm-emptyCart"])) 876 { 877 xml = "<data>" + 878 "<command>private.emptyCart</command>" + 879 "<lang>" + globalLang + "</lang>" + 880 "</data>"; 881 882 xmlRequest.init (xml); 883 884 xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "diving_updateCart_response"); 885 } 886 887 return false; 888} 889 890/* ------------------------------------------------------------------------------------------------------------ */ 891/* diving_addProduct */ 892/* ------------------------------------------------------------------------------------------------------------ */ 893function diving_addProduct (productId) 894{ 895 xml = "<data>" + 896 "<command>private.addProduct</command>" + 897 "<productId>" + productId + "</productId>" + 898 "<lang>
898" + globalLang + "</lang>" + 899 "</data>"; 900 901 xmlRequest.init (xml); 902 903 xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "diving_addProduct_response"); 904 905 return false; 906} 907 908/* ------------------------------------------------------------------------------------------------------------ */ 909/* diving_addProduct_response */ 910/* ------------------------------------------------------------------------------------------------------------ */ 911function diving_addProduct_response (i) 912{ 913 xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText)); 914 915 try 916 { 917 var returnCode = xmlRequest.getValue("returnCode"); 918 919 if (returnCode == "OK") 920 { 921// location.href = "index2.php?id=37&lang=" + globalLang; 922// return; 923 html = "<div class='popup'>" + 924 "<div class='popupTitle'><div>" + myTailJS["popupTitle-addProduct"] + " </div></div>" + 925 "<div class='popup_in'>" + 926 myTailJS["popup-chooseAction"] + "<br/><br/>" + 927 " <button class='btn btn-orange' style='margin-left:30px' onclick='$.fancybox.close()'><span>" + 928 myTailJS["popup-continueShoping"] + "</span></button>" + 929 " <button class='btn btn-orange' onclick='location.href = \"index2.php?id=37&lang=" + globalLang + "\"'><span>" + 930 myTailJS["popup-gotoCart"] + "</span></button>" + 931 "</div>" + 932 "</div>"; 933 $.fancybox(html, {padding: 20, showCloseButton: true, onClosed: function() {}}); 934 } 935 } 936 catch (e) 937 { 938 } 939 940 return false; 941} 942 943/* ------------------------------------------------------------------------------------------------------------ */ 944/* diving_updateProductQuantity */ 945/* ------------------------------------------------------------------------------------------------------------ */ 946function diving_updateProductQuantity (productId, value) 947{ 948 // don't allow order submit until cart update is done 949 $('#sendOrderBtn').prop('disabled', true); 950 951 if (value == 1) 952 which = "inc"; 953 else 954 which = "dec"; 955 956 if ($("tr#productRow" + productId + " span.glyphicon." + which).hasClass ("disabled")) return; 957 958 $("tr#productRow" + productId + " span.glyphicon." + which).addClass ("disabled"); 959 960 var shipmentId = $("select#shipment").val (); 961 962 xml = "<data>" + 963 "<command>private.updateProductQuantity</command>" + 964 "<productId>" + productId + "</productId>" + 965 "<value>" + value + "</value>" + 966 "<shipmentId>" + shipmentId + "</shipmentId>" + 967 "<lang>" + globalLang + "</lang>" + 968 "</data>"; 969 970 xmlRequest.init (xml); 971 972 xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "diving_updateCart_response"); 973 974 return false; 975} 976 977/* ------------------------------------------------------------------------------------------------------------ */ 978/* diving_deleteProduct */ 979/* ------------------------------------------------------------------------------------------------------------ */ 980function diving_deleteProduct (productId) 981{ 982 // don't allow order submit until cart update is done 983 $('#sendOrderBtn').prop('disabled', true); 984 985 var shipmentId = $("select#shipment").val (); 986 987 xml = "<data>" + 988 "<command>private.deleteProduct</command>" + 989 "<productId>" + productId + "</productId>" + 990 "<shipmentId>" + shipmentId + "</shipmentId>" + 991 "<lang>" + globalLang + "</lang>" + 992 "</data>"; 993 994 xmlRequest.init (xml); 995 996 xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "diving_updateCart_response"); 997 998 return false; 999} 1000 1001/* ------------------------------------------------------------------------------------------------------------ */ 1002/* diving_selectShipment */ 1003/* ------------------------------------------------------------------------------------------------------------ */ 1004function diving_selectShipment () 1005{ 1006 // don't allow order submit until cart update is done 1007 $('#sendOrderBtn').prop('disabled', true); 1008 1009 var shipmentId = $("select#shipment").val (); 1010 1011 xml = "<data>" + 1012 "<command>private.updateCart</command>" + 1013 "<shipmentId>" + shipmentId + "</shipmentId>" + 1014 "<lang>" + globalLang + "</lang>" + 1015 "</data>"; 1016 1017 xmlRequest.init (xml); 1018 1019 xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "diving_updateCart_response"); 1020 1021 return false;
1022} 1023 1024/* ------------------------------------------------------------------------------------------------------------ */ 1025/* diving_updateCart_response */ 1026/* ------------------------------------------------------------------------------------------------------------ */ 1027function diving_updateCart_response (i) 1028{ 1029 xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText)); 1030 1031 try 1032 { 1033 var returnCode = xmlRequest.getValue("returnCode"); 1034 1035 if (returnCode == "OK") 1036 { 1037 var total = xmlRequest.getValue("total"); 1038 1039 $(".top-cart .amount").html (total); 1040 1041 var cartHtml = xmlRequest.getValue("cartHtml"); 1042 1043 $(".table-cart").html (cartHtml); 1044 1045 var totalAmount = xmlRequest.getValue("totalAmount"); 1046 1047 $("form#shopProductsForm input#amount").val (totalAmount); 1048 1049 if (total == 0) 1050 { 1051 $("#orderDetails").hide (); 1052 } 1053 } 1054 } 1055 catch (e) 1056 { 1057 } 1058 1059 // re-allow to submit the order 1060 $('#sendOrderBtn').prop('disabled', false); 1061 1062 return false; 1063} 1064 1065/* ------------------------------------------------------------------------------------------------------------ */ 1066/* diving_eventCheckTz */ 1067/* ------------------------------------------------------------------------------------------------------------ */ 1068function diving_eventCheckTz () 1069{ 1070 var lang = $("form#eventRegisterForm input#lang").val(); 1071 var eventId = $("form#eventRegisterForm input#eventId").val(); 1072 var tz = $("form#eventRegisterForm input#idNumber").val(); 1073 1074 if (tz != "") 1075 { 1076 var xml = "<data>" + 1077 "<command>private.eventCheckTz</command>" + 1078 "<lang>" + lang + "</lang>" + 1079 "<eventId>" + eventId + "</eventId>" + 1080 "<tz>" + tz + "</tz>" + 1081 "</data>"; 1082 1083 xmlRequest.init (xml); 1084 xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "diving_eventCheckTz_response"); 1085 } 1086 1087 return false; 1088} 1089 1090function diving_eventCheckTz_response (i) 1091{ 1092 xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText)); 1093 1094 try 1095 { 1096 var returnCode = xmlRequest.getValue("returnCode"); 1097 1098 var firstname = xmlRequest.getValue("firstname"); 1099 var lastname = xmlRequest.getValue("lastname"); 1100 var email = xmlRequest.getValue("email"); 1101 var price = xmlRequest.getValue("price"); 1102 1103 $("input#firstname").val (firstname); 1104 $("input#lastname").val (lastname); 1105 $("input#email").val (email); 1106 $("input#priceToPay").val (price); 1107 $("input#sum").val (price); 1108 $("input#basePrice").val (price); 1109 1110 $("select#numRegistered").val ("1"); 1111 1112 $("form#eventRegisterForm div.enter_registered").each (function () 1113 { 1114 $(this).hide (); 1115 }); 1116 } 1117 catch (e) 1118 { 1119 alert ("AJAX Error"); 1120 return false; 1121 } 1122 1123 return false; 1124} 1125 1126/* ------------------------------------------------------------------------------------------------------------ */ 1127/* diving_submitEventRegister */ 1128/* ------------------------------------------------------------------------------------------------------------ */ 1129function diving_submitEventRegister () 1130{ 1131 var formValidator = new Validator("eventRegisterForm"); 1132 1133 formValidator.clearAllValidations (); 1134 1135 formValidator.addValidation("firstname", "required", myTailJS["required-firstname"]); 1136 formValidator.addValidation("lastname", "required", myTailJS["required-lastname"]); 1137 formValidator.addValidation("email", "required", myTailJS["required-email"]); 1138 formValidator.addValidation("email", "email", myTailJS["invalid-email"]); 1139 formValidator.addValidation("phone", "required", myTailJS["required-phone"]); 1140 formValidator.addValidation("idNumber", "required", myTailJS["required-tz"]); 1141 1142 var numRegistered = $("select#numRegistered").val(); 1143 1144 if (numRegistered > 1) 1145 { 1146 for (i = 1; i < numRegistered; i++) 1147 { 1148 formValidator.addValidation("registered" + i, "required", myTailJS["required-registered"] + " " + i); 1149 } 1150 } 1151 1152 if (numRegistered == undefined) numRegistered = 1; 1153 1154 if (formValidator.validate ()) 1155 { 1156 var oForm = document.getElementById("eventRegisterForm"); 1157 1158 var xml = "<data>" + 1159 "<command>private.checkEventRegister</command>" + 1160 "<eventId><![CDATA[" + oForm.eventId.value + "]]></eventId>" + 1161 "<email><![CDATA[" + oForm.email.value + "]]></email>" + 1162 "<tz><![CDATA[" + oForm.idNumber.value + "]]></tz>" + 1163 "<numRegistered>" + numRegistered + "</numRegistered>" +
1164 "<datetime><![CDATA[" + oForm.datetime.value + "]]></datetime>" + 1165 "</data>"; 1166 1167 xmlRequest.init (xml); 1168 xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "diving_afterCheckEventRegister"); 1169 } 1170 1171 return false; 1172} 1173 1174/* -------------------------------------------------------------------------------------------------------------------- */ 1175/* diving_afterCheckEventRegister */ 1176/* -------------------------------------------------------------------------------------------------------------------- */ 1177function diving_afterCheckEventRegister (i) 1178{ 1179 xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText)); 1180 1181 try 1182 { 1183 var returnCode = xmlRequest.getValue("returnCode"); 1184 1185 if (returnCode == "OK") 1186 { 1187 diving_askForTruma("eventRegisterForm") 1188 1189 return false; 1190 } 1191 else if (returnCode == "CAN_NOT_REGISTER") 1192 { 1193 alert (myTailJS["event-cantRegister"]); 1194 return false; 1195 } 1196 else if (returnCode == "MAX_EXCEEDED") 1197 { 1198 alert (myTailJS["event-maxEceeded"]); 1199 return false; 1200 } 1201 else if (returnCode == "ALREADY_REGISTERED") 1202 { 1203 alert (myTailJS["event-alreadyRegistered"]); 1204 return false; 1205 } 1206 } 1207 catch (e) 1208 { 1209 } 1210 1211 return false; 1212} 1213 1214/* -------------------------------------------------------------------------------------------------------------------- */ 1215/* diving_downloadView */ 1216/* -------------------------------------------------------------------------------------------------------------------- */ 1217function diving_downloadView(val) 1218{ 1219 var today = new Date(); 1220 today.setTime( today.getTime() + (365 * 1000 * 60 * 60 * 24)); 1221 1222 document.cookie = "downloadsView=" +escape( val ) + ";expires=" + today.toUTCString(); 1223 1224 location.reload(); 1225} 1226 1227/* -------------------------------------------------------------------------------------------------------------------- */ 1228/* diving_ask4password */ 1229/* -------------------------------------------------------------------------------------------------------------------- */ 1230function diving_ask4password(val) 1231{ 1232 diving_openPopup("getPasswordPopupHtml"); 1233 1234 $('#fileId').val(val); 1235 1236 return true; 1237} 1238 1239/* -------------------------------------------------------------------------------------------------------------------- */ 1240/* diving_downloadStat */ 1241/* -------------------------------------------------------------------------------------------------------------------- */ 1242function diving_downloadStat(downloadId, tz) 1243{ 1244 var xml = "<data>" + 1245 "<command>private.downloadStat</command>" + 1246 "<downloadId>" + downloadId + "</downloadId>" + 1247 "<tz>" + tz + "</tz>" + 1248 "</data>"; 1249 1250 xmlRequest.init (xml); 1251 xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "diving_afterDownloadStat"); 1252 1253 return true; 1254} 1255 1256function diving_afterDownloadStat() 1257{ 1258} 1259 1260/* ------------------------------------------------------------------------------------------------------------ */ 1261/* diving_submitEnterPackageForm */ 1262/* ------------------------------------------------------------------------------------------------------------ */ 1263function diving_submitEnterPackageForm () 1264{ 1265 oForm = document.getElementById("enterPackageForm"); 1266 1267 if (oForm.enterPassword.value == "") 1268 { 1269 alert (myTailJS["required-password"]); 1270 return false; 1271 } 1272 1273 var xml = "<data>" + 1274 "<command>private.checkEnterPackage</command>" + 1275 "<password>" + oForm.enterPassword.value + "</password>" + 1276 "</data>"; 1277 1278 xmlRequest.init (xml); 1279 xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "diving_submitEnterPackageForm_response"); 1280 return false; 1281} 1282 1283function diving_submitEnterPackageForm_response (i) 1284{ 1285 oForm = document.getElementById("enterPackageForm"); 1286 1287 xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText)); 1288 1289 try 1290 { 1291 var returnCode = xmlRequest.getValue("returnCode"); 1292 1293 if (returnCode == "OK") 1294 { 1295 oForm.packageId.value = xmlRequest.getValue("packageId") 1296 oForm.submit(); 1297 } 1298 else 1299 { 1300 alert (myTailJS["wrong-password"]); 1301 oForm.enterPassword.focus (); 1302 return false;
1303 } 1304 } 1305 catch (e) 1306 { 1307 alert ("AJAX Error"); 1308 return false; 1309 } 1310 1311 return false; 1312} 1313 1314/* ------------------------------------------------------------------------------------------------------------ */ 1315/* diving_onSelectPackage */ 1316/* ------------------------------------------------------------------------------------------------------------ */ 1317function diving_onSelectPackage (lang, instructor) 1318{ 1319 var selected = $("form#orderPackageForm select#packageId").val(); 1320 1321 if (selected != "") 1322 { 1323 var tz = $("form#orderPackageForm input#tz").val(); 1324 1325 if (tz != "") 1326 tz = "&tz=" + tz; 1327 1328 if (instructor != undefined && instructor != "") 1329 instructor = "&instructor=1"; 1330 else 1331 instructor = ""; 1332 1333 location.href = "index2.php?id=120&packageId=" + selected + tz + instructor + "&lang=" + lang; 1334 } 1335} 1336 1337/* ------------------------------------------------------------------------------------------------------------ */ 1338/* diving_calcTotals */ 1339/* ------------------------------------------------------------------------------------------------------------ */ 1340function diving_calcTotals () 1341{ 1342 var packageId = $("form#orderPackageForm select#packageId").val(); 1343 var packageType = $("form#orderPackageForm input#packageType").val(); 1344 var packageCompany = $("form#orderPackageForm input#packageCompany").val(); 1345 var packagePrice = $("form#orderPackageForm input#packagePrice").val(); 1346 1347 var cnt = 1; 1348 1349 if (document.getElementById('tz1') && document.getElementById('tz1').value != '') cnt++; 1350 if (document.getElementById('tz2') && document.getElementById('tz2').value != '') cnt++; 1351 if (document.getElementById('tz3') && document.getElementById('tz3').value != '') cnt++; 1352 if (document.getElementById('tz4') && document.getElementById('tz4').value != '') cnt++; 1353 if (document.getElementById('tz5') && document.getElementById('tz5').value != '') cnt++; 1354 if (document.getElementById('tz6') && document.getElementById('tz6').value != '') cnt++; 1355 1356// if (packageId == 9 || packageId == 10) 1357 if (packageType == "renew" && packageCompany == "") 1358 { 1359 if (document.getElementById('degreeId2') && document.getElementById('degreeId2').value != '') cnt++; 1360 if (document.getElementById('degreeId3') && document.getElementById('degreeId3').value != '') cnt++; 1361 } 1362 1363 var total = cnt * packagePrice; 1364 1365 if (cnt > 1) 1366 { 1367 if (document.getElementById("refreshDiving1") && document.getElementById("refreshDiving1").value == 0) total -= 150; 1368 if (document.getElementById("refreshDiving2") && document.getElementById("refreshDiving2").value == 0) total -= 150; 1369 if (document.getElementById("refreshDiving3") && document.getElementById("refreshDiving3").value == 0) total -= 150; 1370 if (document.getElementById("refreshDiving4") && document.getElementById("refreshDiving4").value == 0) total -= 150; 1371 if (document.getElementById("refreshDiving5") && document.getElementById("refreshDiving5").value == 0) total -= 150; 1372 } 1373 1374// if (packageId == 11) 1375 if (packageType == "renew" && packageCompany != "") 1376 { 1377 if (document.getElementById('degreeId2') && document.getElementById('degreeId2').value != '') total += 70; 1378 if (document.getElementById('degreeId3') && document.getElementById('degreeId3').value != '') total += 70; 1379 } 1380 1381// if (packageId == 9 || packageId == 10 || packageId == 12 || packageId == 13 || packageId == 14) 1382 if (packageCompany == "") 1383 { 1384 cnt = 0; 1385 } 1386 1387 $("span#num").html (cnt); 1388 $("span#total").html (total); 1389 $("input#sum").val (total); 1390 1391 if (document.getElementById('truma').innerHTML != '') 1392 document.getElementById('sum').value += parseInt(document.getElementById('truma').innerHTML); 1393 1394} 1395 1396var global_index; 1397var global_showMsg; 1398 1399/* ------------------------------------------------------------------------------------------------------------ */ 1400/* diving_checkTz */ 1401/* ------------------------------------------------------------------------------------------------------------ */ 1402function diving_checkTz (index, showMsg) 1403{ 1404 if (showMsg == undefined) showMsg = true; 1405 1406 if (showMsg == "0") showMsg = false; 1407 1408 global_showMsg = showMsg; 1409 global_index = index; 1410 1411 var lang = $("form#orderPackageForm input#lang").val(); 1412 var packageId = $("form#orderPackageForm select#packageId").val(); 1413 var tz = $("form#orderPackageForm input#tz" + global_index).val(); 1414 var idType = $("form#orderPackageForm input[name=idType" + global_index + "]:checked" ).val(); 1415 1416 if (tz != "") 1417 { 1418 var xml = "<data>" + 1419 "<command>private.checkTz</command>" + 1420 "<lang>" + lang + "</lang>" + 1421 "<packageId>" + packageId + "</packageId>" + 1422 "<tz>" + tz + "</tz>" + 1423 "<idType>" + idType + "</idType>" + 1424 "</data>"; 1425 1426 xmlRequest.init (xml); 1427 xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "diving_checkTz_response"); 1428 } 1429 else 1430 { 1431 diving_calcTotals (); 1432 } 1433 1434 return false;
1435} 1436 1437function diving_checkTz_response (i) 1438{ 1439 xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText)); 1440 1441 try 1442 { 1443 var returnCode = xmlRequest.getValue("returnCode"); 1444 var msg = xmlRequest.getValue("msg"); 1445 1446 var firstName = xmlRequest.getValue("firstName"); 1447 var lastName = xmlRequest.getValue("lastName"); 1448 var firstNameEng = xmlRequest.getValue("firstNameEng"); 1449 var lastNameEng = xmlRequest.getValue("lastNameEng"); 1450 var gender = xmlRequest.getValue("gender"); 1451 1452// $("input#firstname" + global_index).prop( "disabled", false); 1453// $("input#lastname" + global_index).prop( "disabled", false); 1454// $("input#firstnameEng" + global_index).prop( "disabled", false); 1455// $("input#lastnameEng" + global_index).prop( "disabled", false); 1456 1457 if (returnCode == "CHOOSE") 1458 { 1459 if (global_showMsg) 1460 { 1461 $("#msgPopup div.popup_in").html (msg); 1462 1463 saveHtmlCode = $("#msgPopup").html(); 1464 $("#msgPopup").html(""); 1465 1466 $.fancybox(saveHtmlCode, {padding: 20, showCloseButton: true, 1467 onClosed: function() 1468 { 1469 $("#msgPopup").html(saveHtmlCode); 1470 $("form#orderPackageForm input#tz" + global_index).focus(); 1471 $("form#orderPackageForm input#tz" + global_index).select(); 1472 }}); 1473 } 1474 } 1475 else if (returnCode == "GO_TO_URL") 1476 { 1477 if (location.href.indexOf(msg) == -1) 1478 location.href = msg; 1479 } 1480 else if (returnCode != "OK") 1481 { 1482 if (returnCode == "INVALID_TZ") 1483 { 1484 alert (myTailJS["invalid-tz"]); 1485 } 1486 else if (global_showMsg) 1487 { 1488 alert (msg); 1489 } 1490 1491 $("form#orderPackageForm input#tz" + global_index).focus(); 1492 $("form#orderPackageForm input#tz" + global_index).select(); 1493 $("form#orderPackageForm input#tz" + global_index).val(""); 1494 1495 firstName = ""; 1496 lastName = ""; 1497 firstNameEng = ""; 1498 lastNameEng = ""; 1499 gender = ""; 1500 } 1501 1502 $("input#firstname" + global_index).val (firstName); 1503 $("input#lastname" + global_index).val (lastName); 1504 $("input#firstnameEng" + global_index).val (firstNameEng); 1505 $("input#lastnameEng" + global_index).val (lastNameEng); 1506 $("select#gender" + global_index).val (gender); 1507 1508 /* 1509 if (returnCode == "OK" && firstName != "") 1510 { 1511 $("input#firstname" + global_index).prop( "disabled", true); 1512 $("input#lastname" + global_index).prop( "disabled", true); 1513 $("input#firstnameEng" + global_index).prop( "disabled", true); 1514 $("input#lastnameEng" + global_index).prop( "disabled", true); 1515 } 1516 */ 1517 } 1518 catch (e) 1519 { 1520 alert ("AJAX Error"); 1521 return false; 1522 } 1523 1524 diving_calcTotals (); 1525 1526 return false; 1527} 1528 1529/* ------------------------------------------------------------------------------------------------------------ */ 1530/* diving_checkInstructor */ 1531/* ------------------------------------------------------------------------------------------------------------ */ 1532function diving_checkInstructor (index) 1533{ 1534 var packageId = $("form#orderPackageForm select#packageId").val(); 1535 var packageType = $("form#orderPackageForm input#packageType").val(); 1536 var packageSubType = $("form#orderPackageForm input#packageSubType").val(); 1537 1538 if (packageSubType == "split" || packageType == "instructor") 1539 { 1540 global_index = index; 1541 1542 var lang = $("form#orderPackageForm input#lang").val(); 1543 var tz = $("form#orderPackageForm input#tz" + global_index).val(); 1544 var birthYear = $("form#orderPackageForm select#birthYear" + global_index).val(); 1545 var birthMonth = $("form#orderPackageForm select#birthMonth" + global_index).val(); 1546 var birthDay = $("form#orderPackageForm select#birthDay" + global_index).val(); 1547 1548 if (tz != "" && birthYear != "" && birthMonth != "" && birthDay != "") 1549 { 1550 var xml = "<data>" + 1551 "<command>private.checkInstructor</command>" + 1552 "<lang>" + lang + "</lang>" + 1553 "<packageId>" + packageId + "</packageId>" + 1554 "<tz>" + tz + "</tz>" + 1555 "<birthYear>" + birthYear + "</birthYear>" + 1556 "<birthMonth>" + birthMonth + "</birthMonth>" + 1557 "<birthDay>" + birthDay + "</birthDay>" + 1558 "</data>"; 1559 1560 xmlRequest.init (xml); 1561 xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "checkInstructor_response"); 1562 } 1563 1564 return false;
1565 } 1566} 1567 1568function checkInstructor_response (i) 1569{ 1570 xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText)); 1571 1572 try 1573 { 1574 var returnCode = xmlRequest.getValue("returnCode"); 1575 var msg = xmlRequest.getValue("msg"); 1576 1577 if (returnCode != "OK") 1578 { 1579 alert (msg); 1580 1581 $("select#birthYear" + global_index).val (""); 1582 $("select#birthMonth" + global_index).val (""); 1583 $("select#birthDay" + global_index).val (""); 1584 1585 $("form#orderPackageForm input#tz" + global_index).focus(); 1586 $("form#orderPackageForm input#tz" + global_index).select(); 1587 } 1588 } 1589 catch (e) 1590 { 1591 alert ("AJAX Error"); 1592 return false; 1593 } 1594 1595 return false; 1596} 1597 1598/* ------------------------------------------------------------------------------------------------------------ */ 1599/* diving_submitTrumaForm */ 1600/* ------------------------------------------------------------------------------------------------------------ */ 1601function diving_submitTrumaForm () 1602{ 1603 var formValidator = new Validator("trumaForm"); 1604 1605 formValidator.clearAllValidations (); 1606 1607 formValidator.addValidation("firstname", "required", myTailJS["required-firstname"]); 1608 formValidator.addValidation("lastname", "required", myTailJS["required-lastname"]); 1609 formValidator.addValidation("email", "required", myTailJS["required-email"]); 1610 formValidator.addValidation("email", "email", myTailJS["invalid-email"]); 1611 formValidator.addValidation("trumaAmount", "required", myTailJS["required-trumaAmount"]); 1612 1613 if ($("#diffInvoiceDetails").prop ("checked")) 1614 { 1615 formValidator.addValidation ("invoiceName", "required", myTailJS["required-invoiceName"]); 1616 } 1617 1618 if (formValidator.validate ()) 1619 { 1620 if ($("input#trumaAmount").val() < 10) 1621 { 1622 alert ("ס××× ×תר××× ×××× ××××ת ××¢× 10 ש\"×"); 1623 return false; 1624 } 1625 1626 return true; 1627 } 1628 1629 return false; 1630} 1631 1632/* ------------------------------------------------------------------------------------------------------------ */ 1633/* diving_submitLoginOrderKitForm */ 1634/* ------------------------------------------------------------------------------------------------------------ */ 1635function diving_submitLoginOrderKitForm () 1636{ 1637 oForm = document.getElementById("loginOrderKitForm"); 1638 1639 if (oForm.enterPassword.value == "") 1640 { 1641 alert (myTailJS["required-password"]); 1642 return false; 1643 } 1644 1645 var xml = "<data>" + 1646 "<command>private.checkOrderKitPassword</command>" + 1647 "<code>" + oForm.code.value + "</code>" + 1648 "<password>" + oForm.enterPassword.value + "</password>" + 1649 "</data>"; 1650 1651 xmlRequest.init (xml); 1652 xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "diving_submitLoginOrderKitForm_response"); 1653 return false; 1654} 1655 1656function diving_submitLoginOrderKitForm_response (i) 1657{ 1658 oForm = document.getElementById("loginOrderKitForm"); 1659 1660 xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText)); 1661 1662 try 1663 { 1664 var returnCode = xmlRequest.getValue("returnCode"); 1665 1666 if (returnCode == "OK") 1667 { 1668 oForm.submit(); 1669 } 1670 else 1671 { 1672 alert (myTailJS["wrong-password"]); 1673 oForm.enterPassword.focus (); 1674 return false; 1675 } 1676 } 1677 catch (e) 1678 { 1679 alert ("AJAX Error"); 1680 return false; 1681 } 1682 1683 return false; 1684} 1685 1686/* ------------------------------------------------------------------------------------------------------------ */ 1687/* diving_submitOrderKitForm */ 1688/* ------------------------------------------------------------------------------------------------------------ */ 1689function diving_submitOrderKitForm () 1690{ 1691 var formValidator = new Validator("orderKitForm"); 1692 1693 formValidator.clearAllValidations (); 1694 1695 formValidator.addValidation ("courseKit", "required", myTailJS["required-courseKit"]); 1696 formValidator.addValidation ("firstname", "required", myTailJS["required-firstname"]); 1697 formValidator.addValidation ("lastname", "required", myTailJS["required-lastname"]); 1698// formValidator.addValidation ("tz", "required", myTailJS["required-tz"]); 1699 formValidator.addValidation ("phone", "required", myTailJS["required-phone"]); 1700 formValidator.addValidation ("email", "required", myTailJS["required-email"]); 1701 formValidator.addValidation ("email", "email", myTailJS["invalid-email"]); 1702 1703 if (formValidator.validate ()) 1704 { 1705 $('#submitOrderBtn').prop('disabled', true).html(myTailJS["sending"]); 1706 1707 return true; 1708 } 1709 1710 return false;
1711} 1712 1713/* ------------------------------------------------------------------------------------------------------------ */ 1714/* diving_handleMoreRegisters */ 1715/* ------------------------------------------------------------------------------------------------------------ */ 1716function diving_handleMoreRegisters (price) 1717{ 1718 var numRegistered = $("select#numRegistered").val(); 1719 1720 $("form#eventRegisterForm div.enter_registered").each (function () 1721 { 1722 $(this).hide (); 1723 }); 1724 1725 for (i = 1; i < numRegistered; i++) 1726 { 1727 $("form#eventRegisterForm div#enter_registered" + i).show(); 1728 } 1729 1730 var totalPrice = $("form#eventRegisterForm input#basePrice").val() * 1; 1731 1732 totalPrice += (price * (numRegistered - 1)); 1733 1734 $("form#eventRegisterForm input#sum").val(totalPrice); 1735 $("form#eventRegisterForm input#priceToPay").val(totalPrice); 1736 1737} 1738 1739/* ------------------------------------------------------------------------------------------------------------ */ 1740/* diving_checkTzForCourse */ 1741/* ------------------------------------------------------------------------------------------------------------ */ 1742function diving_checkTzForCourse () 1743{ 1744 var lang = $("form#courseRegisterForm input#lang").val(); 1745 var scubaCourse = $("form#courseRegisterForm input#scubaCourse").val(); 1746 var tz = $("form#courseRegisterForm input#tz").val(); 1747 var idType = $("form#courseRegisterForm input[name=idType]:checked").val(); 1748 1749 if (tz != "") 1750 { 1751 var xml = "<data>" + 1752 "<command>private.checkTzForCourse</command>" + 1753 "<lang>" + lang + "</lang>" + 1754 "<scubaCourse>" + scubaCourse + "</scubaCourse>" + 1755 "<tz>" + tz + "</tz>" + 1756 "<idType>" + idType + "</idType>" + 1757 "</data>"; 1758 1759 xmlRequest.init (xml); 1760 xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "diving_checkTzForCourse_response"); 1761 } 1762 1763 return false; 1764} 1765 1766function diving_checkTzForCourse_response (i) 1767{ 1768 xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText)); 1769 1770 try 1771 { 1772 var returnCode = xmlRequest.getValue("returnCode"); 1773 1774 if (returnCode != "OK") 1775 { 1776 if (returnCode == "INVALID_TZ") 1777 { 1778 alert (myTailJS["invalid-tz"]); 1779 } 1780 else if (returnCode == "NOT_UNIQUE") 1781 { 1782 alert (myTailJS["not-unique"]); 1783 } 1784 } 1785 else 1786 { 1787 var price = xmlRequest.getValue("price"); 1788 1789 $("#total").html (price); 1790 $("input#price").val (price); 1791 1792 if (price == 0) 1793 { 1794 $("#handleInvoice").hide(); 1795 $(".invoiceDetails").each (function () { $(this).hide () }); 1796 } 1797 else 1798 { 1799 $("#handleInvoice").show(); 1800 } 1801 } 1802 } 1803 catch (e) 1804 { 1805 alert ("AJAX Error"); 1806 return false; 1807 } 1808 1809 return false; 1810} 1811 1812/* ------------------------------------------------------------------------------------------------------------ */ 1813/* diving_submitScubaCourseRegisterForm */ 1814/* ------------------------------------------------------------------------------------------------------------ */ 1815function diving_submitScubaCourseRegisterForm () 1816{ 1817 var formValidator = new Validator("courseRegisterForm"); 1818 1819 formValidator.clearAllValidations (); 1820 1821 formValidator.addValidation ("tz", "required", myTailJS["required-tz"]); 1822 formValidator.addValidation ("firstname", "required", myTailJS["required-firstname"]); 1823 formValidator.addValidation ("lastname", "required", myTailJS["required-lastname"]); 1824 formValidator.addValidation ("email", "required", myTailJS["email-required"]); 1825 formValidator.addValidation ("email", "email", myTailJS["email-invalid"]); 1826 1827 return formValidator.validate (); 1828} 1829 1830/* ------------------------------------------------------------------------------------------------------------ */ 1831/* diving_saveSearch */ 1832/* ------------------------------------------------------------------------------------------------------------ */ 1833function diving_saveSearch (formName) 1834{ 1835 $("form#" + formName + " input, form#" + formName + " select").each (function () 1836 { 1837 if ($(this).attr('type') == "checkbox") 1838 { 1839 if ($(this).is(":checked")) 1840 var value = 1; 1841 else 1842 var value = 0; 1843 } 1844 else 1845 { 1846 var value = $(this).val(); 1847 } 1848 commonSetCookie ($(this).attr('id'), value); 1849 }); 1850 return true; 1851} 1852
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.