/*
WICK: Web Input Completion Kit
http://wick.sourceforge.net/
Copyright (c) 2004, Christopher T. Holland
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the Christopher T. Holland, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*/

collection = new Array();
customCollectionsArray = new Array();

/* start dhtml building blocks */

// by mas: function Max
function Max(n, m) {
 if (n > m) {
  return n;
 }
 else {
  return m;
 }
}

/*
Updated by Michael Rowe
mikerowe81[at]gmail.com

*** Fixes and Features were only tested in Firefox 1.0 and IE 6.0,
    so I'm not sure how they will do in other browsers ***
	
Bug Fixes:
 - Prevented nav keys from scrolling Firefox window
   - Fixing this caused the up arrow key to move the cursor, which would prevent further typing
     after the menu appears. Fix on 139-143. There's probably a better way???
 - When mouse was used to select item in Firefox, text would be selected
 - Popup box appears in bottom right in Firefox when certain <!DOCTYPE...> is used
 
Added Features:
 - Added configuration options section to easily update which element(s) you want to be WICK enabled.
 - Added function to disable "enter" key from submitting form, so it doesn't have to be added in the html file.
*/

// **** Configuration Options *****

// Identify which element(s) you want to be WICK enabled.
	// wickClass will identify all input and textarea elements with that class attribute (e.g. wickClass="wickEnabled")
	var wickClass = "wickEnabled";
	// wickId will identify the input or textarea element with that id attribute (e.g. wickId="to_box")
	var wickId = null;
	// wickObj will identify the element that you specify (e.g. wickObj=document.getElementById('pm_to'))
	var wickObj = null;
	
// Would you like to prevent the enter key from submitting the form? (helpful for <input>, not necessary for <textarea>)
	var changeOnSubmit = true;
	//Identify form by name attribute (e.g. formName="email_form")
	var formName = "email_form";
	//identify form by id attribute (e.g. formId="email_form_id")
	var formId = null;
	//identify form by class attribute (e.g. formClass="form_style")
	var formClass = null;

// **** End Configuration Options *****

function freezeEvent(e) {
if (e.preventDefault) e.preventDefault();
e.returnValue = false;
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
return false;
}//freezeEvent

function isWithinNode(e,i,c,t,obj) {
answer = false;
te = e;
while(te && !answer) {
	if	((te.id && (te.id == i)) || (te.className && (te.className == i+"Class"))
			|| (!t && c && te.className && (te.className == c))
			|| (!t && c && te.className && (te.className.indexOf(c) != -1))
			|| (t && te.tagName && (te.tagName.toLowerCase() == t))
			|| (obj && (te == obj))
		) {
		answer = te;
	} else {
		te = te.parentNode;
	}
}
return te;
}//isWithinNode

function getEvent(event) {
return (event ? event : window.event);
}//getEvent()

function getEventElement(e) {
return (e.srcElement ? e.srcElement: (e.target ? e.target : e.currentTarget));
}//getEventElement()

function findElementPosX(obj) {
	curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	}//if offsetParent exists
	else if (obj.x)
		curleft += obj.x
	return curleft;
}//findElementPosX

function findElementPosY(obj) {
	curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	}//if offsetParent exists
	else if (obj.y)
		curtop += obj.y
	return curtop;
}//findElementPosY

/* end dhtml building blocks */

function handleKeyPress(event) {
e = getEvent(event);
eL = getEventElement(e);

//upEl = isWithinNode(eL,null,"wickEnabled",null,null);
upEl = isWithinNode(eL,wickId,wickClass,null,wickObj);

kc = e["keyCode"];

if (siw && ((kc == 13) || (kc == 9))) {
	siw.selectingSomething = true;
	if (siw.isSafari) siw.inputBox.blur();   //hack to "wake up" safari
	siw.inputBox.focus();
	siw.inputBox.value = siw.inputBox.value.replace(/[ \r\n\t\f\s]+$/gi,' ');
	hideSmartInputFloater();
} else if (upEl && (kc != 38) && (kc != 40) && (kc != 37) && (kc != 39) && (kc != 13) && (kc != 27)) {
	if (!siw || (siw && !siw.selectingSomething)) {
		processSmartInput(upEl);
	}
} else if (siw && siw.inputBox) {
	siw.inputBox.focus(); //kinda part of the hack.
	//probably a bad hack for firefox to keep the cursor at the end when up arrow is pressed
	if(siw.isGecko && (kc == 38)) {
		valueHold = upEl.value;
		upEl.value = "";
		upEl.value = valueHold;
	}
}

}//handleKeyPress()


function handleKeyDown(event) {
e = getEvent(event);
eL = getEventElement(e);

if (siw && (kc = e["keyCode"])) {
	if (kc == 40) {
		siw.selectingSomething = true;
		freezeEvent(e);
		if (siw.isGecko) siw.inputBox.blur(); /* Gecko hack */
		selectNextSmartInputMatchItem();
	} else if (kc == 38) {
		siw.selectingSomething = true;
		freezeEvent(e);
		if (siw.isGecko) siw.inputBox.blur();
		selectPreviousSmartInputMatchItem();
	} else if ((kc == 13) || (kc == 9)) {
		siw.selectingSomething = true;
		activateCurrentSmartInputMatch();
		freezeEvent(e);
	} else if (kc == 27)  {
		hideSmartInputFloater();
		freezeEvent(e);
	} else {
		siw.selectingSomething = false;
	}
	if(siw) {
		siw.inputBox.focus();
	}
}

}//handleKeyDown()

function handleFocus(event) {
	e = getEvent(event);
	eL = getEventElement(e);
	if (focEl = isWithinNode(eL,wickId,wickClass,null,wickObj)) {
	if (!siw || (siw && !siw.selectingSomething)) processSmartInput(focEl);
	}
}//handleFocus()

function handleBlur(event) {
	e = getEvent(event);
	eL = getEventElement(e);
	if (blurEl = isWithinNode(eL,wickId,wickClass,null,wickObj)) {
		if (siw && !siw.selectingSomething) hideSmartInputFloater();
	}
}//handleBlur()

function handleClick(event) {
	e2 = getEvent(event);
	eL2 = getEventElement(e2);
	if (siw && siw.selectingSomething) {
		selectFromMouseClick();
	}
}//handleClick()

function handleMouseOver(event) {
	e = getEvent(event);
	eL = getEventElement(e);
	if (siw && (mEl = isWithinNode(eL,null,"matchedSmartInputItem",null,null))) {
		siw.selectingSomething = true;
		selectFromMouseOver(mEl);
	} else if (isWithinNode(eL,null,"siwCredit",null,null)) {
		siw.selectingSomething = true;
	}else if (siw) {
		siw.selectingSomething = false;
	}
}//handleMouseOver

function showSmartInputFloater() {
if (!siw.floater.style.display || (siw.floater.style.display=="none")) {
	if (!siw.customFloater) {
		x = findElementPosX(siw.inputBox);
		y = findElementPosY(siw.inputBox) + siw.inputBox.offsetHeight;
		//hack: browser-specific adjustments.
		if (!siw.isGecko && !siw.isWinIE) x += 8;
		if (!siw.isGecko && !siw.isWinIE) y += 10;
		siw.floater.style.left = x + "px";
		siw.floater.style.top = y + "px";
	} else {
	//you may
	//do additional things for your custom floater
	//beyond setting display and visibility
	}
	siw.floater.style.display="block";
	siw.floater.style.visibility="visible";
	resizeSmartInputIframe();
	siw.floaterIframe.style.display = "block";
	siw.floaterIframe.style.visibility = "visible";

}
}//showSmartInputFloater()

function resizeSmartInputIframe() {
	if (siw.floater.style.zIndex <= 0) siw.floater.style.zIndex = 2;
	//show Iframe, but below floater, so they both go on top of SELECT elements in IE
	siw.floaterIframe.style.width = siw.floater.offsetWidth;
	siw.floaterIframe.style.height = siw.floater.offsetHeight;
	siw.floaterIframe.style.top = siw.floater.style.top;
	siw.floaterIframe.style.left = siw.floater.style.left;
	siw.floaterIframe.style.zIndex = siw.floater.style.zIndex - 1;
}//resizeSmartInputIframe()

function hideSmartInputFloater() {
if (siw) {
siw.floater.style.display="none";
siw.floater.style.visibility="hidden";
siw.floaterIframe.style.display="none";
siw.floaterIframe.style.visibility="hidden";
siw = null;
}//siw exists
}//hideSmartInputFloater

function processSmartInput(inputBox) {
if (!siw) siw = new smartInputWindow();
siw.inputBox = inputBox;

classData = inputBox.className.split(" ");
siwDirectives = null;
for (i=0;(!siwDirectives && classData[i]);i++) {
	if (classData[i].indexOf("wickEnabled") != -1)
		siwDirectives = classData[i];
}

siw.sourceCollection = collection; /* by default, point to collection array */
siw.collectionIndexPrefix = "";

if (siwDirectives && (siwDirectives.indexOf(":") != -1)) {
	//siw.customFloater = true; //will break the code!
	newFloaterId = siwDirectives.split(":")[1];
	if (newFloaterId && (newFloaterId != "null")) {
		siw.customFloater = true;
		siw.floater = document.getElementById(newFloaterId);
		siw.floaterContent = siw.floater.getElementsByTagName("div")[0];
	}
	customCollection = siwDirectives.split(":")[2];
	if (customCollection && (customCollection != "null")) {
		if (window.customCollectionsArray) {
			siw.collectionIndexPrefix = customCollection + "_";
			siw.sourceCollection = customCollectionsArray[customCollection];
		} else {
			alert("you've referenced a custom collection " + customCollection + " which needs to be defined in your document in an associative array as:\n customCollectionsArray[\""+customCollection+"\"]");
		}
	}//if customCollection directive is set
}


setSmartInputData();
if (siw.matchCollection && (siw.matchCollection.length > 0)) selectSmartInputMatchItem(0);
var content = getSmartInputBoxContent();
if (content) {
	modifySmartInputBoxContent(content);
	showSmartInputFloater();
} else hideSmartInputFloater();
}//processSmartInput()

function smartInputMatch(cleanValue, value) {
	this.cleanValue = cleanValue;
	this.value = value;
	this.isSelected = false;
}//smartInputMatch

function simplify(s) {
return s.toLowerCase().replace(/^[ \s\f\t\n\r]+/,'').replace(/[ \s\f\t\n\r]+$/,'');
//.replace(/[,,,,\u00E9,\u00E8,\u00EA,\u00EB]/gi,"e").replace(/[,,\u00E0,\u00E2]/gi,"a").
}//simplify

function getUserInputToMatch(s) {
a = s;
fields = s.split(",");
if (fields.length > 0) a = fields[fields.length - 1];
return a;
}//getUserInputToMatch

function getUserInputBase() {
s = siw.inputBox.value;
a = s;
if ((lastComma = s.lastIndexOf(",")) != -1) {
	a = a.replace(/^(.*\,[ \r\n\t\f\s]*).*$/i,'$1');
}
else
	a = "";
return a;
}//getUserInputBase()

function runMatchingLogic(userInput, standalone) {
	//userInput = simplify(userInput); //don't want lowercase display
	uifc = userInput.charAt(0).toLowerCase();
	if (uifc == '"') uifc = (n = userInput.charAt(1)) ? n.toLowerCase() : "z";
	if (standalone) userInput = uifc;
	if (siw) siw.matchCollection = new Array();
	pointerToCollectionToUse = siw.sourceCollection;
	if (siw && siw.revisedCollection && (siw.revisedCollection.length > 0) && siw.lastUserInput && (userInput.indexOf(siw.lastUserInput) == 0)) {
		pointerToCollectionToUse = siw.revisedCollection;
	} else if (collectionIndex[siw.collectionIndexPrefix + userInput] && (collectionIndex[siw.collectionIndexPrefix + userInput].length > 0)) {
		pointerToCollectionToUse = collectionIndex[siw.collectionIndexPrefix + userInput];
	} else if (collectionIndex[siw.collectionIndexPrefix + uifc] && (collectionIndex[siw.collectionIndexPrefix + uifc].length > 0)) {
		pointerToCollectionToUse = collectionIndex[siw.collectionIndexPrefix + uifc];
	} else if (siw && (userInput.length == 1) && (!collectionIndex[siw.collectionIndexPrefix + uifc])) {
		siw.buildIndex = true;
	} else if (siw) {
		siw.buildIndex = false;
	}
	
	tempCollection = new Array();

	re1m = new RegExp("^([ \"\>\<\-]*)("+userInput+")","i");
	re2m = new RegExp("([ \"\>\<\-]+)("+userInput+")","i");
	re1 = new RegExp("^([ \"\}\{\-]*)("+userInput+")","gi");
	re2 = new RegExp("([ \"\}\{\-]+)("+userInput+")","gi");
	
	for (i=0,j=0;(i<pointerToCollectionToUse.length);i++) {
		displayMatches = ((!standalone) && (j < siw.MAX_MATCHES));
		entry = pointerToCollectionToUse[i];
		//mEntry = simplify(entry); //don't want lowercase display
		mEntry = entry;
		if (!standalone && (mEntry.indexOf(userInput) == 0)) {
			userInput = userInput.replace(/\>/gi,'\\}').replace(/\< ?/gi,'\\{');
			re = new RegExp("(" + userInput + ")","i");
			if (displayMatches) {
				siw.matchCollection[j] = new smartInputMatch(entry, mEntry.replace(/\>/gi,'}').replace(/\< ?/gi,'{').replace(re,"<b>$1</b>"));
			}
			tempCollection[j] = entry;
			j++;		
		} else if (mEntry.match(re1m) || mEntry.match(re2m)) {
			if (!standalone && displayMatches) {
				siw.matchCollection[j] = new smartInputMatch(entry, mEntry.replace(/\>/gi,'}').replace(/\</gi,'{').replace(re1,"$1<b>$2</b>").replace(re2,"$1<b>$2</b>"));
			}
			tempCollection[j] = entry;
			j++;
		}
	}//loop thru collection
	if (siw) {
		siw.lastUserInput = userInput;
		siw.revisedCollection = tempCollection.join(",").split(",");
		collectionIndex[siw.collectionIndexPrefix + userInput] = tempCollection.join(",").split(",");
	}
	if (standalone || siw.buildIndex) {
		collectionIndex[siw.collectionIndexPrefix + uifc] = tempCollection.join(",").split(",");
		if (siw) siw.buildIndex = false;
	}
}//runMatchingLogic

function setSmartInputData() {
if (siw) {
orgUserInput = siw.inputBox.value;
orgUserInput = getUserInputToMatch(orgUserInput);
userInput = orgUserInput.toLowerCase().replace(/[\r\n\t\f\s]+/gi,' ').replace(/^ +/gi,'').replace(/ +$/gi,'').replace(/ +/gi,' ').replace(/\\/gi,'').replace(/\[/gi,'').replace(/\(/gi,'').replace(/\./gi,'\.').replace(/\?/gi,'');
if (userInput && (userInput != "") && (userInput != '"')) {
	runMatchingLogic(userInput);
}//if userinput not blank and is meaningful
else {
siw.matchCollection = null;
}
}//siw exists ... uhmkaaayyyyy
}//setSmartInputData

function getSmartInputBoxContent() {
a = null;
if (siw && siw.matchCollection && (siw.matchCollection.length > 0)) {
a = '';
for (i = 0;i < siw.matchCollection.length; i++) {
selectedString = siw.matchCollection[i].isSelected ? ' selectedSmartInputItem' : '';
a += '<p class="matchedSmartInputItem' + selectedString + '">' + siw.matchCollection[i].value.replace(/\{ */gi,"&lt;").replace(/\} */gi,"&gt;") + '</p>';
}//
}//siw exists
return a;
}//getSmartInputBoxContent

function modifySmartInputBoxContent(content) {
//todo: remove credits 'cuz no one gives a shit ;] - done
siw.floaterContent.innerHTML = '<div id="smartInputResults">' + content + (siw.showCredit ? ('<p class="siwCredit">Powered By: <a target="PhrawgBlog" href="http://chrisholland.blogspot.com/?from=smartinput&ref='+escape(location.href)+'">Chris Holland</a></p>') : '') +'</div>';
resizeSmartInputIframe();
siw.matchListDisplay = document.getElementById("smartInputResults");
}//modifySmartInputBoxContent()

function selectFromMouseOver(o) {
currentIndex = getCurrentlySelectedSmartInputItem();
if (currentIndex != null) deSelectSmartInputMatchItem(currentIndex);
newIndex = getIndexFromElement(o);
selectSmartInputMatchItem(newIndex);
modifySmartInputBoxContent(getSmartInputBoxContent());
}//selectFromMouseOver

function selectFromMouseClick() {
activateCurrentSmartInputMatch();
siw.inputBox.focus();
hideSmartInputFloater();
}//selectFromMouseClick

function getIndexFromElement(o) {
index = 0;
while(o = o.previousSibling) {
index++;
}//
return index;
}//getIndexFromElement

function getCurrentlySelectedSmartInputItem() {
answer = null;
for (i = 0; ((i < siw.matchCollection.length) && !answer) ; i++) {
	if (siw.matchCollection[i].isSelected)
		answer = i;
}//
return answer;
}//getCurrentlySelectedSmartInputItem

function selectSmartInputMatchItem(index) {
	siw.matchCollection[index].isSelected = true;
}//selectSmartInputMatchItem()

function deSelectSmartInputMatchItem(index) {
	siw.matchCollection[index].isSelected = false;
}//deSelectSmartInputMatchItem()

function selectNextSmartInputMatchItem() {
currentIndex = getCurrentlySelectedSmartInputItem();
if (currentIndex != null) {
	deSelectSmartInputMatchItem(currentIndex);
	if ((currentIndex + 1) < siw.matchCollection.length)
 		selectSmartInputMatchItem(currentIndex + 1);
	else
		selectSmartInputMatchItem(0);
} else {
	selectSmartInputMatchItem(0);
}
modifySmartInputBoxContent(getSmartInputBoxContent());
}//selectNextSmartInputMatchItem

function selectPreviousSmartInputMatchItem() {
currentIndex = getCurrentlySelectedSmartInputItem();
if (currentIndex != null) {
	deSelectSmartInputMatchItem(currentIndex);
	if ((currentIndex - 1) >= 0)
 		selectSmartInputMatchItem(currentIndex - 1);
	else
		selectSmartInputMatchItem(siw.matchCollection.length - 1);
} else {
	selectSmartInputMatchItem(siw.matchCollection.length - 1);
}
modifySmartInputBoxContent(getSmartInputBoxContent());
}//selectPreviousSmartInputMatchItem

function activateCurrentSmartInputMatch() {
	baseValue = getUserInputBase();
	if ((selIndex = getCurrentlySelectedSmartInputItem()) != null) {
		addedValue = siw.matchCollection[selIndex].cleanValue;
		//theString = (baseValue ? baseValue : "") + addedValue + ", ";
		theString = (baseValue ? baseValue : "") + addedValue + " ";
		siw.inputBox.value = theString;
		runMatchingLogic(addedValue, true);
	}
}//activateCurrentSmartInputMatch

function smartInputWindow () {
	this.customFloater = false;
	this.floater = document.getElementById("smartInputFloater");
//	if (! this.floater || this.floater == undefined || this.floater == null) this.floater = createSmartInputObjects();
	this.floaterContent = document.getElementById("smartInputFloaterContent");
	this.floaterIframe = document.getElementById("smartInputFloaterIframe");
	this.selectedSmartInputItem = null;
	this.MAX_MATCHES = 20;
	this.isGecko = (navigator.userAgent.indexOf("Gecko/200") != -1);
	this.isSafari = (navigator.userAgent.indexOf("Safari") != -1);
	this.isWinIE = ((navigator.userAgent.indexOf("Win") != -1 ) && (navigator.userAgent.indexOf("MSIE") != -1 ));
	this.showCredit = false;
}//smartInputWindow Object

function registerSmartInputListeners() {
inputs = document.getElementsByTagName("input");
texts = document.getElementsByTagName("textarea");
allinputs = new Array();
z = 0;
y = 0;
while(inputs[z]) {
allinputs[z] = inputs[z];
z++;
}//
while(texts[y]) {
allinputs[z] = texts[y];
z++;
y++;
}//

for (i=0; i < allinputs.length;i++) {
	if ((c = allinputs[i].className) && (c == "wickEnabled")) {
		allinputs[i].setAttribute("autocomplete","OFF");
		allinputs[i].onfocus = handleFocus;
		allinputs[i].onblur = handleBlur;
		allinputs[i].onkeydown = handleKeyDown;
		allinputs[i].onkeyup = handleKeyPress;
	}
}//loop thru inputs
}//registerSmartInputListeners

siw = null;

if (document.addEventListener) {
	document.addEventListener("keydown", handleKeyDown, false);
	document.addEventListener("keyup", handleKeyPress, false);
	document.addEventListener("mouseup", handleClick, false);
	document.addEventListener("mouseover", handleMouseOver, false);
} else {
	document.onkeydown = handleKeyDown;
	document.onkeyup = handleKeyPress;
	document.onmouseup = handleClick;
	document.onmouseover = handleMouseOver;
}

registerSmartInputListeners();


function createSmartInputObjects() {
//alert('hey')
var floater = document.createElement("TABLE");
document.body.appendChild(floater);
floater.className = "floater";
floater.id = "smartInputFloater";
floater.cellPadding = 0;
floater.cellSpacing = 0;
var oRow = document.createElement("TR");
floater.appendChild(oRow);
var oCell = document.createElement("TD");
oRow.appendChild(oCell);
oCell.id = "smartInputFloaterContent";
oCell.noWrap = true;

var iframe = document.createElement("IFRAME");
document.body.appendChild(iframe);
iframe.id = "smartInputFloaterIframe";
iframe.name = "smartInputFloaterIframeName";
iframe.className = "floater";
iframe.src = "about:blank";
iframe.scrolling = "no";
iframe.frameBorder = 0;

return floater;
}//createSmartInputObjects()

//createSmartInputObjects();

document.write (
'<table id="smartInputFloater" class="floater" cellpadding="0" cellspacing="0"><tr><td id="smartInputFloaterContent" nowrap="nowrap">'
+'<\/td><\/tr><\/table><iframe id="smartInputFloaterIframe" name="smartInputFloaterIframeName" class="floater" src="about:blank" scrolling="no" frameborder="0"></iframe>'
);

//note: instruct users to the fact that no commas should be present in entries.
//it would make things insanely messy.
//this is why i'm filtering commas here:
for (x=0;x<collection.length;x++) {
collection[x] = collection[x].replace(/\,/gi,'');
}//

collectionIndex = new Array();

ds = "";
function debug(s) {
ds += ( s + "\n");
}

function disableFormEnter() {
return false;
}// checkForm

function addFormSubmit() {
	forms = document.getElementsByTagName("form");
	for (i=0; i < forms.length;i++) {	
		if ((forms[i].className == formClass) | (forms[i].id == formId) | (forms[i].name == formName)) {
			forms[i].onsubmit = disableFormEnter;
		}
	}
}

if (changeOnSubmit==true) {
	addFormSubmit();
}

