/*code to generate web bugs using valid XHTML*/

function generateWebBug(container, url)
{
	//is url valid
	if (url != "" && url != null)
	{
		//does browser support DOM scripting?
		if (document.getElementById)
		{
			//find the container
			var _con = document.getElementById(container);
			if (_con != null)
			{
				//create a new <image> element
				var _img = document.createElement('img');
				
				_img.setAttribute('alt', 'Monkey Mountain web bug. Don\'t be afraid.');
				_img.setAttribute('src', url);
				_img.setAttribute('width', '1');
				_img.setAttribute('height', '1');
				
				//attach <img> to container
				_con.appendChild(_img);
			}			
		}
		//does browser support document.images?
		else if (document.images)
		{
			var _img = new Image();
			_img.src = url;
		}
		//does browser support document.write?
		else if (document.write)
		{
			document.open();
			document.write('<img src="' + url + '" alt="Monkey Mountain web bug. Don\'t be afraid." width="1" height="1" />');
			document.close();
		}
	}
}

