// General Axcis Functions for MCE
	
function SetCookie(c_name, value)
{
	try
	{
		var exdate=new Date();
	}
	catch (e)
	{
		alert(e.toString());
	}
	exdate.setTime(exdate.getTime()+365*24*3600*1000);
	var valCook = c_name + "=" + escape(value) + "; expires=" + exdate.toUTCString();
	document.cookie = valCook;
	return valCook;
}

function GetCookie(c_name)
{
	if (document.cookie.length>0)
	{
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1)
		{
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";", c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start, c_end));
		}
	}
	return null;
}

// function to indicate which radio button is selected
function ToggleBtn(btn, dot)
{
    // uncheck any button in table of buttons
    for (i=0; i<radioBtns.all.length; i++)
    {
        var oChild = radioBtns.all(i)
        if (oChild.className == "radioBtnWhiteDot")
        {
            oChild.style.display = "none";
        }
        if (oChild.checked == "yes")
        {
            oChild.checked = "no";
        }
      }
    // set Checked value to button that has been selected
    btn.checked = "yes";
    
    // show white dot to indicate button selected
    dot.style.display = "block";
}

// function to mark selected from a list
function ToggleSelect(sItem, listname)
{
    // unselect any item in list
    var x=document.getElementById(listname);
    var nItem = 0;
    for (i=0; i<x.rows.length; i++)
    {
      var aCells = x.rows(i).cells;
      if (aCells.length < 2)
				return false;
			if (aCells(1).innerText == sItem)
			{
				aCells(0).innerHTML = "l";
				nItem = i;
			}
			else
			{
				aCells(0).innerHTML = "&nbsp;";
			}
    }
    x.rows(nItem).cells(1).focus();
    oCurFocus.focus();
}

function LoadTable(oTable, value, bWithRadio)
{
	var listname = "";
	var pos = 0;
	var end = 0;
	var result = "";
	var n = 1;
	listname = oTable.id;
	bLoadingList = true;
	// Empty Table
	var nIndex;
	for (nIndex=oTable.rows.length-1; nIndex>=0; nIndex--)
	{
		oTable.deleteRow(nIndex);
	}
	// Add all elements
	var nRow = 0;
	while (pos<value.length && value.indexOf("\r\n", pos) != -1)
	{
		end = value.indexOf("\r\n", pos);
		var oRow = oTable.insertRow(nRow++);

		var oCell = oRow.insertCell(0);
		if (bWithRadio)
		{
			oCell.className = "radioListWhiteDot";
			if (n++ == 1)
				oCell.innerHTML = "l";
			else
				oCell.innerHTML = "&nbsp;";
			oCell.width = 30;
			oCell = oRow.insertCell(1);
			oCell.className = "button3";
		}
		else
		{
			oCell.className = "button2";
		}
		oCell.MCFocusable = "true";
		oCell.name = listname;
		oCell.style.cursor = "pointer";
		oCell.innerHTML = value.substr(pos, end-pos);
		pos = end+2;
	}
	bLoadingList = false;
}

function TwoChars(nIn)
{
	var sOut = String(nIn);
	if (sOut.length == 1)
	{
		sOut = "0" + sOut;
	}
	return sOut;
}

function GetDateString()
{
	var d = new Date();
	var sDate = String(d.getFullYear());
	sDate = sDate + TwoChars(d.getMonth() + 1);
	sDate = sDate + TwoChars(d.getDate());
	sDate = sDate + TwoChars(d.getHours());
	sDate = sDate + TwoChars(d.getMinutes());
	return sDate;
}

function JumpTo(jumpElement)
{
	sPrevArrowDirection = null;
	oCurFocus = jumpElement;
	oCurFocus.focus();
}
