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

	firmquestions: null,
	firmpartners: null,
	firmemployees: null,

	bootcamp: null,
	bootcampquestions: null,
	resourcekitNo: null,
	resourcekitYes: null,
	
	referral: null,
	otherreferral: null,

	firmtype: null,
	otherfirmtype: null,

	othermembershipCheck: null,
	othermembership: null,
	
	initialize: function(node)
	{
		this.node = node;
		
		this.firmquestions = cssQuery('div[id="firmquestions"]', this.node)[0];
		this.firmpartners = cssQuery('input[id="firmpartners"]', this.node)[0];
		this.firmemployees = cssQuery('input[id="firmemployees"]', this.node)[0];
		this.firmtypes = cssQuery('input[id="firmtypes"]', this.node)[0];

		this.bootcamp = cssQuery('select[id="bootcamp"]', this.node)[0];
		this.bootcampquestions = cssQuery('div[id="bootcampquestions"]', this.node)[0];
		this.resourcekitNo = cssQuery('input[id="resourcekitNo"]', this.node)[0];
		this.resourcekitYes = cssQuery('input[id="resourcekitYes"]', this.node)[0];

		this.referral = cssQuery('select[id="referral"]', this.node)[0];
		//this.otherreferral = cssQuery('input[id="otherreferral"]', this.node)[0];
		this.otherreferral = cssQuery('div[id="otherreferral"]', 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.othermembershipCheck = cssQuery('input[id="othermembershipCheck"]', this.node)[0];
		this.othermembership = cssQuery('input[id="othermembership"]', this.node)[0];
		
		Event.observe(this.bootcamp, 'change', delegate(this, this.invalidate));
		Event.observe(this.referral, 'change', delegate(this, this.invalidate));
		Event.observe(this.othermembershipCheck, 'click', delegate(this, this.invalidate));
		Event.observe(this.firmtype, 'change', delegate(this, this.invalidate));
		
		this.draw();
	},
	
	invalidate: function()
	{
    	this.draw();
	},

	draw: function()
	{
		
		if(parseInt(this.bootcamp.options[this.bootcamp.selectedIndex].value))
		{
			this.bootcampquestions.style.display = 'block';
		}
		else
		{
			this.bootcampquestions.style.display = 'none';
			this.resourcekitNo.checked = true;
		}

		if(parseInt(this.referral.options[this.referral.selectedIndex].value) === 0)
		{
			this.otherreferral.style.display = 'inline';
		}
		else
		{
			this.otherreferral.style.display = 'none';
			this.otherreferral.value = '';
		}
		
		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(this.othermembershipCheck.checked)
		{
			this.othermembership.style.display = 'inline';
		}
		else
		{
			this.othermembership.style.display = 'none';
			this.othermembership.value = '';
		}
	}
}
