function searchTips ()
{
	cb = function(html)
	{
		if ($('tipsarchive_wrapper'))
		{
			$('tipsarchive_wrapper').innerHTML = html;

			// Reload the Facebox object so that the current links are facebox-active
			reloadFaceboxCodeObject();
		}
	};

	if ($('tipsarchive_wrapper'))
	{
		ajax.get('/ajax/student/module.tipsarchive.php?search_query='+$('search_query').value, cb);
	}
}

function searchVideos ()
{
	cb = function(html)
	{
		if ($('videolibrary_wrapper'))
		{
			$('videolibrary_wrapper').innerHTML = html;

			// Reload the Facebox object so that the current links are facebox-active
			reloadFaceboxCodeObject();
		}
	};

	if ($('videolibrary_wrapper'))
	{
		ajax.get('/ajax/student/module.videolibrary.php?search_query='+$('search_query').value, cb);
	}
}


function studentLogin()
{
	cb = function(resp)
	{
		if (resp.evalJSON().status == "success")
		{
			location.href = resp.evalJSON().href;
		}
		if (resp.evalJSON().status == "temporarypasswordsuccess")
		{
			$('login_form_code').innerHTML = $('password_change_code').innerHTML;
			$('ajaxEmail_confirm').value = resp.evalJSON().email;
		}
	};
	
	// Clean and submit
	$('ajaxEmail').value = ajax.clean($F('ajaxEmail'));
	$('ajaxPassword').value = ajax.clean($F('ajaxPassword'));
	ajax.transfer('usertype=student&module=login&action=login&Email='+ajax.encode($F('ajaxEmail'))+'&Password='+ajax.encode($F('ajaxPassword')), cb);
}

function confirmPassword()
{
	cb = function(resp)
	{
		if (resp.evalJSON().status == "confirmpasswordsuccess")
		{
			location.href = resp.evalJSON().href;
		}
	};

	// Clean and submit
	$('ajaxEmail_confirm').value = ajax.clean($F('ajaxEmail_confirm'));
	$('ajaxPassword_confirm').value = ajax.clean($F('ajaxPassword_confirm'));
	$('ajaxConfirmPassword_confirm').value = ajax.clean($F('ajaxConfirmPassword_confirm'));
	$('ajaxa_confirm').value = ajax.clean($F('ajaxa_confirm'));
	ajax.transfer('usertype=student&module=login&action=login&Email='+ajax.encode($F('ajaxEmail_confirm'))+'&Password='+ajax.encode($F('ajaxPassword_confirm'))+'&ConfirmPassword='+ajax.encode($F('ajaxConfirmPassword_confirm'))+'&a='+ajax.encode($F('ajaxa_confirm')), cb);

}


var lo_fb_done;
var lo_gc_done;
function studentlogout()
{
	// Set both "done" vars to default of false
	lo_fb_done = false;
	lo_gc_done = false;

	// Facebook Logout
	if ($('lo_fb') && $F('lo_fb') == 'on')
	{
		// Show the loading icon for FB logout
		if ($('lo_fb_loading')) $('lo_fb_loading').show();

		// Send the FB logout directive
//		facebook_logout();
		FB.Connect.logout(logout_fb_cb); // logout_fb_cb is the callback function
	}else{
		// Set the "logout of facebook is done" var to true, since we're "done" doing the nothing that has to be done...
		lo_fb_done = true;
	}

	// Google Calendar Logout
	if ($('lo_gc') && $F('lo_gc') == 'on')
	{
		// Show the loading icon for GC logout
		if ($('lo_gc_loading')) $('lo_gc_loading').show();

		// Create the invisible iframe that logs the user out of GC
		elem = new Element('iframe', {'id': 'lo_gc_iframe', 'src': 'https://www.google.com/accounts/logout', 'style': 'display: none;'})
			.insert('Uh oh! Your browser does not support iframes, and I therefore cannot log you out of Google Calendar.')
		;

		$('logoutwindow').insert(elem);

		// Set up the callback to fire when the iframe is done loading
		Event.observe('lo_gc_iframe', 'load', function()
		{
			logout_gc_cb();
		});
	}else{
		// Set the "logout of google calendar is done" var to true, since we're "done" doing the nothing that has to be done...
		lo_gc_done = true;
	}

	// Start the logout check function
	window.setTimeout('logout_cb()', 250);

	// Return false to halt posting of the form, instead we're waiting for the callback on the above FB logout directive
	return false;
}
function facebook_logout(docallback)
{
	// Data protections
	docallback = (docallback == true ? true : false);

	var user = FB.Facebook.apiClient.get_session() ? FB.Facebook.apiClient.get_session().uid : null;
	if (user != null)
	{
		var singleton=FB.Connect._singleton;
		var nextUrl=FBIntern.Uri.addQueryParameters(FB.XdComm.Server.singleton.get_receiverUrl(),'fb_login&fname=_parent&session=loggedout')

		singleton._ensureLoginHandler();
		singleton._logoutCallback = logout_fb_cb;
		logoutUrl=FBIntern.Utility.getFacebookUrl('www')+'logout.php?app_key='+FB.Facebook.apiKey+'&session_key='+encodeURIComponent(FB.Facebook.apiClient.get_session().session_key)+'&next='+encodeURIComponent(nextUrl);
		FB.Facebook.apiClient.set_session(null);
		singleton.set__userInfo(null);
		singleton._logoutIframe = FB.XdComm.Server.singleton.createNamedHiddenIFrame('fbLogout',logoutUrl,'fb_logout',null);

		if (docallback)
		{
			// Start the callback check function
			window.setTimeout('logout_fb_check()', 250);
		}
	}else{
		if (docallback)
		{
			// No user currently connected, so just jump straight the the callback
			logout_fb_cb();
		}
	}
}
function logout_fb_check()
{
	var user = FB.Facebook.apiClient.get_session() ? FB.Facebook.apiClient.get_session().uid : null;
	if (user != null)
	{
		// FB user is still connected, wait .25 seconds and try again
		window.setTimeout('logout_fb_check()', 250);
	}else{
		// FB user is not present, so we must be logged out now - fire the callback
		logout_fb_cb();
	}
}
function logout_fb_cb()
{
	// Hide the loading icon for FB logout
	if ($('lo_fb_loading')) $('lo_fb_loading').hide();

	// Show the 'success' icon for FB logout
	if ($('lo_fb_success')) $('lo_fb_success').show();

	lo_fb_done = true;
}
function logout_gc_cb()
{
	// Hide the loading icon for GC logout
	if ($('lo_gc_loading')) $('lo_gc_loading').hide();

	// Show the 'success' icon for GC logout
	if ($('lo_gc_success')) $('lo_gc_success').show();

	lo_gc_done = true;
}
function logout_cb()
{
	if (lo_fb_done && lo_gc_done)
	{
		// Both components are satisfied - proceed
		cb = function(resp)
		{
			// All done... redirect the user to the login/logout page
			location.href = '?logout'+(resp.evalJSON().lo_fb == '1' ? '&lo_fb' : '')+(resp.evalJSON().lo_gc == '1' ? '&lo_gc' : '');
		};

		// Post to the logout module via ajax transfer
		ajax.transfer('usertype=student&module=logout&action=finalize&lo_fb='+($('lo_fb') && $F('lo_fb') == 'on' ? '1' : ($('lo_fb') ? '0' : '-1'))+'&lo_gc='+($('lo_gc') && $F('lo_gc') == 'on' ? '1' : ($('lo_gc') ? '0' : '-1')), cb);
	}else{
		// One or both of the components are not yet satisfied - wait .25 seconds and try again
		window.setTimeout('logout_cb()', 250);
	}
}

function selectGCal(src)
{
	cb = function()
	{
		// Hide the calendar selection div
		if ($('selectGCal'))
		{
			$('selectGCal').hide();
		}

		// Update the calendar actions link box
		if ($('calendarlinks'))
		{
			$('calendarlinks').remove();
					
			elem = new Element('div', {})
					.insert(new Element('div', {'id': 'calendarlinks'})
						.insert(new Element('a', {'href': '?', 'class': 'calendar_thumb_popup_toggle arrowed'}).insert('Calendar actions'))
						.insert(new Element('div', {'class': 'clearboth', 'style': 'height: 1px;'}))
						.insert(new Element('div', {'id': 'calendar_thumb_popup', 'class': 'calendar_thumb_popup', 'style': 'display: none;'})
							.insert(new Element('div', {'class': 'top'})
								.insert(new Element('a', {'href': '?', 'class': 'calendar_thumb_popup_toggle'}).insert('Calendar actions'))
							)

							.insert(new Element('div', {'class': 'mid'})
								.insert(new Element('p')
									.insert(new Element('a', {'href': '/student/content/addcalendarevent.php?onclose=checkForChanges', 'rel': 'facebox', 'class': 'hidepopup'}).insert('Add event'))
									.insert(new Element('br'))
									.insert(new Element('a', {'href': '/student/content/largecalendar.php', 'rel': 'facebox', 'class': 'hidepopup'}).insert('View larger'))
									.insert(new Element('br'))
									.insert(new Element('a', {'href': '?gcs=1', 'class': 'unselect'}).insert('Switch calendars'))
									.insert(new Element('br'))
									.insert(new Element('a', {'href': '?gcul=1'}).insert('Disconnect'))
									.insert(new Element('br'))
									.insert(new Element('a', {'href': '/student/content/calendartips.php', 'rel': 'facebox'}).insert('Calendar tips'))
								)
							)

							.insert(new Element('div', {'class': 'bottom'}))
						)
					)
				;

			$('module_mycalendar').insert(elem);
			
			reloadFaceboxCodeObject();
			
			// Create onclick handlers for popup toggle links
			for (i = 0; i < $$('#calendarlinks a.calendar_thumb_popup_toggle').length; i++)
			{
				$$('#calendarlinks a.calendar_thumb_popup_toggle')[i].onclick = function()
				{
					$('calendar_thumb_popup').toggle();
					return false;
				};
			}
			
			// Create onclick handlers for unselect links
			for (i = 0; i < $$('#calendar_thumb_popup a.unselect').length; i++)
			{
				$$('#calendar_thumb_popup a.unselect')[i].onclick = function()
				{
					unselectGCal();
					$('calendar_thumb_popup').hide();
					return false;
				};
			}
			
			// Create onclick handlers for links that hide the popup
			for (i = 0; i < $$('#calendar_thumb_popup a.hidepopup').length; i++)
			{
				$$('#calendar_thumb_popup a.hidepopup')[i].onclick = function()
				{
					$('calendar_thumb_popup').hide();
				};
			}
		}
	};	

	if (src != '')
	{
		ajax.transfer('usertype=student&module=student&action=selectgcal&src='+src, cb);
	}
}

function unselectGCal()
{
	cb = function()
	{
		// Hide the calendar, ITIS
		if ($('calendariframe'))
		{
			$('calendariframe').remove();
		}

		// Show the calendar selection div
		if ($('selectGCal'))
		{
			for (i = 0; i < $$('input:checked[type=\'radio\'][name=\'selectgcal\']').length; i++)
			{
				$$('input:checked[type=\'radio\'][name=\'selectgcal\']')[i].checked = false;
			}
			
			$('selectGCal').show();
		}

		// Update the calendar actions link box
		if ($('calendarlinks'))
		{
			$('calendarlinks').remove();
					
			elem = new Element('div', {})
					.insert(new Element('div', {'id': 'calendarlinks', 'style': 'float: right;'})
						.insert(new Element('a', {'href': '?', 'class': 'calendar_thumb_popup_toggle arrowed'}).insert('Calendar actions'))
						.insert(new Element('div', {'class': 'clearboth', 'style': 'height: 1px;'}))
						.insert(new Element('div', {'id': 'calendar_thumb_popup', 'class': 'calendar_thumb_popup', 'style': 'display: none;'})
							.insert(new Element('div', {'class': 'top'})
								.insert(new Element('a', {'href': '?', 'class': 'calendar_thumb_popup_toggle'}).insert('Calendar actions'))
							)

							.insert(new Element('div', {'class': 'mid'})
								.insert(new Element('p')
									.insert(new Element('a', {'href': '/student/content/calendartips.php', 'rel': 'facebox'}).insert('Calendar tips'))
									.insert(new Element('br'))
									.insert(new Element('a', {'href': '?gcul=1'}).insert('Disconnect'))
								)
							)

							.insert(new Element('div', {'class': 'bottom'}))
						)
					)
				;

			if ($('module_mycalendar'))
			{
				$('module_mycalendar').insert(elem);
			}else if ($('calendarlinks_wrapper'))
			{
				$('calendarlinks_wrapper').insert(elem);
			}

			reloadFaceboxCodeObject();
			
			// Create onclick handlers for popup toggle links
			for (i = 0; i < $$('#calendarlinks a.calendar_thumb_popup_toggle').length; i++)
			{
				$$('#calendarlinks a.calendar_thumb_popup_toggle')[i].onclick = function()
				{
					$('calendar_thumb_popup').toggle();
					return false;
				};
			}
		}
	};	

	ajax.transfer('usertype=student&module=student&action=unselectgcal', cb);
}

function meetingnotesandtodos_selectGCal(src)
{
	cb = function()
	{
		// Hide the calendar selection div
		if ($('selectGCal'))
		{
			$('selectGCal').hide();
		}
		
		// Update the calendar iframe
		if ($('calendar'))
		{
			elem = new Element('div', {})
					.insert(new Element('div', {'id': 'calendaroverlay'})
						.insert(new Element('a', {'href': '/student/content/largecalendar.php', 'rel': 'facebox'}))
					)
					.insert(new Element('iframe', {'id': 'calendariframe', 'src': 'https://www.google.com/calendar/embed?showTitle=0&showNav=0&showPrint=0&showCalendars=0&showTz=0&height=290&wkst=1&bgcolor=%23FFFFFF&src='+src+'&color=%232952A3&ctz=America%2FLos_Angeles', 'style': 'border-width: 0;', 'width': '375', 'height': '290', 'frameborder': '0', 'scrolling': 'no'}))
					
			;		

			$('calendar').insert(elem);
		}
		
		// Update the calendar actions link box
		if ($('calendarlinks'))
		{
			$('calendarlinks').remove();
				
			elem = new Element('div', {})
					.insert(new Element('div', {'id': 'calendarlinks', 'style': 'float: right;'})
						.insert(new Element('a', {'href': '?', 'class': 'calendar_thumb_popup_toggle arrowed'}).insert('Calendar actions'))
						.insert(new Element('div', {'class': 'clearboth', 'style': 'height: 1px;'}))
						.insert(new Element('div', {'id': 'calendar_thumb_popup', 'class': 'calendar_thumb_popup', 'style': 'display: none;'})
							.insert(new Element('div', {'class': 'top'})
								.insert(new Element('a', {'href': '?', 'class': 'calendar_thumb_popup_toggle'}).insert('Calendar actions'))
							)

							.insert(new Element('div', {'class': 'mid'})
								.insert(new Element('p')
									.insert(new Element('a', {'href': '/student/content/addcalendarevent.php?onclose=checkForChanges', 'rel': 'facebox', 'class': 'hidepopup'}).insert('Add event'))
									.insert(new Element('br'))
									.insert(new Element('a', {'href': '/student/content/largecalendar.php', 'rel': 'facebox', 'class': 'hidepopup'}).insert('View larger'))
									.insert(new Element('br'))
									.insert(new Element('a', {'href': '?gcs=1', 'class': 'unselect'}).insert('Switch calendars'))
									.insert(new Element('br'))
									.insert(new Element('a', {'href': '?gcul=1'}).insert('Disconnect'))
									.insert(new Element('br'))
									.insert(new Element('a', {'href': '/student/content/calendartips.php', 'rel': 'facebox'}).insert('Calendar tips'))
								)
							)

							.insert(new Element('div', {'class': 'bottom'}))
						)
					)
				;

			$('calendarlinks_wrapper').insert(elem);

			reloadFaceboxCodeObject();
			
			// Create onclick handlers for popup toggle links
			for (i = 0; i < $$('#calendarlinks a.calendar_thumb_popup_toggle').length; i++)
			{
				$$('#calendarlinks a.calendar_thumb_popup_toggle')[i].onclick = function()
				{
					$('calendar_thumb_popup').toggle();
					return false;
				};
			}
			
			// Create onclick handlers for unselect links
			for (i = 0; i < $$('#calendar_thumb_popup a.unselect').length; i++)
			{
				$$('#calendar_thumb_popup a.unselect')[i].onclick = function()
				{
					unselectGCal();
					$('calendar_thumb_popup').hide();
					return false;
				};
			}
			
			// Create onclick handlers for links that hide the popup
			for (i = 0; i < $$('#calendar_thumb_popup a.hidepopup').length; i++)
			{
				$$('#calendar_thumb_popup a.hidepopup')[i].onclick = function()
				{
					$('calendar_thumb_popup').hide();
				};
			}
		}
	};	
	ajax.transfer('usertype=student&module=student&action=selectgcal&src='+src, cb);
}

moduleChanged = {};
function markChanged(pagename)
{
	moduleChanged[pagename] = true;
}

function markUnchanged(pagename)
{
	moduleChanged[pagename] = false;
}

function checkForChanges(pagename)
{
	if (pagename == 'goals')
	{
		if ('#goals')
		{
			edited = false;
			if ($F('Content_new') != '')
			{
				edited = true;
			}else{
				$$('#goals .item div.edit').each( function(elem)
				{
					if (elem.visible())
					{
						// If at least one edit window has been opened, prompt the user
						edited = true;
					}
				});
			}

			if (edited)
			{
				return confirm('Lose all unsaved changes?');
			}else{
				return true;
			}
		}else{
			return true;
		}
	}else if (pagename == 'meetingnotes')
	{
		if (moduleChanged['meetingnotes'])
		{
			if (confirm('Lose all unsaved changes?'))
			{
				markUnchanged('meetingnotes');
				return true;
			}else{
				return false;
			}
		}else{
			return true;
		}
	}else if (pagename == 'addcalendarevent')
	{
		if (moduleChanged['addcalendarevent'])
		{
			if (confirm('Lose all unsaved changes?'))
			{
				markUnchanged('addcalendarevent');
				return true;
			}else{
				return false;
			}
		}else{
			return true;
		}
	}else{
		return true;
	}
}

function facebox_destroyVideo()
{
	if ($('faceboxvideo'))
	{
		$('faceboxvideo').remove();
	}

	return true;
}

function dashboard_closefaceboxcb(pagename, params)
{
	if (pagename == 'vision')
	{
		dashboard_updateVision();
	}else if (pagename == 'goals')
	{
		dashboard_updateGoals();
		dashboard_updateRecognitions();
	}else if (pagename == 'meetingnotes')
	{
		if ($('studentdashboard'))
		{
			dashboard_updateMeetingNotes();
		}else if ($('meetingnotesandtodos'))
		{
			meetingnotesandtodos_updateMeetingNotes(params);
		}
	}

	ajax.transfer('usertype=student&module='+pagename+'&action=close');
}

function dashboard_updateVision()
{
	cb = function(html)
	{
		if ($('dashboard_vision_wrapper'))
		{
			$('dashboard_vision_wrapper').innerHTML = html;
		}
	};

	if ($('dashboard_vision_wrapper'))
	{
		ajax.get('/ajax/student/module.vision.php', cb);
	}
}

function dashboard_updateGoals()
{
	cb = function(html)
	{
		if ($('dashboard_goals_wrapper'))
		{
			$('dashboard_goals_wrapper').innerHTML = html;
		}
	};

	if ($('dashboard_goals_wrapper'))
	{
		ajax.get('/ajax/student/module.goals.php', cb);
	}
}

function dashboard_updateRecognitions()
{
	cb = function(html)
	{
		if ($('dashboard_recognitions_wrapper'))
		{
			$('dashboard_recognitions_wrapper').innerHTML = html;

			// If there a recognition present, show the post-it
			if (parseInt($F('curr_recognition')) > 0)
			{
				$('dashboard_recognitions_wrapper').show();
			}
		}
	};

	if ($('dashboard_recognitions_wrapper'))
	{
		ajax.get('/ajax/student/module.recognitions.php', cb);
	}
}

function dashboard_updateRecognitionsIcon()
{
	cb = function(html)
	{
		if ($('recognitions_icon_wrapper'))
		{
			$('recognitions_icon_wrapper').innerHTML = html;

			reloadFaceboxCodeObject();
		}
	};

	if ($('recognitions_icon_wrapper'))
	{
		ajax.get('/ajax/student/module.recognitionsicon.php', cb);
	}
}

function dashboard_updateMeetingNotes()
{
	cb = function(html)
	{
		if ($('dashboard_meetingnotes_wrapper'))
		{
			$('dashboard_meetingnotes_wrapper').innerHTML = html;

			reloadFaceboxCodeObject();
		}
	};

	if ($('dashboard_meetingnotes_wrapper'))
	{
		ajax.get('/ajax/student/module.meetingnotes.php', cb);
	}
}

function meetingnotesandtodos_updateMeetingNotes(id)
{
	cb = function(html)
	{
		if ($('meetingnotes_container'))
		{
			$('meetingnotes_container').innerHTML = html;

			reloadFaceboxCodeObject();
		}

		// Scroll to the correct meeting note
		if ($('meetingnote_'+id)) $('meetingnotes').scrollTo(0, ($('meetingnote_'+id).offsetTop - 48));
	};

	// Data protection
	id = (id != null && parseInt(id) > 0 ? parseInt(id) : "");

	if (id > 0 && $('meetingnotes_container'))
	{
		meetingnotes_ajax.get('/ajax/student/module.mnatd.meetingnotes.php'+(id != '' ? '?ID='+id : ''), cb);
	}
}


function vision_save()
{
	cb = function()
	{
		facebox.close(true); 
	};

	// Clean and submit
	$('Content').value = ajax.clean($F('Content'));
	ajax.transfer('usertype=student&module=vision&action=save&content='+ajax.encode(ajax.clean($F('Content'))), cb);
}


function todos_reorder()
{
	list = Sortable.sequence('todos').join(',');

	if (typeof(todos_ajax) != 'undefined')
	{
		todos_ajax.transfer('usertype=student&module=todos&action=reorder&list='+list);
	}else{
		ajax.transfer('usertype=student&module=todos&action=reorder&list='+list);
	}
}

function todos_markAsDone(ID)
{
	cb = function(resp)
	{
		if (parseInt(resp.evalJSON().ID) > 0)
		{
			ID = resp.evalJSON().ID;


			if ($('Item_'+ID+'_content'))
			{
				// Strike the item out
				$('Item_'+ID+'_content').addClassName('done');

				dashboard_updateRecognitions();
			}else{
				if (typeof(todos_ajax) != 'undefined')
				{
					xfer = todos_ajax;
				}else{
					xfer = ajax;
				}

				xfer.addError('Hmmm... I saved your change but couldn\'t update the display. Please reload.');
				xfer.showError();
			}
		}
	};
	if (typeof(todos_ajax) != 'undefined')
	{
		todos_ajax.transfer('usertype=student&module=todos&action=markasdone&id='+ID, cb);
	}else{
		ajax.transfer('usertype=student&module=todos&action=markasdone&id='+ID, cb);
	}
}

function todos_markAsUndone(ID)
{
	cb = function(resp)
	{
		if (parseInt(resp.evalJSON().ID) > 0)
		{
			ID = resp.evalJSON().ID;

			if ($('Item_'+ID+'_content'))
			{
				// Un-strike the item
				$('Item_'+ID+'_content').removeClassName('done');
			}else{
				if (typeof(todos_ajax) != 'undefined')
				{
					xfer = todos_ajax;
				}else{
					xfer = ajax;
				}

				xfer.addError('Hmmm... I saved your change but couldn\'t update the display. Please reload.');
				xfer.showError();
			}
		}
	};
	if (typeof(todos_ajax) != 'undefined')
	{
		todos_ajax.transfer('usertype=student&module=todos&action=markasundone&id='+ID, cb);
	}else{
		ajax.transfer('usertype=student&module=todos&action=markasundone&id='+ID, cb);
	}
}

function todos_save(ID)
{
	cb = function(resp)
	{
		if (parseInt(resp.evalJSON().ID) > 0)
		{
			ID = resp.evalJSON().ID;

			if ($('todo_'+ID))
			{
				// Update the on-screen text
				$('Item_'+ID+'_content').innerHTML = core.truncate(todos_ajax.cleanQuotes($F('Content_'+ID)), 40);

				// Switch to "view" mode
				$('Item_'+ID+'_edit').hide();
				$('Item_'+ID+'_view').show();
			}else{
				todos_ajax.addError('Hmmm... I saved your change but couldn\'t update the display. Please reload.');
				todos_ajax.showError();
			}
		}
	};
	
	// Clean and submit
	$('Content_'+ID).value = todos_ajax.clean($F('Content_'+ID));
	todos_ajax.transfer('usertype=student&module=todos&action=save&id='+ID+'&content='+todos_ajax.encode(todos_ajax.cleanQuotes(todos_ajax.clean($F('Content_'+ID)))), cb);
}

function todos_add()
{
	cb = function(resp)
	{
		if (parseInt(resp.evalJSON().ID) > 0)
		{
			ID = resp.evalJSON().ID;

			// Define the new item
			elem = new Element('li', {'class': 'item', 'id': 'todo_'+ID, 'style': 'margin-bottom: 5px; padding-bottom: 5px; border-bottom: solid 1px #eee;'})
						.insert(new Element('div', {'style': 'float: left; width: 20px;'})
							.insert(new Element('input', {'type': 'checkbox', 'id': 'Item_'+ID+'_Done', 'class': 'toggledone'}))
						)

						.insert(new Element('div', {'style': 'float: left;'})
							.insert(new Element('div', {'id': 'Item_'+ID+'_edit', 'style': 'display: none;'})
								.insert(new Element('form', {'action': '?savetodo='+ID, 'method': 'post', 'onsubmit': 'todos_save("'+ID+'"); return false;'})
									.insert(new Element('fieldset', {})
										.insert(new Element('input', {'id': 'Content_original_'+ID, 'style': 'display: none;', 'value': $F('todo_Content_new')}))
										.insert(new Element('input', {'id': 'Content_'+ID, 'name': 'Content_'+ID, 'class': 'content', 'style': 'line-height: 19px;', 'value': $F('todo_Content_new')})
										)
										.insert(new Element('div', {'class': 'actions', 'style': 'color: #fe9900; font-weight: bold;'})
											.insert('(')
											.insert(new Element('a', {'href': '?', 'class': 'save'}).insert('Save'))
											.insert('&nbsp;|&nbsp;')
											.insert(new Element('a', {'href': '?', 'class': 'cancel'}).insert('Cancel')
											)
											.insert(')')
										)
									)
								)
							)
							.insert(new Element('div', {'id': 'Item_'+ID+'_view', 'class': 'view'})
								.insert(new Element('div', {'style': 'float: right; width: 20px;'})
									.insert(new Element('div', {'id': 'addtocalendar_'+ID, 'class': 'popup_tiny_left', 'style': 'margin: -5px 0 0 -103px; display: none;'})
										.insert(new Element('a', {'href': '/student/content/addcalendarevent.php?What='+todos_ajax.encode(todos_ajax.cleanQuotes($F('todo_Content_new'))), 'rel': 'facebox'}).insert('Add to calendar'))
									)
									.insert(new Element('a', {'href': '#', 'class': 'showaddtocalendarpopup'}).insert(new Element('img', {'src': '/images/icon_calendar_sm.png', 'style': 'width: 20px; height: 15px; border: none;', 'alt': 'Add'})))
								)
								.insert(new Element('div', {'id': 'Item_'+ID+'_content', 'class': 'content', 'style': 'line-height: 19px;'})
									.insert($('todo_Content_new').value)
								)
								.insert(new Element('div', {'class': 'orange a', 'style': 'color: #fe9900; font-weight: bold;'})
									.insert('(')
									.insert(new Element('a', {'href': '?edittodo='+ID, 'class': 'edit'}).insert('Edit')
									)
									.insert('&nbsp;|&nbsp;')
									.insert(new Element('a', {'href': '?deletetodo='+ID, 'class': 'delete'}).insert('Delete')
									)
									.insert(')')
								)
								.insert(new Element('div', {'class': 'clearboth'}))
							)
						)
						
						.insert(new Element('div', {'class': 'clearboth'}))
						;

			// Insert the new item
			if ($$('#todos li').length > 0)
			{
				$('todos').insertBefore(elem, $$('#todos li')[0]);
			}else{
				$('todos').insert(elem);
			}

			// Create onclick handlers for checkboxes
			$('Item_'+ID+'_Done').onclick = function(e)
			{
				ID = parseInt(e.target.parentNode.parentNode.id.replace(/^todo_([0-9]*)$/, '$1'));

				if ($(this).checked)
				{
					todos_markAsDone(ID);
				}else{
					todos_markAsUndone(ID);
				}
			};

			// Create onclick handlers for add to calendar tiny_popup
			$$('#addtocalendar_'+ID+' a').shift().onclick = function(e)
			{
				ID = parseInt(e.target.parentNode.id.replace(/^addtocalendar_([0-9]*)$/, '$1'));

				$(this).parentNode.hide();
			};
			$$('#todo_'+ID+' a.showaddtocalendarpopup').shift().onclick = function(e)
			{
				ID = parseInt(e.target.parentNode.parentNode.parentNode.id.replace(/^Item_([0-9]*)_view$/, '$1'));

				$('addtocalendar_'+ID).toggle();
				return false;
			};

			reloadFaceboxCodeObject();

			// Create onclick handlers for Edit, Delete, Save and Cancel actions links
			$$('#todo_'+ID+' a.edit').shift().onclick = function(e)
			{
				ID = parseInt(e.target.parentNode.parentNode.id.replace(/^Item_([0-9]*)_view$/, '$1'));

				$('Item_'+ID+'_view').hide();
				$('Item_'+ID+'_edit').show();
				return false;
			};
			$$('#todo_'+ID+' a.delete').shift().onclick = function(e)
			{
				ID = parseInt(e.target.parentNode.parentNode.id.replace(/^Item_([0-9]*)_view$/, '$1'));

				todos_delete(ID);
				return false;
			};
			$$('#todo_'+ID+' a.save').shift().onclick = function(e)
			{
				ID = parseInt(e.target.parentNode.parentNode.parentNode.parentNode.id.replace(/^Item_([0-9]*)_edit$/, '$1'));

				todos_save(ID);
				return false;
			};
			$$('#todo_'+ID+' a.cancel').shift().onclick = function(e)
			{
				ID = parseInt(e.target.parentNode.parentNode.parentNode.parentNode.id.replace(/^Item_([0-9]*)_edit$/, '$1'));

				$('Content_'+ID).value = $F('Content_original_'+ID).replace(/"/g, '\\"');
				$('Item_'+ID+'_edit').hide();
				$('Item_'+ID+'_view').show();
				return false;
			};

			// Refresh the Sortable script (to include this new item)
			Sortable.create("todos", {'scroll': 'todos', 'onUpdate': function() { todos_reorder(); }   });

			// Clear the ADD input
			$('todo_Content_new').value = '';
		}
	};
	// Clean and submit
	$('todo_Content_new').value = todos_ajax.clean($F('todo_Content_new'));
	todos_ajax.transfer('usertype=student&module=todos&action=add&content='+todos_ajax.encode(todos_ajax.cleanQuotes($F('todo_Content_new'))), cb);
}

function todos_delete(ID)
{
	if (confirm('Are you sure you want to delete this to-do item?'))
	{
		cb = function(resp)
		{
			if (parseInt(resp.evalJSON().ID) > 0)
			{
				ID = resp.evalJSON().ID;

				if ($('todo_'+ID))
				{
					// Remove the item from the display
					$('todo_'+ID).remove();

					// Hide the whole box, ITIS
					if ($$('#todos li').length == 0)
					{
						$('todos_wrapper').hide();
					}
				}else{
					todos_ajax.addError('Hmmm... I saved your change but couldn\'t update the display. Please reload.');
					todos_ajax.showError();
				}
			}
		};
		todos_ajax.transfer('usertype=student&module=todos&action=delete&id='+ID, cb);
	}
}


function addcalendarevent(src)
{
	// Data protection
	src = (src != null ? src : '');

	cb = function(resp)
	{
		if (typeof(todos_ajax) != 'undefined')
		{
			if ($('calendar'))
			{
				todos_ajax.addSuccess("Your calendar event has been added to your Google calendar.");
				todos_ajax.showSuccess();

				markUnchanged('addcalendarevent');
				facebox.close(true);
			}else{
				ajax.addSuccess("Your calendar event has been added to your Google calendar.");
				ajax.showSuccess();

				markUnchanged('addcalendarevent');
			}
		
			if (src != '' && $('calendar'))
			{
				if ($$('#calendar iframe').length > 0)
				{
					for (i = 0; i < $$('#calendar iframe').length; i++)
					{
						$$('#calendar iframe')[i].remove();
					}

					elem = new Element('div', {})
							.insert(new Element('iframe', {'id': 'calendariframe', 'src': 'https://www.google.com/calendar/embed?showTitle=0&showNav=0&showPrint=0&showCalendars=0&showTz=0&height=290&wkst=1&bgcolor=%23FFFFFF&src='+src+'&color=%232952A3&ctz=America%2FLos_Angeles', 'style': 'border-width: 0;', 'width': '375', 'height': '290', 'frameborder': '0', 'scrolling': 'no'}))

					;		

					$('calendar').insert(elem);
				}
			}
		}else{
			ajax.addSuccess("Your calendar event has been added to your Google calendar.");
			ajax.showSuccess();

			markUnchanged('addcalendarevent');
			facebox.close(true);
		}
	};

	// Clean and submit
	$('What').value = ajax.clean($F('What'));
	$('StartDate').value = ajax.clean($F('StartDate'));
	$('StartTime').value = ajax.clean($F('StartTime'));
	$('EndDate').value = ajax.clean($F('EndDate'));
	$('EndTime').value = ajax.clean($F('EndTime'));
	$('Where').value = ajax.clean($F('Where'));
	$('HowDescription').innerHTML = ajax.clean($F('HowDescription'));
	tzoffset = -(new Date().getTimezoneOffset()) / 60;
	ajax.transfer('usertype=student&module=addcalendarevent&action=add&What='+ajax.encode(ajax.cleanQuotes(ajax.clean($F('What'))))+'&StartDate='+ajax.encode(ajax.cleanQuotes(ajax.clean($F('StartDate'))))+'&StartTime='+ajax.encode(ajax.cleanQuotes(ajax.clean($F('StartTime'))))+'&EndDate='+ajax.encode(ajax.cleanQuotes(ajax.clean($F('EndDate'))))+'&EndTime='+ajax.encode(ajax.cleanQuotes(ajax.clean($F('EndTime'))))+'&Where='+ajax.encode(ajax.cleanQuotes(ajax.clean($F('Where'))))+'&Description='+ajax.encode(ajax.cleanQuotes(ajax.clean($F('HowDescription'))))+'&tzoffset='+ajax.encode(tzoffset), cb);
}


function goals_reorder()
{
	list = Sortable.sequence('goals').join(',');

	ajax.transfer('usertype=student&module=goals&action=reorder&list='+list);
}

function goals_markAsDone(ID)
{
	cb = function(resp)
	{
		if (parseInt(resp.evalJSON().ID) > 0)
		{
			ID = resp.evalJSON().ID;

			if ($('goal_'+ID))
			{
				// Strike the item out
				$$('#Item_'+ID+'_view span.content').shift().addClassName('done');

				// Swap Done/Undo buttons
				$('Item_'+ID+'_done').hide();
				$('Item_'+ID+'_undo').show();
			}else{
				ajax.addError('Hmmm... I saved your change but couldn\'t update the display. Please reload.');
				ajax.showError();
			}
		}
	};
	ajax.transfer('usertype=student&module=goals&action=markasdone&id='+ID, cb);
}

function goals_markAsUndone(ID)
{
	cb = function(resp)
	{
		if (parseInt(resp.evalJSON().ID) > 0)
		{
			ID = resp.evalJSON().ID;

			if ($('goal_'+ID))
			{
				// Un-strike the item
				$$('#Item_'+ID+'_view span.content').shift().removeClassName('done');

				// Swap Done/Undo buttons
				$('Item_'+ID+'_undo').hide();
				$('Item_'+ID+'_done').show();
			}else{
				ajax.addError('Hmmm... I saved your change but couldn\'t update the display. Please reload.');
				ajax.showError();
			}
		}
	};
	ajax.transfer('usertype=student&module=goals&action=markasundone&id='+ID, cb);
}

function goals_save(ID)
{
	cb = function(resp)
	{
		if (parseInt(resp.evalJSON().ID) > 0)
		{
			ID = resp.evalJSON().ID;

			if ($('goal_'+ID))
			{
				// Update the on-screen text
				$('Item_'+ID+'_content').innerHTML = core.truncate(ajax.cleanQuotes($F('Content_'+ID)), 40);

				// Switch to "view" mode
				$('Item_'+ID+'_edit').hide();
				$('Item_'+ID+'_view').show();
			}else{
				ajax.addError('Hmmm... I saved your change but couldn\'t update the display. Please reload.');
				ajax.showError();
			}
		}
	};
	
	// Clean and submit
	$('Content_'+ID).value = ajax.clean($F('Content_'+ID));
	ajax.transfer('usertype=student&module=goals&action=save&id='+ID+'&content='+ajax.encode(ajax.cleanQuotes(ajax.clean($F('Content_'+ID)))), cb);
}

function goals_add()
{
	cb = function(resp)
	{
		if (parseInt(resp.evalJSON().ID) > 0)
		{
			ID = resp.evalJSON().ID;

			// Define the new item
			elem = new Element('li', {'class': 'item', 'id': 'goal_'+ID, 'style': 'margin-bottom: 5px; padding-bottom: 5px; border-bottom: solid 1px #eee;'})
						.insert(new Element('div', {'style': 'float: left; width: 20px;'})
							.insert(new Element('input', {'type': 'checkbox', 'id': 'Item_'+ID+'_Done', 'class': 'toggledone'}))
						)

						.insert(new Element('div', {'style': 'float: left;'})
							.insert(new Element('input', {'id': 'Content_original_'+ID, 'style': 'display: none;', 'value': $F('Content_new')}))
							.insert(new Element('div', {'id': 'Item_'+ID+'_edit', 'style': 'display: none;'})
								.insert(new Element('form', {'action': '?savegoal='+ID, 'method': 'post', 'onsubmit': 'goals_save("'+ID+'"); return false;'})
									.insert(new Element('fieldset', {})
										.insert(new Element('input', {'id': 'Content_'+ID, 'name': 'Content_'+ID, 'class': 'content', 'style': 'line-height: 19px;', 'value': $F('Content_new')})
										)
										.insert(new Element('span', {'class': 'orange a', 'style': 'color: #fe9900; font-weight: bold;'})
											.insert('&nbsp;(')
											.insert(new Element('a', {'href': '?', 'class': 'save'}).insert('Save'))
											.insert('&nbsp;|&nbsp;')
											.insert(new Element('a', {'href': '?', 'class': 'cancel'}).insert('Cancel')
											)
											.insert(')')
										)
									)
								)
							)
							.insert(new Element('div', {'id': 'Item_'+ID+'_view'})
								.insert(new Element('span', {'id': 'Item_'+ID+'_content', 'class': 'content', 'style': 'line-height: 19px;'})
									.insert($('Content_new').value)
								)
								.insert(new Element('span', {'class': 'orange a', 'style': 'color: #fe9900; font-weight: bold;'})
									.insert('&nbsp;(')
									.insert(new Element('a', {'href': '?editgoal='+ID, 'class': 'edit'}).insert('Edit')
									)
									.insert('&nbsp;|&nbsp;')
									.insert(new Element('a', {'href': 'deletegoal='+ID, 'class': 'delete'}).insert('Delete')
									)
									.insert(')')
								)
							)
						)
						
						.insert(new Element('div', {'class': 'clearboth'}))
						;

			// Insert the new item
			$('goals_wrapper').show();
			if ($$('#goals li').length > 0)
			{
				$('goals').insertBefore(elem, $$('#goals li')[0]);
			}else{
				$('goals').insert(elem);
			}

			// Create onclick handlers for checkboxes
			$('Item_'+ID+'_Done').onclick = function()
			{
				if ($(this).checked)
				{
					goals_markAsDone(ID);
				}else{
					goals_markAsUndone(ID);
				}
			};

			reloadFaceboxCodeObject();

			// Create onclick handlers for Edit, Delete, Save and Cancel actions links
			$$('#goal_'+ID+' a.edit').shift().onclick = function()
			{
				ID = this.parentNode.parentNode.id.replace(/^Item_([0-9]*)_.*$/, '$1');

				$('Item_'+ID+'_view').hide();
				$('Item_'+ID+'_edit').show();
				return false;
			};
			$$('#goal_'+ID+' a.delete').shift().onclick = function()
			{
				ID = this.parentNode.parentNode.id.replace(/^Item_([0-9]*)_.*$/, '$1');

				goals_delete(ID);
				return false;
			};
			$$('#goal_'+ID+' a.save').shift().onclick = function()
			{
				ID = this.parentNode.parentNode.parentNode.parentNode.id.replace(/^Item_([0-9]*)_.*$/, '$1');

				goals_save(ID);
				return false;
			};
			$$('#goal_'+ID+' a.cancel').shift().onclick = function()
			{
				ID = this.parentNode.parentNode.parentNode.parentNode.id.replace(/^Item_([0-9]*)_.*$/, '$1');

				$('Content_'+ID).value = $F('Content_original_'+ID).replace(/"/g, '\\"');
				$('Item_'+ID+'_edit').hide();
				$('Item_'+ID+'_view').show();
				return false;
			};

			// Refresh the Sortable script (to include this new item)
			Sortable.create("goals", {'scroll': 'goals', 'onUpdate': function() { goals_reorder(); }   });

			// Clear the ADD input
			$('Content_new').value = '';
		}
	};
	// Clean and submit
	$('Content_new').value = ajax.clean($F('Content_new'));
	ajax.transfer('usertype=student&module=goals&action=add&content='+ajax.encode(ajax.cleanQuotes($F('Content_new'))), cb);
}

function goals_delete(ID)
{
	if (confirm('Are you sure you want to delete this goal?'))
	{
		cb = function(resp)
		{
			if (parseInt(resp.evalJSON().ID) > 0)
			{
				ID = resp.evalJSON().ID;

				if ($('goal_'+ID))
				{
					// Remove the item from the display
					$('goal_'+ID).remove();

					// Hide the whole box, ITIS
					if ($$('#goals li').length == 0)
					{
						$('goals_wrapper').hide();
					}
				}else{
					ajax.addError('Hmmm... I saved your change but couldn\'t update the display. Please reload.');
					ajax.showError();
				}
			}
		};
		ajax.transfer('usertype=student&module=goals&action=delete&id='+ID, cb);
	}
}


function meetingnotes_delete(ID)
{
	if (confirm('Are you sure you want to delete this meeting?'))
	{
		cb = function()
		{
			meetingnotesandtodos_updateMeetingNotes($F('MeetingNoteID'));
		};

		meetingnotes_ajax.transfer('usertype=student&module=meetingnotes&action=delete&id='+meetingnotes_ajax.encode(ID), cb);
	}
}

function meetingnotes_save(addnote)
{
	addnote = (addnote == true ? true : false);

	if (!addnote || (addnote && $F('NewMeetingNoteID') == "new"))
	{
		if (addnote)
		{
			cb = function(resp)
			{
				// Update the ID input
				if (parseInt(resp.evalJSON().ID) > 0)
				{
					ID = parseInt(resp.evalJSON().ID);
					$('NewMeetingNoteID').value = ID;			
					$('NewNoteMeetingNoteID').value = ID;			
				}
				
				// If Content contains something, post it, otherwise, show the success message
				if (meetingnotes_ajax.clean($F('meetingnote_Content')) != '')
				{
					meetingnotes_addnote(true);
				}else{
					markUnchanged('meetingnotes');
					ajax.addSuccess("Saved");
					ajax.showSuccess();				

					$$('.calendar')[0].remove();
					facebox.close(true, ID);
				}
			};
		}else{
			cb = function()
			{
				markUnchanged('meetingnotes');
				meetingnotes_ajax.addSuccess("Saved");
				meetingnotes_ajax.showSuccess();
			};
		}

		// Clean and submit
		$('Title').value = meetingnotes_ajax.clean($F('Title'));
		$('Date').value = meetingnotes_ajax.clean($F('Date'));
		ajax.transfer('usertype=student&module=meetingnotes&action=save&id='+meetingnotes_ajax.encode($F('NewNoteMeetingNoteID'))+'&title='+meetingnotes_ajax.encode(meetingnotes_ajax.cleanQuotes(meetingnotes_ajax.clean($F('Title'))))+'&date='+meetingnotes_ajax.encode(meetingnotes_ajax.cleanQuotes($F('Date'))), cb);
	}else if (addnote && parseInt($F('MeetingNoteID')) > 0)
	{
		meetingnotes_addnote(false);
	}
}

function meetingnotes_addnote(newNote, contentelem)
{
	// Data protection
	newNote = (newNote == true ? true : false);
	contentelem = (contentelem != null ? contentelem : 'meetingnote_Content');

	if (newNote)
	{
		cb = function(resp)
		{	
			markUnchanged('meetingnotes');
			// Don't need to do the following cb anymore, because as of P2 R3 we are reloading the entire Meeting notes module, as opposed to viewing it in a popup as before
			//meetingnotes_addnote_cb(resp);

			ajax.addSuccess("Saved");
			ajax.showSuccess();

			$$('.calendar')[0].remove();
			facebox.close(true, ID);
		};

		// Clean and submit
		if ($(contentelem))
		{
			$(contentelem).value = meetingnotes_ajax.clean($F(contentelem));
			ajax.transfer('usertype=student&module=meetingnotes&action=add&meetingnoteid='+meetingnotes_ajax.encode($F('NewMeetingNoteID'))+'&content='+meetingnotes_ajax.encode(meetingnotes_ajax.clean($F(contentelem))), cb);
		}
	}else{
		cb = function(resp)
		{
			markUnchanged('meetingnotes');
			meetingnotes_addnote_cb(resp, contentelem);
		};

		// Clean and submit
		if ($(contentelem))
		{
			$(contentelem).value = meetingnotes_ajax.clean($F(contentelem));
			meetingnotes_ajax.transfer('usertype=student&module=meetingnotes&action=add&meetingnoteid='+meetingnotes_ajax.encode($F('MeetingNoteID'))+'&content='+meetingnotes_ajax.encode(meetingnotes_ajax.clean($F(contentelem))), cb);
		}
	}
}

function meetingnotes_addnote_cb(resp, contentelem)
{
	// Data protection
	contentelem = (contentelem != null ? contentelem : 'meetingnote_Content');

	if (parseInt(resp.evalJSON().ID) > 0)
	{
		ID = resp.evalJSON().ID;

		// Define the new item
		elem = new Element('li', {'id': 'meetingnote_'+ID, 'class': 'item highlighted'})
					.insert(new Element('div', {'style': 'padding-bottom: 5px;'})
						.insert($F(contentelem))
					)
					.insert(new Element('div', {'class': 'small lightergrey i'})
						.insert('Note added by me '+(resp.evalJSON().Timestmap != '' ? ' '+resp.evalJSON().Timestamp : ''))
					);

		// Insert the new item
		$('meetingnotes_transcript').insert(elem);

		// Clear the ADD input
		$(contentelem).value = '';
		
		// Scroll to the bottom of the list
		$('meetingnotes_transcript').scrollTop = $('meetingnotes_transcript').scrollHeight;
		window.setTimeout('new Effect.Highlight($(\'meetingnote_'+ID+'\'), { startcolor: \'#fcfcd6\', endcolor: \'#ffffff\', restorecolor: \'#ffffff\', duration: 1 });', 5000);
	}
}

var recognitionslocked = false;
function closeRecognition()
{
	if (!recognitionslocked)
	{
		if ($('curr_recognition') && parseInt($F('curr_recognition')) > 0)
		{
			// Lock the recognitions AJAX calls
			recognitionslocked = true;

			$('recognition_loading').show();

			ajax.transfer('usertype=student&amp;module=recognitions&amp;action=close&amp;id='+parseInt($F('curr_recognition')), closeRecognition_cb);
		}else{
			alert('Oops! An error has occurred. Please reload this page.');
		}
	}
}

function closeRecognition_cb()
{
	closeRecogntion_cb_cb = function(html)
	{
		if (parseInt(html.evalJSON().NumRecognitions) == 0)
		{
			// The user just closed the only recognition note, so unclock the interface and hide the display
			recognitionslocked = false;
			$('recognition_loading').hide();
			$('curr_recognition').value = '0';
			$('dashboard_recognitions_wrapper').hide();
		}else{
			// There is at least one more recognition to show, update display
			if (parseInt(html.evalJSON().ID) > 0 && html.evalJSON().Content != '')
			{
				// Update display output
				$('recognition_content').innerHTML = html.evalJSON().Content;
				str = 'Coach '+html.evalJSON().CoachDisplayName;
				$('recognition_credits').innerHTML = '&mdash; '+str.toUpperCase();

				// Update the curr var
				$('curr_recognition').value = parseInt(html.evalJSON().ID);

				// If we are now viewing the last recognition, hide the "additional" post-it, ITIS
				if (parseInt(html.evalJSON().NumRecognitions) < 2)
				{
					$('recognition_additional').hide();
				}

				// Unlock the interface and hide the loading indicator
				recognitionslocked = false;
				$('recognition_loading').hide();
			}
		}

		dashboard_updateRecognitionsIcon();
	};

	// Get the next recognition note and NumRecognitions via AJAX, and then update the display
	ajax.transfer('usertype=student&amp;module=recognitions&amp;action=getNewest', closeRecogntion_cb_cb);
}

