function form_change(element){
	switch($F(element)){
		case '1':
			changeType('1');
			element_value = 'for_sale';
			break;
		case '2':
			changeType('2');
			element_value = 'for_lease';
			break;
		case '3':
			changeType('3');
			element_value = 'vacation';
			break;
	}
	var text_elements = Array('for_sale', 'for_lease', 'vacation');
	for(i=0; i<text_elements.length; i++){
		if(text_elements[i] == element_value){
			$(text_elements[i]+'_text').style.fontWeight = 'bold';
		}else{
			$(text_elements[i]+'_text').style.fontWeight = '';
		}
	}
}

var vr_elements = new Array(
'vr_price',
'price_label'
);

var pl_elements = new Array(
'year_built_input',
'sale_price'
);

var sale_elements = new Array(
'price_label'
);

var le_elements = new Array(
'lease_price_label'
);

function changeUser(element){
	$('signup_block').show();
	switch(element.value){
		case 'Agent':
			$('agent_id_block').show();
			$('brokerage_block').show();
			$('mls_listing_id_block').show();
			$('payment_info').hide();
			$('for_sale_price').hide();
			$('for_lease_price').hide();
			$('for_sale_free').show();
			$('for_lease_free').show();
			break;
		default:
			$('agent_id_block').hide();
			$('brokerage_block').hide();
			$('mls_listing_id_block').hide();
			$('payment_info').show();
			$('for_sale_price').show();
			$('for_lease_price').show();
			$('for_sale_free').hide();
			$('for_lease_free').hide();
			break;
	}
	new Validation('signup_form', {immediate: true});
	var img1 = new Image();
	img1.src = "http://condocompany.com/images/pass.png";
	var img2 = new Image();
	img2.src = "http://condocompany.com/images/fail.png";
}

function changeType(type){
	switch(type){
		case '3':
			hide_elements = pl_elements.concat(sale_elements).concat(le_elements);
			show_elements = vr_elements;
			if(radio_value('signup_form','user_type') == 'Agent'){
				$('payment_info').show();
			}
			break;
		case '1':
			hide_elements = vr_elements.concat(le_elements);
			show_elements = pl_elements.concat(sale_elements);
			if(radio_value('signup_form','user_type') == 'Agent'){
				$('payment_info').hide();
			}
			break;
		case '2':
			hide_elements = vr_elements.concat(sale_elements);
			show_elements = pl_elements.concat(le_elements);
			if(radio_value('signup_form','user_type') == 'Agent'){
				$('payment_info').hide();
			}
			break;
	}
	hide_elements.each(function(element) {
		$(element).hide();
	});
	show_elements.each(function(element) {
		$(element).show();
	});
}

function radio_value (form, name) {
	var elements = Form.getInputs( $(form), 'radio');
	var e =  elements.detect(function(e) {
		return e.checked;
	});
	return e.value;
}

function checkEmail(){
	var email = $F('email');
	var url = '/lib/check_email.php';
	var opt = {
		method: 'post',
		postBody: 'email=' + email,
		onSuccess: function(t) {
			var advice = $('advice-confirmation-email');
			if(t.responseText) {
				new Effect.Appear(advice, {duration : .5 });
			} else {
				advice.hide();
			}
		}
	}
	var ajax = new Ajax.Request(url, opt);
}
