// ###Core### - Common

			function ShowAnnouncementSize(e)
			{
				var count_so_far = $('#announcement')[0].value.length;
				$('#counter').text ( count_so_far );
				var feedback_color = (count_so_far > 140) ? 'red' : ( (count_so_far >= 120) ? 'yellow' : 'white');
				$('#announcement').css('background-color', feedback_color);
				$('#submit_announcement')[0].disabled = (count_so_far == 0 || count_so_far > 140);
			}
			
			function ShowProgress(e)
			{
				$('#myskillsmap_icon').show();
				$('#submit_announcement')[0].disabled = true;
			}
			
			function DecorateTables()
			{
			  $('table tbody tr:odd').addClass('row_odd');
			  $('table tbody tr:even').addClass('row_even');
			}

			function AutoResizeLayoutVertically()
			{
			  $('#subcontainer').height($('#main').height());
			}
			
			function ResizeLayoutForContent()
			{
			  $('#main').addClass('contents_main');
			  $('#sidebar').addClass('contents_sidebar');
			  $('#subcontainer').height($('#main').height());
			}
			
			function SwitchToTheme(themeName)
			{
				var themeOff = (themeName == 'pfm') ? 'cwr' : 'pfm';
				var themeOn = (themeName == 'pfm') ? 'pfm' : 'cwr';
				
				$('#dynamicnav,#container,#subcontainer,#main,#call_to_action,#skills_widget_overview,#portfolio_overview,#watch_demos,#getting_started,#features_sidebar,#widget_setup_sidebar,#footer,#copyright,#policies').each(
					function() {$(this).removeClass(themeOff).addClass(themeOn);
				});
				
				$.cookie('msm-theme', themeName);
			}
			
			function ToggleTheme()
			{
				var currentThemeName = $.cookie('msm-theme');
				var newTheme = (currentThemeName == null ||  currentThemeName == '' || currentThemeName == 'pfm') ? 'cwr' : 'pfm';
				SwitchToTheme(newTheme);
			}

// ###Core### - Sign-In/Up

			function ShowEasyLoginHelp(event)
			{ 
				if (event.type == 'mouseenter') 
					$("#easy_login_help").show(); 
				
				if (event.type == 'mouseleave') 
					$("#easy_login_help").hide();
			}
			
			function AttachShowEasyLoginHelp()
			{
					$('#top_header ul').bind('mouseenter mouseleave',	
																function(event){ ShowEasyLoginHelp(event); return true;});			
			}

// ###Core### - Nagging

			function DefaultNagTimeOut()
			{
				return 30 * 1000; // seconds
			}
			
			function NagStartTimeCookieName()
			{
				return 'msm-nag-start';
			}
			
			function CreateNagPanel(is_on_hold)
			{
				var nag_contents = '';
				nag_contents += '<div>Your trial ' + (is_on_hold ? 'has ended' : 'will soon be over') + '. A Personal subscription would bring you the following benefits:</div>';
				nag_contents += '<ul>';
				nag_contents += '<li>4 new projects per year</li>';
				nag_contents += '<li>12 activities per project</li>';
				nag_contents += '</ul>';
				nag_contents += '<a href="/account/upgrade-options">';
				nag_contents += '<img alt="Upgrade" src="/static/img/lnf/Upgrade.png"/>';
				nag_contents += '</a>';

				$('#nagcontents').html(nag_contents);

				buttons = {}
				if (!is_on_hold)
				{
					buttons['Cancel'] = function() { $(this).dialog('close'); } 
				}
				
				$('#nagdialog').dialog({
						autoOpen: false,
						width: 400,
						modal: true,
						buttons: buttons,
						closeOnEscape: true});
					
			}
		
			function Nag()
			{
				$('#nagdialog').dialog('open');
				var start = SetNagStartTimeCookie()
				setTimeout('Nag();',DefaultNagTimeOut());	
				//$('#nastarttime').text(start);
				//$('#nagelapsed').text('0');
			}
			
			function SetNagStartTimeCookie()
			{
				var start_time = (new Date()).getTime().toString();
				$.cookie(NagStartTimeCookieName(), start_time);  // { path: '/administration', expires: 7 }
				return start_time;
			}
			
			function SetUpNagProcess(is_on_hold)
			{
				CreateNagPanel(is_on_hold);

				var start = $.cookie(NagStartTimeCookieName());
				if (start == null)
					start = SetNagStartTimeCookie();
				//$('#starttime').text(start);

				var start_time = new Date();
				start_time.setTime(start);
				
				var elapsed = (new Date()) - start_time;
				//$('#elapsed').text(elapsed.toString());
				
				var time_out = DefaultNagTimeOut;
				if (is_on_hold || (elapsed >= time_out))
					Nag();
				else
				{
					new_time_out = time_out - elapsed;
					setTimeout('Nag();',new_time_out);	
				}
			}

// ###Vouching### - XXXXX
			function SendVoucherRequest() {
					$("#request_voucher_dialog").parent().find(".ui-dialog-buttonpane").addClass("wip");
					data = { };
					data['proficiency_id'] 		= $("#request_voucher_dialog #voucher_proficiency_id").val();
					data['submitter_name'] 	= $("#request_voucher_dialog #submitter_name").val();
					data['submitter_email'] 	= $("#request_voucher_dialog #submitter_email").val();
				
					$.ajax({
					   type : 'POST',
					   url  : '/voucher/proficiency/request',
					   data : data,
					   dataType: 'json',
					   async : false,
					   error: function(result) {
							$("#request_voucher_dialog").parent().find(".ui-dialog-buttonpane").removeClass("wip");
					   },
					   success: function(result) {
							error_list = result['errors'];

							$('#request_voucher_dialog').dialog('close');
							$("#request_voucher_dialog").parent().find(".ui-dialog-buttonpane").removeClass("wip");
						}
					});
			}
	
			function SetupVoucherRequestDetails() {
				$('#request_voucher_dialog').dialog({
					autoOpen: false,
					modal: true,
					position: [350,156],
					width: 420,
					height: 250,
					closeOnEscape: true,
					buttons: {
						'Cancel': function() { 
							$(this).dialog('close'); 
						},
						'Send Request': function() { 
							SendVoucherRequest();
						} 
					}
				});
			}
	
			function PromptForVoucherRequestDetails(target) {
					$("#request_voucher_dialog").parent().find(".ui-dialog-buttonpane").addClass("wip");
					target_data = target.split(":");
					
					data = {};
					data['target_type'] 		= target_data[0];
					data['proficiency_id'] 	= target_data[1];
				
					$.ajax({
					   type : 'GET',
					   url  : '/voucher/proficiency',
					   data : data,
					   dataType: 'json',
					   async : false,
					   error: function(result) {
							$("#request_voucher_dialog").parent().find(".ui-dialog-buttonpane").removeClass("wip");
					   },
					   success: function(result) {
							error_list = result['errors'];

							$("#request_voucher_dialog #voucher_proficiency_id").val(result['id']);
							$("#request_voucher_dialog #voucher_skill").text(result['skill_label']);
							$("#request_voucher_dialog #voucher_activity").text(result['activity_title']);
							$('#request_voucher_dialog').dialog('open');
							$("#request_voucher_dialog").parent().find(".ui-dialog-buttonpane").removeClass("wip");
						}
					});
			}


// ###Core### - XXXXX

			
