

function findDivWithText(text) {


	var elements = document.querySelectorAll('.number_block');


	for (var element of elements) {

		if (element.innerText.trim() === text) {
			return element;
		}
	}

	return null; 
}

function highlight_quad(item)
{
	var classItem = 'hilight-quad';

	const specificElement = document.querySelector(`[data-values="${item}"]`);

	if (specificElement !== null) {
		specificElement.classList.add(classItem);
	} 

}
function highlight_street(item)
{
	var classItem = 'hilight-street';

	const specificElement = document.querySelector(`[data-values="${item}"]`);

	if (specificElement !== null) {
		specificElement.classList.add(classItem);
	} 

}

function highlight_double_street(item)
{
	var classItem = 'hilight-double-street';

	const specificElement = document.querySelector(`[data-values="${item}"]`);

	if (specificElement !== null) {
		specificElement.classList.add(classItem);
	} 

}

function highlight_split_across(item)
{
	var classItem = 'hilight-split-across';

	const specificElement = document.querySelector(`[data-values="${item}"]`);

	if (specificElement !== null) {
		specificElement.classList.add(classItem);
	} 

}
function highlight_split_down(item)
{

	var classItem = 'hilight-split-upDown';

	const specificElement = document.querySelector(`[data-values="${item}"]`);

	if (specificElement !== null) {
		specificElement.classList.add(classItem);
	} 
	
}

function highlight_uniques(item)
{
	var container = null;

	if(item==0)
	{
		container = document.querySelector(`[data-values="zdiv3${item}"]`);
	}
	else
	{
		container = document.querySelector(`[data-values="div3${item}"]`);
	}
	var classItem = 'hilight-unique';

	if (container !== null) {
		
		container.classList.add(classItem);
	} 
}

function highlight_straight_numbers(item)
{
	var container = null;
	
	if(item==0)
	{
		
		container = document.querySelector(`[data-values="zdiv1${item}"]`);
	}
	else
	{
		container = document.querySelector(`[data-values="div1${item}"]`);
	}

	
	var classItem = 'hilight-straight';

	if (container !== null) {
		container.classList.add(classItem);
	} 
}


function highlight_number_groups(item) {
	
	var container = null;

	if(item==0)
	{
		container = document.querySelector(`[data-values="zdiv2${item}"]`);
	}
	else
	{
		container = document.querySelector(`[data-values="div2${item}"]`);
	}
	var classItem = 'hilight-groups';

	if (container !== null) {

		container.classList.add(classItem);
	} 
	
}

function unHighLightAllNumbers() {

	// Remove outside 
	var outsideTags = ['1to18', '19to36', 'row3', 'row2', 'row1', 'dozen1', 'dozen2', 'dozen3', 'outsideEven', 'outsideOdd'];
	outsideTags.forEach(tag => {
		document.getElementById(tag).classList.remove('outsideHighlight');
	});

	// RedAllOut
	document.getElementById('outsideRed').classList.remove('outsideHighlight');

	// Black
	document.getElementById('outsideBlack').classList.remove('outsideHighlight');

	// Remove inside highlight tokens
	let highlight_classes = ['hilight-quad','hilight-split-upDown','hilight-split-across'
	,'hilight-street'
	,'hilight-double-street'
	,'highlight_straight_numbers'
	,'hilight-unique'
	, 'hilight-pattern-even'
	,'hilight-pattern-odd'
	,'hilight-pattern-high'
	,'hilight-pattern-low'
	,'hilight-pattern-red'
	,'hilight-pattern-black'
	,'hilight-pattern-even-odd-high-low'
	,'hilight-groups'
	,'hilight-pattern-rows'
	,'hilight-pattern-hilow'
	,'hilight-straight'
];

	highlight_classes.forEach(item=>{

		// splits quads
		var elements = document.querySelectorAll('.'+item);
		elements.forEach(function(element) {
		element.classList.remove(item);});

		// straights
		var elements = document.querySelectorAll('.div1'+item);
		elements.forEach(function(element) {
		element.classList.remove(item);});

		// groups
		var elements = document.querySelectorAll('.div2'+item);
		elements.forEach(function(element) {
		element.classList.remove(item);});

		// uniques
		var elements = document.querySelectorAll('.div3'+item);
		elements.forEach(function(element) {
		element.classList.remove(item);});


		// 0 straights
		var elements = document.querySelectorAll('.zdiv1'+item);
		elements.forEach(function(element) {
		element.classList.remove(item);});

		// 0 groups
		var elements = document.querySelectorAll('.zdiv2'+item);
		elements.forEach(function(element) {
		element.classList.remove(item);});

		// 0 uniques
		var elements = document.querySelectorAll('.zdiv3'+item);
		elements.forEach(function(element) {
		element.classList.remove(item);});
	});


}

function highlight_0() {
	// 0
	let item_0 = document.getElementById('zero_0');
	var item_highlight_0 = item_0.classList.contains('greenHighlight');

	if (!item_highlight_0) {
		item_0.classList.add('greenHighlight');
	}
}

function highlight_high() {
	// 19 to 36
	let item_19to36 = document.getElementById('19to36');
	var item_highlight_19to36 = item_19to36.classList.contains('outsideHighlight');

	if (!item_highlight_19to36) {
		item_19to36.classList.add('outsideHighlight');
	}
}

function highlight_low() {
	// 1 to 18
	let item_1to18 = document.getElementById('1to18');
	var item_highlight_1to18 = item_1to18.classList.contains('outsideHighlight');

	if (!item_highlight_1to18) {
		item_1to18.classList.add('outsideHighlight');
	}
}

function highlight_row_1() {
	// row 1
	let item_row1 = document.getElementById('row1');
	var item_highlight_row1 = item_row1.classList.contains('outsideHighlight');

	if (!item_highlight_row1) {
		item_row1.classList.add('outsideHighlight');
	}
}
function highlight_row_2() {
	// row 2
	let item_row2 = document.getElementById('row2');
	var item_highlight_row2 = item_row2.classList.contains('outsideHighlight');

	if (!item_highlight_row2) {
		item_row2.classList.add('outsideHighlight');
	}
}

function highlight_row_3() {
	// row 3
	let item_row3 = document.getElementById('row3');
	var item_highlight_row3 = item_row3.classList.contains('outsideHighlight');

	if (!item_highlight_row3) {
		item_row3.classList.add('outsideHighlight');
	}
}

function highlight_dozen_1() {
	// dozen 1
	let item_dozen1 = document.getElementById('dozen1');
	var item_highlight_dozen1 = item_dozen1.classList.contains('outsideHighlight');

	if (!item_highlight_dozen1) {
		item_dozen1.classList.add('outsideHighlight');
	}

}
function highlight_dozen_2() {

	// dozen 2
	let item_dozen2 = document.getElementById('dozen2');
	var item_highlight_dozen2 = item_dozen2.classList.contains('outsideHighlight');

	if (!item_highlight_dozen2) {
		item_dozen2.classList.add('outsideHighlight');
	}
}
function highlight_dozen_3() {
	// dozen 3
	let item_dozen3 = document.getElementById('dozen3');
	var item_highlight_dozen3 = item_dozen3.classList.contains('outsideHighlight');

	if (!item_highlight_dozen3) {
		item_dozen3.classList.add('outsideHighlight');
	}
}

function highlight_Even() {

	// Even
	let item_outsideEven = document.getElementById('outsideEven');
	var item_highlight_outsideEven = item_outsideEven.classList.contains('outsideHighlight');

	if (!item_highlight_outsideEven) {
		item_outsideEven.classList.add('outsideHighlight');
	}
}



function highlight_Black() {
	// Black
	let item_outsideBlack = document.getElementById('outsideBlack');
	var item_highlight_outsideBlack = item_outsideBlack.classList.contains('outsideHighlight');

	if (!item_highlight_outsideBlack) {
		item_outsideBlack.classList.add('outsideHighlight');
	}
}
function highlight_Red() {
	// Red
	let item_outsideRed = document.getElementById('outsideRed');
	var item_highlight_outsideRed = item_outsideRed.classList.contains('outsideHighlight');

	if (!item_highlight_outsideRed) {
		item_outsideRed.classList.add('outsideHighlight');
	}
}
function highlight_Odd() {
	// Odd
	let item_outsideOdd = document.getElementById('outsideOdd');
	var item_highlight_outsideOdd = item_outsideOdd.classList.contains('outsideHighlight');

	if (!item_highlight_outsideOdd) {
		item_outsideOdd.classList.add('outsideHighlight');
	}
}
function highlight_pattern_even()
{
	var classItem = 'hilight-pattern-even-odd-high-low';

	let item_outsideOdd = document.getElementById('outsideEven');
	var item_highlight_outsideOdd = item_outsideOdd.classList.contains(classItem);

	if (!item_highlight_outsideOdd) {
		item_outsideOdd.classList.add(classItem);
	}
}

function highlight_pattern_odd()
{
	var classItem = 'hilight-pattern-even-odd-high-low';

	let item_outsideOdd = document.getElementById('outsideOdd');
	var item_highlight_outsideOdd = item_outsideOdd.classList.contains(classItem);

	if (!item_highlight_outsideOdd) {
		item_outsideOdd.classList.add(classItem);
	}
}
function highlight_pattern_high()
{
	var classItem = 'hilight-pattern-hilow';

	let item_outsideOdd = document.getElementById('19to36');
	var item_highlight_outsideOdd = item_outsideOdd.classList.contains(classItem);

	if (!item_highlight_outsideOdd) {
		item_outsideOdd.classList.add(classItem);
	}
}
function highlight_pattern_low()
{
	var classItem = 'hilight-pattern-hilow';

	let item_outsideOdd = document.getElementById('1to18');
	var item_highlight_outsideOdd = item_outsideOdd.classList.contains(classItem);

	if (!item_highlight_outsideOdd) {
		item_outsideOdd.classList.add(classItem);
	}
}
function highlight_pattern_red()
{
	var classItem = 'hilight-pattern-even-odd-high-low';

	let item_outsideOdd = document.getElementById('outsideRed');
	var item_highlight_outsideOdd = item_outsideOdd.classList.contains(classItem);

	if (!item_highlight_outsideOdd) {
		item_outsideOdd.classList.add(classItem);
	}
}
function highlight_pattern_black()
{
	var classItem = 'hilight-pattern-even-odd-high-low';

	let item_outsideOdd = document.getElementById('outsideBlack');
	var item_highlight_outsideOdd = item_outsideOdd.classList.contains(classItem);

	if (!item_highlight_outsideOdd) {
		item_outsideOdd.classList.add(classItem);
	}
}


function highlight_pattern_row_1() {

	var classItem = 'hilight-pattern-rows';
	let item_row1 = document.getElementById('row1');
	var item_highlight_row1 = item_row1.classList.contains(classItem);

	if (!item_highlight_row1) {
		item_row1.classList.add(classItem);
	}
}
function highlight_pattern_row_2() {
	var classItem = 'hilight-pattern-rows';
	let item_row1 = document.getElementById('row2');
	var item_highlight_row1 = item_row1.classList.contains(classItem);

	if (!item_highlight_row1) {
		item_row1.classList.add(classItem);
	}
}

function highlight_pattern_row_3() {
	var classItem = 'hilight-pattern-rows';
	let item_row1 = document.getElementById('row3');
	var item_highlight_row1 = item_row1.classList.contains(classItem);

	if (!item_highlight_row1) {
		item_row1.classList.add(classItem);
	}
}

function highlight_pattern_dozen_1() {
	var classItem = 'hilight-pattern-even-odd-high-low';
	let item_row1 = document.getElementById('dozen1');
	var item_highlight_row1 = item_row1.classList.contains(classItem);

	if (!item_highlight_row1) {
		item_row1.classList.add(classItem);
	}

}
function highlight_pattern_dozen_2() {
	var classItem = 'hilight-pattern-even-odd-high-low';
	let item_row1 = document.getElementById('dozen2');
	var item_highlight_row1 = item_row1.classList.contains(classItem);

	if (!item_highlight_row1) {
		item_row1.classList.add(classItem);
	}

}
function highlight_pattern_dozen_3() {
	var classItem = 'hilight-pattern-even-odd-high-low';
	let item_row1 = document.getElementById('dozen3');
	var item_highlight_row1 = item_row1.classList.contains(classItem);

	if (!item_highlight_row1) {
		item_row1.classList.add(classItem);
	}

}
