function setupSellForm(){
	// Format
	if($("#format").val() == "VEHICLE"){
		$("#certificate_expiry_container").hide();
	} else {
		$("#certificate_expiry_container").slideDown();
	}
	
	// Owner
	if($("#owner").val() == 1){
		$("#vat_container").slideDown();
		$("#owner_container").removeClass("formboxrowlast");
	} else {
		$("#vat_container").hide();
		$("#owner_container").addClass("formboxrowlast");
	}
}

function configureSellForm(){
	// Format
	if($("#format").val() == "VEHICLE"){
		$("#certificate_expiry_container").slideUp("fast");
	} else {
		$("#certificate_expiry_container").slideDown();
	}
	
	// Owner
	if($("#owner").val() == 1){
		$("#vat_container").slideDown();
		$("#owner_container").removeClass("formboxrowlast");
	} else {
		$("#vat_container").slideUp("fast");
		$("#owner_container").addClass("formboxrowlast");
	}
}

$(document).ready(function(){
	setupSellForm();
	$("#format").bind("change",function(){
		configureSellForm();
	});
	$("#owner").bind("change",function(){
		configureSellForm();
	});
	$("#registration").searchbox({format: 'regspace', uppercase: true, nospace: false });
        $('#sellconfirmationform').bind("submit",function(){
		if ($('#agreetoterms').is(':checked')) {
		 	return true;
		} else {
			alert("Please confirm you have read our terms and conditions.");
		 	return false;
		}
	});
});