Modifications to enable YUI-Grids layout structure. Unfinished.
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / cataloguing / addbiblio.tmpl
1 <!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
2 <title>Koha &rsaquo; Cataloging &rsaquo; <!-- TMPL_IF NAME="biblionumber" -->Edit MARC Record Number <!-- TMPL_VAR name="biblionumber" --><!-- TMPL_ELSE -->Add MARC Record<!-- /TMPL_IF --></title>
3 <!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
4 <!-- TMPL_INCLUDE NAME="header.inc" -->
5
6 <!--TMPL_UNLESS Name="popup"-->
7     <!-- TMPL_INCLUDE NAME="menu-catalogue.inc" -->
8 <!--/TMPL_UNLESS-->
9
10 <!--TMPL_IF Name="done"-->
11     <script language="javascript" type="text/javascript">
12         opener.document.forms['f'].biblionumber.value=<!--TMPL_VAR Name="biblionumber"-->;
13         opener.document.forms['f'].title.value='<!--TMPL_VAR Name="title" ESCAPE="HTML"-->';
14         window.close();
15     </script>
16 <!--TMPL_ELSE-->
17     <form method="post" name="f" id="f" action="/cgi-bin/koha/cataloguing/addbiblio.pl" onsubmit="return Check();">
18 <!-- /TMPL_IF -->
19
20 <h1><!-- TMPL_IF NAME="biblionumtagfield" -->Edit MARC Record Number <!-- TMPL_VAR name="biblionumber" --><!-- TMPL_ELSE -->Add MARC Record<!-- /TMPL_IF --></h1>
21
22 <div id="action">
23     <!-- TMPL_IF name="biblionumber" -->
24         <input type="submit" value="Save Bibliographic Record" />
25     <!-- TMPL_ELSE -->
26         <input type="submit" value="Add Bibliographic Record" />
27     <!-- /TMPL_IF -->
28     <input type="button" value="z39.50 Search" onclick="PopupZ3950(); return false;" />
29 </div>
30 <br />
31  Change framework : <!--TMPL_VAR Name="framework" -->
32
33         <input type="hidden" name="op" value="addbiblio" />
34
35 <!--TMPL_IF Name="popup"-->
36         <input type="hidden" name="mode" value="popup" />
37 <!--/TMPL_IF-->
38         <input type="hidden" name="frameworkcode" value="<!-- TMPL_VAR NAME="frameworkcode" -->" />
39         <input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->" />
40         <input type="hidden" name="breedingid" value="<!-- TMPL_VAR NAME="breedingid" -->" />
41
42         <div id="tabs">
43         <!-- TMPL_LOOP name="BIG_LOOP" -->
44             <!-- TMPL_IF name="number" -->
45                 <a href="javascript:active(<!-- TMPL_VAR name="number"-->)" class="tab_inactive" id="link<!-- TMPL_VAR name="number"-->"><!-- TMPL_VAR name="number"--></a>
46             <!-- TMPL_ELSE -->
47                 <a href="javascript:active(<!-- TMPL_VAR name="number"-->)" class="tab_active" id="link<!-- TMPL_VAR name="number"-->"><!-- TMPL_VAR name="number"--></a>
48             <!-- /TMPL_IF -->
49         <!--  /TMPL_LOOP -->
50         </div>
51
52 <!-- TMPL_LOOP name="BIG_LOOP" -->
53 <!-- hide every tab except the 1st -->
54 <!-- TMPL_IF name="number" -->
55     <div id="<!-- TMPL_VAR name="number" -->XX" class="content_hidden">
56 <!-- TMPL_ELSE -->
57     <div id="0XX" class="content_visible">
58 <!-- /TMPL_IF -->
59 <!-- TMPL_UNLESS name="number" -->
60     <!-- show duplicate warning on tab 0 only -->
61         <!-- TMPL_IF name="duplicatebiblionumber" -->
62                     <div class="error">
63                         <p class="problem">Is this a duplicate of <a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=<!-- TMPL_VAR name="duplicatebiblionumber" -->" onclick="openWindow('../MARCdetail.pl?biblionumber=<!-- TMPL_VAR name="duplicatebiblionumber" -->&amp;popup=1', 'Duplicate biblio'; return false;)"><!-- TMPL_VAR name="duplicatetitle" --></a>?</p>
64                         <p>You must either :</p>
65                         <ul>
66                             <li>If it <em>is</em> a duplicate, <a href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=<!-- TMPL_VAR name="duplicatebiblionumber" -->">Edit Items</a> of the existing record.</li>
67                             <li>If not, click to <input type="hidden" value="0" id="confirm_not_duplicate" name="confirm_not_duplicate" /> <a href="#" onclick="confirmnotdup(); return false;">Confirm it's not a duplicate</a></li>
68                         </ul>
69                     </div>
70         <!-- /TMPL_IF -->
71     <!-- /TMPL_UNLESS -->
72     
73     <!-- TMPL_LOOP NAME="innerloop" -->
74         <!-- TMPL_IF NAME="tag" -->
75         <div class="tag" id="tag_<!-- TMPL_VAR name="tag"-->_<!-- TMPL_VAR NAME='index'-->">
76         <div class="tag_title" name="div_indicator">
77             <!-- TMPL_UNLESS name="hide_marc" -->
78                 <span title="<!-- TMPL_VAR NAME="tag_lib" -->"><!-- TMPL_VAR NAME="tag" --></span>
79                 <!-- TMPL_IF NAME="fixedfield" -->
80                         <input tabindex="1"
81                                class="indicator flat"
82                                type="text"
83                                style="display:none;"
84                                name="tag_<!-- TMPL_VAR NAME="tag" -->_indicator_<!-- TMPL_VAR NAME='index'-->"
85                                size="2"
86                                maxlength="2"
87                                value="<!-- TMPL_VAR NAME="indicator" -->" />
88                 <!-- TMPL_ELSE -->
89                         <input tabindex="1"
90                                class="indicator flat"
91                                type="text"
92                                name="tag_<!-- TMPL_VAR NAME="tag" -->_indicator_<!-- TMPL_VAR NAME='index'-->"
93                                size="2"
94                                maxlength="2"
95                                value="<!-- TMPL_VAR NAME="indicator" -->" />
96                 <!-- /TMPL_IF --> -
97             <!-- TMPL_ELSE -->
98                 <!-- TMPL_IF NAME="fixedfield" -->
99                     <input tabindex="1"
100                            type="hidden"
101                            name="tag_<!-- TMPL_VAR NAME="tag" -->_indicator_<!-- TMPL_VAR NAME='index'-->"
102                            value="<!-- TMPL_VAR NAME="indicator" -->" />
103                 <!-- TMPL_ELSE -->
104                     <input tabindex="1"
105                            type="hidden"
106                            name="tag_<!-- TMPL_VAR NAME="tag" -->_indicator_<!-- TMPL_VAR NAME='index'-->"
107                            value="<!-- TMPL_VAR NAME="indicator" -->" />
108                 <!-- /TMPL_IF -->
109             <!-- /TMPL_UNLESS -->
110
111             <!-- TMPL_UNLESS NAME="advancedMARCEditor" -->
112                     <a onclick="ExpandField('tag_<!-- TMPL_VAR name="tag"-->_<!-- TMPL_VAR NAME='index'-->')"><!-- TMPL_VAR NAME="tag_lib" --></a>
113             <!-- /TMPL_UNLESS -->
114             <!-- TMPL_IF name="repeatable" -->
115                 <span class="buttonPlus" onclick="CloneField('tag_<!-- TMPL_VAR name="tag"-->_<!-- TMPL_VAR NAME='index'-->')">+</span>
116             <!-- /TMPL_IF -->
117             
118         </div>
119         
120         <!-- TMPL_LOOP NAME="subfield_loop" -->
121             <!--  One line on the marc editor -->
122             <div name="line" class="subfield_line" style="<!-- TMPL_VAR NAME='visibility' -->;" id="subfield<!-- TMPL_VAR NAME='tag' --><!-- TMPL_VAR NAME='subfield' -->">
123             
124                 <!--TMPL_UNLESS NAME="advancedMARCEditor" -->
125                 <label for="tag_<!-- TMPL_VAR NAME='tag'-->_subfield_<!--  TMPL_VAR NAME='subfield'-->_<!-- TMPL_VAR NAME='index'-->_<!-- TMPL_VAR NAME='index_subfield'-->"
126                         <!-- TMPL_IF NAME="fixedfield" --> style="display:none;" <!-- /TMPL_IF --> class="labelsubfield" >
127                 <!-- /TMPL_UNLESS --> 
128                 
129                 <!-- TMPL_UNLESS name="hide_marc" -->
130                     <img class="buttonUp" <!-- TMPL_IF NAME="fixedfield" --> style="display:none;" <!-- /TMPL_IF --> src="<!-- TMPL_VAR NAME="themelang" -->/images/up.png" onclick="upSubfield('subfield<!-- TMPL_VAR NAME='tag' --><!-- TMPL_VAR NAME='subfield' -->')" alt="" />
131                         <input title="<!-- TMPL_VAR NAME='marc_lib_plain' -->"
132                             style=" <!-- TMPL_IF NAME="fixedfield" -->display:none; <!-- /TMPL_IF -->border:0;" type="text"
133                             name="tag_<!-- TMPL_VAR NAME='tag'-->_code_<!--  TMPL_VAR NAME='subfield'-->_<!-- TMPL_VAR NAME='index'-->_<!-- TMPL_VAR NAME='index_subfield'-->"
134                             value="<!-- TMPL_VAR NAME="subfield" -->"
135                             size="1"
136                             maxlength="1"
137                             class="flat"
138                             tabindex="-1" />
139                 <!-- TMPL_ELSE -->
140                     <input type="hidden"
141                            name="tag_<!-- TMPL_VAR NAME='tag'-->_code_<!--  TMPL_VAR NAME='subfield'-->_<!-- TMPL_VAR NAME='index'-->_<!-- TMPL_VAR NAME='index_subfield'-->"
142                            value="<!-- TMPL_VAR NAME="subfield" -->" />
143                 <!-- /TMPL_UNLESS -->
144             
145                 <!-- TMPL_UNLESS NAME="advancedMARCEditor" -->
146                     <!-- TMPL_IF name="mandatory" --><span class="subfield_mandatory"><!-- /TMPL_IF -->
147                         <!-- TMPL_VAR NAME="marc_lib" -->
148                     <!-- TMPL_IF name="mandatory" --></span><!-- /TMPL_IF -->
149                     </label>
150                 <!-- /TMPL_UNLESS -->
151                 
152                 <!-- TMPL_VAR NAME="marc_value" -->
153                 
154                 <!-- TMPL_IF NAME="repeatable" -->
155                     <span class="buttonPlus" onclick="CloneSubfield('subfield<!-- TMPL_VAR NAME='tag' --><!-- TMPL_VAR NAME='subfield' -->')">+</span>
156                 <!-- /TMPL_IF -->
157                 
158             </div>
159             <!-- End of the line -->
160             
161         <!-- /TMPL_LOOP -->
162         </div>
163         <!-- /TMPL_IF --><!-- tag -->
164     <!-- /TMPL_LOOP -->
165     </div>
166 <!-- /TMPL_LOOP -->
167
168 </form>
169
170 <script language="javascript" type="text/javascript">
171
172 function _(s) { return s } // dummy function for gettext
173
174 function confirmnotdup(){
175         document.getElementById("confirm_not_duplicate").value = 1;
176         var checkform = document.getElementById("f");
177         Check(checkform);
178 }
179
180 function active(numlayer){
181     for (i=0; i <= 10 ; i++ ) {
182         var tab;
183         try{
184                 tab = document.getElementById(i+'XX');
185                 tab.getAttribute('id'); // do not remove this line. It throws an execption.
186         }
187         catch(e){
188                 continue;
189         }
190         if (numlayer==i) {
191             tab.setAttribute("class","content_visible");
192             var tabactive=document.getElementById('link'+i);
193             tabactive.removeAttribute("class");
194             tabactive.setAttribute("class","tab_active");
195         } else {
196             tab.setAttribute("class","content_hidden");
197             try {
198                 var tabactive=document.getElementById('link'+i);
199                 tabactive.removeAttribute("class");
200                 tabactive.setAttribute("class","tab_inactive");
201             }
202             catch(e){};
203         }
204     }
205 }
206
207 /**
208  * 
209  * 
210  */
211 function Check(){
212     var StrAlert = AreMandatoriesNotOk();
213     if( ! StrAlert ){
214         document.f.submit;
215         return true;
216     } else {
217         alert(StrAlert);
218         return false;
219     }
220 }
221
222 function Dopop(link,i) {
223     defaultvalue = document.getElementById(i).value;
224     window.open(link+"&result="+defaultvalue,"value builder",'width=700,height=550,toolbar=false,scrollbars=yes');
225 }
226
227 /**
228  * this function open a popup to search on z3950 server.
229  */
230 function PopupZ3950() {
231     var strQuery = AreZ3950MandoriesOk();
232     if(strQuery){
233         window.open("/cgi-bin/koha/cataloguing/z3950_search.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&frameworkcode=<!-- TMPL_VAR NAME="frameworkcode" -->"+strQuery,"z3950search",'width=640,height=400,location=yes,toolbar=no,scrollbars=yes');
234     } else {
235         var strAlert = _("To perform a z39.50 search, you must enter at least one of the following: \n\n ISBN\n ISSN\n Title\n Author\n");    
236         alert(strAlert);
237     }
238 }
239
240 /**
241  * check if mandatory subfields are writed
242  */
243 function AreMandatoriesNotOk(){
244     var mandatories = new Array();
245     var tab = new Array();
246     var label = new Array();
247     var flag=0;
248     <!-- TMPL_LOOP NAME='BIG_LOOP' --> 
249         <!-- TMPL_LOOP NAME='innerloop' -->
250             <!-- TMPL_LOOP NAME='subfield_loop'-->
251                 <!-- TMPL_IF NAME='mandatory'-->
252                     mandatories.push("<!-- TMPL_VAR NAME='id' -->");
253                         tab.push("<!-- TMPL_VAR NAME='number' -->");
254                         label.push("<!-- TMPL_VAR NAME='marc_lib' -->");
255                 <!-- /TMPL_IF -->
256             <!-- /TMPL_LOOP -->
257         <!-- /TMPL_LOOP -->
258     <!-- /TMPL_LOOP -->
259     var StrAlert = "Can't save this record because the following field aren't filled :\n\n";
260     for(var i=0,len=mandatories.length; i<len ; i++){
261         if( ! document.getElementById(mandatories[i]).value){
262             flag = 1;
263             document.getElementById(mandatories[i]).setAttribute('class','subfield_not_filled');
264             document.getElementById(mandatories[i]).focus();
265             StrAlert += "\t* "+label[i]+" in tab "+tab[i]+"\n";
266         }
267     }
268     if(flag){
269             return StrAlert;
270         } else {
271                 return flag;
272         }
273 }
274
275 /** 
276  * check if z3950 mandatories are set or not
277  */
278 function AreZ3950MandoriesOk(){
279     var mandatories = new Array();
280     var mandatories_label = new Array();
281     
282     <!-- TMPL_LOOP NAME='BIG_LOOP' --> 
283         <!-- TMPL_LOOP NAME='innerloop' -->
284             <!-- TMPL_LOOP NAME='subfield_loop'-->
285                 <!-- TMPL_IF NAME='z3950_mandatory'-->
286                     mandatories.push("<!-- TMPL_VAR NAME='id' -->");
287                     mandatories_label.push("<!-- TMPL_VAR NAME='z3950_mandatory' -->");
288                 <!-- /TMPL_IF -->
289             <!-- /TMPL_LOOP -->
290         <!-- /TMPL_LOOP -->
291     <!-- /TMPL_LOOP -->
292     
293     var error = 0;
294     var strQuery="";
295     for(var i=0,len=mandatories.length; i<len ; i++){
296         var field_value = document.getElementById(mandatories[i]).value;
297         if( ! field_value ){
298             error++;
299         } else {
300             strQuery += "&"+mandatories_label[i]+"="+field_value;
301         }
302     }
303     if(error < 4){
304         return strQuery;
305     } else {
306         return false;
307     }
308 }
309
310 function Changefwk(FwkList) {
311         var fwk = FwkList.options[FwkList.selectedIndex].value;
312         window.location = "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=<!--TMPL_VAR Name="oldbiblionumber"-->&breedingid=<!-- TMPL_VAR name="breedingid" -->&frameworkcode="+fwk;
313
314 }
315
316 function openAuth(tagid,authtype,X) {
317 //      defaultid=document.getElementById(subfieldid);
318 //     alert("X"+X);
319     Y=X.parentNode.getAttribute("id");
320 //     alert("tagid"+Y);
321         newin=window.open("../authorities/auth_finder.pl?authtypecode="+  authtype+ "&tagid="+Y, "value builder",'width=700,height=550,toolbar=false,scrollbars=yes');
322 }
323
324
325 function ExpandField(index) {
326     var original = document.getElementById(index); //original <div>
327     var divs = original.getElementsByTagName('div');
328     for(var i=0,divslen = divs.length ; i<divslen ; i++){      // foreach div
329         if(divs[i].getAttribute("name") == 'line'){  // if it s a subfield
330             if (divs[i].style.display == 'block') {
331                 divs[i].style.display = 'none';
332             } else {
333                 divs[i].style.display = 'block';
334             }
335         }
336     }
337 }
338
339 /**
340  * To clone a field or a subfield by clickink on '+' button
341  */ 
342 function CloneField(index) {
343     var original = document.getElementById(index); //original <div>
344     var clone = original.cloneNode(true);
345     var new_key = CreateKey();
346     var new_id  = original.getAttribute('id')+new_key;
347     
348     clone.setAttribute('id',new_id); // setting a new id for the parent div
349     
350     var divs = clone.getElementsByTagName('div');
351     
352     <!-- TMPL_UNLESS NAME='hide_marc'--> // No indicator if hide_marc
353         // setting a new name for the new indicator
354         var indicator = clone.getElementsByTagName('input')[0];
355         indicator.setAttribute('name',indicator.getAttribute('name')+new_key);
356     <!-- /TMPL_UNLESS -->
357         
358     // settings all subfields
359     for(var i=0,divslen = divs.length ; i<divslen ; i++){      // foreach div
360         if(divs[i].getAttribute("name") == 'line'){  // if it s a subfield
361             
362             // set the attribute for the new 'div' subfields
363             divs[i].setAttribute('id',divs[i].getAttribute('id')+new_key);
364             
365             var inputs   = divs[i].getElementsByTagName('input');
366             var id_input = "";
367             
368             inputs[0].setAttribute('id',inputs[0].getAttribute('id')+new_key);
369             inputs[0].setAttribute('name',inputs[0].getAttribute('name')+new_key);
370             var id_input;
371             try {
372                 id_input = inputs[1].getAttribute('id')+new_key;
373                 inputs[1].setAttribute('id',id_input);
374                 inputs[1].setAttribute('name',inputs[1].getAttribute('name')+new_key);
375             } catch(e) {
376                 try{ // it s a select if it is not an input
377                     var selects = divs[i].getElementsByTagName('select');
378                     id_input = selects[0].getAttribute('id')+new_key;
379                     selects[0].setAttribute('id',id_input);
380                     selects[0].setAttribute('name',selects[0].getAttribute('name')+new_key);
381                 }catch(e2){ // it is a textarea if it s not a select or an input
382                         var textaeras = divs[i].getElementsByTagName('textarea');
383                         id_input = textaeras[0].getAttribute('id')+new_key;
384                         textaeras[0].setAttribute('id',id_input);
385                     textaeras[0].setAttribute('name',textaeras[0].getAttribute('name')+new_key);
386                 }
387             }
388             
389             <!-- TMPL_UNLESS NAME='advancedMARCEditor'-->
390             // when cloning a subfield, re set its label too.
391             var labels = divs[i].getElementsByTagName('label');
392             labels[0].setAttribute('for',id_input);
393             <!-- /TMPL_UNLESS -->
394             
395             <!-- TMPL_UNLESS NAME='hide_marc'-->
396                 // updating javascript parameters on button up
397                 var imgs = divs[i].getElementsByTagName('img');
398                 imgs[0].setAttribute('onclick',"upSubfield(\'"+divs[i].getAttribute('id')+"\');");
399             <!-- /TMPL_UNLESS -->
400             
401             // setting its '+' button
402             var CloneButtonPlus=0;
403             try {
404                 CloneButtonPlus = divs[i].getElementsByTagName('span')[0];
405                 if(CloneButtonPlus.getAttribute('class') == 'buttonPlus'){
406                     CloneButtonPlus.setAttribute('onclick',"CloneSubfield('" + divs[i].getAttribute('id') + "')");
407                 } else {
408                     CloneButtonPlus = 0;
409                 }
410             }
411             catch(e){
412                 // do nothig if ButtonPlus & CloneButtonPlus don t exist.
413             }
414             
415             // button ...
416             var spans=0;
417             try {
418                 spans = divs[i].getElementsByTagName('span');
419             } catch(e) {
420                 // no spans
421             }
422             if(spans){
423                 var buttonDot;
424                 if(!CloneButtonPlus){ // it s impossible to have  + ... (buttonDot AND buttonPlus)
425                     buttonDot = spans[0];
426                     if(buttonDot){
427                         // 2 possibilities :
428                         try{
429                             var buttonDotOnClick = buttonDot.getAttribute('onclick');
430                             if(buttonDotOnClick.match('Clictag')){   // -1- It s a plugin
431                                 var re = /\('.*'\)/i;
432                                 buttonDotOnClick = buttonDotOnClick.replace(re,"('"+inputs[1].getAttribute('id')+"')");
433                                 if(buttonDotOnClick){
434                                     buttonDot.setAttribute('onclick',buttonDotOnClick);
435                                 }
436                             } else {
437                                 if(buttonDotOnClick.match('Dopop')) {  // -2- It's a auth value
438                                     
439                                     var re1 = /&index=.*',/;
440                                     var re2 = /,.*\)/;
441
442                                     buttonDotOnClick = buttonDotOnClick.replace(re1,"&index="+inputs[1].getAttribute('id')+"',");
443                                     buttonDotOnClick = buttonDotOnClick.replace(re2,",'"+inputs[1].getAttribute('id')+"')");
444                                     
445                                     if(buttonDotOnClick){
446                                             buttonDot.setAttribute('onclick',buttonDotOnClick);
447                                     }
448                                 }
449                             }
450                             try {
451                                 // do not copy the script section.
452                                 var script = spans[0].getElementsByTagName('script')[0];
453                                 spans[0].removeChild(script);
454                             } catch(e) {
455                                 // do nothing if there is no script
456                             }
457                         }catch(e){}
458                         }
459                 }
460             }
461             <!-- TMPL_UNLESS NAME='hide_marc'-->
462                 var buttonUp = divs[i].getElementsByTagName('img')[0];
463                 buttonUp.setAttribute('onclick',"upSubfield('" + divs[i].getAttribute('id') + "')");
464             <!-- /TMPL_UNLESS -->
465             
466         } else { // it's a indicator div
467             if(divs[i].getAttribute('name') == 'div_indicator'){
468                 var inputs = divs[i].getElementsByTagName('input');
469                 inputs[0].setAttribute('id',inputs[0].getAttribute('id')+new_key);
470                 
471                 var CloneButtonPlus;
472                 try {
473                     CloneButtonPlus = divs[i].getElementsByTagName('span')[1]; // 0 is the title
474                     CloneButtonPlus.setAttribute('onclick',"CloneField('" + divs[i].parentNode.getAttribute('id') + "')");
475                 }
476                 catch(e){
477                     // do nothig CloneButtonPlus doesn't exist.
478                 }
479             }
480         }
481     }
482     
483     // insert this line on the page
484     original.parentNode.insertBefore(clone,original.nextSibling);
485 }
486
487 function CloneSubfield(index){
488     var original = document.getElementById(index); //original <div>
489     var clone = original.cloneNode(true);
490     var new_key = CreateKey();
491     var new_id  = original.getAttribute('id')+new_key;
492     
493     // set the attribute for the new 'div' subfields
494     var inputs     = clone.getElementsByTagName('input');
495     var selects    = clone.getElementsByTagName('select');
496     var textareas  = clone.getElementsByTagName('textarea');
497         
498     // input
499     var id_input = "";
500     for(var i=0,len=inputs.length; i<len ; i++ ){
501         id_input = inputs[i].getAttribute('id')+new_key;
502         inputs[i].setAttribute('id',id_input);
503         inputs[i].setAttribute('name',inputs[i].getAttribute('name')+new_key);
504     }
505     
506     // select 
507     for(var i=0,len=selects.length; i<len ; i++ ){
508         id_input = selects[i].getAttribute('id')+new_key;
509         selects[i].setAttribute('id',selects[i].getAttribute('id')+new_key);
510         selects[i].setAttribute('name',selects[i].getAttribute('name')+new_key);
511     }
512     
513     // textarea
514     for(var i=0,len=textareas.length; i<len ; i++ ){
515         id_input = textareas[i].getAttribute('id')+new_key;
516         textareas[i].setAttribute('id',textareas[i].getAttribute('id')+new_key);
517         textareas[i].setAttribute('name',textareas[i].getAttribute('name')+new_key);
518     }
519     
520     <!-- TMPL_UNLESS NAME='advancedMARCEditor' -->
521     // when cloning a subfield, reset its label too.
522     var label = clone.getElementsByTagName('label')[0];
523     label.setAttribute('for',id_input);
524     <!-- /TMPL_UNLESS -->
525     
526     // setting a new if for the parent div
527     clone.setAttribute('id',new_id);
528     
529     var CloneButtonPlus;
530     try {
531         var spans = clone.getElementsByTagName('span');
532         if(spans.length){
533                 for(var i = 0 ,lenspans = spans.length ; i < lenspans ; i++){
534                         if(spans[i].getAttribute('class') == 'buttonPlus'){
535                     CloneButtonPlus = spans[i];
536                     CloneButtonPlus.setAttribute('onclick',"CloneSubfield('" + new_id + "')");
537                     var buttonUp = clone.getElementsByTagName('img')[0];
538                     buttonUp.setAttribute('onclick',"upSubfield('" + new_id + "')");
539                 }
540             }
541         }
542     }
543     catch(e){
544         // do nothig if ButtonPlus & CloneButtonPlus don't exist.
545     }
546     // insert this line on the page
547     original.parentNode.insertBefore(clone,original.nextSibling);
548 }
549
550 /**
551  * This function create a random number
552  */
553 function CreateKey(){
554     return parseInt(Math.random() * 100000);
555 }
556
557 /**
558  * This function allows to move a subfield up by clickink on the 'up' button .
559  */
560 function upSubfield(index) {
561     try{
562         var line = document.getElementById(index); // get the line where the user has clicked.
563     } catch(e) {
564         return; // this line doesn't exist...
565     }
566     var tag = line.parentNode; // get the dad of this line. (should be "<div id='tag_...'>")
567     
568     // getting all subfields for this tag
569     var subfields = tag.getElementsByTagName('div');
570     var subfieldsLength = subfields.length;
571     
572     if(subfieldsLength<=1) return; // nothing to do if there is just one subfield.
573     
574     // among all subfields 
575     for(var i=0;i<subfieldsLength;i++){ 
576         if(subfields[i].getAttribute('id') == index){ //looking for the subfield which is clicked :
577             if(i==1){ // if the clicked subfield is on the top
578                 tag.appendChild(subfields[1]);
579                 return;
580             } else {
581                 var lineAbove = subfields[i-1];
582                 tag.insertBefore(line,lineAbove);
583                 return;
584             }
585         }
586     }
587 }
588
589 function unHideSubfield(index,labelindex) { // FIXME :: is it used ?
590     subfield = document.getElementById(index);
591     subfield.style.display = 'block';
592     label = document.getElementById(labelindex);
593     label.style.display='none'; 
594 }
595
596 </script>
597 </div>
598 </div>
599 </div>
600
601 <!-- TMPL_INCLUDE NAME="mainmenu.inc" -->
602 <!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->