function getMeasurementLabel(m, full) {
	var retVal = "&nbsp;";
	var TRANSLATE_TOGGLE = {
		"type":"Type","count":"#","percent":"%","percent change":"%Ch","median":"Mdn","change":"Ch","rate":"Rt","currency":"$","average currency":"Av$",
		"total currency":"Tot$","% level 1":"%1","% level 2":"%2","% level 3":"%3","% level 4":"%4","% level 5":"%5","at or above proficient":"AOAP",
		"does not meet":"DNM","exceeds":"E","failed":"F","meets":"M","passedadvanced":"PA","passed":"PASS","partially meets":"PM","advanced":"ADV",
		"at or above proficient":"AOAP","basic":"B","below basic":"BB","proficient":"PROF","approaches":"APP","falls far below":"FB","meets":"M",
		"partially proficient":"PP","unsatisfactory":"U","below":"B","distinguished":"D","well below":"WB","not meeting":"NM","pass+":"P+","did not pass":"DNP",
		"undetermined":"U","approaches standard":"AS","academic warning":"AW","exemplary":"E","exceeds standard":"ES","meets standard":"MS","approaching basic":"AB",
		"mastery":"M","advanced/above proficient":"AP","needs improvement":"NI","warning/failing":"WF","does not meet":"DNM","apprentice":"APP",
		"exceeded expectations":"EE","met expectations":"ME","minimal":"M","novice":"N","nearing proficient":"NP","beginning":"B","progressing":"PROG",
		"achieved the standard":"AS","achieved the standard with honors":"AS+","below the standard":"BS","achievement level 1":"L1","achievement level 2":"L2",
		"achievement level 3":"L3","achievement level 4":"L4","little evidence of achievement":"LE","nearly achieved the standard":"NA","advanced proficient":"ADVP",
		"beginning step":"BS","approaches standard":"AS","emergent/developing":"ED","limited knowledge":"LK","satisfactory":"S","no score":"NS",
		"proficient with distinction":"PD","substantially below proficient":"SBP","below standard":"BS","met standard":"MS","well below standard":"WB",
		"far below basic":"FBB","exceeding":"E","failing":"F","meeting":"M","pass":"PASS","below proficient":"BP","near proficient":"NP","score":"Score",
		"average":"Av","degree days":"Degree Days","honors":"HON","not proficient":"NP","pct chg price from last year":"%Ch1YR$","pct chg price from three years ago":"%Ch3YR$",
		"pct chg price from five years ago":"%Ch5YR$","pct chg num sales from last year":"%Ch1YR#","pct chg price from last quarter":"%Ch1Q$",
		"pct chg num sales from last qtr":"%Ch1Q#","pct chg price from 4 qtrs previous":"%Ch4Q$","pct chg num sales from 4 qtrs previous":"%Ch4Q#",
		"pct chg vac units from last qtr":"%Ch1Q","pct chg vac units from 4 qtrs previous":"%Ch4Q","pct chg no-stat units from last qtr":"%Ch1Q",
		"pct chg no-stat units from 4 qtrs previous":"%Ch4Q","square foot":"Sq Ft","units":"Units","count2":"Ct","adjusted rate":"AdjRt","change percent":"Ch%",
		"total number":"Tot#","total count":"TotCt","index":"Index","share":"Share","currency aggregate":"$"
	};
	if (full) {
		if (m == "count")
			retVal = "Number";
		else if (m == "count2")
			retVal = "Count";
		else if (m == "currency aggregate")
			retVal = "Currency";
		else
			retVal = m.substr(0,1).toUpperCase() + m.substr(1);
	} 
	else if (TRANSLATE_TOGGLE[m])
		retVal = TRANSLATE_TOGGLE[m];

	return retVal;
}

function saveEffect() {
	jQuery('#mypolicymap').fadeTo(2000, 0.2, function() { 
		jQuery('#mypolicymap').fadeTo(2000, 1);
	});
}

function teaseIndicators(extra) {
	var link = getContextPath() + (isPublicUser() ? '/register?reg_type=sub' : '/servlets/upgrade?reg_type=sub');

	var text = "Available to subscribers only.  If you're a subscriber, <a onclick='loginAlert(this)' class='pagelinks'>login</a> to access, or become a <a href='" + link + "' class='pagelinks'>subscriber</a>.";

	if(extra) {
		text += "<br><br>" + extra;
	}
 	var alerter = new PAlerter();
	alerter.popup(text, null, null, "OK");
}

function comingIndicators () {
	var text = "Not yet available to PolicyMap users. Stay tuned to our PolicyMap email updates and blog for a release announcement about these data.";
	var alerter = new PAlerter();
	alerter.popup(text, null, null, "OK");	
}

function superMarketLIIFTeaseAlert() {
	var text = "Available to select subscribers only. For information about obtaining a Supermarket Study of Low Access Areas, please <a href='/contact.html'>contact us</a>.";
	var alerter = new PAlerter();
	alerter.popup(text, null, null, "OK");	
}
// special TRF Supermarket Study of LAA alert
function trfSuperMarketTeaseAlert() {
	var text = "Only available to subscribers. For more information about accessing this data, please <a href='/contact.html' class='pagelinks'>contact us</a>";
	var alerter = new PAlerter();
	alerter.popup(text, null, null, "OK");	
}
function naIndicators() {
	var text = "This data is not available.";
	var alerter = new PAlerter();
	alerter.popup(text, null, null, "OK");	
}

function sendMail(domain, account, subject) {
	var a = "mailto:" + account + domain + "?" + "subject=" + subject;
	location.href = a;
}

function setMenuScroll() {
	var scroll = jQuery(".scrollingDiv");
	for (var i=0; i<scroll.length; i++) {
		// Scrolling is buggy on ie6 so removing scrolling div
/*		if (version < 7) {
			var fragment = document.createDocumentFragment();
			while(scroll[i].firstChild) {
			    fragment.appendChild(scroll[i].firstChild);
			}
			scroll[i].parentNode.insertBefore(fragment, scroll[i]);
			scroll[i].parentNode.removeChild(scroll[i]);
		}
		else {	// this initialises the scrolling with custom scrollbar for the menu
*/
			jQuery(scroll[i]).jScrollPane({showArrows:true,scrollbarWidth:10});
			// added css for when scroll bar goes on the left side
			if (scroll[i].className == "scrollingDiv leftSide") {
				var par = jQuery(scroll[i]).parent()[0];
				jQuery(par).find('.jScrollPaneTrack').css('left','0')
				jQuery(par).find('.jScrollPaneDrag').css('padding','0')
				jQuery(par).find('.jScrollArrowUp').css('left','0')
				jQuery(par).find('.jScrollArrowDown').css('left','0')
				jQuery(scroll[i]).css({'margin':'0 30px', 'width':'193px'});
				jQuery(par).css('left', '-18px');
			}
//		}
	}
}

// expiry alert is shown only once.
function showExpiryAlertFunction() {
	if (isExpiredSubscription() && showExpNoteCount()) {
		var alerter = new PAlerter();
		var content = "Your PolicyMap subscription has expired; however, you may continue to use your account to access the site as a registered user."; 
		alerter.popup(content, null, null, "OK");
	}
}

// When user clicks login alert in subscriber/register alerts no need to redirect to login page
// This alert takes the login form from the top right of the app and displays it in an alert
function loginAlert(elem) {
	var log = document.getElementById('login');
	var div = document.createElement('div');
	div.appendChild(log);
	var alerter = new PAlerter();
	alerter.popup(div, null, null, "Cancel", "Submit", function() { validateAndLogin(); }, function() { loginAlertCancel(); });
}

function loginAlertCancel(elem) {
	jQuery("#login").appendTo("#loginFormContainer");
}

function updateSessionLinks() {
	var envname = PEnvironment.pageName;

	if (envname == 'tables') {
		var a = document.getElementById('homeLink');
		a.href = "map";
	} else if (envname == 'reports' || envname == 'report_area' || envname == 'report_generate') {
		var q = PSession.toURI();
		var a = document.getElementById('homeLink');
		a.href +=q;
		if (envname == 'report_area' || envname == 'report_generate') {
			var a = document.getElementById('reportsLink');
			a.href += q;
		}
	}
}

function startSlideShow(type) {
	var slideShow = new BizCaseAnimations(type);
	slideShow.loadAnim();
}

function scrollCarousel(dir) {
	var ul = $('ul.sc_menu');
	var left = ul.position().left;

	// each li elements width and the padding is used to calculate the max
	var liWidth = 223;
	var padding = 8;
	var max = -(liWidth*9 + 9*padding);

	if (dir == 'left') {
		left = left + (liWidth + padding);
		$('#CarouselLeft').css({backgroundPosition:"0 0"});
		$('#CarouselRight').css({backgroundPosition:"0 0"});
		// starting point is 0 so don't go past it
		if (left >= 0) {
			left = 0;
			$('#CarouselLeft').css({backgroundPosition:"0 -16px"});
		}
	}
	else if (dir == 'right') {
		left = left - (liWidth + padding);
		$('#CarouselRight').css({backgroundPosition:"0 0"});
		$('#CarouselLeft').css({backgroundPosition:"0 0"});
		// don't allow scrolling if it's reached the end
		if (left <= max) {
			left = max;
			$('#CarouselRight').css({backgroundPosition:"0 -16px"});
		}
	}

	// This is to ensure the menu will scroll one item at a time
	if (!ul.hasClass('animationdone'))
		return;

	ul.removeClass('animationdone');
	ul.animate({left:left}, 500, function() {
		ul.addClass('animationdone');
	});
}

/* Toggle for showing the full copy */
function clientStoriesToggle(elem) {
	if ($(elem).hasClass('readmore')) {
		$(elem).parent('.links').prev('.desc').children('.long-version').show();
		$(elem).children('.text').html('Collapse');
		$(elem).removeClass('readmore');
		$(elem).addClass('collapse');
	}
	else {
		$(elem).parent('.links').prev('.desc').children('.long-version').hide();
		$(elem).children('.text').html('Read More');
		$(elem).addClass('readmore');
		$(elem).removeClass('collapse');
	}
}

function showVideoPlayer(type) {
	var alerter = new PAlerter();
	alerter.box.style.width = "800px";

	// All available videos go here, just pass the right type to the function to fire the alerter
	var videos = {};
	
	// Market Studies
	videos['market-studies'] = '<div class="videoHeader">Market Studies</div>';
	videos['market-studies'] += '<div class="video"><object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/LqBlWp7mUww?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/LqBlWp7mUww?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object></div>';

	// Data
	videos['data'] = '<div class="videoHeader">Data</div>';
	videos['data'] += '<div class="video"><object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/7j0UOEjtMq0?fs=1&amp;hl=en_US&amp;hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/7j0UOEjtMq0?fs=1&amp;hl=en_US&amp;hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object></div>';

	// Maps and Analysis
	videos['maps-analysis'] = '<div class="videoHeader">Maps and Analysis</div>';
	videos['maps-analysis'] += '<div class="video"><object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/rZobULCqghk?fs=1&amp;hl=en_US&amp;hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/rZobULCqghk?fs=1&amp;hl=en_US&amp;hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object></div>'

	// All On Your Website
	videos['your-website'] = '<div class="videoHeader">All On Your Website</div>';
	videos['your-website'] += '<div class="video"><object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/23ntkccE0KQ?fs=1&amp;hl=en_US&amp;hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/23ntkccE0KQ?fs=1&amp;hl=en_US&amp;hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object></div>';
	
	// Using Analytics
	videos['analytics'] = '<div class="videoHeader">Using Analytics<br />See how it works</div>';
	videos['analytics'] += '<div class="video"><object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/LnS_GdekZbA?fs=1&amp;hl=en_US&amp;hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/LnS_GdekZbA?fs=1&amp;hl=en_US&amp;hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object></div>';
	
	// PolicyMap Primer
	videos['primer'] = '<div class="videoHeader">PolicyMap Primer<br />Quick Tutorial</div>';
	videos['primer'] += '<div class="video"><object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/-l9Qpk5pk2Y?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/-l9Qpk5pk2Y?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object></div>';

	// Data Loader
	videos['data-loader'] = '<div class="videoHeader">Using the Data Loader<br />See how it works</div>';
	videos['data-loader'] += '<div class="video"><object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/VDI6xlzVtBM?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/VDI6xlzVtBM?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object></div>';

	var content = {};
	content.content = videos[type];

	var func = function() {
	}

	content.popupStyle = "video";
	content.addCancel = false;
	alerter.popup(content, null, null, func ,null, null, null);
}

