4 * @var sql_box_locked lock for the sqlbox textarea in the querybox/querywindow
6 var sql_box_locked = false;
9 * @var array holds elements which content should only selected once
11 var only_once_elements = new Array();
14 * selects the content of a given object, f.e. a textarea
16 * @param object element element of which the content will be selected
17 * @param var lock variable which holds the lock for this element
18 * or true, if no lock exists
19 * @param boolean only_once if true this is only done once
20 * f.e. only on first focus
22 function selectContent( element, lock, only_once ) {
23 if ( only_once && only_once_elements[element.name] ) {
27 only_once_elements[element.name] = true;
37 * Displays an confirmation box before to submit a "DROP DATABASE" query.
38 * This function is called while clicking links
40 * @param object the link
41 * @param object the sql query to submit
43 * @return boolean whether to run the query or not
45 function confirmLinkDropDB(theLink, theSqlQuery)
47 // Confirmation is not required in the configuration file
48 // or browser is Opera (crappy js implementation)
49 if (confirmMsg == '' || typeof(window.opera) != 'undefined') {
53 var is_confirmed = confirm(confirmMsgDropDB + '\n' + confirmMsg + ' :\n' + theSqlQuery);
55 theLink.href += '&is_js_confirmed=1';
59 } // end of the 'confirmLinkDropDB()' function
62 * Displays an confirmation box before to submit a "DROP/DELETE/ALTER" query.
63 * This function is called while clicking links
65 * @param object the link
66 * @param object the sql query to submit
68 * @return boolean whether to run the query or not
70 function confirmLink(theLink, theSqlQuery)
72 // Confirmation is not required in the configuration file
73 // or browser is Opera (crappy js implementation)
74 if (confirmMsg == '' || typeof(window.opera) != 'undefined') {
78 var is_confirmed = confirm(confirmMsg + ' :\n' + theSqlQuery);
80 if ( typeof(theLink.href) != 'undefined' ) {
81 theLink.href += '&is_js_confirmed=1';
82 } else if ( typeof(theLink.form) != 'undefined' ) {
83 theLink.form.action += '?is_js_confirmed=1';
88 } // end of the 'confirmLink()' function
92 * Displays an confirmation box before doing some action
94 * @param object the message to display
96 * @return boolean whether to run the query or not
98 function confirmAction(theMessage)
100 // TODO: Confirmation is not required in the configuration file
101 // or browser is Opera (crappy js implementation)
102 if (typeof(window.opera) != 'undefined') {
106 var is_confirmed = confirm(theMessage);
109 } // end of the 'confirmAction()' function
113 * Displays an error message if a "DROP DATABASE" statement is submitted
114 * while it isn't allowed, else confirms a "DROP/DELETE/ALTER" query before
115 * sumitting it if required.
116 * This function is called by the 'checkSqlQuery()' js function.
118 * @param object the form
119 * @param object the sql query textarea
121 * @return boolean whether to run the query or not
123 * @see checkSqlQuery()
125 function confirmQuery(theForm1, sqlQuery1)
127 // Confirmation is not required in the configuration file
128 if (confirmMsg == '') {
132 // The replace function (js1.2) isn't supported
133 else if (typeof(sqlQuery1.value.replace) == 'undefined') {
137 // js1.2+ -> validation with regular expressions
139 // "DROP DATABASE" statement isn't allowed
140 if (noDropDbMsg != '') {
141 var drop_re = new RegExp('DROP\\s+(IF EXISTS\\s+)?DATABASE\\s', 'i');
142 if (drop_re.test(sqlQuery1.value)) {
150 // Confirms a "DROP/DELETE/ALTER" statement
152 // TODO: find a way (if possible) to use the parser-analyser
153 // for this kind of verification
154 // For now, I just added a ^ to check for the statement at
155 // beginning of expression
157 var do_confirm_re_0 = new RegExp('^DROP\\s+(IF EXISTS\\s+)?(TABLE|DATABASE)\\s', 'i');
158 var do_confirm_re_1 = new RegExp('^ALTER\\s+TABLE\\s+((`[^`]+`)|([A-Za-z0-9_$]+))\\s+DROP\\s', 'i');
159 var do_confirm_re_2 = new RegExp('^DELETE\\s+FROM\\s', 'i');
160 if (do_confirm_re_0.test(sqlQuery1.value)
161 || do_confirm_re_1.test(sqlQuery1.value)
162 || do_confirm_re_2.test(sqlQuery1.value)) {
163 var message = (sqlQuery1.value.length > 100)
164 ? sqlQuery1.value.substr(0, 100) + '\n ...'
166 var is_confirmed = confirm(confirmMsg + ' :\n' + message);
167 // drop/delete/alter statement is confirmed -> update the
168 // "is_js_confirmed" form field so the confirm test won't be
169 // run on the server side and allows to submit the form
171 theForm1.elements['is_js_confirmed'].value = 1;
174 // "DROP/DELETE/ALTER" statement is rejected -> do not submit
180 } // end if (handle confirm box result)
181 } // end if (display confirm box)
182 } // end confirmation stuff
185 } // end of the 'confirmQuery()' function
189 * Displays an error message if the user submitted the sql query form with no
190 * sql query, else checks for "DROP/DELETE/ALTER" statements
192 * @param object the form
194 * @return boolean always false
196 * @see confirmQuery()
198 function checkSqlQuery(theForm)
200 var sqlQuery = theForm.elements['sql_query'];
203 // The replace function (js1.2) isn't supported -> basic tests
204 if (typeof(sqlQuery.value.replace) == 'undefined') {
205 isEmpty = (sqlQuery.value == '') ? 1 : 0;
206 if (isEmpty && typeof(theForm.elements['sql_file']) != 'undefined') {
207 isEmpty = (theForm.elements['sql_file'].value == '') ? 1 : 0;
209 if (isEmpty && typeof(theForm.elements['sql_localfile']) != 'undefined') {
210 isEmpty = (theForm.elements['sql_localfile'].value == '') ? 1 : 0;
212 if (isEmpty && typeof(theForm.elements['id_bookmark']) != 'undefined') {
213 isEmpty = (theForm.elements['id_bookmark'].value == null || theForm.elements['id_bookmark'].value == '');
216 // js1.2+ -> validation with regular expressions
218 var space_re = new RegExp('\\s+');
219 if (typeof(theForm.elements['sql_file']) != 'undefined' &&
220 theForm.elements['sql_file'].value.replace(space_re, '') != '') {
223 if (typeof(theForm.elements['sql_localfile']) != 'undefined' &&
224 theForm.elements['sql_localfile'].value.replace(space_re, '') != '') {
227 if (isEmpty && typeof(theForm.elements['id_bookmark']) != 'undefined' &&
228 (theForm.elements['id_bookmark'].value != null || theForm.elements['id_bookmark'].value != '') &&
229 theForm.elements['id_bookmark'].selectedIndex != 0
233 // Checks for "DROP/DELETE/ALTER" statements
234 if (sqlQuery.value.replace(space_re, '') != '') {
235 if (confirmQuery(theForm, sqlQuery)) {
253 } // end of the 'checkSqlQuery()' function
257 * Check if a form's element is empty
260 * @param object the form
261 * @param string the name of the form field to put the focus on
263 * @return boolean whether the form field is empty or not
265 function emptyCheckTheField(theForm, theFieldName)
268 var theField = theForm.elements[theFieldName];
269 // Whether the replace function (js1.2) is supported or not
270 var isRegExp = (typeof(theField.value.replace) != 'undefined');
273 isEmpty = (theField.value == '') ? 1 : 0;
275 var space_re = new RegExp('\\s+');
276 isEmpty = (theField.value.replace(space_re, '') == '') ? 1 : 0;
280 } // end of the 'emptyCheckTheField()' function
284 * Displays an error message if an element of a form hasn't been completed and
287 * @param object the form
288 * @param string the name of the form field to put the focus on
290 * @return boolean whether the form field is empty or not
292 function emptyFormElements(theForm, theFieldName)
294 var theField = theForm.elements[theFieldName];
295 var isEmpty = emptyCheckTheField(theForm, theFieldName);
306 } // end of the 'emptyFormElements()' function
310 * Ensures a value submitted in a form is numeric and is in a range
312 * @param object the form
313 * @param string the name of the form field to check
314 * @param integer the minimum authorized value
315 * @param integer the maximum authorized value
317 * @return boolean whether a valid number has been submitted or not
319 function checkFormElementInRange(theForm, theFieldName, message, min, max)
321 var theField = theForm.elements[theFieldName];
322 var val = parseInt(theField.value);
324 if (typeof(min) == 'undefined') {
327 if (typeof(max) == 'undefined') {
328 max = Number.MAX_VALUE;
338 // It's a number but it is not between min and max
339 else if (val < min || val > max) {
341 alert(message.replace('%d', val));
345 // It's a valid number
347 theField.value = val;
351 } // end of the 'checkFormElementInRange()' function
354 function checkTableEditForm(theForm, fieldsCnt)
356 // TODO: avoid sending a message if user just wants to add a line
357 // on the form but has not completed at least one field name
359 var atLeastOneField = 0;
360 var i, elm, elm2, elm3, val, id;
362 for (i=0; i<fieldsCnt; i++)
364 id = "field_" + i + "_2";
365 elm = getElement(id);
366 if (elm.value == 'VARCHAR' || elm.value == 'CHAR') {
367 elm2 = getElement("field_" + i + "_3");
368 val = parseInt(elm2.value);
369 elm3 = getElement("field_" + i + "_1");
370 if (isNaN(val) && elm3.value != "") {
378 if (atLeastOneField == 0) {
379 id = "field_" + i + "_1";
380 if (!emptyCheckTheField(theForm, id)) {
385 if (atLeastOneField == 0) {
386 var theField = theForm.elements["field_0_1"];
393 } // enf of the 'checkTableEditForm()' function
397 * Ensures the choice between 'transmit', 'zipped', 'gzipped' and 'bzipped'
398 * checkboxes is consistant
400 * @param object the form
401 * @param string a code for the action that causes this function to be run
403 * @return boolean always true
405 function checkTransmitDump(theForm, theAction)
407 var formElts = theForm.elements;
409 // 'zipped' option has been checked
410 if (theAction == 'zip' && formElts['zip'].checked) {
411 if (!formElts['asfile'].checked) {
412 theForm.elements['asfile'].checked = true;
414 if (typeof(formElts['gzip']) != 'undefined' && formElts['gzip'].checked) {
415 theForm.elements['gzip'].checked = false;
417 if (typeof(formElts['bzip']) != 'undefined' && formElts['bzip'].checked) {
418 theForm.elements['bzip'].checked = false;
421 // 'gzipped' option has been checked
422 else if (theAction == 'gzip' && formElts['gzip'].checked) {
423 if (!formElts['asfile'].checked) {
424 theForm.elements['asfile'].checked = true;
426 if (typeof(formElts['zip']) != 'undefined' && formElts['zip'].checked) {
427 theForm.elements['zip'].checked = false;
429 if (typeof(formElts['bzip']) != 'undefined' && formElts['bzip'].checked) {
430 theForm.elements['bzip'].checked = false;
433 // 'bzipped' option has been checked
434 else if (theAction == 'bzip' && formElts['bzip'].checked) {
435 if (!formElts['asfile'].checked) {
436 theForm.elements['asfile'].checked = true;
438 if (typeof(formElts['zip']) != 'undefined' && formElts['zip'].checked) {
439 theForm.elements['zip'].checked = false;
441 if (typeof(formElts['gzip']) != 'undefined' && formElts['gzip'].checked) {
442 theForm.elements['gzip'].checked = false;
445 // 'transmit' option has been unchecked
446 else if (theAction == 'transmit' && !formElts['asfile'].checked) {
447 if (typeof(formElts['zip']) != 'undefined' && formElts['zip'].checked) {
448 theForm.elements['zip'].checked = false;
450 if ((typeof(formElts['gzip']) != 'undefined' && formElts['gzip'].checked)) {
451 theForm.elements['gzip'].checked = false;
453 if ((typeof(formElts['bzip']) != 'undefined' && formElts['bzip'].checked)) {
454 theForm.elements['bzip'].checked = false;
459 } // end of the 'checkTransmitDump()' function
463 * This array is used to remember mark status of rows in browse mode
465 var marked_row = new Array;
468 * enables highlight and marking of rows in data tables
471 function PMA_markRowsInit() {
472 // for every table row ...
473 var rows = document.getElementsByTagName('tr');
474 for ( var i = 0; i < rows.length; i++ ) {
475 // ... with the class 'odd' or 'even' ...
476 if ( 'odd' != rows[i].className.substr(0,3) && 'even' != rows[i].className.substr(0,4) ) {
479 // ... add event listeners ...
480 // ... to highlight the row on mouseover ...
481 if ( navigator.appName == 'Microsoft Internet Explorer' ) {
482 // but only for IE, other browsers are handled by :hover in css
483 rows[i].onmouseover = function() {
484 this.className += ' hover';
486 rows[i].onmouseout = function() {
487 this.className = this.className.replace( ' hover', '' );
490 // Do not set click events if not wanted
491 if (rows[i].className.search(/noclick/) != -1) {
494 // ... and to mark the row on click ...
495 rows[i].onmousedown = function() {
499 checkbox = this.getElementsByTagName( 'input' )[0];
500 if ( checkbox && checkbox.type == 'checkbox' ) {
501 unique_id = checkbox.name + checkbox.value;
502 } else if ( this.id.length > 0 ) {
508 if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
509 marked_row[unique_id] = true;
511 marked_row[unique_id] = false;
514 if ( marked_row[unique_id] ) {
515 this.className += ' marked';
517 this.className = this.className.replace(' marked', '');
520 if ( checkbox && checkbox.disabled == false ) {
521 checkbox.checked = marked_row[unique_id];
525 // ... and disable label ...
526 var labeltag = rows[i].getElementsByTagName('label')[0];
528 labeltag.onclick = function() {
532 // .. and checkbox clicks
533 var checkbox = rows[i].getElementsByTagName('input')[0];
535 checkbox.onclick = function() {
536 // opera does not recognize return false;
537 this.checked = ! this.checked;
542 window.onload=PMA_markRowsInit;
545 * marks all rows and selects its first checkbox inside the given element
546 * the given element is usaly a table or a div containing the table or tables
548 * @param container DOM element
550 function markAllRows( container_id ) {
551 var rows = document.getElementById(container_id).getElementsByTagName('tr');
555 for ( var i = 0; i < rows.length; i++ ) {
557 checkbox = rows[i].getElementsByTagName( 'input' )[0];
559 if ( checkbox && checkbox.type == 'checkbox' ) {
560 unique_id = checkbox.name + checkbox.value;
561 if ( checkbox.disabled == false ) {
562 checkbox.checked = true;
563 if ( typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
564 rows[i].className += ' marked';
565 marked_row[unique_id] = true;
575 * marks all rows and selects its first checkbox inside the given element
576 * the given element is usaly a table or a div containing the table or tables
578 * @param container DOM element
580 function unMarkAllRows( container_id ) {
581 var rows = document.getElementById(container_id).getElementsByTagName('tr');
585 for ( var i = 0; i < rows.length; i++ ) {
587 checkbox = rows[i].getElementsByTagName( 'input' )[0];
589 if ( checkbox && checkbox.type == 'checkbox' ) {
590 unique_id = checkbox.name + checkbox.value;
591 checkbox.checked = false;
592 rows[i].className = rows[i].className.replace(' marked', '');
593 marked_row[unique_id] = false;
601 * Sets/unsets the pointer and marker in browse mode
603 * @param object the table row
604 * @param integer the row number
605 * @param string the action calling this script (over, out or click)
606 * @param string the default background color
607 * @param string the color to use for mouseover
608 * @param string the color to use for marking a row
610 * @return boolean whether pointer is set or not
612 function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
616 // 1. Pointer and mark feature are disabled or the browser can't get the
618 if ((thePointerColor == '' && theMarkColor == '')
619 || typeof(theRow.style) == 'undefined') {
623 // 1.1 Sets the mouse pointer to pointer on mouseover and back to normal otherwise.
624 if (theAction == "over" || theAction == "click") {
625 theRow.style.cursor='pointer';
627 theRow.style.cursor='default';
630 // 2. Gets the current row and exits if the browser can't get it
631 if (typeof(document.getElementsByTagName) != 'undefined') {
632 theCells = theRow.getElementsByTagName('td');
634 else if (typeof(theRow.cells) != 'undefined') {
635 theCells = theRow.cells;
641 // 3. Gets the current color...
642 var rowCellsCnt = theCells.length;
643 var domDetect = null;
644 var currentColor = null;
646 // 3.1 ... with DOM compatible browsers except Opera that does not return
647 // valid values with "getAttribute"
648 if (typeof(window.opera) == 'undefined'
649 && typeof(theCells[0].getAttribute) != 'undefined') {
650 currentColor = theCells[0].getAttribute('bgcolor');
653 // 3.2 ... with other browsers
655 currentColor = theCells[0].style.backgroundColor;
659 // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it
660 if (currentColor.indexOf("rgb") >= 0)
662 var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
663 currentColor.indexOf(')'));
664 var rgbValues = rgbStr.split(",");
666 var hexChars = "0123456789ABCDEF";
667 for (var i = 0; i < 3; i++)
669 var v = rgbValues[i].valueOf();
670 currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
674 // 4. Defines the new color
675 // 4.1 Current color is the default one
676 if (currentColor == ''
677 || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
678 if (theAction == 'over' && thePointerColor != '') {
679 newColor = thePointerColor;
681 else if (theAction == 'click' && theMarkColor != '') {
682 newColor = theMarkColor;
683 marked_row[theRowNum] = true;
684 // Garvin: deactivated onclick marking of the checkbox because it's also executed
685 // when an action (like edit/delete) on a single item is performed. Then the checkbox
686 // would get deactived, even though we need it activated. Maybe there is a way
687 // to detect if the row was clicked, and not an item therein...
688 // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
691 // 4.1.2 Current color is the pointer one
692 else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
693 && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
694 if (theAction == 'out') {
695 newColor = theDefaultColor;
697 else if (theAction == 'click' && theMarkColor != '') {
698 newColor = theMarkColor;
699 marked_row[theRowNum] = true;
700 // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
703 // 4.1.3 Current color is the marker one
704 else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
705 if (theAction == 'click') {
706 newColor = (thePointerColor != '')
709 marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
712 // document.getElementById('id_rows_to_delete' + theRowNum).checked = false;
716 // 5. Sets the new color...
719 // 5.1 ... with DOM compatible browsers except Opera
721 for (c = 0; c < rowCellsCnt; c++) {
722 theCells[c].setAttribute('bgcolor', newColor, 0);
725 // 5.2 ... with other browsers
727 for (c = 0; c < rowCellsCnt; c++) {
728 theCells[c].style.backgroundColor = newColor;
734 } // end of the 'setPointer()' function
737 * Sets/unsets the pointer and marker in vertical browse mode
739 * @param object the table row
740 * @param integer the column number
741 * @param string the action calling this script (over, out or click)
742 * @param string the default background Class
743 * @param string the Class to use for mouseover
744 * @param string the Class to use for marking a row
746 * @return boolean whether pointer is set or not
748 * @author Garvin Hicking <me@supergarv.de> (rewrite of setPointer.)
750 function setVerticalPointer(theRow, theColNum, theAction, theDefaultClass1, theDefaultClass2, thePointerClass, theMarkClass) {
751 // 1. Pointer and mark feature are disabled or the browser can't get the
753 if ((thePointerClass == '' && theMarkClass == '')
754 || typeof(theRow.style) == 'undefined') {
758 var tagSwitch = null;
760 // 2. Gets the current row and exits if the browser can't get it
761 if (typeof(document.getElementsByTagName) != 'undefined') {
763 } else if (typeof(document.getElementById('table_results')) != 'undefined') {
771 if (tagSwitch == 'tag') {
772 theRows = document.getElementById('table_results').getElementsByTagName('tr');
773 theCells = theRows[1].getElementsByTagName('td');
774 } else if (tagSwitch == 'cells') {
775 theRows = document.getElementById('table_results').rows;
776 theCells = theRows[1].cells;
779 // 3. Gets the current Class...
780 var currentClass = null;
783 // 3.1 ... with DOM compatible browsers except Opera that does not return
784 // valid values with "getAttribute"
785 if (typeof(window.opera) == 'undefined'
786 && typeof(theCells[theColNum].getAttribute) != 'undefined') {
787 currentClass = theCells[theColNum].className;
790 // 4. Defines the new Class
791 // 4.1 Current Class is the default one
792 if (currentClass == ''
793 || currentClass.toLowerCase() == theDefaultClass1.toLowerCase()
794 || currentClass.toLowerCase() == theDefaultClass2.toLowerCase()) {
795 if (theAction == 'over' && thePointerClass != '') {
796 newClass = thePointerClass;
797 } else if (theAction == 'click' && theMarkClass != '') {
798 newClass = theMarkClass;
799 marked_row[theColNum] = true;
802 // 4.1.2 Current Class is the pointer one
803 else if (currentClass.toLowerCase() == thePointerClass.toLowerCase() &&
804 (typeof(marked_row[theColNum]) == 'undefined' || !marked_row[theColNum]) || marked_row[theColNum] == false) {
805 if (theAction == 'out') {
807 newClass = theDefaultClass1;
809 newClass = theDefaultClass2;
812 else if (theAction == 'click' && theMarkClass != '') {
813 newClass = theMarkClass;
814 marked_row[theColNum] = true;
817 // 4.1.3 Current Class is the marker one
818 else if (currentClass.toLowerCase() == theMarkClass.toLowerCase()) {
819 if (theAction == 'click') {
820 newClass = (thePointerClass != '')
822 : ((theColNum % 2) ? theDefaultClass2 : theDefaultClass1);
823 marked_row[theColNum] = false;
827 // 5 ... with DOM compatible browsers except Opera
831 var rowCnt = theRows.length;
832 for (c = 0; c < rowCnt; c++) {
833 if (tagSwitch == 'tag') {
834 Cells = theRows[c].getElementsByTagName('td');
835 } else if (tagSwitch == 'cells') {
836 Cells = theRows[c].cells;
839 Cell = Cells[theColNum];
841 // 5.1 Sets the new Class...
842 Cell.className = Cell.className.replace(currentClass, newClass);
847 } // end of the 'setVerticalPointer()' function
850 * Checks/unchecks all checkbox in given conainer (f.e. a form, fieldset or div)
852 * @param string container_id the container id
853 * @param boolean state new value for checkbox (true or false)
854 * @return boolean always true
856 function setCheckboxes( container_id, state ) {
857 var checkboxes = document.getElementById(container_id).getElementsByTagName('input');
859 for ( var i = 0; i < checkboxes.length; i++ ) {
860 if ( checkboxes[i].type == 'checkbox' ) {
861 checkboxes[i].checked = state;
866 } // end of the 'setCheckboxes()' function
869 // added 2004-05-08 by Michael Keck <mail_at_michaelkeck_dot_de>
870 // copy the checked from left to right or from right to left
871 // so it's easier for users to see, if $cfg['ModifyAtRight']=true, what they've checked ;)
872 function copyCheckboxesRange(the_form, the_name, the_clicked)
874 if (typeof(document.forms[the_form].elements[the_name]) != 'undefined' && typeof(document.forms[the_form].elements[the_name + 'r']) != 'undefined') {
875 if (the_clicked !== 'r') {
876 if (document.forms[the_form].elements[the_name].checked == true) {
877 document.forms[the_form].elements[the_name + 'r'].checked = true;
879 document.forms[the_form].elements[the_name + 'r'].checked = false;
881 } else if (the_clicked == 'r') {
882 if (document.forms[the_form].elements[the_name + 'r'].checked == true) {
883 document.forms[the_form].elements[the_name].checked = true;
885 document.forms[the_form].elements[the_name].checked = false;
892 // added 2004-05-08 by Michael Keck <mail_at_michaelkeck_dot_de>
893 // - this was directly written to each td, so why not a function ;)
894 // setCheckboxColumn(\'id_rows_to_delete' . $row_no . ''\');
895 function setCheckboxColumn(theCheckbox){
896 if (document.getElementById(theCheckbox)) {
897 document.getElementById(theCheckbox).checked = (document.getElementById(theCheckbox).checked ? false : true);
898 if (document.getElementById(theCheckbox + 'r')) {
899 document.getElementById(theCheckbox + 'r').checked = document.getElementById(theCheckbox).checked;
902 if (document.getElementById(theCheckbox + 'r')) {
903 document.getElementById(theCheckbox + 'r').checked = (document.getElementById(theCheckbox +'r').checked ? false : true);
904 if (document.getElementById(theCheckbox)) {
905 document.getElementById(theCheckbox).checked = document.getElementById(theCheckbox + 'r').checked;
913 * Checks/unchecks all options of a <select> element
915 * @param string the form name
916 * @param string the element name
917 * @param boolean whether to check or to uncheck the element
919 * @return boolean always true
921 function setSelectOptions(the_form, the_select, do_check)
923 var selectObject = document.forms[the_form].elements[the_select];
924 var selectCount = selectObject.length;
926 for (var i = 0; i < selectCount; i++) {
927 selectObject.options[i].selected = do_check;
931 } // end of the 'setSelectOptions()' function
934 * Inserts multiple fields.
937 function insertValueQuery() {
938 var myQuery = document.sqlform.sql_query;
939 var myListBox = document.sqlform.dummy;
941 if(myListBox.options.length > 0) {
942 sql_box_locked = true;
945 for(var i=0; i<myListBox.options.length; i++) {
946 if (myListBox.options[i].selected){
950 chaineAj += myListBox.options[i].value;
955 if (document.selection) {
957 sel = document.selection.createRange();
959 document.sqlform.insert.focus();
961 //MOZILLA/NETSCAPE support
962 else if (document.sqlform.sql_query.selectionStart || document.sqlform.sql_query.selectionStart == "0") {
963 var startPos = document.sqlform.sql_query.selectionStart;
964 var endPos = document.sqlform.sql_query.selectionEnd;
965 var chaineSql = document.sqlform.sql_query.value;
967 myQuery.value = chaineSql.substring(0, startPos) + chaineAj + chaineSql.substring(endPos, chaineSql.length);
969 myQuery.value += chaineAj;
971 sql_box_locked = false;
976 * listbox redirection
978 function goToUrl(selObj, goToLocation) {
979 eval("document.location.href = '" + goToLocation + "pos=" + selObj.options[selObj.selectedIndex].value + "'");
985 function getElement(e,f){
988 if(f.document.layers[e]) {
989 return f.document.layers[e];
991 for(W=0;i<f.document.layers.length;W++) {
992 return(getElement(e,fdocument.layers[W]));
996 return document.all[e];
998 return document.getElementById(e);
1002 * Refresh the WYSIWYG-PDF scratchboard after changes have been made
1004 function refreshDragOption(e) {
1005 myid = getElement(e);
1006 if (myid.style.visibility == 'visible') {
1012 * Refresh/resize the WYSIWYG-PDF scratchboard
1014 function refreshLayout() {
1015 myid = getElement('pdflayout');
1017 if (document.pdfoptions.orientation.value == 'P') {
1025 myid.style.width = pdfPaperSize(document.pdfoptions.paper.value, posa) + 'px';
1026 myid.style.height = pdfPaperSize(document.pdfoptions.paper.value, posb) + 'px';
1030 * Show/hide the WYSIWYG-PDF scratchboard
1032 function ToggleDragDrop(e) {
1033 myid = getElement(e);
1035 if (myid.style.visibility == 'hidden') {
1037 myid.style.visibility = 'visible';
1038 myid.style.display = 'block';
1039 document.edcoord.showwysiwyg.value = '1';
1041 myid.style.visibility = 'hidden';
1042 myid.style.display = 'none';
1043 document.edcoord.showwysiwyg.value = '0';
1048 * PDF scratchboard: When a position is entered manually, update
1049 * the fields inside the scratchboard.
1051 function dragPlace(no, axis, value) {
1053 getElement("table_" + no).style.left = value + 'px';
1055 getElement("table_" + no).style.top = value + 'px';
1060 * Returns paper sizes for a given format
1062 function pdfPaperSize(format, axis) {
1063 switch (format.toUpperCase()) {
1065 if (axis == 'x') return 4767.87; else return 6740.79;
1068 if (axis == 'x') return 3370.39; else return 4767.87;
1071 if (axis == 'x') return 2383.94; else return 3370.39;
1074 if (axis == 'x') return 1683.78; else return 2383.94;
1077 if (axis == 'x') return 1190.55; else return 1683.78;
1080 if (axis == 'x') return 841.89; else return 1190.55;
1083 if (axis == 'x') return 595.28; else return 841.89;
1086 if (axis == 'x') return 419.53; else return 595.28;
1089 if (axis == 'x') return 297.64; else return 419.53;
1092 if (axis == 'x') return 209.76; else return 297.64;
1095 if (axis == 'x') return 147.40; else return 209.76;
1098 if (axis == 'x') return 104.88; else return 147.40;
1101 if (axis == 'x') return 73.70; else return 104.88;
1104 if (axis == 'x') return 2834.65; else return 4008.19;
1107 if (axis == 'x') return 2004.09; else return 2834.65;
1110 if (axis == 'x') return 1417.32; else return 2004.09;
1113 if (axis == 'x') return 1000.63; else return 1417.32;
1116 if (axis == 'x') return 708.66; else return 1000.63;
1119 if (axis == 'x') return 498.90; else return 708.66;
1122 if (axis == 'x') return 354.33; else return 498.90;
1125 if (axis == 'x') return 249.45; else return 354.33;
1128 if (axis == 'x') return 175.75; else return 249.45;
1131 if (axis == 'x') return 124.72; else return 175.75;
1134 if (axis == 'x') return 87.87; else return 124.72;
1137 if (axis == 'x') return 2599.37; else return 3676.54;
1140 if (axis == 'x') return 1836.85; else return 2599.37;
1143 if (axis == 'x') return 1298.27; else return 1836.85;
1146 if (axis == 'x') return 918.43; else return 1298.27;
1149 if (axis == 'x') return 649.13; else return 918.43;
1152 if (axis == 'x') return 459.21; else return 649.13;
1155 if (axis == 'x') return 323.15; else return 459.21;
1158 if (axis == 'x') return 229.61; else return 323.15;
1161 if (axis == 'x') return 161.57; else return 229.61;
1164 if (axis == 'x') return 113.39; else return 161.57;
1167 if (axis == 'x') return 79.37; else return 113.39;
1170 if (axis == 'x') return 2437.80; else return 3458.27;
1173 if (axis == 'x') return 1729.13; else return 2437.80;
1176 if (axis == 'x') return 1218.90; else return 1729.13;
1179 if (axis == 'x') return 864.57; else return 1218.90;
1182 if (axis == 'x') return 609.45; else return 864.57;
1185 if (axis == 'x') return 2551.18; else return 3628.35;
1188 if (axis == 'x') return 1814.17; else return 2551.18;
1191 if (axis == 'x') return 1275.59; else return 1814.17;
1194 if (axis == 'x') return 907.09; else return 1275.59;
1197 if (axis == 'x') return 637.80; else return 907.09;
1200 if (axis == 'x') return 612.00; else return 792.00;
1203 if (axis == 'x') return 612.00; else return 1008.00;
1206 if (axis == 'x') return 521.86; else return 756.00;
1209 if (axis == 'x') return 612.00; else return 936.00;