/*
	rotate banners

	7/8/05 RedLime Web Development
	limes@redlimeweb.com

	12/28/05 - allow for two dissimilar features

	supply feature images, urls, alts, and titles
	simply call rotateBanners()
*/

//  how many features?
var numFeatures = 4

//  override rand for testing: true or false
var override = false
//  iced tea is now permanent
var overrideNum = 4

//  not using preload array cuz we don't need to waste the time
fimage1 = "banners/lbt-468x60.gif"
fimage2 = "banners/lbt-468x60.gif"
fimage3 = "banners/shea-radiance-460x60.gif"
fimage4 = "banners/elements-468x60.gif"

//  corresponding urls
url1 = "http://lipbalmtubes.com"
url2 = "http://www.lipbalmtubes.com"
url3 = "http://www.shearadiance.com"
url4 = "http://www.elementsbathandbody.com"

//  corresponding alt text
alt1 = "Lip Balm Tubes"
alt2 = "Lip Balm Tubes"
alt3 = "Shea Radiance"
alt4 = "Wholesale Bath & Body Supplies"

//  corresponding title text
title1 = "Lip Balm Supplies"
title2 = "Lip Balm Supplies"
title3 = "Shea Radiance"
title4 = "Elements Bath and Body"

//  set up random number seeds
rnd.today = new Date()
rnd.seed = rnd.today.getTime()

//  return random base for making random number
function rnd() {
	rnd.seed = (rnd.seed*9301+49297) % 233280
	return rnd.seed/(233280.0)
};

//  build the real random integer
var rand = Math.ceil(rnd()*numFeatures)

//  override rand for testing
if (override) { rand = overrideNum }

//  second random integer
var rand2 = rand
while (rand2 == rand)
	rand2 = Math.ceil(rnd()*numFeatures)

//  sets feature attributes randomly
//  feature - id name of feature a
//  fnum - feature number, which one
//  band - bandwidth, low or high
function rotateBanners(feature,fnum,band) {
	var bannerRotation = document.getElementById(feature)

	//  which random number to use?
	var fran = (fnum == 1) ? rand : rand2

	var title = eval("title" + fran)

	if (band == "low") {
		var content = title
		bannerRotation.innerHTML = content
	} else {
		var feat = eval("document." + feature)
		feat.src = eval("fimage" + fran)
		feat.alt = eval("alt" + fran)
	}

	bannerRotation.href = eval("url" + fran)
	bannerRotation.title = title
}
