source /home/ventana/source/light2.tcl
source /home/ventana/source/submenu/update_button.tcl

#####################################################
# Create the menu for the "Lights Isolation" button #
#####################################################

#--------------
# initially
#--------------
#set li1 1
#set li3 1



proc create_lightisol_submenu2 { } {

   global li1 li2 li3 li4 li5 li6 li7 li8

   set lightisol2 .ventana2.bar.lightisol.menu
   menu $lightisol2

   $lightisol2 add check -label "Toolsled Stbd" \
	-variable li1 -command {isolate2 1 }
   $lightisol2 add check -label "Toolsled Port" \
	-variable li2 -command {isolate2 2 }
   $lightisol2 add check -label "Toolsled Incandescent" \
	-variable li3 -command {isolate2 3 }
   $lightisol2 add check -label "Camera Incandescent" \
	-variable li4 -command {isolate2 4 }

   #set li4 0	
   #$lightisol2 add check -label "Camera Incandescent Lamp" \
	-variable li8 -command {isolate2 8 }
   $lightisol2 add check -label "Stbd Lower" \
	-variable li5 -command {isolate2 5 }
   $lightisol2 add check -label "Port Lower" \
	-variable li6 -command {isolate2 6 }
   $lightisol2 add check -label "Stbd Upper" \
	-variable li7 -command {isolate2 7 }
   $lightisol2 add check -label "Port Upper" \
	-variable li8 -command {isolate2 8 }
	

}

proc isolate2 { id } {
	#global lm1 lm2 lm3 lm4 lm5 lm6 lm7 lm8
	global li1 li2 li3 li4 li5 li6 li7 li8
	global active_color
	
	if { $id == 1} {
		# if both are on, we have to turn off lightmenu first, then isolate
		if { $li1 == 1 && $active_color(1) == "white" } {
		      	set active_color(1) "blue"
			change_color 1 "blue"
						
			# turn "off"  lightmenu switch
			send_switches_down 0 49 0    				
		}
		
		# else, just turn on the lightisol switch
		#send_switches_down 0 57 $li1
		send_momentary_but_down 0 57 $li1	
		update_button 0 57
		
			
	}
	
	if { $id == 2} {
		# if both are on, we have to turn off lightmenu first, then isolate
		if { $li2 == 1 && $active_color(2) == "white" } {
		        set active_color(2) "blue"
			change_color 2 "blue"
			
			# turn "off"  lightmenu switch
			send_switches_down 0 50 0    				
		}
		
		# else, just turn on the lightisol switch
		#send_switches_down 0 58 $li2	
		send_momentary_but_down 0 58 $li2	
		update_button 0 58
		
		
	}
	
	if { $id == 3} {
		# if both are on, we have to turn off lightmenu first, then isolate
		if { $li3 == 1 && $active_color(3) == "white" } {
			set active_color(3) "blue"
			change_color 3 "blue"
					
			# turn "off"  lightmenu switch
			send_switches_down 0 51 0   				
		}
		
		# else, just turn on the lightisol switch
		#send_switches_down 0 59 $li3
		send_momentary_but_down 0 59 $li3	
		update_button 0 59
			
	}
	
	if { $id == 4} {
		# if both are on, we have to turn off lightmenu first, then isolate
		if { $li4 == 1 && $active_color(4) == "white" } {
		     	set active_color(4) "blue"
			change_color 4 "blue"
			
			# turn "off"  lightmenu switch
			send_switches_down 0 52 0
		}
		
		# else, just turn on the lightisol switch
		#send_switches_down 0 60 $li4	
		send_momentary_but_down 0 60 $li4
		update_button 0 60
		
	}
	
	if { $id == 5} {
		# if both are on, we have to turn off lightmenu first, then isolate
		if { $li5 == 1 && $active_color(5) == "white"  } {
			set active_color(5) "blue"
			change_color 5 "blue"
			
			# turn "off"  lightmenu switch
			send_switches_down 0 53 0
		}
		
		# else, just turn on the lightisol switch
		#send_switches_down 0 61 $li5	
		send_momentary_but_down 0 61 $li5
		update_button 0 61
		
	}
	
	if { $id == 6} {
		# if both are on, we have to turn off lightmenu first, then isolate
		if { $li6 == 1 &&  $active_color(6) == "white"} {
		        set active_color(6) "blue"
			change_color 6 "blue"		
			
			
			# turn "off"  lightmenu switch
			send_switches_down 0 54 0 				
		}
		
		# else, just turn on the lightisol switch
		#send_switches_down 0 62 $li6	
		send_momentary_but_down 0 62 $li6
		update_button 0 62	
		
	}
	
	if { $id == 7} {
		# if both are on, we have to turn off lightmenu first, then isolate
		if { $li7 == 1 && $active_color(7) == "white"  } {
			set active_color(7) "blue"
			change_color 7 "blue"		
			
			
			# turn "off"  lightmenu switch
			send_switches_down 0 55 0  				
		}
		
		# else, just turn on the lightisol switch
		#send_switches_down 0 63 $li7	
		send_momentary_but_down 0 63 $li7
		update_button 0 63
		
	}
	
	if { $id == 8} {
		# if both are on, we have to turn off lightmenu first, then isolate
		if { $li8 == 1 && $active_color(8) == "white" } {
		        set active_color(8) "blue"
			change_color 8 "blue"
	    	
			
			# turn "off"  lightmenu switch
			send_switches_down 0 56 0
		}
		
		# else, just turn on the lightisol switch
		#send_switches_down 0 64 $li8	
		
		send_momentary_but_down 0 64 $li8
		update_button 0 64
	}
	
	

# end of proc "isolate2"	
}