<!--








function RSS_Simple_CreateObject(BoxID,
				
				HTML,
				
				URL,
				Items,
				SnippetLength,
				Target,
				ShowLogo
				)
{
	
	HTML = UnXML(HTML);
	URL = UnXML(URL);
	
	var BoxObject = Boxes.Objects[BoxID];

	if (!BoxObject.RSS_Simple)
	{//If object not initialized yet...
		BoxObject.RSS_Simple = new Object; //Creating a RSS_Simple instance inside the box if not existing already
		
		BoxObject.RSS_Simple.Save_Handler = new XMLHTTPEngine("RSS_Simple_Save","","POST"); //Creates RSS_SimpleSave Ajax Handler for the box
		BoxObject.RSS_Simple.Save_Handler.onLoad = RSS_Simple_Save_Handler_onLoad; //Links the onload function
		BoxObject.RSS_Simple.Save_Handler.BoxID = BoxID; //Saves the BoxID
		BoxObject.RSS_Simple.Save_Handler.BoxObject = BoxObject; //Saves the BoxID
		
		BoxObject.RSS_Simple.RSS = document.createElement("DIV");
		BoxObject.RSS_Simple.RSS.style.width="100%";
		BoxObject.RSS_Simple.RSS.style.display="";
		BoxObject.RSS_Simple.RSS.ondblclick=RSS_Simple_onClick;
		BoxObject.Content.appendChild(BoxObject.RSS_Simple.RSS);

		BoxObject.RSS_Simple.EditTool = document.createElement("DIV");
		BoxObject.RSS_Simple.EditTool.style.width="100%";
		BoxObject.RSS_Simple.EditTool.style.overflow="hidden";
		BoxObject.RSS_Simple.EditTool.style.display="none";

			var EditTable = document.createElement("TABLE");
			EditTable.className = 'box_table_nospace';
			EditTable.style.width="100%";
	
			var Row_URL = EditTable.insertRow(0);
			var Row_Items = EditTable.insertRow(1);
			var Row_Target = EditTable.insertRow(2);
			
			var TMP_Cell;
			var TMP_Element;
			var TMP_Option;
	
				TMP_Cell = Row_URL.insertCell(0);
				TMP_Cell.width = "40px";
				TMP_Element = document.createElement("SPAN");
				TMP_Element.style.fontSize = "10px";
				TMP_Element.innerHTML = "URL:";
				TMP_Cell.appendChild(TMP_Element);
	
				TMP_Cell = Row_URL.insertCell(1);
				TMP_Cell.colSpan=3;
				TMP_Element = document.createElement("DIV");
				TMP_Element.style.width = "100%";
				/*TMP_Cell.style.colSpan=3;
				if (TMP_Cell.setExpression) {TMP_Cell.setExpression("colspan","3")};
				if (TMP_Cell.setAttribute) {TMP_Cell.setAttribute("colspan", "3")};*/
				BoxObject.RSS_Simple.EditTool.URL = document.createElement("INPUT");
				BoxObject.RSS_Simple.EditTool.URL.style.width = "100%";
				BoxObject.RSS_Simple.EditTool.URL.style.styleFloat = "left";
				TMP_Element.appendChild(BoxObject.RSS_Simple.EditTool.URL);
				TMP_Cell.appendChild(TMP_Element);
	
	
				TMP_Cell = Row_Items.insertCell(0);
				TMP_Cell.width = "40px";
				TMP_Element = document.createElement("SPAN");
				TMP_Element.innerHTML = "Items:";
				TMP_Element.style.fontSize = "10px";
				TMP_Cell.appendChild(TMP_Element);
	
				TMP_Cell = Row_Items.insertCell(1);
				TMP_Cell.width = "50%"
				TMP_Element = document.createElement("DIV");
				TMP_Element.style.width = "100%";
				BoxObject.RSS_Simple.EditTool.Items = document.createElement("SELECT");
				BoxObject.RSS_Simple.EditTool.Items.style.width = "100%";
				BoxObject.RSS_Simple.EditTool.Items.style.styleFloat = "left";
					for (var RunIndex=1; RunIndex<=10; RunIndex++)
					{
						TMP_Option = document.createElement("OPTION"); 
						TMP_Option.value=RunIndex;
						TMP_Option.innerHTML=RunIndex;
						BoxObject.RSS_Simple.EditTool.Items.appendChild(TMP_Option);
					}
					TMP_Option = document.createElement("OPTION"); TMP_Option.value=15; TMP_Option.innerHTML=15; BoxObject.RSS_Simple.EditTool.Items.appendChild(TMP_Option);
					TMP_Option = document.createElement("OPTION"); TMP_Option.value=20; TMP_Option.innerHTML=20; BoxObject.RSS_Simple.EditTool.Items.appendChild(TMP_Option);
					TMP_Option = document.createElement("OPTION"); TMP_Option.value=25; TMP_Option.innerHTML=25; BoxObject.RSS_Simple.EditTool.Items.appendChild(TMP_Option);
					TMP_Option = document.createElement("OPTION"); TMP_Option.value=50; TMP_Option.innerHTML=50; BoxObject.RSS_Simple.EditTool.Items.appendChild(TMP_Option);

					TMP_Element.appendChild(BoxObject.RSS_Simple.EditTool.Items);
				TMP_Cell.appendChild(TMP_Element);
	
				TMP_Cell = Row_Items.insertCell(2);
				TMP_Cell.width = "50px"
				TMP_Element = document.createElement("SPAN");
				TMP_Element.innerHTML = "Snippet:";
				TMP_Element.style.fontSize = "10px";
				TMP_Cell.appendChild(TMP_Element);
	
				TMP_Cell = Row_Items.insertCell(3);
				TMP_Cell.width = "50%"
				TMP_Element = document.createElement("DIV");
				TMP_Element.style.width = "100%";
				BoxObject.RSS_Simple.EditTool.SnippetLength = document.createElement("SELECT");
				BoxObject.RSS_Simple.EditTool.SnippetLength.style.width = "100%";
				BoxObject.RSS_Simple.EditTool.SnippetLength.style.styleFloat = "left";
					TMP_Option = document.createElement("OPTION"); TMP_Option.value=0; TMP_Option.innerHTML="None"; BoxObject.RSS_Simple.EditTool.SnippetLength.appendChild(TMP_Option);
					TMP_Option = document.createElement("OPTION"); TMP_Option.value=32; TMP_Option.innerHTML="Tiny"; BoxObject.RSS_Simple.EditTool.SnippetLength.appendChild(TMP_Option);
					TMP_Option = document.createElement("OPTION"); TMP_Option.value=64; TMP_Option.innerHTML="Short"; BoxObject.RSS_Simple.EditTool.SnippetLength.appendChild(TMP_Option);
					TMP_Option = document.createElement("OPTION"); TMP_Option.value=512; TMP_Option.innerHTML="Medium"; BoxObject.RSS_Simple.EditTool.SnippetLength.appendChild(TMP_Option);
					TMP_Option = document.createElement("OPTION"); TMP_Option.value=4096; TMP_Option.innerHTML="Long"; BoxObject.RSS_Simple.EditTool.SnippetLength.appendChild(TMP_Option);
				TMP_Element.appendChild(BoxObject.RSS_Simple.EditTool.SnippetLength);
				TMP_Cell.appendChild(TMP_Element);


				TMP_Cell = Row_Target.insertCell(0);
				TMP_Element = document.createElement("SPAN");
				TMP_Element.innerHTML = "Open in:";
				TMP_Element.style.fontSize = "10px";
				TMP_Cell.appendChild(TMP_Element);
	
				TMP_Cell = Row_Target.insertCell(1);
				TMP_Element = document.createElement("DIV");
				TMP_Element.style.width = "100%";
				BoxObject.RSS_Simple.EditTool.Target = document.createElement("SELECT");
				BoxObject.RSS_Simple.EditTool.Target.style.width = "100%";
				BoxObject.RSS_Simple.EditTool.Target.style.styleFloat = "left";
					TMP_Option = document.createElement("OPTION"); TMP_Option.value=0; TMP_Option.innerHTML="Same"; BoxObject.RSS_Simple.EditTool.Target.appendChild(TMP_Option);
					TMP_Option = document.createElement("OPTION"); TMP_Option.value=1; TMP_Option.innerHTML="New"; BoxObject.RSS_Simple.EditTool.Target.appendChild(TMP_Option);
				TMP_Element.appendChild(BoxObject.RSS_Simple.EditTool.Target);
				TMP_Cell.appendChild(TMP_Element);
	
				TMP_Cell = Row_Target.insertCell(2);
				TMP_Element = document.createElement("SPAN");
				TMP_Element.innerHTML = "Show source?:";
				TMP_Element.style.fontSize = "10px";
				TMP_Cell.appendChild(TMP_Element);
	
				TMP_Cell = Row_Target.insertCell(3);
				TMP_Element = document.createElement("DIV");
				TMP_Element.style.width = "100%";
				BoxObject.RSS_Simple.EditTool.ShowLogo = document.createElement("SELECT");
				BoxObject.RSS_Simple.EditTool.ShowLogo.style.width = "100%";
				BoxObject.RSS_Simple.EditTool.ShowLogo.style.styleFloat = "left";
					TMP_Option = document.createElement("OPTION"); TMP_Option.value=0; TMP_Option.innerHTML="None"; BoxObject.RSS_Simple.EditTool.ShowLogo.appendChild(TMP_Option);
					TMP_Option = document.createElement("OPTION"); TMP_Option.value=1; TMP_Option.innerHTML="More"; BoxObject.RSS_Simple.EditTool.ShowLogo.appendChild(TMP_Option);
					TMP_Option = document.createElement("OPTION"); TMP_Option.value=2; TMP_Option.innerHTML="Text"; BoxObject.RSS_Simple.EditTool.ShowLogo.appendChild(TMP_Option);
					TMP_Option = document.createElement("OPTION"); TMP_Option.value=3; TMP_Option.innerHTML="Image"; BoxObject.RSS_Simple.EditTool.ShowLogo.appendChild(TMP_Option);
				TMP_Element.appendChild(BoxObject.RSS_Simple.EditTool.ShowLogo);
				TMP_Cell.appendChild(TMP_Element);

	
			BoxObject.RSS_Simple.EditTool.appendChild(EditTable);
		
		BoxObject.Content.appendChild(BoxObject.RSS_Simple.EditTool);


		BoxObject.RSS_Simple.ActionBar = document.createElement("CENTER");
		BoxObject.RSS_Simple.ActionBar.style.width="100%";
		BoxObject.RSS_Simple.ActionBar.style.display="none";

			BoxObject.RSS_Simple.CancelButton = document.createElement("INPUT");
			BoxObject.RSS_Simple.CancelButton.type="button";
			BoxObject.RSS_Simple.CancelButton.value="Cancel";
			BoxObject.RSS_Simple.CancelButton.onclick=RSS_Simple_CancelEdit;
			BoxObject.RSS_Simple.ActionBar.appendChild(BoxObject.RSS_Simple.CancelButton);
			
			BoxObject.RSS_Simple.SaveButton = document.createElement("INPUT");
			BoxObject.RSS_Simple.SaveButton.type="button";
			BoxObject.RSS_Simple.SaveButton.value="Save";
			BoxObject.RSS_Simple.SaveButton.onclick=RSS_Simple_SaveEdit;
			BoxObject.RSS_Simple.ActionBar.appendChild(BoxObject.RSS_Simple.SaveButton);

		BoxObject.Content.appendChild(BoxObject.RSS_Simple.ActionBar);

		//Assigns edit function
		BoxObject.EditBox = RSS_Simple_Edit;

		//Free up memory
		Row_URL = null;
		Row_Items = null;
		Row_Target = null;
		TMP_Cell = null;
		TMP_Element = null;
		TMP_Option = null;
	}


	//Resets visuals
	BoxObject.RSS_Simple.RSS.style.display="";
	BoxObject.RSS_Simple.EditTool.style.display="none";
	BoxObject.RSS_Simple.ActionBar.style.display="none";

	Box_UpdateLoadStatus(BoxObject,"");
	BoxObject.RSS_Simple.RSS.innerHTML=HTML;

	BoxObject.RSS_Simple.EditTool.URL.value = URL;
	BoxObject.RSS_Simple.EditTool.Items.value = Items;
	BoxObject.RSS_Simple.EditTool.SnippetLength.value = SnippetLength;
	BoxObject.RSS_Simple.EditTool.Target.value = Target;
	BoxObject.RSS_Simple.EditTool.ShowLogo.value = ShowLogo;

	BoxObject.RSS_Simple.EditMode = false;
}





function RSS_Simple_onClick(Event)
{
	//Debug_Reset();
	//Debug(document.body.innerHTML);

	RSS_Simple_Edit(Boxes.GetContainingBox(this));
	
	
	//Free up memory
	BoxObject = null;

	return(false);
}



function RSS_Simple_Edit(BoxObject)
{
	if (!BoxObject.RSS_Simple.EditMode)
	{
		//Entering edit mode
		BoxObject.RSS_Simple.EditMode = true;
		
		BoxObject.RSS_Simple.RSS.style.display="none";

		BoxObject.RSS_Simple.EditTool.style.display="";
		BoxObject.RSS_Simple.ActionBar.style.display="";


		//Save values
		//BoxObject.RSS_Simple.EditTool.value = BoxObject.RSS_Simple.CurrentBBCode;

		BoxObject.RSS_Simple.EditTool.focus();
	}
}


function RSS_Simple_CancelEdit(Event)
{
	var BoxObject = Boxes.GetContainingBox(this);
	
	if (BoxObject.RSS_Simple.EditMode)
	{
		//Entering edit mode
		BoxObject.RSS_Simple.EditMode = false;
		
		BoxObject.RSS_Simple.RSS.style.display="";

		BoxObject.RSS_Simple.EditTool.style.display="none";
		BoxObject.RSS_Simple.ActionBar.style.display="none";
	}
	
	EditBox_Finished(BoxObject.BoxID);
	
	//Free up memory
	BoxObject = null;

	return(false);
}




function RSS_Simple_SaveEdit(Event)
{
	var BoxObject = Boxes.GetContainingBox(this);
	
	if (BoxObject.RSS_Simple.EditMode)
	{
		//Entering edit mode
		BoxObject.RSS_Simple.EditMode = false;
		
//		BoxObject.RSS_Simple.Text.innerHTML=RSS_Simple_ProcessBBCode(BoxObject.RSS_Simple.EditTool.value);
		Box_UpdateLoadStatus(BoxObject,"updating");
//		BoxObject.RSS_Simple.RSS.innerHTML="<center>Updating...</center>";
		BoxObject.RSS_Simple.RSS.style.display="";
		BoxObject.RSS_Simple.EditTool.style.display="none";
		BoxObject.RSS_Simple.ActionBar.style.display="none";

		//Storing the current HTML and BBCode as backup
//		BoxObject.RSS_Simple.CurrentHTML = BoxObject.RSS_Simple.Text.innerHTML;
		
		RSS_Simple_Save_Server(BoxObject.RSS_Simple.Save_Handler,BoxObject.RSS_Simple.EditTool.URL.value,BoxObject.RSS_Simple.EditTool.Items.value,BoxObject.RSS_Simple.EditTool.SnippetLength.value,BoxObject.RSS_Simple.EditTool.Target.value,BoxObject.RSS_Simple.EditTool.ShowLogo.value);
	}
	
	EditBox_Finished(BoxObject.BoxID);

	//Free up memory
	BoxObject = null;

}








RSS_Simple_Save_Handler_onLoad = function(Handler)
{//Function executed upon response from server
	
	function Save_Revert(Reason)
	{//In case of failure to reorder box - Revert/Alert about box reorder failure
		window.alert(Reason); //Alerting the failure reason
		Box_UpdateLoadStatus(Handler.BoxObject,"");
		Handler.BoxObject.Text.innerHTML = "";
		//Handler.BoxObject.Text.innerHTML = Handler.BoxObject.CurrentHTML;
	}
	
	var Response = Handler.getXML();
	if (!Response)
	{//Invalid result retuned
		Save_Revert("No server response");
		Response = null; //Free up memory
		return(false);
	}
	
	var XMLroot = Response.getElementsByTagName('root').item(0);
	Response = null; //Free up memory

	if (!XMLroot)
	{//Invalid result retuned
		Save_Revert("Invalid server XML response");
		XMLroot = null; //Free up memory
		return(false);
	} 
	
	var Status = XMLroot.getElementsByTagName('status').item(0);
	if (!Status)
	{//Invalid result retuned
		Save_Revert("No status reported");
		Status = null; XMLroot = null; //Free up memory
		return(false);
	} 

	var StatusID = Status.getElementsByTagName('status_id').item(0); 
	StatusID = StatusID?StatusID.childNodes.item(0).data:0;
	
	var StatusMessage = Status.getElementsByTagName('status_message').item(0); 
	StatusMessage = StatusMessage?StatusMessage.childNodes.item(0).data:'Unknown';
	
	if (StatusID != 1)
	{
		Save_Revert(StatusMessage);
		StatusID = null; StatusMessage = null; Status = null; XMLroot = null; //Free up memory
		return(false);
	}
	
	//Free up memory
	StatusID = null;
	StatusMessage = null;
	Status = null;

	//Else

	var DataSet = XMLroot.getElementsByTagName('data').item(0);
	if (!DataSet)
	{//Failed to receive data from server regarding the renaming box - Unexpected error - Reverting rename
		Save_Revert("No data reported");
		DataSet = null; Response = null; //Free up memory
		return(false);
	}
	
	var BoxID = DataSet.getElementsByTagName('box_id').item(0);
	BoxID = (BoxID.childNodes.item(0))?parseInt(BoxID.childNodes.item(0).data):false;

	var BoxContent = DataSet.getElementsByTagName('box_content').item(0);
	BoxContent = MergeChildrenItems(BoxContent.childNodes);

	var BoxScript = DataSet.getElementsByTagName('box_script').item(0);
	BoxScript = MergeChildrenItems(BoxScript.childNodes);

	var BoxPrerequisiteScripts = DataSet.getElementsByTagName('box_prerequisitescripts').item(0);
	BoxPrerequisiteScripts = (BoxPrerequisiteScripts.childNodes.item(0))?BoxPrerequisiteScripts.childNodes.item(0).data:"";

	var BoxScriptCode = DataSet.getElementsByTagName('box_scriptcode').item(0);
	BoxScriptCode = MergeChildrenItems(BoxScriptCode.childNodes);

	if (!BoxID)
	{//Bad/missing BoxID or title - Unexpected error - reverts rename
		Save_Revert("Missing Box details in response");
		BoxID = null; DataSet = null; XMLroot = null; //Free up memory
		return(false);
	}
	else
	{
		Box_UpdateLoadStatus(Handler.BoxObject,"");
		eval(BoxScriptCode);
	};
	
	//Free up memory
	BoxID = null;
	BoxContent = null;
	BoxScript = null;
	BoxScriptCode = null;
	DataSet = null;
	XMLroot = null;
};




function RSS_Simple_Save_Server(Handler,URL,Items,SnippetLength,Target,ShowLogo)
{//Call server to with Box Order command via Ajax
 //Allow multiple saves - it's up to the user
	try 
	{
		Handler.URL='/cgi-bin/profile/boxes/rss_simple.pl?usk='+USK+'&act=save&bid='+Handler.BoxID;
		Handler.resetData();
		Handler.addData("URL",URL);
		Handler.addData("Items",Items);
		Handler.addData("SnippetLength",SnippetLength);
		Handler.addData("Target",Target);
		Handler.addData("ShowLogo",ShowLogo);
		
		Debug("Calling "+Handler.URL);
		
		Handler.Execute(); //Execute server call
	}
	catch (e)
	{//Error - Could not call server
		//(?)
	};
};









function RSS_Simple_Init()
{
	if (!Boxes.LoadedScripts['rss_simple'])
	{
		Boxes.LoadedScripts['rss_simple'] = new Object;
		Boxes.LoadedScripts['rss_simple'].StatusID=1; //Marking script as load-pendin
		Boxes.LoadedScripts['rss_simple'].DelayedCommands = "";
	}
	else
	{
		Boxes.LoadedScripts['rss_simple'].StatusID=1; //Flagging script as loaded
		//Debug(Boxes.LoadedScripts['rss_simple'].DelayedCommands);
		eval(Boxes.LoadedScripts['rss_simple'].DelayedCommands);//Executes the delayed commands
	}
}



RSS_Simple_Init();

-->
