// JavaScript Document


function buildit() {
	var chosenDay = document.tournamentForm.days.value;
	var chosenType = document.tournamentForm.types.value;
	
	buildTable = '<h3>';
	buildTable += 'Search Values';/* put search values here */
	buildTable += '</h3>';
	buildTable += '<table class="table1" style="font-weight: bold"><tr><th width="15%">Day</th><th width="15%">Time</th><th>Tournament Name</th><th width="20%">Buy-In</th></tr>';
	var rowColour = 'light';
	
	
	
	// check for monday tournaments 
	if (chosenDay == 'mon' || chosenDay == 'all') {
		for (i = 0; i < recordNo.length; i++) {
		  if (recordNo[i].vc == false) {
			var createRow = 0;
			var textColor = '#000000';
			if (recordNo[i].type == 'Big Guarantees') { textColor = '#fd1b14'}
			if (recordNo[i].type == 'Freerolls') { textColor = '#2481ca'}
			if (recordNo[i].type == 'Giveaways') { textColor = '#81ca24'}
			
			switch(chosenType) {
				case 'big':  		if (recordNo[i].type == 'Big Guarantees') { createRow = 1}
				break;
				case 'freerolls':  	if (recordNo[i].type == 'Freerolls') { createRow = 1}
				break;
				case 'giveaways':  	if (recordNo[i].type == 'Giveaways') { createRow = 1}
				break;
				case 'all':  createRow = 1;
				break;
				default: creatRow = 0;
				break;
			} // end switch
				
				if (recordNo[i].mon == 1 && createRow == 1) {
				buildTable += '<tr class="';
				buildTable += rowColour;
				buildTable += '"><td><font color="';
				buildTable += textColor;
				buildTable += '">Monday</font></td><td><font color="';
				buildTable += textColor;
				buildTable += '">';
				buildTable += recordNo[i].time;
				buildTable += '</font></td><td><font color="';
				buildTable += textColor;
				buildTable += '">';
				buildTable += recordNo[i].name;
				buildTable += '</font></td><td><font color="';
				buildTable += textColor;
				buildTable += '">';
				buildTable += recordNo[i].buyin;
				buildTable += '</font></td><tr>';
				if (rowColour == 'light') {
					rowColour = 'dark';
					} else {
						rowColour = 'light';
					} // end  row color if/else
				} // end if recordNo = mon
			}  // end test for vc only
		}  // end for loop
	} // end monday
	
	
	
	
	
		// check for tuesday tournaments 
		if (chosenDay == 'tue' || chosenDay == 'all') {
		for (i = 0; i < recordNo.length; i++) {
		  if (recordNo[i].vc == false) {
			var createRow = 0;
			var textColor = '#000000';
			if (recordNo[i].type == 'Big Guarantees') { textColor = '#fd1b14'}
			if (recordNo[i].type == 'Freerolls') { textColor = '#2481ca'}
			if (recordNo[i].type == 'Giveaways') { textColor = '#81ca24'}
			
			switch(chosenType) {
				case 'big':  		if (recordNo[i].type == 'Big Guarantees') { createRow = 1}
				break;
				case 'freerolls':  	if (recordNo[i].type == 'Freerolls') { createRow = 1}
				break;
				case 'giveaways':  	if (recordNo[i].type == 'Giveaways') { createRow = 1}
				break;
				case 'all':  createRow = 1;
				break;
				default: createRow = 0;
				break;
			} // end switch
				
				if (recordNo[i].tue == 1 && createRow == 1) {
				buildTable += '<tr class="';
				buildTable += rowColour;
				buildTable += '"><td><font color="';
				buildTable += textColor;
				buildTable += '">Tuesday</font></td><td><font color="';
				buildTable += textColor;
				buildTable += '">';
				buildTable += recordNo[i].time;
				buildTable += '</font></td><td><font color="';
				buildTable += textColor;
				buildTable += '">';
				buildTable += recordNo[i].name;
				buildTable += '</font></td><td><font color="';
				buildTable += textColor;
				buildTable += '">';
				buildTable += recordNo[i].buyin;
				buildTable += '</font></td><tr>';
				if (rowColour == 'light') {
					rowColour = 'dark';
					} else {
						rowColour = 'light';
					} // end  row color if/else
				} // end if recordNo = tue
			}  // end test for vc only
		}  // end for loop
		}// end tuesday
		

		
		// check for wednesday tournaments 
		if (chosenDay == 'wed' || chosenDay == 'all') {
		for (i = 0; i < recordNo.length; i++) {
		 if (recordNo[i].vc == false) {
			var createRow = 0;
			var textColor = '#000000';
			if (recordNo[i].type == 'Big Guarantees') { textColor = '#fd1b14'}
			if (recordNo[i].type == 'Freerolls') { textColor = '#2481ca'}
			if (recordNo[i].type == 'Giveaways') { textColor = '#81ca24'}
			
			switch(chosenType) {
				case 'big':  		if (recordNo[i].type == 'Big Guarantees') { createRow = 1}
				break;
				case 'freerolls':  	if (recordNo[i].type == 'Freerolls') { createRow = 1}
				break;
				case 'giveaways':  	if (recordNo[i].type == 'Giveaways') { createRow = 1}
				break;
				case 'all':  createRow = 1;
				break;
				default: createRow = 0;
				break;
			} // end switch
				
				if (recordNo[i].wed == 1 && createRow == 1) {
				buildTable += '<tr class="';
				buildTable += rowColour;
				buildTable += '"><td><font color="';
				buildTable += textColor;
				buildTable += '">Wednesday</font></td><td><font color="';
				buildTable += textColor;
				buildTable += '">';
				buildTable += recordNo[i].time;
				buildTable += '</font></td><td><font color="';
				buildTable += textColor;
				buildTable += '">';
				buildTable += recordNo[i].name;
				buildTable += '</font></td><td><font color="';
				buildTable += textColor;
				buildTable += '">';
				buildTable += recordNo[i].buyin;
				buildTable += '</font></td><tr>';
				if (rowColour == 'light') {
					rowColour = 'dark';
					} else {
						rowColour = 'light';
					} // end  row color if/else
				} // end if recordNo = wed
			}  // end test for vc only
		}  // end for loop
		}// end wednesday
		
		
		// check for thursday tournaments 
		if (chosenDay == 'thu' || chosenDay == 'all') {
		for (i = 0; i < recordNo.length; i++) {
		  if (recordNo[i].vc == false) {
			var createRow = 0;
			var textColor = '#000000';
			if (recordNo[i].type == 'Big Guarantees') { textColor = '#fd1b14'}
			if (recordNo[i].type == 'Freerolls') { textColor = '#2481ca'}
			if (recordNo[i].type == 'Giveaways') { textColor = '#81ca24'}
			
			switch(chosenType) {
				case 'big':  		if (recordNo[i].type == 'Big Guarantees') { createRow = 1}
				break;
				case 'freerolls':  	if (recordNo[i].type == 'Freerolls') { createRow = 1}
				break;
				case 'giveaways':  	if (recordNo[i].type == 'Giveaways') { createRow = 1}
				break;
				case 'all':  createRow = 1;
				break;
				default: createRow = 0;
				break;
			} // end switch
				
				if (recordNo[i].thu == 1 && createRow == 1) {
				buildTable += '<tr class="';
				buildTable += rowColour;
				buildTable += '"><td><font color="';
				buildTable += textColor;
				buildTable += '">Thursday</font></td><td><font color="';
				buildTable += textColor;
				buildTable += '">';
				buildTable += recordNo[i].time;
				buildTable += '</font></td><td><font color="';
				buildTable += textColor;
				buildTable += '">';
				buildTable += recordNo[i].name;
				buildTable += '</font></td><td><font color="';
				buildTable += textColor;
				buildTable += '">';
				buildTable += recordNo[i].buyin;
				buildTable += '</font></td><tr>';
				if (rowColour == 'light') {
					rowColour = 'dark';
					} else {
						rowColour = 'light';
					} // end  row color if/else
				} // end if recordNo = thu
			}  // end test for vc only
		}  // end for loop
		}// end thursday
		
		
		// check for friday tournaments
		if (chosenDay == 'fri' || chosenDay == 'all') {
		for (i = 0; i < recordNo.length; i++) {
		  if (recordNo[i].vc == false) {
			var createRow = 0;
			var textColor = '#000000';
			if (recordNo[i].type == 'Big Guarantees') { textColor = '#fd1b14'}
			if (recordNo[i].type == 'Freerolls') { textColor = '#2481ca'}
			if (recordNo[i].type == 'Giveaways') { textColor = '#81ca24'}
			
			switch(chosenType) {
				case 'big':  		if (recordNo[i].type == 'Big Guarantees') { createRow = 1}
				break;
				case 'freerolls':  	if (recordNo[i].type == 'Freerolls') { createRow = 1}
				break;
				case 'giveaways':  	if (recordNo[i].type == 'Giveaways') { createRow = 1}
				break;
				case 'all':  createRow = 1;
				break;
				default: createRow = 0;
				break;
			} // end switch
				
				if (recordNo[i].fri == 1 && createRow == 1) {
				buildTable += '<tr class="';
				buildTable += rowColour;
				buildTable += '"><td><font color="';
				buildTable += textColor;
				buildTable += '">Friday</font></td><td><font color="';
				buildTable += textColor;
				buildTable += '">';
				buildTable += recordNo[i].time;
				buildTable += '</font></td><td><font color="';
				buildTable += textColor;
				buildTable += '">';
				buildTable += recordNo[i].name;
				buildTable += '</font></td><td><font color="';
				buildTable += textColor;
				buildTable += '">';
				buildTable += recordNo[i].buyin;
				buildTable += '</font></td><tr>';
				if (rowColour == 'light') {
					rowColour = 'dark';
					} else {
						rowColour = 'light';
					} // end  row color if/else
				} // end if recordNo = fri
			}  // end test for vc only
		}  // end for loop
		}// end friday
		
		
		
		// check for saturday tournaments 
		if (chosenDay == 'sat' || chosenDay == 'all') {
		for (i = 0; i < recordNo.length; i++) {
		  if (recordNo[i].vc == false) {
			var createRow = 0;
			var textColor = '#000000';
			if (recordNo[i].type == 'Big Guarantees') { textColor = '#fd1b14'}
			if (recordNo[i].type == 'Freerolls') { textColor = '#2481ca'}
			if (recordNo[i].type == 'Giveaways') { textColor = '#81ca24'}
			
			switch(chosenType) {
				case 'big':  		if (recordNo[i].type == 'Big Guarantees') { createRow = 1}
				break;
				case 'freerolls':  	if (recordNo[i].type == 'Freerolls') { createRow = 1}
				break;
				case 'giveaways':  	if (recordNo[i].type == 'Giveaways') { createRow = 1}
				break;
				case 'all':  createRow = 1;
				break;
				default: createRow = 0;
				break;
			} // end switch
				
				if (recordNo[i].sat == 1 && createRow == 1) {
				buildTable += '<tr class="';
				buildTable += rowColour;
				buildTable += '"><td><font color="';
				buildTable += textColor;
				buildTable += '">Saturday</font></td><td><font color="';
				buildTable += textColor;
				buildTable += '">';
				buildTable += recordNo[i].time;
				buildTable += '</font></td><td><font color="';
				buildTable += textColor;
				buildTable += '">';
				buildTable += recordNo[i].name;
				buildTable += '</font></td><td><font color="';
				buildTable += textColor;
				buildTable += '">';
				buildTable += recordNo[i].buyin;
				buildTable += '</font></td><tr>';
				if (rowColour == 'light') {
					rowColour = 'dark';
					} else {
						rowColour = 'light';
					} // end  row color if/else
				} // end if recordNo = sat
			}  // end test for vc only
		}  // end for loop
		}// end saturday
		

		// check for sunday tournaments 
		if (chosenDay == 'sun' || chosenDay == 'all') {
		for (i = 0; i < recordNo.length; i++) {
		  if (recordNo[i].vc == false) {
			var createRow = 0;
			var textColor = '#000000';
			if (recordNo[i].type == 'Big Guarantees') { textColor = '#fd1b14'}
			if (recordNo[i].type == 'Freerolls') { textColor = '#2481ca'}
			if (recordNo[i].type == 'Giveaways') { textColor = '#81ca24'}
			
			switch(chosenType) {
				case 'big':  		if (recordNo[i].type == 'Big Guarantees') { createRow = 1}
				break;
				case 'freerolls':  	if (recordNo[i].type == 'Freerolls') { createRow = 1}
				break;
				case 'giveaways':  	if (recordNo[i].type == 'Giveaways') { createRow = 1}
				break;
				case 'all':  createRow = 1;
				break;
				default: createRow = 0;
				break;
			} // end switch
				
				if (recordNo[i].sun == 1 && createRow == 1) {
				buildTable += '<tr class="';
				buildTable += rowColour;
				buildTable += '"><td><font color="';
				buildTable += textColor;
				buildTable += '">Sunday</font></td><td><font color="';
				buildTable += textColor;
				buildTable += '">';
				buildTable += recordNo[i].time;
				buildTable += '</font></td><td><font color="';
				buildTable += textColor;
				buildTable += '">';
				buildTable += recordNo[i].name;
				buildTable += '</font></td><td><font color="';
				buildTable += textColor;
				buildTable += '">';
				buildTable += recordNo[i].buyin;
				buildTable += '</font></td><tr>';
				if (rowColour == 'light') {
					rowColour = 'dark';
					} else {
						rowColour = 'light';
					} // end  row color if/else
				} // end if recordNo = sun
			}  // end test for vc only
		}  // end for loop
		}// end tuesday
		
		
		buildTable += '</table>'
		
		var myTable = document.getElementById('tournamentTable');
		myTable.innerHTML = buildTable;
		
		
} // end buildit function

		
			















