function addLoadEvent(func)
	{
	var oldonload = window.onload;
	if (typeof window.onload != 'function')
		{
		window.onload = func;
		}
	else
		{
		window.onload = function()
			{
			if (oldonload) { oldonload(); }
			func();
			}
		}
	}

function externalLinks()
	{	// swap 'rel external' into 'target _blank' to accomodate HTML5 rules
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++)
		{
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
			{
			anchor.target = "_blank";
			}
		}
	}

function setCookie ( name, value, expires, path, domain, secure )
	{
// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );

// expires is in days
	if ( expires )
		{ expires = expires * 1000 * 60 * 60 * 24; }

	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 getCookie( check_name )
	{
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
		{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );

		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
			{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
				{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
				}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
			}
		a_temp_cookie = null;
		cookie_name = '';
		}
	if ( !b_cookie_found )
		{
		return null;
		}
	}

function deleteCookie( name, path, domain )
	{	// this deletes the cookie when called
	if ( Get_Cookie( name ) ) document.cookie = name + "=" +
		( ( path ) ? ";path=" + path : "") +
		( ( domain ) ? ";domain=" + domain : "" ) +
		";expires=Thu, 01-Jan-1970 00:00:01 GMT";
	}

function getViewportInfo()
	{	// find the height & breadth of the viewing area
// credit: http://andylangton.co.uk/articles/javascript/get-viewport-size-javascript/

	var w = 0;
	var h = 1;
	var viewport = new Array();

	if (typeof window.innerWidth != 'undefined')
		{	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
		viewport[w] = window.innerWidth,
		viewport[h] = window.innerHeight
		}
	else if (typeof document.documentElement != 'undefined'
		&& typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
		{	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
		viewport[w] = document.documentElement.clientWidth,
		viewport[h] = document.documentElement.clientHeight
		}
	else
		{	// older versions of IE
		viewport[w] = document.getElementsByTagName('body')[0].clientWidth,
		viewport[h] = document.getElementsByTagName('body')[0].clientHeight
		}
	return viewport[w] + '|' + viewport[h] + '|' + screen.width + '|' + screen.height;
	}

function saveLocalInfo ( cName )
	{

	vp = 	getViewportInfo()	+ '|' + 
		navigator.appName	+ '|' +
		navigator.appVersion	+ '|' +
		navigator.platform	+ '|' +
		navigator.userAgent;
//	Saves:	0 	current screen width
//		1	current screen height
//		2	hardware screen resolution width
//		3	hardware screen resolution height
//		4	browser name
//		5	browser version
//		6	platform OS
//		7	user agent header
	setCookie ( cName, vp, 366 )

	}

function putFocusByID ( id )
	{	// put the curser into the element ID='id'
	document.getElementById( id ).focus();
	}

function putFocus ( F, E )
	{	// put the curser into the E-th element of the F-th form & select anything there already
		// (make sure hidden fields aren't first)
	if (document.forms.length > 0)
		{
		document.forms[F].elements[E].focus();
		document.forms[F].elements[E].select();
		}
	}

