/**
 * @author marc.zahn - mzahn@magix.net
 */
function getBrowser()
{
	if (navigator.userAgent.indexOf('Opera') != -1)
	{
		return 'opera'
	}
	if (navigator.userAgent.indexOf('MSIE') != -1)
	{
		return 'msie';
	}
	if (navigator.userAgent.indexOf('Firefox') != -1)
	{
		return 'firefox';
	}
}

function getBrowserVersion()
{
	switch (getBrowser())
	{
		case 'msie':
		{
			if (navigator.userAgent.indexOf('MSIE 7') != -1)
				return '7';
			else if (navigator.userAgent.indexOf('MSIE 6') != -1)
				return '6';
			else
				return false;
			break;
		}
		case 'firefox':
		{
			return false;
			break;
		}
		case 'opera':
		{
			return false;
			break;
		}
		default:
		{
			break;
		}
	}
}

function trim(str)
{
	str = str.replace(/\n|\r|\s|\r\n|\n\r/g, '');
	return str;
}

function getPopupContainer(width, id, content, returnAsObject)
{
	popupContainer 			= document.createElement('table');
	popupContainer.id				= id;
	popupContainer.className		= 'boxSmallRadiusWithoutTitle';
	popupContainer.style.width		= width + 'px';
	
		var colDef				= document.createElement('colgroup');
			var item				= document.createElement('col');
			item.style.width		= '10px';
		colDef.appendChild(item);
			item					= document.createElement('col');
			item.style.width		= width - 40 + 'px';
		colDef.appendChild(item);
			item					= document.createElement('col');
			item.style.width		= '10px';
		colDef.appendChild(item);
	popupContainer.appendChild(colDef);
		var row						= document.createElement('tr');
			var col						= document.createElement('td');
			col.className				= 'bb_TL';
		row.appendChild(col);
			col							= document.createElement('td');
			col.className				= 'bb_TC';
		row.appendChild(col);
			col							= document.createElement('td');
			col.className				= 'bb_TR';
		row.appendChild(col);
	popupContainer.appendChild(row);
		row					= document.createElement('tr');
			col				= document.createElement('td');
			col.className	= 'bb_ML';
		row.appendChild(col);
			col 			= document.createElement('td');
			col.className	= 'bb_MC';
			
			
			if ((typeof content) == 'object')
			{
				col.appendChild(content)
			}
			else
			{
				col.innerHTML		+= content;
			}
			
		row.appendChild(col);
			col = document.createElement('td');
			col.className	= 'bb_MR';
		row.appendChild(col);
	popupContainer.appendChild(row);
		var row				= document.createElement('tr');
			var col			= document.createElement('td');
			col.className	= 'bb_BL';
		row.appendChild(col);
			col				= document.createElement('td');
			col.className	= 'bb_BC';
		row.appendChild(col);
			col				= document.createElement('td');
			col.className	= 'bb_BR';
		row.appendChild(col);
	
	popupContainer.appendChild(row);
	
	if (returnAsObject)
	{
		return popupContainer;
	}
	else
	{
		return popupContainer.outerHTML;
	}
}

function getLabel(id, title, width)
{
	tmp				= document.createElement('label');
	tmp.id			= id;
	if (width != 'auto')
	{
		tmp.style.width = width;
	}
	tmp.innerHTML	= title;
	return tmp;
}

function getSubLabel(id, title, width, marginLeft)
{
	tmp						= document.createElement('label');
	tmp.id					= id;
	tmp.style.marginLeft	= marginLeft + 'px';
	tmp.style.marginTop		= '0px';
	tmp.style.fontSize		= '10px';
	if (width != 'auto')
	{
		tmp.style.width = width;
	}
	tmp.innerHTML	= title;
	return tmp;
}

function getInputText(id, name, value)
{
	tmp				= document.createElement('input');
	tmp.id			= id;
	tmp.type		= 'text';
	tmp.value		= value;
	tmp.name		= name;
	tmp.className	= 'textfeld';
	return tmp;
}

function getInputPassword(id, name)
{
	tmp				= document.createElement('input');
	tmp.id			= id;
	tmp.type		= 'password';
	tmp.name		= name;
	tmp.className	= 'textfeld';
	return tmp;
}

function getInputCheckbox(id, name)
{
	tmp				= document.createElement('input');
	tmp.id			= id;
	tmp.type		= 'checkbox';
	tmp.name		= name;
	tmp.className	= 'regCheck';
	tmp.value		= '1';
	tmp.style.marginRight	= '4px';
	return tmp;
}

function getSelectList(id, name, items, active)
{
	var list	= document.createElement('select');
	list.id		= id;
	list.style.color	= '#000000';
	list.name	= name;
	for (var i = 0; i < items.length; i++)
	{
		list.options[i] = new Option();
		list.options[i].text	= items[i].caption;
		list.options[i].value	= items[i].value;
		list.options[i].style.color	= '#000000';
		if (items[i].value == active || (active == '' && i == 0))
			list.options[i].selected = true;
	}
	return list;
}

function getClear()
{
	tmp 			= document.createElement('br');
	tmp.style.clear	= 'both';
	return tmp;
}

function deleteAllNodes(element)
{
	while (element.firstChild)
		element.removeChild(element.firstChild);
}