/********************************************************************************** * 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-image var autoImage = document.getElementById('autoImage'); // Ensure Array Exists & they want this displayed on the current page if( autoImages != null && typeof( autoImages ) != undefined && autoImage != null ) { // Store the name, title and colour for our image var imageName = null; var imageTitle = null; var imageColour = null; var imageLink = null; // Grab a random number and save the information from the array var randomImage = Math.floor( Math.random() * autoImages.length ); if( autoImages[randomImage] != null && autoImages[randomImage][ImageName] != null && autoImages[randomImage][ImageTitle] != null ) { // Store the information for name, title and colour imageName = autoImages[randomImage][ImageName]; imageTitle = autoImages[randomImage][ImageTitle]; if( autoImages[randomImage][ImageColour] != null ) { imageColour = autoImages[randomImage][ImageColour]; } if( autoImages[randomImage][ImageLink] != null ) { imageLink = autoImages[randomImage][ImageLink]; } } // Ensure if either the name or title is blank, then we check all images in order for a valid name and title if( imageName == null || imageTitle == null ) { for( var i = 0; i < autoImages.length; i++ ) { if( autoImages[i] != null && autoImages[i][ImageName] != null && autoImages[i][ImageTitle] != null ) { imageName = autoImages[i][ImageName]; imageTitle = autoImages[i][ImageTitle]; if( autoImages[i][ImageColour] != null ) { imageColour = autoImages[i][ImageColour]; } if( autoImages[randomImage][ImageLink] != null ) { imageLink = autoImages[randomImage][ImageLink]; } break; } } } // Now we build and output the image as necessary if( imageName != null && imageTitle != null ) { // Hold the image colour var imageTitleClass; // Determine the colour for our title if( imageColour != null ) { switch( imageColour ) { case 0: imageTitleClass = "titleOrange"; break; case 1: imageTitleClass = "titleBlue"; break; case 2: imageTitleClass = "titleYellow"; break; case 3: imageTitleClass = "titleGreen"; break; case 4: imageTitleClass = "titleRed"; break; default: imageTitleClass = "titleYellow"; break; } } // Build and display our output var output; // Add our h2 title output = '