//-----------------------------------------------------------------------------
function Set_Cookie(name, value, expires, path, domain, secure) 
{
	var today = new Date();	today.setTime(today.getTime());			// set time, it's in milliseconds

	if( expires )
		expires = expires * 1000 * 60 * 60 * 24;					// save expires days
	var expires_date = new Date(today.getTime() + (expires));

	document.cookie = name + "=" + escape(value) +
		((expires) ? ";expires=" + expires_date.toGMTString() : "") +
		((path) ? ";path=" + path : "") +
		((domain) ? ";domain=" + domain : "") +
		((secure) ? ";secure" : "");
}
function Get_Cookie(check_name)
{
	var a_all_cookies = document.cookie.split(';');					// split cookies into name/value pairs
	var a_temp_cookie = '', cookie_name = '', cookie_value = '';
	var b_cookie_found = false;

	for( i = 0; i < a_all_cookies.length; i++ ) {
		a_temp_cookie = a_all_cookies[i].split('=');				// now we'll split apart each name=value pair
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');	// and trim left/right whitespace while we're at it
		if( cookie_name == check_name ) {							// if the extracted name matches passed check_name
			b_cookie_found = true;
			if( a_temp_cookie.length > 1 )
				cookie_value = unescape(a_temp_cookie[1].replace(/^\s+|\s+$/g, ''));	// we need to handle case where cookie has no value but exists (no = sign, that is):
			return cookie_value;									// note that in cases where cookie is initialized but no value, null is returned
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if( !b_cookie_found )
		return null;
}				
function Delete_Cookie(name, path, domain)
{
	if( Get_Cookie(name) )
		document.cookie = name + "=" + ((path) ? ";path=" + path : "") + ((domain) ? ";domain=" + domain : "") + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

//-----------------------------------------------------------------------------
function GetRadioVal(rbl_name)
{
	var e = document.forms[0].elements[rbl_name];
	for( var i = 0; i < e.length; i++ )
		if( e[i].checked )
			return e[i].value;
	return null;
}

//-----------------------------------------------------------------------------
function F1Help() {
	if (help_page) {
		var url = web_root + "/PrMOHelp.aspx?topic=" + help_page;
		var help_win = window.open(url, "_PrMO_Help", "height=650,width=950,scrollbars=yes,status=no,location=no,directories=no,resizable=yes");
		help_win.focus();
		return false; // cancel original F1 event
	}
}
document.onhelp = F1Help;
function HotKey(e) {
	var KeyID = (window.event) ? event.keyCode : e.keyCode;
	if (KeyID == 112)
		F1Help();
}

