
 function Utils(){
 	
 }
 
 Utils.prototype.stripWhitespacesLeftAndRight = function(str){
 	var leftSideStripped = this.stripWhitespacesLeft(str);
    var bothSideStripped = this.stripWhitespacesRight(leftSideStripped);
    return bothSideStripped;
 }
 
 
 Utils.prototype.stripWhitespacesLeft = function(str){
	var whitespace = " \t\n\r";
    //Strip whitespaces at the beginnig
    var i = 0;
    while ((i < str.length) && this.isCharInString(str.charAt(i), whitespace)) i++;
    var leftSideStripped = str.substring (i, str.length);
    return leftSideStripped;
 }
 
 
 Utils.prototype.stripWhitespacesRight = function(str){
	var whitespace = " \t\n\r";
    var i = str.length-1;
    while (( i > 0) && this.isCharInString(str.charAt(i), whitespace)) i--;
    var rightSideStripped =  str.substring (0, i+1);
    return rightSideStripped;
 }
 
 // Returns true if single character c (actually a string) is contained within string s.
 Utils.prototype.isCharInString = function(chr,str){
 	  for (i = 0; i < str.length; i++){
        if (str.charAt(i) == chr) return true;
    }
    return false
 }

Utils.prototype.trim = function(str){
	return (string.replace(/\s+/g, ""));
}

Utils.prototype.removeChildNodes = function(id){
	var node = document.getElementById(id);
    if (node.hasChildNodes()) {
       while(node.hasChildNodes()){
       node.removeChild(node.lastChild);
       }
    }
}


Utils.prototype.jumpIntoNextField = function(elem,content)
{
if (content.length==elem.maxLength){
	var numberOfCells = 4;
	var currentCell=elem.id;
	//alert(currentCell.substring(5));
	if (currentCell.substring(5) < numberOfCells){
		var next = parseInt(currentCell.substring(5)) + 1;
		//alert(currentCell.substring(0,5)+next);
		document.getElementById(currentCell.substring(0,5)+next).focus();
	}
	
	}
}


  

var utils = new Utils();
