/*
Script by RoBorg
RoBorg@geniusbug.com
http://javascript.geniusbug.com
Please do not remove or edit this message
*/


//Start setup [Edit below here]

var d = new dynamicSelect();

d.addSelect('office');

d.selects['office'].addOption('banning');
d.selects['office'].options['banning'].createOption('Select Program', '');
/*d.selects['office'].options['banning'].createOption('Hospice', 'sghosintake@vna-ic.org');*/
d.selects['office'].options['banning'].createOption('Hospice', 'luis@cavemedia.com');
d.selects['office'].options['banning'].createOption('Home Health', 'Sghhintake@vna-ic.org');
d.selects['office'].options['banning'].createOption('TeleHealth', 'Sghhintake@vna-ic.org');
d.selects['office'].options['banning'].createOption('Infusion', 'Sghhintake@vna-ic.org');

d.selects['office'].addOption('barstow');
d.selects['office'].options['barstow'].createOption('Select Program', '');
d.selects['office'].options['barstow'].createOption('Hospice', 'Barhosintake@vna-ic.org');
d.selects['office'].options['barstow'].createOption('Home Health', 'Barhhintake@vna-ic.org');
d.selects['office'].options['barstow'].createOption('TeleHealth', 'Barhhintake@vna-ic.org');
d.selects['office'].options['barstow'].createOption('Infusion', 'Barhhintake@vna-ic.org');

d.selects['office'].addOption('murrieta');
d.selects['office'].options['murrieta'].createOption('Select Program', '');
d.selects['office'].options['murrieta'].createOption('Hospice', 'Murhosintake@vna-ic.org');
d.selects['office'].options['murrieta'].createOption('Home Health', 'Murhhintake@vna-ic.org');
d.selects['office'].options['murrieta'].createOption('TeleHealth', 'Murhhintake@vna-ic.org');
d.selects['office'].options['murrieta'].createOption('Infusion', 'Murhhintake@vna-ic.org');

d.selects['office'].addOption('pd');
d.selects['office'].options['pd'].createOption('Select Program', '');
d.selects['office'].options['pd'].createOption('Hospice', 'Pdhosintake@vna-ic.org');
d.selects['office'].options['pd'].createOption('Home Health', 'Pdhhintake@vna-ic.org');
d.selects['office'].options['pd'].createOption('TeleHealth', 'Pdhhintake@vna-ic.org');
d.selects['office'].options['pd'].createOption('Infusion', 'Pdhhintake@vna-ic.org');

d.selects['office'].addOption('riverside');
d.selects['office'].options['riverside'].createOption('Select Program', '');
d.selects['office'].options['riverside'].createOption('Hospice', 'Corphosintake@vna-ic.org');
d.selects['office'].options['riverside'].createOption('Home Health', 'Corphhintake@vna-ic.org');
d.selects['office'].options['riverside'].createOption('TeleHealth', 'Corphhintake@vna-ic.org');
d.selects['office'].options['riverside'].createOption('Infusion', 'Corphhintake@vna-ic.org');

d.selects['office'].addOption('victorville');
d.selects['office'].options['victorville'].createOption('Select Program', '');
d.selects['office'].options['victorville'].createOption('Hospice', 'Vvhosintake@vna-ic.org');
d.selects['office'].options['victorville'].createOption('Home Health', 'Vvhhintake@vna-ic.org');
d.selects['office'].options['victorville'].createOption('TeleHealth', 'Vvhhintake@vna-ic.org');
d.selects['office'].options['victorville'].createOption('Infusion', 'Vvhhintake@vna-ic.org');

d.selects['office'].addOption('yuccavalley');
d.selects['office'].options['yuccavalley'].createOption('Select Program', '');
d.selects['office'].options['yuccavalley'].createOption('Hospice', 'Yvhosintake@vna-ic.org');
d.selects['office'].options['yuccavalley'].createOption('Home Health', 'Yvhhintake@vna-ic.org');
d.selects['office'].options['yuccavalley'].createOption('TeleHealth', 'Yvhhintake@vna-ic.org');
d.selects['office'].options['yuccavalley'].createOption('Infusion', 'Yvhhintake@vna-ic.org');

//End setup [Edit above here]


function dynamicSelect()
{
	this.selects = new Array();
	
	this.addSelect = function(name)
	{
		this.selects[name] = new selectObj();
	}


	this.updateOptions = function(source, target)
	{
		var form = source.form;
		var target = form.elements[target];
		var value = source.options[source.selectedIndex].value;
		
		while(target.options.length) target.remove(0);
		
		if(!this.selects[source.name].options[value])
		{
			//alert('Invalid selection.'); //For debugging while you set it up
			return;
		}
		
		var data = this.selects[source.name].options[value].options;
		
		for(var x=0; x<data.length; x++)
		{
			try
			{
				target.add(data[x]);
			}
			catch(e)
			{
				target.add(data[x], null);
			}
		}
		
		target.selectedIndex = 0;
	}

}


function selectObj()
{
	this.options = new Array();
	
	this.addOption = function(value)
	{
		this.options[value] = new optionObj();
	}
}


function optionObj()
{
	this.options = new Array();
	
	this.createOption = function(name, value)
	{
		this.options[this.options.length] = new Option(name, value);
	}
}


