﻿//	Custom Script: Random Image Generator
//	Modified for use at Schumacher's Nursery &amp; Berry Farm, Inc. - www.schumachersnursery.com
//	Authored by IDEaS Computers - http://www.ideascomputers.com
//	Copyright ©2008 IDEaS Computers, All Rights Reserved.

function HeaderImgRotate ()
{
	if (!document.getElementById) return false;

	var _imgdir = "/Portals/25/Skins/SCHU-V3-S/images/header-images-small/";
	var _imgcontainer = "header-image";
	var _imgcount = 12;

	if (!document.getElementById(_imgcontainer)) return false;

	var _bgimages = new Array();
	_bgimages[0] = "header-images-001.jpg";
	_bgimages[1] = "header-images-002.jpg";
	_bgimages[2] = "header-images-003.jpg";
	_bgimages[3] = "header-images-004.jpg";
	_bgimages[4] = "header-images-005.jpg";
	_bgimages[5] = "header-images-006.jpg";
	_bgimages[6] = "header-images-007.jpg";
	_bgimages[7] = "header-images-008.jpg";
	_bgimages[8] = "header-images-009.jpg";
	_bgimages[9] = "header-images-010.jpg";
	_bgimages[10] = "header-images-011.jpg";
	_bgimages[11] = "header-images-012.jpg";
	
	var _divgrab = document.getElementById(_imgcontainer);
	var _bgstyle = _divgrab.style.backgroundImage;
	var _imgurl = "url(" + _imgdir + _bgimages[rand(_bgimages.length)] + ")";
	

	if (_bgstyle != _imgurl) {
		_divgrab.style.backgroundImage = _imgurl;
	}

	function rand(n) {
		return ( Math.floor ( Math.random ( ) * n ) );
	}
}

// Custom onload event

function addLoadEvent(func) 
{
    var oldonload = window.onload;
	if (typeof window.onload != 'function') 
	{
        window.onload = func;
		} 
	else 
	{
        window.onload = function() 
		{
		    oldonload();
			func();
			}
		}
}

// Fire onload event

addLoadEvent(HeaderImgRotate);

