door open/close on mouse click

hi i know there are many variations of this question but none of the answers work for me i want to open and close a door when you click on the door handle unfortunately while it opens i struggle to trigger the closed. heres my code hopefully just needs tweaking. ive had it working using keyboard functions but cant seem to use it for mouse click.
many thanks

var door : GameObject;
var knob : GameObject;
var smooth : float = 1.0;
var open : boolean = false;
var closed : boolean = true;


function Start (){
door = GameObject.Find("door");
knob = GameObject.Find("Sphere");

}

function Update () {
//to rotate the door to the open angle//
        if (open){
		var doorOpen = Quaternion.Euler(0, -80, 0);
		door.transform.rotation = Quaternion.Slerp(transform.rotation, doorOpen, Time.deltaTime * smooth);
		}
		//to rotate the door to the closed angle//
		if (closed){
		var doorClosed = Quaternion.Euler(0, 0, 0);
		door.transform.rotation = Quaternion.Slerp(transform.rotation, doorClosed, Time.deltaTime * smooth);
}

if (Input.GetMouseButtonDown(0)){
var ray : Ray = Camera.main.ScreenPointToRay 
                            (Input.mousePosition);
        var hit : RaycastHit;
//raytrace on door knob//
 if (knob.collider.Raycast (ray, hit, 10.0)&&closed ==true) {
open = true;
}  
 if (knob.collider.Raycast (ray, hit, 10.0)&&open ==true) {
closed = true;
}  

   //this should make sure that open and closed are opposites but doesnt seem to//
		if (open==true){
			closed = (open == false);
			}

}
}

#pragma strict

var door : GameObject;
var knob : GameObject;
var smooth : float = 1.0;
var open : boolean = false;



function Start ()
{
	door = GameObject.Find("door");
	knob = GameObject.Find("Sphere");
}
 
function Update () {
//to rotate the door to the open angle//
       if (open)	// open = true
       {
      		var doorOpen = Quaternion.Euler(0, 80, 0);	// Get the Euler of the angle that we want to reach
       		var angle = Quaternion.Angle(transform.rotation, doorOpen);		// Convert it to angle
			door.transform.rotation = Quaternion.Slerp(transform.rotation, doorOpen, smooth * Time.deltaTime);
			
			// When we come near the angle, that we want to reach, we snap the door to that angle
			// cuz otherwise we will never reach it, because of the smoothed lerp of the Quaternion.
			// If the snap is too obvious try replacing the "smooth" with 0.5 for example.
			if (angle <= smooth)
				door.transform.rotation = doorOpen;
       }

       //to rotate the door to the closed angle//
      else  		//  open = false
       {
       		doorOpen = Quaternion.Euler(0, 0, 0);
       		angle = Quaternion.Angle(transform.rotation, doorOpen);
			door.transform.rotation = Quaternion.Slerp(transform.rotation, doorOpen, smooth * Time.deltaTime);
			
			if (angle <= smooth)
				door.transform.rotation = doorOpen;

       }
 
	if (Input.GetMouseButtonDown(0))
	{
		var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
		var hit : RaycastHit;
		//raytrace on door knob//
	 	if (knob.collider.Raycast (ray, hit, 10.0) && open) 
	 	{
			open = false;
		}
		else
		{
			open = true;
		}
	}
}