how to swap 2 gameobjects

hi

My ques is that i wanted to swap 2 gameobjects when i click on either of 1 but the problem is that when i click on the object all other gameobjects also get swap …here is my code plz help me

var  RedPrefab  :GameObject;

var BluePrefab :GameObject;

var EmptyPrefab :GameObject;

var temp =GameObject;

var tr :boolean;


function Start ()
{
 
	tr =false;
}

function Update () 
{    
  
       var distance1 = Vector3.Distance(RedPrefab.transform.position,GreenPrefab.transform.position);              	
      	      
        if(Input.GetMouseButtonDown(0))
			  {
				  	  tr =true;
   				 	 //EmptyPrefab =GreenPrefab.transform.position;
      				 //GreenPrefab.transform.position = RedPrefab.transform.position;
      			     //RedPrefab.transform.position = EmptyPrefab;       			         			     		
  					 var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);
        			 var hit : RaycastHit;         
        	 		 if (collider.Raycast (ray, hit, 100.0)) 
        	  		  { 	  		     
        	  		        			       	              Debug.Log("fg");           
							temp=gameObject.transform.position;
							
        	  		  	         	  		  
   			       	  }     			       	  				
 
			 }
}
function OnCollisionStay(col:Collision) 
   			       	  {
   			       	      if(tr==true)
   			       	      {
   							//if(col.gameObject.tag == "Blue") 
   			       	            // {
   			       	            //  gameObject.transform.position =BluePrefab.transform.position;
   			       	             // BluePrefab.transform.position=gameObject.transform.position;
   			       	               
   			       	           //  }
 								}
   			       	  }

Who this script is attached to. A simple code to swap a prefab with another is like this,
var otherPrefab : GameObject

function OnMouseDown()
{
var temp = transform.position;
transform.position = otherPrefab.transform.position;
otherPrefab.transform.position = temp;
//You can change references if you want as well.
}