Sometimes calling the toString of an object generates an error so we catch it here
function getString(ref)
		{
			try
			{
				if (ref)
				{
					try 
					{	
						return ref;
					} catch (e) {
						return ref.toString();
					}
				}
				else {
					try 
					{
						return ref.toString();
					}
					catch (e) 
					{
						return "undefined";
					}
				}
				
			} catch (e)
			{
				// if we can not convert it to a string write "undefined" just like javascript
				return "undefined";
			}
		}