/**
* Ferry Brouwer
* This javascript check if a string contains a given word and returns a boolean true if it contains, or false if it aint
* @param sentence	: The sentence to search in [String]
* @param word		: The word in the sentence to search for
*/

function containingWord(sentence, word){
	var contains;
	(sentence.indexOf(word) != -1) ? contains=true : contains=false;
	return contains;
}

/**
* Get the next value behind the delimiter
* @param sentence	: The sentence to search in [String]
* @param word		: The word in the sentence (the delimiter after this word breaks the word from the value) [String]
* @param word		: delimiters to strip the sentence (can be more than just one character, example: / or ? or =)[Array]
*/
function getNextValue(sentence, word, delimiters){
	var newValue;
	
	var beginWordCount = sentence.indexOf(word);
	var beginValueCountFound = false;
	
	if(beginWordCount == '-1')return false;
	
	//get indexOf value
	for(var i=beginWordCount; i<sentence.length; i++){
		if(beginValueCountFound)break;
		var newChar = sentence.charAt(i);
		
		//check for delimiters
		for(var j=0; j<delimiters.length; j++){
			if(newChar == delimiters[j]){
				beginValueCountFound = true;
				getValue(i);
				break;
			}	
		}
	}

	//store the value
	function getValue(beginValueCount){
		var nextDelimiterFound = false;
		for(var k=beginValueCount + 1; k<sentence.length; k++){
			if(nextDelimiterFound)break;
			var _newChar = sentence.charAt(k);
			
			//check for delimiters
			for(var l=0; l<delimiters.length; l++){
				if(_newChar == delimiters[l]){
					nextDelimiterFound = true;
					break;
				}	
			}
			if(!nextDelimiterFound){
				(newValue != null) ? newValue += _newChar : newValue = _newChar;
			}
		}
	}
	
	if(newValue == null)newValue = false;
	return newValue;
}

/**
* Replace a char in the word
* @param word	:	String 
* @param char	:	String
* @param newChar:	String the replaced char
*/
function replaceChar(word, char, newChar){
	var indexNum = word.indexOf(char);
	var newWord = "";
	for(var i=0; i<word.length; i++)
		(i != indexNum) ? newWord += word.charAt(i) : newWord += newChar;
	
	return newWord;
}