// JavaScript Document

// Slideshow code
// Original code Copyright 2001-2002 All rights reserved, by Paul Davis - www.kaosweaver.com
// Alterations by Ben MacKay Copyright 2008 - The Socrates Group

function LoadMap() {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map"));
		map.setCenter(new GLatLng(48.971500,-122.443000), 13);
		var marker = new GMarker(new GLatLng(48.965000,-122.443000));
		map.addOverlay(marker);
		
		var html="<h1>Martin&rsquo;s Feed, Inc.</h1><p>69 East Badger Road<br />Lynden, WA 98264</p>";
		marker.openInfoWindowHtml(html);
		
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
	}
}


var SlideShowStack = new Array();

function RunSlideShow() {
	eval(SlideShowStack.shift());
	window.setTimeout("RunSlideShow()", 3000);
}

function RandomSlideShow(SlideShowID, ImageID) {
	this.SlideShowID = SlideShowID;
	this.ImageID = ImageID;
	
	this.ImageListIndex = 0;
	this.l = 0;
	this.ImageList = new Array();
}

RandomSlideShow.prototype.Initialize = function()
{
	this.ImageListIndex=parseInt(Math.random()*this.ImageList.length);
	this.ImageListIndex=(isNaN(this.ImageListIndex))?0:this.ImageListIndex;
	document.getElementById(this.ImageID).src = this.ImageList[this.ImageListIndex];
	
	SlideShowStack.push(this.SlideShowID + ".SwitchPhoto()");
		
};

RandomSlideShow.prototype.AddImageToSlideShow = function(ImageSrc)
{
	this.ImageList[this.ImageList.length] = ImageSrc;
};

RandomSlideShow.prototype.SwitchPhoto = function()
{
	this.ImageListIndex=this.l;
	while (this.l==this.ImageListIndex) {
		this.ImageListIndex=parseInt(Math.random()*this.ImageList.length);
		this.ImageListIndex=(isNaN(this.ImageListIndex))?0:this.ImageListIndex;
	}
	
	document.getElementById(this.ImageID).src = this.ImageList[this.ImageListIndex];
		
	SlideShowStack.push(this.SlideShowID + ".SwitchPhoto()");

};
