function getControlValue(control) {
var result;
var controlType = control.tagName.toUpperCase();
// in case of dropdown box
if (controlType == 'SELECT') {
var selectedIndex = control.selectedIndex;
if (control.selectedIndex != -1) {
var optValue = control.options[selectedIndex].value;
if (optValue != null) {
result = optValue;
} else {
result = control.options[selectedIndex].text;
}
} else {
result = '';
}
}
// in case of input
if (controlType == 'INPUT') {
var subType = control.type.toLowerCase();
if (subType == 'text' || subType == 'hidden' || subType == 'textarea' || subType=='file') {
result = control.value;
} else if (subType == 'checkbox' || subType == 'radio') {
// ? anything else
result = control.value;
}
}
// in case of text area
if (controlType == 'TEXTAREA') {
result = control.value
}
return trim(result);
}
function isArray(test) {
if(typeof test == 'object' && typeof test.sort == 'function' && typeof test.length == 'number') {
return true;
} else {
return false;
}
}
function trim(s) {
if (s == null) {
return '';
}
var tempStr;
tempStr = s.replace(/\s+$/g,'');
tempStr = tempStr.replace(/^\s+/g,'');
return tempStr;
}
// ------------------------------------------------------------------------------
var errors = new Felix();
function Felix() {
this.show = function(id, param) {
var s = eval(id);
if (s.indexOf('{1}') > -1) {
for (var i=0; i < param.length; i++) {
s = s.replace('{' + i + '}', param[i]);
}
} else {
s = s.replace('{0}', param);
}
return this.prefix + s + this.suffix;
}
}
function getFelixHint(control) {
var id = control.id;
if (id == null || id == '') {
id = control.name;
}
var felixhint = document.getElementById(id + '.hint');
return felixhint;
}
function getFelixDef(control) {
var id = control.id;
if (id == null || id == '') {
id = control.name;
}
var felixdef = document.getElementById(id + '.def');
if (felixdef == null) {
felixdef = control;
}
return felixdef;
}