Three new functions: CheckAll, which toggles checkboxes in results lists; confirmDele...
[koha.git] / koha-tmpl / opac-tmpl / npl / en / includes / script.js
1 function ValidateCode()
2 {
3  // Validating the patron id by Oscar R. Paredes
4  // Please do not remove this line and the line above.
5   var patron_id = document.forms['auth'].userid.value;
6   var snumber = "Pp 0123456789";
7   var len = patron_id.length;
8   var new_patron_id = "";
9   var bOK = true
10   if (patron_id.length != 0)
11   {
12    for (i=0;(i<len)&&(bOK);i++)
13     { pos = snumber.indexOf(patron_id.substring(i,i+1));
14       if (pos <0 || pos > 12)
15         { alert("Your card number is invalid, please verify it.");
16           bOK = false;
17         }
18       else
19         { if (pos > 2)
20             car = patron_id.substring(i,i+1);
21           else
22             car = "";
23           new_patron_id = new_patron_id + car;
24         }
25     } // end for i
26    while (bOK && (new_patron_id.length < 7))
27      new_patron_id = "0" + new_patron_id;
28    if (new_patron_id.length > 7)
29      { alert("Your library card number is too long.");
30        bOK = false;
31      }
32    if (bOK)
33      document.forms['auth'].userid.value = new_patron_id;
34    else
35      {
36        document.forms['auth'].userid.value = "";
37        document.forms['auth'].userid.focus();
38      }
39   }
40 }
41
42 function CheckAll()
43 {
44 count = document.mainform.elements.length;
45     for (i=0; i < count; i++) 
46         {
47             if(document.mainform.elements[i].checked == 1){
48                         document.mainform.elements[i].checked = 0;
49                 } else {
50                         document.mainform.elements[i].checked = 1;
51                 }
52         }
53 }
54
55 function confirmDelete(message) {
56         var agree = confirm(message);
57         if(agree) {
58                 return true;
59         } else {
60                 return false;
61         }
62 }
63
64 function Dopop(link) {
65         newin=window.open(link,'popup','width=500,height=400,toolbar=false,scrollbars=yes');
66         }