function foreach(array,callBackfunct,context){
	if(typeof(context)=='undefined')context=arguments.callee.caller;
	//callBackfunct must be defined as callBackfunct(index,item)
	for(var i=0;i<array.length;i++){
		callBackfunct.call(context,i,array[i]);
	}
}

var evaluators={
	alphaNum:/^[A-z0-9_ ]*$/,
	alpha:/^[A-z_ ]*$/,
	integer:/^\d*$/,
	float:/^[\d\.]*$/,
	date:/^\d{1,2}[\/\-\.]\d{1,2}([\/\-\.](\d{2}|\d{4}))?$/,
	path:/^[A-z\d\/:.\-_()~ ]*$/,
	webaddress:/^[A-z\d\\/:.\-_()&?+@ ]*$/,
	email:/^([A-z\d.\-_]+@[A-z\d.\-_]+)*$/,
	phone:/^(\(*\d{3}\)*[-. ]\d{3}[-. ]\d{4}|\d{3}[-. ]\d{4})/,
	noEscChars:/[^\\\/\'\"]/
}

function GetPageWidth(){
	var width=0;
	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	if (typeof window.innerWidth != 'undefined'){
		width = window.innerWidth;
	}
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	else if (
		typeof document.documentElement != 'undefined'
		&& typeof document.documentElement.clientWidth !='undefined' 
		&& document.documentElement.clientWidth != 0
	){
		width = document.documentElement.clientWidth;
	}
	// older versions of IE
	else{
		width = document.getElementsByTagName('body')[0].clientWidth;
	}
	return width;
}
function GetPageHeight(){
	var height=0;
	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	if (typeof window.innerHeight != 'undefined'){
		height = window.innerHeight;
	}
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	else if (
		typeof document.documentElement != 'undefined'
		&& typeof document.documentElement.clientHeight !='undefined' 
		&& document.documentElement.clientHeight != 0
	){
		height = document.documentElement.clientHeight;
	}
	// older versions of IE
	else{
		height = document.getElementsByTagName('body')[0].clientHeight;
	}
	return height;
}
function GetAbsOffset(element) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}

// this is the jQuery UI combobox from http://jqueryui.com/demos/autocomplete/
(function( $ ) {
	$.widget( "ui.combobox", {
		_create: function() {
			var self = this,
				select = this.element.hide(),
				selected = select.children( ":selected" ),
				value = selected.val() ? selected.text() : "";
			var input = this.input = $( "<input>" )
				.insertAfter( select )
				.val( value )
				.autocomplete({
					delay: 0,
					minLength: 0,
					source: function( request, response ) {
						var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
						response( select.children( "option" ).map(function() {
							var text = $( this ).text();
							if ( this.value && ( !request.term || matcher.test(text) ) )
								return {
									label: text.replace(
										new RegExp(
											"(?![^&;]+;)(?!<[^<>]*)(" +
											$.ui.autocomplete.escapeRegex(request.term) +
											")(?![^<>]*>)(?![^&;]+;)", "gi"
										), "<strong>$1</strong>" ),
									value: text,
									option: this
								};
						}) );
					},
					select: function( event, ui ) {
						ui.item.option.selected = true;
						self._trigger( "selected", event, {
							item: ui.item.option
						});
					},
					change: function( event, ui ) {
						if ( !ui.item ) {
							var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
								valid = false;
							select.children( "option" ).each(function() {
								if ( $( this ).text().match( matcher ) ) {
									this.selected = valid = true;
									return false;
								}
							});
							if ( !valid ) {
								// remove invalid value, as it didn't match anything
								$( this ).val( "" );
								select.val( "" );
								input.data( "autocomplete" ).term = "";
								return false;
							}
						}
					}
				})
				.addClass( "ui-widget ui-widget-content ui-corner-left" );

			input.data( "autocomplete" )._renderItem = function( ul, item ) {
				return $( "<li></li>" )
					.data( "item.autocomplete", item )
					.append( "<a>" + item.label + "</a>" )
					.appendTo( ul );
			};

			this.button = $( "<button type='button'>&nbsp;</button>" )
				.attr( "tabIndex", -1 )
				.attr( "title", "Show All Items" )
				.insertAfter( input )
				.button({
					icons: {
						primary: "ui-icon-triangle-1-s"
					},
					text: false
				})
				.removeClass( "ui-corner-all" )
				.addClass( "ui-corner-right ui-button-icon" )
				.click(function() {
					// close if already visible
					if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
						input.autocomplete( "close" );
						return;
					}

					// work around a bug (likely same cause as #5265)
					$( this ).blur();

					// pass empty string as value to search for, displaying all results
					input.autocomplete( "search", "" );
					input.focus();
				});
		},

		destroy: function() {
			this.input.remove();
			this.button.remove();
			this.element.show();
			$.Widget.prototype.destroy.call( this );
		}
	});
})( jQuery );
//-----------------------------------------------------------------------------------------



