/* Cufon Text */
Cufon.replace('.futura_bold, #content .column_left h2, #content .column_left h3');
Cufon.replace('h1', {textShadow:'3px 3px 5px black'});

/* jQuery Init */

$(document).ready(function()
{
	// CONTENT LISTING
	$('.content_summary').click(function() {
		document.location = $('.pill', this).attr('href');
	});
	$('.content_summary').hover(function() {
		$('.pill', this).addClass('hover');
		document.body.style.cursor = 'pointer';
	}, function() {
		$('.pill', this).removeClass('hover');
		document.body.style.cursor = 'auto';
	});
	
	// FORM FIELDS
	$('input, textarea').focus(function()
	{
		if(this.value == this.defaultValue) this.select();
	}).mouseup(function(event) {
		event.preventDefault();
	});;
	
	// ENQUIRY
	if ($('.validation_messages').length == 0)
	{
		$('#enquiry').css('display', 'none');
		$('#enquiry_button').css('display', 'block');
	}
	$('#enquiry_button a').click(function() {
		event.preventDefault();
		$('#enquiry').show('fast');
		$('#enquiry_button').hide();
	});
	
	
	
	// QUESTIONNAIRE
	
	// hide initially
	$('#questionnaire .form_part').css('display', 'none');
	$('#questionnaire #part1').css('display', 'block');
	$('#questionnaire ol .next').css('display', 'block');
	$('#questionnaire #p2_dwelling_other, #questionnaire #p5_timeframe_other').css('display', 'none');
	$('#questionnaire ol#budget_amount').css('display', 'none');

	// hover
	$('#questionnaire h3').hover(function() {
		$(this).css('color', '#b00');
		document.body.style.cursor = 'pointer';
		Cufon.refresh();
	}, function() {
		$(this).css('color', '#7d7980');
		document.body.style.cursor = 'auto';
		Cufon.refresh();
	});

	// click
	$('#questionnaire li h3').click(function() {
		$('.form_part').hide('fast');
		$(this).siblings('.form_part').show('fast');
	});
	$('#questionnaire .pill').click(function() {
		$('.form_part').hide('fast');
		$(this).closest('ol').parent('li').next('li').children('.form_part').show('fast');
		return false; // stop actual link
	});
	$('input[name="p6_budget"]').change(function() {
		if ($('input[name="p6_budget"]:checked').val() == 'yes')
		{
			$('#budget_amount').show('fast');
		}
		else $('#budget_amount').hide('fast');
	});

	// select
	$('#questionnaire #p2_dwelling5, #questionnaire #p5_timeframe5').change(function() {
		$(this).parent().children('input[type="text"]').css('display', 'inline');
	});
});