	$(document).ready(function () {
			playSlide();

			$(".slide_control").bind("mouseover", function(){
				gotoSlide($(this).attr("index"));
				pauseSlide = true;
			});

			$(".slide_control").bind("mouseout", function(){
				pauseSlide = false;
			});

		});

		var slidePictures = new Array();
		var slideHTML = new Array();
		var slideLinks = new Array();

		var currentSlide = 0;
		var frameInterval = 5500;
		var pauseSlide = false;
	

		//create slide show
		slidePictures[0] = "images/home-hero-leadpaintcoatings.jpg";
		slidePictures[1] = "images/home-hero-fsc.jpg";
		slidePictures[2] = "images/home-hero-pesticideapplicators.jpg";
		slidePictures[3] = "images/home-hero-dementia.jpg";
		slidePictures[4] = "images/home-hero-managingsafety.jpg";
		slidePictures[5] = "images/home-hero-lostyouth.jpg";
		slidePictures[6] = "images/home-hero-controllingexposure.jpg";
		
		slideHTML[0] = "<h2>Lead-Containing Paints and Coatings: Preventing Exposure in the Construction Industry</h2>";
		slideHTML[0] += "<p>This manual is for employers, supervisors, and workers who may come into contact with lead-containing paints and coatings in the construction industry.</p>";

		slideHTML[1] = "<h2></h2>";
		slideHTML[1] += "<p>As part of its contribution to sustainability, the Bookstore will use only FSC certified paper. Forest Stewardship Council (FSC) is an international certification and labeling system that guarantees that the forest products you purchase come from responsibly managed forests and verified recycled sources.</p>";

		slideHTML[2] = "<h2>Standard Practices For Pesticide Applicators</h2>";
		slideHTML[2] += "<p>This manual deals with the health and safety of workers who work with or near pesticides.</p>";

		slideHTML[3] = "<h2>Dementia: Understanding Risks & Preventing Violence</h2>";
		slideHTML[3] += "<p>The purpose of this book is to provide some understanding of how clinical care approaches and interventions can prevent or minimize the risk of injury to workers when caring for people with dementia.</p>";
		
		slideHTML[4] = "<h2>Managing Safety from a Supervisor's Perspective</h2>";
		slideHTML[4] += "<p>This infoflip is designed to help supervisors manage their responsibilities for the health and safety of their workers.</p>";
		
		slideHTML[5] = "<h2>Lost Youth</h2>";
		slideHTML[5] += "<p>Michael, Jennifer, John, and Nick all speak of losing their youth after suffering serious workplace accidents. Through dramatic recreations of these accidents and one-on-one discussions with the young people and their parents, Lost Youth tells four stories of lives forever altered.</p>";

		slideHTML[6] = "<h2>Controlling Exposure: Protecting Workers from Infectious Disease</h2>";
		slideHTML[6] += "<p>This book describes common infectious diseases and how they are spread, and explains how to protect workers from exposure to infectious diseases.</p>";
	
		slideLinks[0]= "lead_paints_and_coatings/product-BK93.html?nav=";
		slideLinks[1]= "http://www.fsccanada.org/default.htm";
		slideLinks[2]= "practices-for-pesticide-applicators/product-BK35.html?nav=newreleases";
		slideLinks[3]= "dementia_understanding_risks/product-BK125.html";
		slideLinks[4]= "managing-saftey-supervisor-perspective/product-BK119.html?nav=publications";
		slideLinks[5]= "lost-youth-unedited/product-DVD-40UE.html?nav=videos";
		slideLinks[6]= "Controlling%20_Exposure/product-BK129.html?nav=publications";


		function playSlide(){
			gotoSlide(currentSlide);
			intervalId = setInterval( 
				function(){
					if (!pauseSlide){	
						var index = 0;
						if (currentSlide < slidePictures.length - 1)
							index = parseInt(currentSlide) + 1;
						gotoSlide(index);
					}
				}
			, frameInterval );
		}

		function gotoSlide(index){
			//console.log(index);
			
			// swap image
			$("#slide_container_back")
				.html("<img src='"+slidePictures[index]+"' />");
			$("#slide_container_front")
				.show()
				.html("<img src='"+slidePictures[currentSlide]+"' />")
				.fadeOut("slow");
			
			// add link
			$("#home_hero_window .container").css("cursor", "pointer")
				.unbind()
				.click(function(){window.location=slideLinks[index]})
				.mouseover(function(){pauseSlide=true;})
				.mouseout(function(){pauseSlide=false;})
			;

			// text
			$("#slide_text_container").html(slideHTML[index]);

			// buttons
			$("#home_hero_num a").removeClass("slide_control_active");
			$(".slide_control[index=" + index + "]").addClass("slide_control_active");
			currentSlide = index;
		}
