var TUNA = 2;


function trim(stringToTrim) {
return stringToTrim.replace(/^\s+|\s+$/g,"");
}


function isInteger(input) {
var validChars = '0123456789';
var isNumber = true;
var ch;

for (i = 0; (i < input.length) && isNumber == true; i++) { 
ch = input.charAt(i); 
if (validChars.indexOf(ch) == -1) {
isNumber = false;
}
}

return isNumber;   
}


function inputTextControl(obj, graphicId, type, minLength, maxLength) {
var content = trim(obj.value);
var typeControl   = false,
lengthControl = false;

if (type == 'string') {
if (!isInteger(content)) {
typeControl = true;
}
} else if (type == 'number') {
if (isInteger(content)) {
typeControl = true;
}
}

if (content.length >= minLength && content.length <= maxLength) {
lengthControl = true;
}

var graphic = $(graphicId);
if (typeControl && lengthControl) {
if (graphic.style.visibility != 'visible') {
graphic.style.visibility = 'visible';
new Effect.Pulsate(graphic, { pulses: 2, duration: 1.0 });
}
} else {
if (graphic.style.visibility != 'hidden') {
graphic.style.visibility = 'hidden';
}
}
}


function flash(obj) {
new Effect.Highlight(obj, { startcolor:'#FF6600' });
return false;
}