function in_array(stringToSearch, arrayToSearch) {
	var thisEntry;
	for (var s = 0; s < arrayToSearch.length; s++) {
		thisEntry = arrayToSearch[s].toString();
		if (thisEntry == stringToSearch) {
			return true;
		}
	}
	return false;
}


function Widgets() {
};

// Common function to set the value of a hiddenfield
Widgets.setValue = function(sId, nValue, bDoNotSubmit) {
	var el = Widgets.getElement(sId);
	if (el) {
		el.value = nValue;
		if (!bDoNotSubmit) {
		    var doSubmit = false;
			if (typeof el.form.onsubmit == "function") {
				
				var onSubmitResult = el.form.onsubmit();
				if ((typeof onSubmitResult == "undefined") || onSubmitResult) {
					doSubmit = true;
				}
			} else {
				doSubmit = true;
			}
			if (doSubmit) {
				this.didSubmit=true;
				el.form.submit();
			}
		}
	}
}

/*
* Returns a reference to the first object with the specified value of the ID attribute.
* If the attribute is already an object it will return the same object.
* 
* @param mixed sId Specifies the value of an ID attribute
* @return object A reference to the object
*/
Widgets.getElement = function(sId) {
	var el = null;
	// If sId is an object we don't have to find the object, else we do 
	if (typeof sId == 'object') {
		el = sId;
	}else if (typeof sId == 'string') {
		el = document.getElementById(sId);
	}
	if (el) {
		return el;
	} else {
		return null;
	}
}

Widgets.findItem = function(oElement, sId) {
	var el = oElement;
	if (oElement.widgetId == sId) {
		return oElement;
	} else if (oElement.parentNode) {
		return Widgets.findItem(oElement.parentNode, sId);
	} else {
		return false;
	}
};

Widgets.COMBOBOX_START_ZINDEX = 1000;
Widgets.CONTEXTMENU_START_ZINDEX = 1000;

Widgets.elements ={};