// makes a gap junction between 2 axonal compartments
// $o1 - cell[1], 
// $2 - section index in cell[1].collat[]
// $o3 - cell[2], 
// $4 - section index in cell[2].collat[]
// $5 - gj conductance
// $6, $7 - position within section1, section2
begintemplate gapjunction
      public g
	  public setg, setcells, cell1, cell2, pos1, pos2, get
      objref con1, con2
      proc init() {
        objref con1, con2
        $o1.collat[$2] con1 = new Gap($6)
        $o3.collat[$4] con2 = new Gap($7)
        setpointer con1.vgap, $o3.collat[$4].v($7)
        setpointer con2.vgap, $o1.collat[$2].v($6)
		con1.g = $5
		con2.g = $5
      }
	 proc setg() { // change the gj conductance externally
        con1.g = $1
        con2.g = $1
      }
	  proc setcells(){ //IDs of cells that are coupled
	    cell1=$1
		cell2=$2
		pos1=$3
		pos2=$4
	  }
	  proc get(){
		print "cell1 ", cell1, " pos1 ", pos1 
		print "cell2 ", cell2, " pos2 ", pos2
	  }
endtemplate gapjunction