
function StartMenuItem(id, windowName)
{
	var hWnd;
	
	if (id != 0)
	{
		if (window.top.frames.length == 0 || windowName == "top" || windowName == "")
			hWnd = window.top;
		else
			hWnd = window.top.frames(windowName);
		
		if (hWnd)
			hWnd.location.href = sVRoot + "/RS/Startpage/StartMenuItem.aspx?id=" + id;
	}
}

function GetString(name)
{
	var text, 
		expr = /\\n/g,
		s;

	try
	{	
		if ((s = xmlStrings.selectSingleNode("strings/string[@name='" + name + "']")) != null)
			text = s.text.replace(expr, '\n');
		else
			text = name;
	}
	catch (e)
	{
		text = name;
	}
	return text;
}

function GetParam(fieldName)
{
	var node, 
		value = "";

	if ((node = xmlParams.selectSingleNode("parameters/" + fieldName)) != null)
		value = node.text;

	return value;
}

function OnButtonOver(object)
{
	if (object.STATUS < 2)
	{
		object._className = object.className;
		object.className = "FlatButtonOver";
	}
}

function OnButtonOut(object)
{
	if (object.STATUS < 2)
		object.className = object._className;
}

function SetButtonState(object, state)
{
	if (typeof(object) != "undefined" && object != null)
	{
		switch (state)
		{
			case -1: // Disabled
				object.STATUS = -1;
				object.style.cursor = "not-allowed";
				break;
				
			case 0:
			case 1: // Done, normal
				object.STATUS = 1;
				object.className = "FlatButton";
				object.style.cursor = "hand";
				break;
			
			case 2: // Busy
				object.STATUS = 2;
				object.className = "FlatButtonBusy";
				try
				{
					object.style.cursor = "progress";
				}
				catch (e)
				{
					object.style.cursor = "wait";
				}
				break;
		}
		OnButtonOut(object);
	}
}

function TagIt(s, t)
{
	return "<" + t + ">" + s + "</" + t + ">";
}

function AlertResult(xml)
{
	var node;
	
	if ((node = xml.selectSingleNode("result/errors/error[0]/description")) != null)
		alert(node.text);
}

