function addCategory(form) { var startString = form.category.value.trim(); var newString = form.category_select.options[form.category_select.selectedIndex].text; if(newString == "") return; if(startString != "") startString += ", "; startString += newString; form.category.value = startString; } function deleteThisLink(form) { var del=confirm("Warning! Your are about to permanently remove the link \""+form.name.value+"\".") if (!del) { return; } else { form.action.value="delete"; form.submit(); } } String.prototype.trim = function() { // skip leading and trailing whitespace // and return everything in between var x=this; x=x.replace(/^\s*(.*)/, "$1"); x=x.replace(/(.*?)\s*$/, "$1"); return x; } var _values = new Array(); var _catids = new Array(); _values.push('art'); _catids['art'] = 1; _values.push('books'); _catids['books'] = 2; _values.push('Clips'); _catids['Clips'] = 13054; _values.push('design'); _catids['design'] = 3; _values.push('E-mail'); _catids['E-mail'] = 12931; _values.push('email'); _catids['email'] = 8984; _values.push('eMails'); _catids['eMails'] = 13504; _values.push('flash'); _catids['flash'] = 4; _values.push('friends'); _catids['friends'] = 5; _values.push('funny'); _catids['funny'] = 6; _values.push('Groningen'); _catids['Groningen'] = 13048; _values.push('illustration'); _catids['illustration'] = 7; _values.push('LiNKY'); _catids['LiNKY'] = 130; _values.push('Masonic'); _catids['Masonic'] = 13558; _values.push('news'); _catids['news'] = 8; _values.push('PC'); _catids['PC'] = 12930; _values.push('Rehab'); _catids['Rehab'] = 13545; _values.push('Shopping'); _catids['Shopping'] = 13318; _values.push('Webdesign'); _catids['Webdesign'] = 12555; var _lastValue=''; var _previousText = ''; var _form = ""; function replaceText(_v) { var _count = 0; // number of different strings pattern was found in. var _index = -1; // index in the array of the item found. var _str = ""; // the new value in the text-box var _previousText = ''; // the stuff up to the last comma. var _tempArray = new Array(); if (_form.value.lastIndexOf(',') > -1) { _previousText = _form.value.substring(0,_form.value.lastIndexOf(',')+1) + " "; _str = _form.value.substring(_form.value.lastIndexOf(',')+1).trim(); } else if(_form.value) _str = _form.value; if (_lastValue == _str) return; // nothing need be done if (_lastValue.length>_str.length) {_lastValue=_str;return;} // deleted a char for (i in _values) { // is this new value in one of the items in the array? // (it must start at the begining of the item'string) if (_values[i].toLowerCase().indexOf(_str.toLowerCase()) == 0) { _tempArray[_tempArray.length] = _values[i]; _count++; _index = i; } } if (_index >= 0 && _index < _values.length && _count>0) { if (_count == 1) { _str = _values[_index]; } else { _str = _values[_index].substring(0,lenToUse(_tempArray)); } _form.value=_previousText + _str; _lastValue = _str; } } // this returns an integer that represents the length of // the given strings in _index where all parameters are // equal up to // 1 -> first char's match only. // 0 -> no match. function lenToUse(_list) { var mismatchFound = false; var _return = 0; var _shortestLength = 99; for (i=0;i<_list.length;i++) { // find out the shortest string's length if (_list[i].length < _shortestLength) _shortestLength = _list[i].length; } for (i=0;i<_shortestLength;i++) { // see if each charater in all _list's strings are equal intil their are // not - then that is the return value. _matchStr = _list[0].substring(i,i+1); for (j=1;j<_list.length;j++) { if (_list[j].substring(i,i+1).toLowerCase() != _matchStr.toLowerCase()) { if (!mismatchFound) // only track upto the first time a mismatch is found. _return = i-1; // last round was succesful. mismatchFound = true; } } if (!mismatchFound) { _return = i; } } return (_return+1); // this makes the return value start at 1 for first position } function compute(form) { _form = form; setTimeout('replaceText()',20); // 30 msecs later... } function submitForm() { document.my_linky_auto.category.value = _catids[document.my_linky_auto.category.value]; } function remote() { window.open("http://www.mylinky.com/my_linky_remote.php","linkyremote","scrollbars=yes,left=15,top=15,width=220,height=480,status=yes,resizable=yes"); } function init() { document.my_linky_auto.category.focus(); }