// NOTE :  I COMMENTED OUT AMDECO BROCHURE ROTATIONS BELOW AND IN INDEX.ASP.  IF WE WANT TO DO ANOTHER AMEDCO TYPE
//OF BROCHURE LATER, THEN WE WOULD JUST UNCOMMENT HERE AND IN INDEX.ASP AND PUT IN THE ALTERNATIVE BROCHURE IMAGES
//TEXT AND FILES

// Number of items
var arraysize = 4;
var columnsnumber = 6;

// Number of left images
var leftarraysize = 6;
var leftcolumnsnumber = 2;


// Array for right items - images not quite correct name
var imagesArray = new Array(columnsnumber);

// Init second dimension: 0 - first cell text, 1 - second cell text, 5 - first cell image, 6 - second cell image
// 4 - image is preloaded, 2 - file name of first image, 3 - file name of second image
for (i = 0; i <= columnsnumber; i++)
{
     imagesArray[i] = new Array(arraysize);
}

// Load array with data

// START SPECIAL AD SECTION -- SHOW FIRST AND STAY UP THE LONGEST, THEN ROTATE
// NOTE - BE SURE TO CHECK STARTUP IMAGE IN INDEX.ASP, <TD> ID = FIRST & ID = SECOND
//START **** comment out these lines below when taking out the special advertisement.  Otherwise, uncomment when putting the special ad back in.  Comment out the other replacements below.
imagesArray[0][0] = "<img src='images/5.jpg' width='157' height='235' border='0' alt=''>";
imagesArray[1][0] = "<map name='productmap'><area href='headline.asp' shape='rect' coords='2, 130, 166, 217'></map><img src='images/5_text.jpg' width='169' height='235' border='0' usemap='#productmap' >";
imagesArray[2][0] = "images/5.jpg";
imagesArray[3][0] = "images/5_text.jpg";
imagesArray[4][0] = true;

imagesArray[0][2] = "<img src='images/5.jpg' width='157' height='235' border='0' alt=''>";
imagesArray[1][2] = "<map name='productmap'><area href='headline.asp' shape='rect' coords='2, 130, 166, 217'></map><img src='images/5_text.jpg' width='169' height='235' border='0' usemap='#productmap' >";
imagesArray[2][2] = "images/5.jpg";
imagesArray[3][2] = "images/5_text.jpg";
imagesArray[4][2] = true;

imagesArray[0][4] = "<img src='images/5.jpg' width='157' height='235' border='0' alt=''>";
imagesArray[1][4] = "<map name='productmap'><area href='headline.asp' shape='rect' coords='2, 130, 166, 217'></map><img src='images/5_text.jpg' width='169' height='235' border='0' usemap='#productmap' >";
imagesArray[2][4] = "images/5.jpg";
imagesArray[3][4] = "images/5_text.jpg";
imagesArray[4][4] = true;
//END **** comment out these lines above when taking out the special advertisement.  Otherwise, uncomment when putting the special ad back in.    Comment out or comment back in the other replacements below.  See below.
// END SPECIAL AD SECTION

// START SECTION WHEN AD IS TO BE PULLED OFF THE SITE
//START **** comment out these lines below when taking out the special advertisement.  Otherwise, uncomment when putting the special ad back in.  Comment out the other replacements above.
//imagesArray[0][0] = "<a href='browsetheaisle.asp?did=46'><img src='images/2.jpg' width='157' height='235' border='0' alt=''></a>";
//imagesArray[1][0] = "<map name='productmap'><area href='browsetheaisle.asp?did=46' shape='rect' coords='2,4,166,227'><area href='browsetheaisle.asp?did=46' shape='rect' coords='16, 142, 149, 174'><area href='browsetheaisle.asp?did=46' shape='rect' coords='16, 182, 149, 214'></map><img src='images/2_text.jpg' width='169' height='235' border='0' usemap='#productmap' >";
//imagesArray[2][0] = "images/2.jpg";
//imagesArray[3][0] = "images/2_text.jpg";
//imagesArray[4][0] = false;

//imagesArray[0][2] = "<a href='browsetheaisle.asp?did=46'><img src='images/2.jpg' width='157' height='235' border='0' alt=''></a>";
//imagesArray[1][2] = "<map name='productmap'><area href='browsetheaisle.asp?did=46' shape='rect' coords='2,4,166,227'><area href='browsetheaisle.asp?did=46' shape='rect' coords='16, 142, 149, 174'><area href='browsetheaisle.asp?did=46' shape='rect' coords='16, 182, 149, 214'></map><img src='images/2_text.jpg' width='169' height='235' border='0' usemap='#productmap' >";
//imagesArray[2][2] = "images/2.jpg";
//imagesArray[3][2] = "images/2_text.jpg";
//imagesArray[4][2] = false;

//imagesArray[0][4] = "<a href='research.asp'><img src='images/3.jpg' width='157' height='235' border='0' alt=''></a>";
//imagesArray[1][4] = "<map name='productmap'><area href='research1.asp' shape='rect' coords='2,4,166,227'></map><img src='images/3_text.jpg' width='169' height='235' border='0' usemap='#productmap' >";
//imagesArray[2][4] = "images/3.jpg";
//imagesArray[3][4] = "images/3_text.jpg";
//imagesArray[4][4] = false;
//END **** comment out these lines above when taking out the special advertisement.  Otherwise, uncomment when putting the special ad back in.    Comment out or comment back in the other replacements below.  See below.
// END SECTION WHEN AD IS TO BE PULLED OFF THE SITE

imagesArray[0][1] = "<a href='browsetheaisle.asp?did=46'><img src='images/1.jpg' width='157' height='235' border='0' alt=''></a>";
imagesArray[1][1] = "<map name='productmap'><area href='browsetheaisle.asp?did=46' shape='rect' coords='100, 115, 135, 130'><area href='browsetheaisle.asp?did=46' shape='rect' coords='16, 142, 149, 174'><area href='browsetheaisle.asp?did=46' shape='rect' coords='16, 182, 149, 214'></map><img src='images/1_text.jpg' width='169' height='235' border='0' usemap='#productmap' >";
imagesArray[2][1] = "images/1.jpg";
imagesArray[3][1] = "images/1_text.jpg";
imagesArray[4][1] = false;

//imagesArray[0][3] = "<a href='research.asp'><img src='images/3.jpg' width='157' height='235' border='0' alt=''></a>";
//imagesArray[1][3] = "<map name='productmap'><area href='research.asp' shape='rect' coords='2,4,166,227'></map><img src='images/3_text.jpg' width='169' height='235' border='0' usemap='#productmap' >";
//imagesArray[2][3] = "images/3.jpg";
//imagesArray[3][3] = "images/3_text.jpg";
//imagesArray[4][3] = false;

imagesArray[0][3] = "<a href='browsetheaisle.asp?did=46'><img src='images/1.jpg' width='157' height='235' border='0' alt=''></a>";
imagesArray[1][3] = "<map name='productmap'><area href='browsetheaisle.asp?did=46' shape='rect' coords='100, 115, 135, 130'><area href='browsetheaisle.asp?did=46' shape='rect' coords='16, 142, 149, 174'><area href='browsetheaisle.asp?did=46' shape='rect' coords='16, 182, 149, 214'></map><img src='images/1_text.jpg' width='169' height='235' border='0' usemap='#productmap' >";
imagesArray[2][3] = "images/1.jpg";
imagesArray[3][3] = "images/1_text.jpg";
imagesArray[4][3] = false;


// Preload first array image
imagesArray[5][0] = new Image();
imagesArray[5][0].src = imagesArray[2][0];

imagesArray[6][0] = new Image();
imagesArray[6][0].src = imagesArray[3][0];

imagesArray[4][0] = true;


// Array for left images
var leftimagesArray = new Array(leftcolumnsnumber);

// Init second dimension: 0 - image path, 1 - image is preloaded, 2 - service cell
for (i = 0; i <= leftcolumnsnumber; i++)
{
     leftimagesArray[i] = new Array(leftarraysize);
}

// Load leftarray with data
leftimagesArray[0][0] = "images/h_photo2.jpg";
leftimagesArray[1][0] = false;

leftimagesArray[0][1] = "images/h_photo3.jpg";
leftimagesArray[1][1] = false;

leftimagesArray[0][2] = "images/h_photo4.jpg";
leftimagesArray[1][2] = false;

leftimagesArray[0][3] = "images/h_photo5.jpg";
leftimagesArray[1][3] = false;

leftimagesArray[0][4] = "images/h_photo6.jpg";
leftimagesArray[1][4] = false;

leftimagesArray[0][5] = "images/h_photo7.jpg";
leftimagesArray[1][5] = false;

leftimagesArray[0][6] = "images/h_photo1.jpg";
leftimagesArray[1][6] = true;

// Preload first array image
leftimagesArray[2][0] = new Image();
leftimagesArray[2][0].src = leftimagesArray[0][0];

leftimagesArray[1][0] = true;


// Init rotate step, left images rotate step, global step
var step = 0;
var leftstep = 0;
var framestep = 0;

// Rotate function
function rotate() {
	
	if (framestep == 0) {

		document.all.item("first").innerHTML = imagesArray[0][step];
		document.all.item("second").innerHTML = imagesArray[1][step];

		// Increment step
		step++;
	
		if (step > arraysize) {
			step = 0;
		}
	
		// Preload next image
		if (!imagesArray[4][step]) {

			imagesArray[5][step] = new Image();
			imagesArray[5][step].src = imagesArray[2][step];

			imagesArray[6][step] = new Image();
			imagesArray[6][step].src = imagesArray[3][step];

			imagesArray[4][step] = true;

		}
		
		framestep = 1;
		
	}
	else {

		document.all.item("leftimage").innerHTML = "<img src='" + leftimagesArray[0][leftstep] + "' width='312' height='280'>";

		// Increment step
		leftstep++;
	
		if (leftstep > leftarraysize) {
			leftstep = 0;
		}
	
		// Preload next image
		if (!leftimagesArray[1][leftstep]) {

			leftimagesArray[2][leftstep] = new Image();
			leftimagesArray[2][leftstep].src = leftimagesArray[0][leftstep];

			leftimagesArray[1][leftstep] = true;

		}

		framestep = 0;

	}
	
	return;	
}

// Service variable
var timerID;

// Timer for rotation
timerID = setInterval(rotate, 7000);
