function randomPassword(formObj){
	if(confirm("Are you sure you want to generate a random password?\nDoing so will remove the existing username and password.")){
		str = "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"
		username=""; password=""
		for(var x=0; x<12; x++){
			rnd1 = parseInt(Math.random()*str.length)
			rnd2 = parseInt(Math.random()*str.length)
			username = username + str.charAt(rnd1)
			password = password + str.charAt(rnd2)
		}
		formObj.username.value = username
		formObj.password.value = password
		alert("Please make a note of your new username and password:\n\nUsername: "+username+"\nPassword: "+password+"\n\nYour username and password are case sensitive.")
	}
}

function keywordPopup(id){
	window.open("/dbadmin2/remove_kword.asp?id="+id,"pop","top=100, left=100, height=300, width=300, scrollbars=yes")
}

function NkeywordPopup(id){
	window.open("/dbadmin2/remove_kword_names.asp?id="+id,"pop","top=100, left=100, height=300, width=300, scrollbars=yes")
}

function getKeyword(formObj){
	wrdstr = formObj.wordlist.value;
	wrdlist = wrdstr.split("::")
	kwrd = formObj.keywords_2002.value;
	wrd = formObj.words.value;
	nwrd = formObj.keywords02.value;
	if (nwrd != ""){
		if (kwrd == ""){
			formObj.keywords_2002.value = nwrd
			formObj.words.value = wrdlist[nwrd]
		}else{
			if(formObj.keywords_2002.value.indexOf(nwrd) < 0){
			formObj.keywords_2002.value = nwrd +"," + kwrd
			formObj.words.value = wrdlist[nwrd] + ":" + wrd
			}else{
				alert("The selected Keyword is already in the list")
			}
		}
	}
}

function catCount(formObj){
	categories = 0
	for(var x=0; x<formObj.category.length; x++){
		if(formObj.category[x].checked==true){
			categories = categories + parseInt(formObj.category[x].value)
		}	
	}
	formObj.categories.value = categories
}

function checkFormat(formElement){
//	phone = formElement.value
//	if (event.keyCode < 48 || event.keyCode > 57){
//		event.returnValue = false
//	}else{
//		if (phone.length == 3 || phone.length == 7){
//			formElement.value = formElement.value + "-"
//		}
//	}
}

function checkPhone(formElement){
	phone = formElement.value
	chk = true; dash = true
	good = "1234567890"
	for (x=0; x<phone.length; x++){
		if (good.indexOf(phone.charAt(x))<0){dash=false}
	}
	if (phone.length != 10 || dash == false){
		if (phone.length !=0 && phone.length != 12){chk = false}
		for (x=0; x<phone.length; x++){
			chr = phone.charAt(x)
			if (x==3 || x==7){
				if (chr != "-"){chk=false}
			}else{
				if (good.indexOf(chr)<0){chk=false}
			}
		}
	}
	if (chk == false){
		alert("All phone numbers must be entered in ###-###-#### format\nor ########## format.")
		formElement.focus()
	}
}

function getCity(formObj){
	window.open("/dbadmin2/getcity.asp?zip="+formObj.zip.value,"getcity","height=1,width=1,left=1,top=1000")
}

function checkWaterfront(formObj){
	wf = formObj.waterfront.value
	wb = formObj.water_body.value
	if (wf == "1" && wb == ""){
		alert("You must enter a body of water if your business is waterfront.")
		formObj.water_body.focus()
	}else{
		formObj.submit()
	}
}