-- tell Camino browser to close all windows that have the specified URL
tell application "Camino"
	-- 'closed' keeps track of whether we have closed any documents
	set closed to false

	set done to false
	repeat until done
		set done to true

		-- Camino has some hidden windows that are not regular browser
		-- windows.  Those windows don't have a URL.  We keep count of
		-- how many windows do have a URL.
		set countOfWindowsWithURL to 0

		repeat with win in windows
			if URL of win exists then
				if URL of win is item 1 of argv then
					close win
					set closed to true

					-- since we have closed a document, we must restart the loop
					set done to false
					exit repeat
				else
					set countOfWindowsWithURL to countOfWindowsWithURL+1
				end if
			end if
		end repeat
	end repeat

	-- if we closed at least one Safari window, and no more are
	-- open, then tell Safari to exit
	if closed and countOfWindowsWithURL is 0 then quit

	-- return true if we closed at least one window, false if not
	closed
end tell
