
function create_array() {

//manufacturers array
	mans = new Array("<a href=\"http://www.aquadis.com\" target=\"_blank\" class=\"navlink\">Aquadis</a>","<a href=\"http://www.barclayproducts.com\" target=\"_blank\" class=\"navlink\">Barclay Products</a>","<a href=\"http://www.bigjohntolietseat.com\" target=\"_blank\" class=\"navlink\">Big John Toliet Seat</a>","<a href=\"http://www.churchseats.com\" target=\"_blank\" class=\"navlink\">Church Seats</a>","<a href=\"http://www.WDI-comfortseats.com\" target=\"_blank\" class=\"navlink\">Comfort Seat</a>","<a href=\"http://www.duravit.us\" target=\"_blank\" class=\"navlink\">Duravit</a>","<a href=\"http://www.herbeau.com\" target=\"_blank\" class=\"navlink\">Herbeau</a>","<a href=\"http://www.lebijoucollection.net\" target=\"_blank\" class=\"navlink\">Lebijou</a>","<a href=\"http://www.neptuneb.com\" target=\"_blank\" class=\"navlink\">Neptune</a>","<a href=\"http://www.porcher-us.com\" target=\"_blank\" class=\"navlink\">Porcher</a>","<a href=\"http://www.pressalit.com\" target=\"_blank\" class=\"navlink\">Pressalit Toliet Seats</a>","<a href=\"http://www.stthomascreations.com\" target=\"_blank\" class=\"navlink\">St. Thomas Creations</a>","<a href=\"http://www.sunrisespecialty.com\" target=\"_blank\" class=\"navlink\">Sunrise Specialty</a>","<a href=\"http://www.totousa.com\" target=\"_blank\" class=\"navlink\">Toto</a>","<a href=\"http://www.washlet.com\" target=\"_blank\" class=\"navlink\">Toto Washlets</a>","<a href=\"http://www.totoneorest.com\" target=\"_blank\" class=\"navlink\">Toto Neorest</a>","<a href=\"http://www.villeroy-boch.com\" target=\"_blank\" class=\"navlink\">Villeroy & Boch</a>");

//array 1
	toilets = new Array("1","1","0","0","0","1","1","1","1","1","0","1","1","1","0","1","1");

//array 2
	seats = new Array("0","0","0","0","0","1","1","0","1","1","0","1","0","1","1","1","1");

//array 3
	bidets = new Array("0","0","1","1","1","0","1","0","0","1","1","0","1","1","1","0","1");

}

function sort_array() {
	
//Checks the value of the checkbox to see if it is checked.
	if (document.getElementById("Toilets").checked) {

	//Begins sorting the array elements by checkbox values
		var abcd = 0;
		var counter = mans.length;
		for (i = 0; i < counter; ++i) {
			if(toilets[i-abcd] != "1") {
				mans.splice(i-abcd, 1);
				toilets.splice(i-abcd, 1);
				seats.splice(i-abcd, 1);
				bidets.splice(i-abcd, 1);
				abcd = abcd + 1;
			}
		}
	}

//Checks the value of the checkbox to see if it is checked.
	if (document.getElementById("Seats").checked) {

	//Begins sorting the array elements by checkbox values
		var abcd = 0;
		var counter = mans.length;
		for (i = 0; i < counter; ++i) {
			if(seats[i-abcd] != "1") {
				mans.splice(i-abcd, 1);
				toilets.splice(i-abcd, 1);
				seats.splice(i-abcd, 1);
				bidets.splice(i-abcd, 1);
				abcd = abcd + 1;
			}
		}
	}

//Checks the value of the checkbox to see if it is checked.
	if (document.getElementById("Bidets").checked) {

	//Begins sorting the array elements by checkbox values
		var abcd = 0;
		var counter = mans.length;
		for (i = 0; i < counter; ++i) {
			if(bidets[i-abcd] != "1") {
				mans.splice(i-abcd, 1);
				toilets.splice(i-abcd, 1);
				seats.splice(i-abcd, 1);
				bidets.splice(i-abcd, 1);
				abcd = abcd + 1;
			}
		}
	}

}


function display_array() {
//formats the sorted array for printing
	var output_mans = mans.join("<br />");
	
//Displays the formated array elements in the correct html elements
	document.getElementById("manufacturer_list").innerHTML = output_mans;
}

function run_sort() {
//Runs all of the sorting procedures and then displays the correct sorted list
	create_array();
	sort_array();
	display_array();
}

function check_uncheck(box) {
	if (document.getElementById(box).checked) {
		document.getElementById(box).checked = false;
	}
	else {
		document.getElementById(box).checked = true;
	}
}