//START RIGHTBLOCK_BASE

		var SwitchRightBlock_target = null;
		var SwitchRightBlock_callback = null;
		var ContainerForAds;

		function SwitchRightblock(_fx, _callback)
		{
			if(ContainerForAds == undefined)
				ContainerForAds = document.getElementById('div_RightBlock_ad');

			switch(_fx)
			{
				case 'Notes':
				{
					if(loggedInObject.getStatus()==false)
					//if(ShmoopUser_auth == false)
					{
						Goto('/login');
						return;
					}

					item_id = '';
					if(ShmoopItem_ids != undefined)
					{
						for(var i=0; i<ShmoopItem_ids.length; i++)
							item_id += ShmoopItem_ids[i] + ',';
					}

					item_id += ShmoopObject_id;

					document.getElementById('RightBlock_LinkBlock_Conversations').className = 'PageFx_Button_Un';
					document.getElementById('RightBlock_LinkBlock_Conversations_img').src = '/media/v1d3/page_fx/un/conversations.gif';
					document.getElementById('RightBlock_LinkBlock_WGO').className = 'PageFx_Button_Un';
					document.getElementById('RightBlock_LinkBlock_WGO_img').src = '/media/v1d3/page_fx/un/whats_going_on.gif';
					document.getElementById('RightBlock_LinkBlock_Notes').className = 'PageFx_Button_Sel';
					document.getElementById('RightBlock_LinkBlock_Notes_img').src = '/media/v1d3/page_fx/at/take_notes.png';
					break;
				}
				case 'Conversations':
				{
					if(loggedInObject.getStatus()==false)
					//if(ShmoopUser_auth == false)
					{
						Goto('/login');
						return;
					}

					item_id = ShmoopObject_id;

					document.getElementById('RightBlock_LinkBlock_WGO').className = 'PageFx_Button_Un';
					document.getElementById('RightBlock_LinkBlock_WGO_img').src = '/media/v1d3/page_fx/un/whats_going_on.gif';
					document.getElementById('RightBlock_LinkBlock_Notes').className = 'PageFx_Button_Un';
					document.getElementById('RightBlock_LinkBlock_Notes_img').src = '/media/v1d3/page_fx/un/take_notes.gif';
					document.getElementById('RightBlock_LinkBlock_Conversations').className = 'PageFx_Button_Sel';
					document.getElementById('RightBlock_LinkBlock_Conversations_img').src = '/media/v1d3/page_fx/at/conversations.png';
					break;
				}
				case 'WGO':
				default:
				{
					item_id = ShmoopObject_id;

					document.getElementById('RightBlock_LinkBlock_Notes').className = 'PageFx_Button_Un';
					document.getElementById('RightBlock_LinkBlock_Notes_img').src = '/media/v1d3/page_fx/un/take_notes.gif';
					document.getElementById('RightBlock_LinkBlock_Conversations').className = 'PageFx_Button_Un';
					document.getElementById('RightBlock_LinkBlock_Conversations_img').src = '/media/v1d3/page_fx/un/conversations.gif';
					document.getElementById('RightBlock_LinkBlock_WGO').className = 'PageFx_Button_Sel';
					document.getElementById('RightBlock_LinkBlock_WGO_img').src = '/media/v1d3/page_fx/at/whats_going_on.png';
					break;
				}
			}

			SwitchRightBlock_target = _fx;
			SwitchRightBlock_callback = _callback;

			document.getElementById('RightBlock_Replace').innerHTML = '<div style="font-size:13px;margin-top:15px;color:#aaa;width:460px;" align="center">Loading<div><img src="/media/ajax/bar_fff_000.gif" style="margin-left:-5px;"><\/div><\/div>';

			var url = '/ajax/template/rightblock?fx=' + _fx + '&item_id=' + item_id;
			var xhrcall = new Ajax(url, {onComplete:SwitchRightBlock_Response}).request();

			//SAVE RIGHT BLOCK CLICKED VALUE IN HIDDEN FIELD TO USE WHEN USER CLICKS OUTSIDE OF INPUTBOX, (WHEN RETURN TO REST JS FUNCTION IS FIRED).
			document.getElementById('input_right_block_value').value = _fx;
		}

		function SwitchRightBlock_Response(_response)
		{
			//switch the viewer

			if(SwitchRightBlock_target == 'Notes')
			{
				eval(_response);
			}
			else if(SwitchRightBlock_target == 'Conversations')
			{
				document.getElementById('RightBlock_Replace').innerHTML = _response;
			}
			else if(SwitchRightBlock_target == 'WGO')
			{
				document.getElementById('RightBlock_Replace').innerHTML = _response;
				var adtoreplace = document.getElementById('div_RightBlock_ad');
				adtoreplace.parentNode.replaceChild(ContainerForAds, adtoreplace);
			}

			if(SwitchRightBlock_callback != undefined && SwitchRightBlock_callback != null)
			{
				SwitchRightBlock_callback.call(this);
			}
		}

//END RIGHTBLOCK_BASE

//START RIGHTBLOCK_DICTIONARY JS

	var CursorSelectedText = '';
	var DefinitionNumber = false;

	function Dictionary_Open(_windowtype, _position, _ajax){
		var modalwindow = document.getElementById('ModalWindow_'+_windowtype);
		SetPosition(modalwindow, 'modal', _position);
		modalwindow.style.display = 'block';
		sIFR.replaceElement(named({sSelector:"div.div_subheadline", sFlashSrc:"/_sifr/Univers57Cond.swf", sColor:"#333333", sWmode:"transparent"}));

		CloseModalWindow();
		ActiveModalWindow = _windowtype;
	}

	function OpenDictionary()
	{
		var selectedText = '';
		if(Prototype.Browser.IE)
		{
			try
			{
				selectedText = document.selection.createRange().text;
			}
			catch(err)
			{
				selectedText = '';
			}
		}
		else
		{
			try
			{
				selectedText = window.getSelection().getRangeAt(0).toString();
			}
			catch(err)
			{
				selectedText = '';
			}
		}
		if(!selectedText.match(/^\s*$/))
		{
			$('td_dict_results').hide();
			$('td_dict_working').show();

			CursorSelectedText = selectedText;
			DefinitionNumber = 0;
			var url = '/ajax/template/dictionary?q='+ encodeURIComponent(selectedText);
			new Ajax.Request(url, { onComplete:Dictionary_Response });
		}
	}

	function FetchNthDefinition(_nth)
	{
		var url = '/ajax/template/dictionary?q='+encodeURIComponent(CursorSelectedText)+'&o='+_nth;
		new Ajax.Request(url, { onComplete:Dictionary_Response });
	}

	function Dictionary_Response(_response){
		if(_response == "error"){
			alert("there was an error");
		}
		else
		{
			$('td_dict_working').hide();
			$('td_dict_results').update(_response.responseText).show();
		}
	}

//END RIGHTBLOCK_DICTIONARY JS
