function get(eid) {return document.getElementById(eid);}
;
//  Handle click requests on anchor elements of the selectLanguage tabs.
function changeLanguage(aRef) {
	// get href of anchor with which the call is associated - href is declared as default 
	// page to be safe (in case script fails), but we'll try to reload the current page 
	// with the new page request, if all script processing succeeds
	var href = aRef.href;
	// parse lang= parameter from href attribute of anchor
	var lang = href.substring(href.indexOf('lang=') + 'lang='.length);
	// if lang= parameter not last in href, chop trailing parameters
	lang = lang.substring(0, (-1 != lang.indexOf('&'))?lang.indexOf('&'):lang.length);

	// record key/value pair for language to cookie for future reference
	setCookie('lang', lang);

	// so far so good - let's compose new request for current page, adding needed parameters
	var loc = window.location.toString();	// URL of current view/page
	// get base location URL without trailing parameters
	var baseLoc = loc.substring(0, (-1 != loc.indexOf('?')?loc.indexOf('?'):loc.length));
	var p = '';	// initialize parameters for concatenation to assemble with new value for lang key
	// if no parameters embedded in current location URL...
	if (-1 == loc.indexOf('?')) p += 'lang=' + lang;	// use lang= only
	// ...otherwise, get parameters from current URL and split into substrings - one per parameter
	else {
		var parms = loc.substring(loc.indexOf('?') + 1).split('&');
		var last = parms.length;
		for (var i = 0; i < last; i++) {
			if ('' == parms[i]) continue;		// skip this for empty split() artifact
			var kvPair = parms[i].split('=');
			var key = kvPair[0];
			var value = kvPair[1];
			p += key + '=' + (('lang' == key)?lang:value);
			if (i < last - 1) p += '&';		// add URL parameter separator, if more parameters
		}
	}
	window.location = baseLoc + '?' + p;	// send request to server for immediate change of language
}
;
function getCookie(key) {
	var c = document.cookie;					// convenience reference
	if ( 0 == c.length ) return null;		// if none, return null - exit immediately

	// implicit else - test for cookie value for lang key
	var c_start = c.indexOf(key + "=");
	if (-1 == c_start) return null;			// if no value for key, return null - exit immediately
	// implicit else - get value from cookie string
	c = c.substring(c_start + (key + "=").length);
	var c_end = c.indexOf( ";" );				// find end of value for key
	if ( -1 == c_end ) c_end = c.length;	// if no trailing semi-colon, this is last value, reset end

	// chop trailing parts, if any and return unescaped value
	return unescape( c.substring( 0, c_end ) );
}
;
function setCookie( key, value, expiredays) {
	// if not given, set default number of days until expiration to one year in the future
	if ('undefined' == typeof expiredays) expiredays = 365.25;
	// get a new Date instance
	var expires = new Date();
	// convert requested (or default) number of days to milliseconds
	expires.setTime( expires.getTime() + 1000*24*60*60 * expiredays );
	// add new key/value pair to cookies for page
	document.cookie = key + '=' + escape(value) + ((null == expiredays)?'':(';expires=' + expires.toGMTString()));
}
;
function removeBlock(bOpen, bClose, s) {
	// remove all subtext between between {bOpen} and {bClose} from 
	// {s}, if both {bOpen} and {bClose} are found and {bOpen} occurs 
	// before {bClose} - otherwise, return {s} unchanged  
	if (-1 != s.indexOf(bOpen) &&							// {bOpen} found 
			-1 != s.indexOf(bClose) && 					// {bClose} found
			s.indexOf(bOpen) < s.indexOf(bClose)) {	// {bOpen} before {bClose}
		s =  s.substring(0, s.indexOf(bOpen)) + 
			s.substring(s.indexOf(bClose) + bClose.length);
	}
	return s;				
}
;
function removeAllBlocks(bOpen, bClose, s) {
	// for all paired instances of {bOpen} and {bClose} found in {s},
	// remove all subtext between between {bOpen} and {bClose} from 
	// {s}, if both {bOpen} and {bClose} are found and {bOpen} occurs 
	// before {bClose} - otherwise, return {s} unchanged  
	while (-1 != s.indexOf(bOpen) && 					// {bOpen} found 
			-1 != s.indexOf(bClose) && 					// {bClose} found
			s.indexOf(bOpen) < s.indexOf(bClose)) { 	// {bOpen} before {bClose}
		s = removeBlock(bOpen, bClose, s);
	}
	return s;				
}
;
function doMailto(aRef) {
	ppDivMgr.doEmailDialog(getPageLang(), false);
//	var href = removeAllBlocks('<span', '</span>', aRef.innerHTML.toLowerCase());
//	aRef.href = 'mailto:' + href;
}
;