﻿function StartRotators(NewInterval, image_list, image_list2)
{		
	function getNextImage()
	{		
		image_index = (image_index+1) % NumberOfImages ;
		
		return(image_list[image_index]);
	}
	function getNextImage2()
	{		
		image_index2 = (image_index2+1) % NumberOfImages2 ;
		
		return(image_list2[image_index2]);
	}
	
	function rotateImages()
	{
		var new_image = getNextImage();
		var new_image2 = getNextImage2();
		document["Rotate1"].src = new_image;
		document["Rotate2"].src = new_image2;
	}
		
	// Set variables
	var Interval = NewInterval;
	var image_index = 0;
	var image_index2 = 0;
	//image_list = new Array();
	//image_list2 = new Array();
	// Set files
	var FolderURL = "/Site/Images/Rotators/";
	var FolderURL = "/Site/Images/Rotators2/";
	
		
	var NumberOfImages = image_list.length;
	var NumberOfImages2 = image_list2.length;
	
	rotateImages();
	var timer = setInterval(rotateImages, Interval);
}

//
// PRELOAD IMAGES
//
function preload() {
 	var brochure = new Array();
 	var pics = preload.arguments;
 	var dir = '/Squidge/Product/Onschedule/Images/' // path to images
 	for (i=0;i<pics.length;i++) {
  		brochure[i] = new Image();
  		brochure[i].src = dir + pics[i] + '.png'; // change file extension, if necessary.
 		// uncomment next line for testing; click OK to continue loop and cancel to break
 		//if(!confirm(brochure[i].src)) break;
 	}
}
//
// LIGHT BOX
//
function ShowLightBox(){
	document.getElementById('LightBox').style.display='block';
	document.getElementById('LightBoxFade').style.display='block';
}
function ShowLightBoxWithImage(ImagePath){
	ShowLightBox();


	// get and set the image
	//get
	var newImg = new Image();
	newImg.src = ImagePath;
	
	// get width
	var width = newImg.width;
		document.getElementById('LightBoxImage').width = 790;
	if(width>790)
	{
		// image is to big for lightbox, scale it
		document.getElementById('LightBoxImage').width = 790;	
		//document.title = ">790";
	}
	else
	{
		// image is correct size, default scaling
		//document.getElementById('LightBoxImage').width = 'auto';
		//document.title = "FINE: " + width;
	}	

	//set
	document.getElementById('LightBoxImage').src = ImagePath;
}

function HideLightBox(){
	document.getElementById('LightBox').style.display='none';
	document.getElementById('LightBoxFade').style.display='none';
	// set default loading image
	document.getElementById('LightBoxImage').src = '/Site/Images/Website/loading.gif';
	// set deault size
	document.getElementById('LightBoxImage').width = 790;
}