Charactercontroller reseting below ground

I have a charactercontroller that after I crouch it drops below the surface, if you move it pops back up on top if you don’t move and crouch again it falls through. what function can I use to grow the top of the Charactercontroller from the top only? here is the code to help.

//basic movement variables
var curSpeed : float = 10.0;
var jumpForce : float = 8.0;
var gravity : float = 20.0;
private var moveDirection : Vector3 = Vector3.zero;
//crouching variables
var crouchRatio : float = .5;
var transitionToCrouchRatio : float = .2;
var crouchVelocity : float;
var curCrouchRatio : float = 1;
var originalLocalScaleY : float;
var crouchLocalScaleY : float;

var feetOnGround : boolean;




function Awake () {
	curCrouchRatio = 1;
	originalLocalScaleY = transform.localScale.y;
	crouchLocalScaleY = transform.localScale.y *crouchRatio;
}

function Update () {
	var v3 = Camera.main.transform.forward;															
	v3.y = 0.0;
	transform.rotation = Quaternion.LookRotation(v3);
	transform.localScale.y = Mathf.Lerp(crouchLocalScaleY, originalLocalScaleY, curCrouchRatio);	//crouching
	var controller : CharacterController = GetComponent(CharacterController);
	// basic movement & jumping
	if(controller.isGrounded){
		moveDirection = Vector3(Input.GetAxis("Horizontal"),0, Input.GetAxis("Vertical"));
		moveDirection = transform.TransformDirection(moveDirection);
		moveDirection *= curSpeed;
		
		
		if(Input.GetButton("Jump")){
			moveDirection.y = jumpForce;
		}
	}
	//crouching
	if(Input.GetButton("Crouch")){
		curCrouchRatio = Mathf.SmoothDamp(curCrouchRatio,0,crouchVelocity, transitionToCrouchRatio);
	}
	if(Input.GetButton("Crouch")== false){
		curCrouchRatio = Mathf.SmoothDamp(curCrouchRatio,1,crouchVelocity, transitionToCrouchRatio);
		transform.localScale.y = 1;
	}
	if(controller.isGrounded){
		feetOnGround = true;
	}else{
		feetOnGround = false;
	}
	moveDirection.y -= gravity * Time.deltaTime;
	controller.Move(moveDirection * Time.deltaTime);
	
}

If I understand your intent, instead of this:

transform.localScale.y = Mathf.Lerp(crouchLocalScaleY, originalLocalScaleY, curCrouchRatio);   //crouching

you want to change the height and center of the CharacterController by changing controller.height and controller.center.y. Untested semi-pseudocode below:

Awake() {
    ...
    originalControllerHeight = controller.height;
    originalControllerCenterY = controller.center.y;
    ...
}

Update() {
    ...
    controller.height = originalControllerHeight * curCrouchRatio;
    controller.center = Vector3(0, originalControllerCenterY * curCrouchRatio, 0);
    ...
}