function dependant_selector() {
	this.day_tag = new Array;
	this.time_tag = new Array;
	this.day_obj = new Array;
}

dependant_selector.prototype.add_day=function(aday) {
	this.day_obj.push(aday);
}

dependant_selector.prototype.day_change=function(event) {
	var theapp = this.app_obj;

	for(x = 0; x < theapp.day_tag.length; x++)
	{
		if(theapp.day_tag[x] == this.id) {
			var setit = document.getElementById(theapp.time_tag[x]);
			break;	
		}
	}

	while (setit.firstChild)
	{
			setit.removeChild(setit.firstChild);
	}

	
	var selatime = document.createElement("option");
	selatime.value = "Select a Time";
	selatime.appendChild(document.createTextNode("Select a Time"));
	setit.appendChild(selatime);
	
	for(x = 0; x < theapp.day_obj.length; x++)
	{
		if(this.options[this.selectedIndex].value == theapp.day_obj[x].day) {
			
			
			
			for(y = 0; y < theapp.day_obj[x].times.length; y++)
			{
				var bopt = document.createElement("option");
				bopt.value = theapp.day_obj[x].times[y];
				bopt.appendChild(document.createTextNode(theapp.day_obj[x].times[y]));	
				setit.appendChild(bopt);
			}
		}
	}
	

}

dependant_selector.prototype.link_sel=function() {
	for(x = 0; x < arguments.length; x++)
	{
		this.day_tag.push(arguments[x]);
		x++;
		this.time_tag.push(arguments[x]);
	}

	for(x = 0; x < this.day_tag.length; x++)
	{
		var taga = document.getElementById(this.day_tag[x]);
		taga.app_obj = this;
		var tagb = document.getElementById(this.time_tag[x]);
		tagb.app_obj = this;

		while (taga.firstChild)
		{
			taga.removeChild(taga.firstChild);
		}

		while (tagb.firstChild)
		{
			tagb.removeChild(tagb.firstChild);
		}

		var seladay = document.createElement("option");
		seladay.value = "Select a Day";
		seladay.appendChild(document.createTextNode("Select a Day"));
		taga.appendChild(seladay);
		
		ranonce = false;
		for(y = 0; y < this.day_obj.length; y++)
		{
			var aopt = document.createElement("option");
			aopt.value = this.day_obj[y].day;
			aopt.appendChild(document.createTextNode(this.day_obj[y].day));
			taga.appendChild(aopt);

			if(ranonce == false){
				ranonce = true;
				var selatime = document.createElement("option");
				selatime.value = "Select a Time";
				selatime.appendChild(document.createTextNode("Select a Time"));
				tagb.appendChild(selatime);

			}		

		}

		taga.onchange = this.day_change;
	}
}
