// #PLib::PLoad('PLib.Dom.Client.prototype');
// #PLib::PLoad('PLib.Dom.Client.Scripts.lowpro');

var TherapyFilter = Class.create();

TherapyFilter.prototype = {
		
	initialize: function() {
		this.confirmLinks = new Hash();
		this.clickActions = new Hash();
		this.changeHandler = this.selectionChanged.bindAsEventListener(this);
		Event.onReady(this.bindToDocument.bindAsEventListener(this));
	},
	
	bindToDocument: function(event) {
		this.rgs = $$('input[name=rgGender]');
		this.ddl = $$('select[name=ddlRegion]').first();
		
		var myThis = this;
		this.rgs.each(function(ctrl)
		{
			Event.observe(ctrl, 'click', myThis.changeHandler);
		});
		Event.observe(this.ddl, 'change', this.changeHandler);
		this.selectionChanged(null);
	},
		
	selectionChanged: function(event)
	{
		var val1 = null;
		var myThis = this;
		this.rgs.each(function(ctrl)
		{
			if(ctrl.checked)
			{
				val1 = ctrl.value;
			}
		});
		
		var val2 = this.ddl.value;
		var ctrls = $$('.therapy_menu_item');
		
		ctrls.each(function(ctrl)
		{
			var valid = true;
			if(val1)
			{
				if(!ctrl.hasClassName(val1)){
					valid = false;
				}
			}
			if(val2 != '_null')
			{
				if(!ctrl.hasClassName(val2)){
					valid = false;
				}
			}
			if(valid)
			{
				ctrl.show();
			}
			else
			{
				ctrl.hide();
			}
		});
		return;
	}
};

var therapyFilter = new TherapyFilter();

