/*
 * DO NOT REMOVE THIS NOTICE
 *
 * PROJECT:   Clearbrook Farm Website
 * VERSION:   1.2
 * DATE:		March 23, 2009
 * COPYRIGHT: (c) 2008 Forrest Snyder
 * LINK:      http://www.forrestsnyder.com
 */


/*********************************BEGIN CREATE WINDOW SCRIPT*******************************/

function createWindow(cwUrl,cwName,cwFeatures) {
	var xWin = window.open(cwUrl,cwName,cwFeatures)
}

/*********************************END CREATE WINDOW SCRIPT*******************************/

/*********************************BEGIN RANDOM IMAGE SCRIPT (HEADER IMAGES)*******************************/


// RIL1.0 :: Random image link      HEADER IMAGE HEADER IMAGE HEADER IMAGE
// ***********************************************
// DOM scripting by brothercake -- http://www.brothercake.com/
// Original concept by Andy Clarke -- http://www.stuffandnonsense.co.uk/
// Create element and attributes based on a method by beetle -- http://www.peterbailey.net/
// +++++++ MODIFIED BY FORREST 3-31-2009 ++++++++
//************************************************


//open initialisation function 
function randomImageLink() { 
//************************************************

/*****************************************************************************
 Define image links
*****************************************************************************/

//identify an image link ('link-id')
var button = new imageLink('someimage');

//add possibilities ('href', 'title text', 'src', 'width', 'height', 'alt text')
button.addLink(' ', 'Clearbrook Farm.', 'images/headers/07farmbacksidehead.jpg', '830', '240', 'Clearbrook Farm.');
button.addLink(' ', 'Flats of new lettuces.', 'images/headers/07lettuceflatshead.jpg', '830', '240', 'Flats of new lettuces.');
button.addLink(' ', 'Flowers along our garden wall.', 'images/headers/07gardenwallhead.jpg', '830', '240', 'Flowers along our garden wall.');
button.addLink(' ', 'A load of fresh vegetables.', 'images/headers/07veggieloadhead.jpg', '830', '240', 'A load of fresh vegetables.');
button.addLink(' ', 'A field of sunflowers.', 'images/headers/07sunflowershead.jpg', '830', '240', 'A field of sunflowers.');
button.addLink(' ', 'A flowering field.', 'images/headers/07springrapehead.jpg', '830', '240', 'A flowering field.');
button.addLink(' ', 'Fall mums.', 'images/headers/07fallmumshead.jpg', '830', '240', 'Fall mums.');
button.addLink(' ', 'Romanescoe and cabbages.', 'images/headers/07colebasketshead.jpg', '830', '240', 'Romanescoe and cabbages.');
button.addLink(' ', 'Bell peppers!', 'images/headers/07bellpeppershead.jpg', '830', '240', 'Bell peppers!');
button.addLink(' ', 'Flowers inside a greenhouse.', 'images/headers/07grnhshanginghead.jpg', '830', '240', 'Flowers inside a greenhouse.');
button.addLink(' ', 'Glorious flats of plants.', 'images/headers/07gloriousflatshead.jpg', '830', '240', 'Glorious flats of plants.');
button.addLink(' ', 'Farm field and woods.', 'images/headers/07fieldwoodshead.jpg', '830', '240', 'Farm field and woods.');

//select a possibility at random
button.selectLink();


/*****************************************************************************
*****************************************************************************/

//close initialisation function
};


//image link constructor
function imageLink(linkid)
{
	//set link object
	this.link = document.getElementById(linkid);
	
	//create an empty array of possible links
	this.possibles = [];
};


//add a possibility 
imageLink.prototype.addLink = function()
{
	//store arguments in possible links array
	this.possibles[this.possibles.length] = arguments;
};


//select a possibility at random 
imageLink.prototype.selectLink = function()
{
	//if the link exists
	if(this.link != null)
	{
		//get a random item from the array
		this.rnd = this.possibles[Math.floor(Math.random() * this.possibles.length)];
		
		//set new link attributes 
		this.link.href = this.rnd[0];
		this.link.title = this.rnd[1];
		
		//get image object inside it
		this.img = this.link.getElementsByTagName('img')[0];
		
		//if it exists
		if(this.img != null)
		{
			//set new image attributes
			this.img.src = this.rnd[2]; 
			this.img.width = this.rnd[3]; 
			this.img.height = this.rnd[4]; 
			this.img.alt = this.rnd[5]; 
		}
	}
};


//call initialisation function if supported
if(typeof document.getElementById != 'undefined') { randomImageLink(); }

/*********************************END OF RANDOM IMAGE SCRIPT*******************************/

