// JavaScript Documentfunction StorySelectorWrapper(storySelector){	this.storySelector = storySelector;	this.showStory = function(selectedStory)	{		this.storySelector.showStory(selectedStory);	}	this.setSelector = function(storySelector)	{		this.storySelector = storySelector;	}}function StorySelector(wrapper/*must be the name of the object passed*/,targetID/*OPTIONAL*/){	this.domHelper = new DomHelper();	this.selectorString = "";	this.stories = new Array();	this.storyTitles = new Array();	this.storyIDs = new Array();	this.targetID = targetID;	this.addStory = function(storyBody/*String*/,storyTitle/*String*/)	{		//alert(storyBody);		this.stories.push(storyBody);		this.storyTitles.push(storyTitle);		this.storyIDs.push(storyTitle.replace(/ /g,""));	}	this.makeStories = function()	{		for(var i=0; i<this.stories.length; i++)		{			this.selectorString += '<div class="selectorStory" id="'+this.storyIDs[i]+'" style="display:none;">';			this.selectorString += '<div class="selectorTitle">';			this.selectorString += this.storyTitles[i];			this.selectorString += '<\/div>';			this.selectorString += '<div class="selectorBody">';			this.selectorString += this.stories[i];			this.selectorString += '<\/div>';			this.selectorString += '<\/div>';		}	}		this.buildForm = function(label, needBlank)	{		this.selectorString += '<form name="selectorForm" id="selectorForm">';		this.selectorString += '<span id="selectorLabel">'+label+'<\/span><select name="selectorBox" id="selectorBox" onchange="wrapper.showStory(document.selectorForm.selectorBox[document.selectorForm.selectorBox.selectedIndex].value);">';		if(needBlank)		{			this.selectorString += '<option selected value="" ><\/option>';		}		for(var i=0; i<this.storyTitles.length; i++)		{			var tempTitle = this.storyTitles[i];			if(tempTitle.length > 35)			{				tempTitle = tempTitle.substring(0, 35);				tempTitle += "...";			}			this.selectorString += '<option value="'+this.storyIDs[i]+'">'+tempTitle+'<\/option>';		}		this.selectorString += '<\/select>';		this.selectorString += '<\/form>';	}		this.showStory = function(selectedStory)	{				////alert(selectedStory);		if(selectedStory!="")		{			this.hideOthers();			var targetElement = this.domHelper.getTarget(selectedStory);			////alert(targetElement);			targetElement.style.display = "block";		}	}		this.hideOthers = function()	{		for(var i=0; i<this.stories.length; i++)		{			var targetElement = this.domHelper.getTarget(this.storyIDs[i]);			targetElement.style.display = "none";		}	}	 	this.makeSelector = function(writeIt/*boolean*/, label, showInitial, needBlank)	{		this.buildForm(label, needBlank);		this.makeStories();		if(writeIt)		{			//alert(this.selectorString);			document.write(this.selectorString);		}		else		{			var targetElement = this.domHelper.getTarget(this.targetID)			{				targetElement.innerHTML = this.selectorString;			}		}		document.selectorForm.selectorBox.options[0].selected = true;		if(showInitial)		{			this.showStory(document.selectorForm.selectorBox.options[0].value);		}	}	}
