// ==========
// ==== Tools
// ==========
function GetSelValue(id)
{
	if (document.getElementById(id))
	{
		var control=document.getElementById(id);
		return control.options[control.selectedIndex].value;
	}
}

function GetSelLabel(id)
{
	if (document.getElementById(id))
	{
		var control=document.getElementById(id);
		return control.options[control.selectedIndex].innerHTML;
	}
}

function SetSelValue(id, svalue)
{
	var i;
	var control=document.getElementById(id);
	for(i=0;i<control.options.length;i++)
	{
		if(control.options(i).value==svalue)
		{
			control.selectedIndex=i;
			break;
		}
	}
}

function OpenNewPage(url, width, height, isscroll)
{
	var win, x, y, optStr;
	if (screen)
	{
		x=Math.floor((screen.width-width)/2);
		y=Math.floor((screen.height-height)/2);
	}
	else
	{
		x=10;
		y=10;
	}
	optStr="channelmode=no,directories=no,fullscreen=no,location=no,menubar=no,resizable=no,"
	if(isscroll) optStr=optStr+"scrollbars=yes,"
	optStr=optStr+"status=no,titlebar=no,toolbar=no,top="+y+",left="+x+",width="+width+",height="+height+"";	
	win = window.open(url, 'win', optStr, false);
	win.focus();
}

//-----------------------------------------------------------------------------
// String utility functions
function trim(sStr)
{
	var re = /\ */gi;	
	return sStr.replace (re, "");
}

// Cookie utility functions
function GetCookie(sName)
{
	var sCookies = new String(unescape(document.cookie));
	sCookies = trim(sCookies);
	var aCookie = sCookies.split(";");  
	for (var i=0; i < aCookie.length; i++)
	{
		var aCrumb = aCookie[i].split("=");
		if (aCrumb[0] == sName) return aCrumb[1];
	}
	return "";
}

function SetCookie(sName, sValue)
{
	document.cookie = sName + "=" + escape(sValue) + "; " + 
	"expires=Mon, 31 Dec 2100 23:59:59 UTC; path=/;";
}

function SetTempCookie(sName, sValue)
{
	document.cookie = sName + "=" + escape(sValue) + "; " + 
	"path=/;";
}

//-----------------------------------------------------------------------------
