net.principa.QuickRego = Class.create();
net.principa.QuickRego.prototype =
{
	node: null,

	firmtype: null,
	otherfirmtype: null,
	
	occupation: null,
	otheroccupation: null,
	
	initialize: function(node)
	{
		this.node = node;
		
		this.firmtypes = cssQuery('input[id="firmtypes"]', this.node)[0];

		this.firmtype = cssQuery('select[id="firmtype"]', this.node)[0];
		//this.otherfirmtype = cssQuery('input[id="otherfirmtype"]', this.node)[0];
		this.otherfirmtype = cssQuery('div[id="otherfirmtype"]', this.node)[0];

		this.occupation = cssQuery('select[id="occupation"]', this.node)[0];
		//this.otherfirmtype = cssQuery('input[id="otheroccupation"]', this.node)[0];
		this.otheroccupation = cssQuery('div[id="otheroccupation"]', this.node)[0];

		Event.observe(this.firmtype, 'change', delegate(this, this.invalidate));
		Event.observe(this.occupation, 'change', delegate(this, this.invalidate));
		
		this.draw();
	},
	
	invalidate: function()
	{
    	this.draw();
	},

	draw: function()
	{		
		if(parseInt(this.firmtype.options[this.firmtype.selectedIndex].value) === 0)
		{
			this.otherfirmtype.style.display = 'inline';
		}
		else
		{
			this.otherfirmtype.style.display = 'none';
			this.otherfirmtype.value = '';
		}
		
		if(parseInt(this.occupation.options[this.occupation.selectedIndex].value) === 0)
		{
			this.otheroccupation.style.display = 'inline';
		}
		else
		{
			this.otheroccupation.style.display = 'none';
			this.otheroccupation.value = '';
		}
	}
}

