/********************************************************************************** * Author: David Millar (www.rTraction.com) * * Date: January. 1, 2007 * * Purpose: Automatically select an image, title, and title bar colour at random * * * ********************************************************************************** * Revision 1.1: added functionality to link to our site or external sites * ********************************************************************************** * Revision 1.0: create a script that creates the hmlt output for the automatic * * image that is displayed on most pages in the bottom of the right * * column (randomly selected from a list specified in * * auto-image-list.js * **********************************************************************************/ // Grab our right side section for auto-story var autoStory = document.getElementById('mystory'); // Ensure Array Exists & they want this displayed on the current page if( autoStories != null && typeof( autoStories ) != undefined && autoStories != null ) { // Store the text, and link for our story var storyText = null; var storyLink = null; // Grab a random number and save the information from the array var randomStory = Math.floor( Math.random() * autoStories.length ); if( autoStories[randomStory] != null && autoStories[randomStory][StoryText] != null && autoStories[randomStory][StoryLink] != null ) { // Story the information for the text and link storyText = autoStories[randomStory][StoryText]; storyLink = autoStories[randomStory][StoryLink]; } // Ensure if either the text or link is blank, then we check all stories in order for a valid text and link if( storyText == null || storyLink == null ) { for( var i = 0; i < autoStories.length; i++ ) { if( autoStories[i] != null && autoStories[i][StoryText] != null && autoStories[i][StoryLink] != null ) { storyText = autoStories[i][StoryText]; storyLink = autoStories[i][StoryLink]; break; } } } // Now we build and output the image as necessary if( storyText != null && storyLink != null ) { // Build and display our output var output; // Add our h2 title output = '

'; output = output + '> Story Gallery'; output = output + '

'; // Add our div container output = output + '
'; // Add our p container output = output + '

'; // Add our text output = output + storyText + '
'; // Add a link output = output + 'Learn more'; // Close our p container output = output + '

'; // Close our div container output = output + '
'; // Add our output to the autoImage container autoStory.innerHTML = output; } }