 		console.log "default options #{JSON.stringify(opt)}"
 		load_site_options() if $('#site')?
 
+# Whether the site's password options has ever been saved.
+site_option_saved = false
+
 save_site_options = (show_note = true)->
 	input = gather_input()
 	optjson = JSON.stringify {

	obj = {}
	obj[input.site] = optjson
	util.storage.sync.set obj, "Options for <b>#{input.site}</b>", show_note
	return

load_site_options = ->

##################################################

gen_passwd = (show_note = true) ->
	site = $('#site').val()
	if site  == '' || $('#salt').val() == '' || $('#passphrase').val() == ''
		$('#passwd').val ''
		return false
	input = gather_input()
	p = passwdgen.generate input
	$('#passwd').val p

	msg = "Password for <b>#{site}</b> generated. <br />"
	# If this site has never been saved, save it's options now.
	# This allows user to change default password options
	# without forgeting options for already used sites.
	unless site_option_saved
		save_site_options util.NO_NOTE
		msg += "Options also saved."
	util.notify msg if show_note
	return true

lastInputTime = new Date(1970, 1, 1)
