var imageArray = [];
var buttonArray = [];
var filterArray = [];
var imageIndex = 0;
var currentImage = 9999;
var thumbArray = [];
var thumbCount = 0;
var currentThumb = 0;
var newFilterFlag = 1;

// browser vars
var version	= navigator.appVersion;
var agent = navigator.userAgent;   
var browserV = "Unknown";   
var browser = "Unknown";   


// constants for the colums of our array

var IMAGE_COL 		= 0;
var HAPPY_COL 		= 1;
var OSCAR_COL 		= 2;
var ANGEL_COL 		= 3;
var SUGAR_COL 		= 4;
var KATCHINA_COL 	= 5;
var JAMBI_COL 		= 6;
var PEPPY_COL 		= 7;
var BEDROOM_COL 	= 8;
var BATHROOM_COL 	= 9;
var OUTSIDE_COL 	= 10;
var KITCHEN_COL 	= 11;
var OFFICE_COL 	= 12;
var DAY_COL 		= 13;
var NIGHT_COL 		= 14;
var STAIRS_COL 	= 15;
var HALLWAY_COL 	= 16;
var LEDGE_COL 	   = 17;
var TITLE_COL 	   = 18;
var PICTURE_COL 	= 19;
var THUMB_COL 	   = 20;
var THUMB_SEL_COL = 21;
var TIME_COL 		= 22;
var DATE_COL 		= 23;
var NOTE_COL 		= 24;
var JOURNAL_COL 	= 25;
var INKADU_COL		= 26;

var NUMBER_COLS = 27;

// constants for search flags

var SHOW_HAPPY 	= 0;
var SHOW_ANGEL 	= 0;
var SHOW_OSCAR 	= 0;
var SHOW_SUGAR 	= 0;
var SHOW_KATCHINA = 0;
var SHOW_JAMBI 	= 0;
var SHOW_PEPPY 	= 0;
var SHOW_BEDROOM 	= 0;
var SHOW_BATHROOM = 0;
var SHOW_OUTSIDE 	= 0;
var SHOW_KITCHEN 	= 0;
var SHOW_OFFICE 	= 0;
var SHOW_DAY 		= 0;
var SHOW_NIGHT 	= 0;
var SHOW_STAIRS 	= 0;
var SHOW_HALLWAY 	= 0;
var SHOW_LEDGE 	= 0;

// constants for buttons

var HAPPY_BUTTON 		= 1;
var OSCAR_BUTTON 		= 2;
var ANGEL_BUTTON 		= 3;
var SUGAR_BUTTON 		= 4;
var KATCHINA_BUTTON 	= 5;
var JAMBI_BUTTON 		= 6;
var PEPPY_BUTTON 		= 7;
var BEDROOM_BUTTON 	= 8;
var BATHROOM_BUTTON 	= 9;
var OUTSIDE_BUTTON 	= 10;
var KITCHEN_BUTTON 	= 11;
var OFFICE_BUTTON 	= 12;
var DAY_BUTTON 		= 13;
var NIGHT_BUTTON 		= 14;
var STAIRS_BUTTON 	= 15;
var HALLWAY_BUTTON 	= 16;
var LEDGE_BUTTON 	   = 17;
var TITLE_BUTTON 	   = 18;
var PICTURE_BUTTON 	= 19;
var THUMB_BUTTON 	   = 20;

var NUMBER_BUTTONS 	= 21;

var OFF_BUTTON			= 0;
var OVER_BUTTON		= 1;
var ON_BUTTON			= 2;
var DISABLE_BUTTON	= 3;





// load()
//
// executed on page load

function load()
{
	var browserName=navigator.appName;
	//alert("browserName = " + browserName);
	//alert("agent = " + agent);

	if(browserName == "Microsoft Internet Explorer")
	{
		browser = "IE";
		var vindex	= agent.indexOf("MSIE ") + 5;
		browserV	= parseInt(agent.substring(vindex));
	}

	if(browserName == "Netscape")
	{
		browser = "Netscape";
		var vindex	= agent.indexOf("Firefox/");
		//alert("vindex = " + vindex);
		if(vindex > 0)
		{
			vindex =+ 8;
			//alert("made it to firefox");
			browser = "Firefox";
			browserV	= parseInt(agent.substring(vindex));
		}
		else
		{
			vindex	= agent.indexOf("Safari/");
			//alert("vindex = " + vindex);
			if(vindex > 0)
			{
				vindex =+ 7;
				browser = "Safari";
				browserV	= parseInt(agent.substring(vindex));
			}
		}
	}
	//alert("browser = " + browser);

	if(browser == "IE")
	{
		//if(browserV != 7)
		//{
			alert("Sorry, the page only works with IE 7, or Firefox");
			return;
		//}
	}
	
	if(browser == "Safari")
	{
		alert("Sorry, the page only works with IE 7, or Firefox");
		return;
	}
	
	hideThumbs();
	hideSliderValue();
	readFilterCookies();
	readThumbSizeCookie();
	loadAllPictures();
	loadButtons();
	setSelectedButtons();
	showSelectedThumbs();
	readThumbCookies();
	setCurrentImage()
	showThumbs();
	keepPrevThumbSize();
}

function hideSliderValue()
{
	var thumbSizeField = document.getElementById("sliderValue3h");			// get the element that holds the thumbs
	 thumbSizeField.style.display = 'none';
}


function navigateThumbs(increment)
{
	if(thumbCount < 1) return;

	//alert("currentThumb = " + currentThumb);

	var newCurrentThumb = currentThumb + increment;

	if(newCurrentThumb < 0)
	{
		// we went before start
		currentThumb = thumbCount - 1;
	}
	else
	{
		if(newCurrentThumb == thumbCount)
		{
			// we are past end
			currentThumb = 0;
		}
		else
		{
			currentThumb = newCurrentThumb;
		}
	}

	// now that we have the new current thumb
	// get the thumb number and set the thumb to it

	var newThumbIndex = thumbArray[currentThumb];

	setSelectedThumb(newThumbIndex);
	setImage(newThumbIndex,currentThumb, "NavigateThumbs");
}

function togglePetButton(i)
{
	switch(i)
	{
	case HAPPY_BUTTON:
		if(SHOW_HAPPY == 1) 
			SHOW_HAPPY = 0;
		else
			SHOW_HAPPY = 1;
		break;

	case OSCAR_BUTTON:
		if(SHOW_OSCAR == 1) 
			SHOW_OSCAR = 0;
		else
			SHOW_OSCAR = 1;
		break;

	case ANGEL_BUTTON:
		if(SHOW_ANGEL == 1) 
			SHOW_ANGEL = 0;
		else
			SHOW_ANGEL = 1;
		break;

	case SUGAR_BUTTON:
		if(SHOW_SUGAR == 1) 
			SHOW_SUGAR = 0;
		else
			SHOW_SUGAR = 1;
		break;

	case KATCHINA_BUTTON:
		if(SHOW_KATCHINA == 1) 
			SHOW_KATCHINA = 0;
		else
			SHOW_KATCHINA = 1;
		break;

	case JAMBI_BUTTON:
		if(SHOW_JAMBI == 1) 
			SHOW_JAMBI = 0;
		else
			SHOW_JAMBI = 1;
		break;

	case PEPPY_BUTTON:
		if(SHOW_PEPPY == 1) 
			SHOW_PEPPY = 0;
		else
			SHOW_PEPPY = 1;
		break;
	}
}

function clearPlaceFilter()
{
	SHOW_BATHROOM 	= 0;
	SHOW_HALLWAY 	= 0;
	SHOW_STAIRS 	= 0;
	SHOW_KITCHEN 	= 0;
	SHOW_OFFICE 	= 0;
	SHOW_LEDGE 		= 0;
	SHOW_OUTSIDE 	= 0;

	deselectButton(BATHROOM_BUTTON);
	deselectButton(OUTSIDE_BUTTON);
	deselectButton(KITCHEN_BUTTON);
	deselectButton(OFFICE_BUTTON);
	deselectButton(STAIRS_BUTTON);
	deselectButton(HALLWAY_BUTTON);
	deselectButton(LEDGE_BUTTON);
}

function setSelectedButtons()
{
	// pet buttons

	if(SHOW_HAPPY == 1) selectButton(HAPPY_BUTTON);
	if(SHOW_HAPPY == 0) deselectButton(HAPPY_BUTTON);

	if(SHOW_OSCAR == 1) selectButton(OSCAR_BUTTON);
	if(SHOW_OSCAR == 0) deselectButton(OSCAR_BUTTON);

	if(SHOW_ANGEL == 1) selectButton(ANGEL_BUTTON);
	if(SHOW_ANGEL == 0) deselectButton(ANGEL_BUTTON);

	if(SHOW_SUGAR == 1) selectButton(SUGAR_BUTTON);
	if(SHOW_SUGAR == 0) deselectButton(SUGAR_BUTTON);

	if(SHOW_KATCHINA == 1) selectButton(KATCHINA_BUTTON);
	if(SHOW_KATCHINA == 0) deselectButton(KATCHINA_BUTTON);

	if(SHOW_JAMBI == 1) selectButton(JAMBI_BUTTON);
	if(SHOW_JAMBI == 0) deselectButton(JAMBI_BUTTON);

	if(SHOW_PEPPY == 1) selectButton(PEPPY_BUTTON);
	if(SHOW_PEPPY == 0) deselectButton(PEPPY_BUTTON);

	// place buttons

	if(SHOW_BATHROOM == 1) selectButton(BATHROOM_BUTTON);
	if(SHOW_BATHROOM == 0) deselectButton(BATHROOM_BUTTON);

	if(SHOW_HALLWAY == 1) selectButton(HALLWAY_BUTTON);
	if(SHOW_HALLWAY == 0) deselectButton(HALLWAY_BUTTON);

	if(SHOW_STAIRS == 1) selectButton(STAIRS_BUTTON);
	if(SHOW_STAIRS == 0) deselectButton(STAIRS_BUTTON);

	if(SHOW_KITCHEN == 1) selectButton(KITCHEN_BUTTON);
	if(SHOW_KITCHEN == 0) deselectButton(KITCHEN_BUTTON);

	if(SHOW_OFFICE == 1) selectButton(OFFICE_BUTTON);
	if(SHOW_OFFICE == 0) deselectButton(OFFICE_BUTTON);

	if(SHOW_LEDGE == 1) selectButton(LEDGE_BUTTON);
	if(SHOW_LEDGE == 0) deselectButton(LEDGE_BUTTON);

	if(SHOW_OUTSIDE == 1) selectButton(OUTSIDE_BUTTON);
	if(SHOW_OUTSIDE == 0) deselectButton(OUTSIDE_BUTTON);
}



function handlePetButton(i)
{
	newFilterFlag = 1;
	currentImage = -1;
	hideThumbs();
	clearImage();
	togglePetButton(i);
	setSelectedButtons();
	showSelectedThumbs();
	setFilterCookies();
	//keepPrevThumbSize();
	showThumbs();
	findCurrentThumb();
}

function handlePlaceButton(i)
{
	newFilterFlag = 1;
	currentImage = -1;
	hideThumbs();
	clearImage();
	setPlaceFilter(i);
	setSelectedButtons();
	showSelectedThumbs();
	setFilterCookies();
	//keepPrevThumbSize();
	showThumbs();
	findCurrentThumb();
}

function findCurrentThumb()
{
	//alert("findCurrentThumb");

	currentThumb = -1;

	for (var i = 0; i<thumbCount;i++)
	{
		if(thumbArray[i] == currentImage)
			currentThumb = i;
	}

	if(currentThumb != -1)
		setImage(currentImage,currentThumb);
	else
	{
		//alert("we have no image match");
		if(thumbCount > 0)
		{
			// we have a thumb array so set it to first thumb
			currentThumb = 0;
			currentImage = thumbArray[currentThumb];
			selectThumb(thumbArray[currentThumb]);
			setImage(thumbArray[currentThumb],currentThumb,"findCurrentThumb");
		}
		else
		{

		}
	}

}

function handleThumbButton(imageIndex, thumbIndex)
{
	setImage(imageIndex,thumbIndex, "handleThumbButton");
	//setCurrentThumb(thumbIndex);
	//createCookie("IMAGE_INDEX_COOKIE",imageIndex,30);
	//createCookie("THUMB_INDEX_COOKIE",thumbIndex,30);

	//currentImage = imageIndex;
	setCurrentThumb(thumbIndex);	
	//alert(currentImage);
	//alert(currentThumb);
	setSelectedThumb(imageIndex);
}

function setCurrentImage()
{
	//alert("setCurrentImage()");
	currentImage = parseInt(readCookie("IMAGE_INDEX_COOKIE"));
	currentThumb = parseInt(readCookie("THUMB_INDEX_COOKIE"));
	
	//alert("currentImage = " + currentImage);
	//alert("currentThumb = " + currentThumb);

	setImage(currentImage, currentThumb, "setCurrentImage");
	setSelectedThumb(currentImage);
	setCurrentThumb(currentThumb);

}

function keepPrevThumbSize()
{
	var thumbSizeField = document.getElementById("sliderValue3h");			// get the element that holds the thumbs
	A_SLIDERS[0].f_setValue(thumbSizeField.value);
}


function setPlaceFilter(i)
{

	switch(i)
	{
		case BATHROOM_BUTTON:
			if(SHOW_BATHROOM == 1) SHOW_BATHROOM = 0;
			else SHOW_BATHROOM = 1;
			SHOW_HALLWAY 	= 0;
			SHOW_STAIRS 	= 0;
			SHOW_KITCHEN 	= 0;
			SHOW_OFFICE 	= 0;
			SHOW_LEDGE 		= 0;
			SHOW_OUTSIDE 	= 0;
			break;
	
		case HALLWAY_BUTTON:
			if(SHOW_HALLWAY== 1) SHOW_HALLWAY = 0;
			else SHOW_HALLWAY = 1;
			SHOW_BATHROOM 	= 0;
			SHOW_STAIRS 	= 0;
			SHOW_KITCHEN 	= 0;
			SHOW_OFFICE 	= 0;
			SHOW_LEDGE 		= 0;
			SHOW_OUTSIDE 	= 0;
			break;
	
		case STAIRS_BUTTON:
			if(SHOW_STAIRS == 1) SHOW_STAIRS = 0;
			else SHOW_STAIRS = 1;
			SHOW_BATHROOM 	= 0;
			SHOW_HALLWAY 	= 0;
			SHOW_KITCHEN 	= 0;
			SHOW_OFFICE 	= 0;
			SHOW_LEDGE 		= 0;
			SHOW_OUTSIDE 	= 0;
			break;
	
		case KITCHEN_BUTTON:
			if(SHOW_KITCHEN == 1) SHOW_KITCHEN = 0;
			else SHOW_KITCHEN = 1;
			SHOW_BATHROOM 	= 0;
			SHOW_HALLWAY 	= 0;
			SHOW_STAIRS 	= 0;
			SHOW_OFFICE 	= 0;
			SHOW_LEDGE 		= 0;
			SHOW_OUTSIDE 	= 0;
			break;
	
		case OFFICE_BUTTON:
			if(SHOW_OFFICE == 1) SHOW_OFFICE = 0;
			else SHOW_OFFICE = 1;
			SHOW_BATHROOM 	= 0;
			SHOW_HALLWAY 	= 0;
			SHOW_STAIRS 	= 0;
			SHOW_KITCHEN 	= 0;
			SHOW_LEDGE 		= 0;
			SHOW_OUTSIDE 	= 0;
			break;
	
		case LEDGE_BUTTON:
			if(SHOW_LEDGE == 1) SHOW_LEDGE = 0;
			else SHOW_LEDGE = 1;
			SHOW_BATHROOM 	= 0;
			SHOW_HALLWAY 	= 0;
			SHOW_STAIRS 	= 0;
			SHOW_KITCHEN 	= 0;
			SHOW_OFFICE 	= 0;
			SHOW_OUTSIDE 	= 0;
			break;
	
		case OUTSIDE_BUTTON:
			if(SHOW_OUTSIDE == 1) SHOW_OUTSIDE = 0;
			else SHOW_OUTSIDE = 1;
			SHOW_BATHROOM 	= 0;
			SHOW_HALLWAY 	= 0;
			SHOW_STAIRS 	= 0;
			SHOW_KITCHEN 	= 0;
			SHOW_OFFICE 	= 0;
			SHOW_LEDGE 		= 0;
			break;
	}
}



function showThumbs()
{
	//alert("showThumbs");
	var thumbsDiv = document.getElementById("thumbs");			// get the element that holds the thumbs
	thumbsDiv.style.display = "block";

}

function hideThumbs()
{
	var thumbsDiv = document.getElementById("thumbs");			// get the element that holds the thumbs
	thumbsDiv.style.display = "none";

}

function setSelectedThumb(i)
{
	if(currentImage == i)
	{
		//alert("do nothign");
		//alert("we clicked on current image thumb");
		// we are clicking on the same thumb so do nothing
	}
	else
	{
  		// we are clicking on a new thumbnail so deselect current image thumb and select new thumb
		//alert("we clicked on new image thumb: i = "+i);

		selectThumb(i);
		if(newFilterFlag == 0)
		{
			deselectThumb(currentImage);
		}
		else
		{
			newFilterFlag = 0;
		}
		currentImage = i;
	}
}


function setSelectedThumb_old(i)
{
	if(currentImage == i)
	{
		//alert("we clicked on current image thumb");
		// we are clicking on the same thumb so do nothing
	}
	else
	{
  		// we are clicking on a new thumbnail so deselect current image thumb and select new thumb
		//alert("we clicked on new image thumb: i = "+i);

		selectThumb(i);
		if(currentImage != 9999)
		{
			deselectThumb(currentImage);
		}
		currentImage = i;
	}
}

function selectThumb(i)
{
	//alert("selectThumb("+i+")");
	//var thumbImage = document.getElementById("thumbImage"+i);			// get the element that holds the thumbs
	var thumb = document.getElementById("thumb"+i);			// get the element that holds the thumbs
	if(thumb != null)
		thumb.style.border = "3px solid red";

}

function deselectThumb(i)
{
	//alert("deselectThumb("+i+")");
	//var thumbImage = document.getElementById("thumbImage"+i);			// get the element that holds the thumbs
	var thumb = document.getElementById("thumb"+i);			// get the element that holds the thumbs
	if(thumb != null)
		thumb.style.border = "3px solid black";
}

function selectButton(i)
{
	//alert("selectButton("+i+")");
	var buttonImage = document.getElementById("buttonImage"+i);			// get the element that holds the thumbs
	var thumb = document.getElementById("button"+i);			// get the element that holds the thumbs
	//buttonImage.src = buttonArray[i][ON_BUTTON].src
	if(thumb != null)
		thumb.style.border = "3px solid red";
}

function deselectButton(i)
{
	//alert("deselectButton("+i+")");
	var buttonImage = document.getElementById("buttonImage"+i);			// get the element that holds the thumbs
	var thumb = document.getElementById("button"+i);			// get the element that holds the thumbs
	//buttonImage.src = buttonArray[i][OFF_BUTTON].src
	if(thumb != null)
		thumb.style.border = "3px solid black";
}



// old functions for selection

function selectThumb_old(i)
{
	//alert("selectThumb("+i+")");
	var thumbImage = document.getElementById("thumbImage"+i);			// get the element that holds the thumbs
	thumbImage.src = imageArray[i][THUMB_SEL_COL].src

}

function deselectThumb_old(i)
{
	//alert("deselectThumb("+i+")");
	var thumbImage = document.getElementById("thumbImage"+i);			// get the element that holds the thumbs
	thumbImage.src = imageArray[i][THUMB_COL].src
}

function selectButton_old(i)
{
	//alert("selectButton("+i+")");
	var buttonImage = document.getElementById("buttonImage"+i);			// get the element that holds the thumbs
	buttonImage.src = buttonArray[i][ON_BUTTON].src
}

function deselectButton_old(i)
{
	//alert("deselectButton("+i+")");
	var buttonImage = document.getElementById("buttonImage"+i);			// get the element that holds the thumbs
	buttonImage.src = buttonArray[i][OFF_BUTTON].src
}

function disableButton(i)
{
	var buttonImage = document.getElementById("buttonImage"+i);			// get the element that holds the thumbs
	buttonImage.src = buttonArray[i][DISABLE_BUTTON].src
}

function enableButton(i)
{
	var buttonImage = document.getElementById("buttonImage"+i);			// get the element that holds the thumbs
	buttonImage.src = buttonArray[i][OFF_BUTTON].src
}

function setFilterCookies()
{
	// pet filter cookies

	createCookie("SHOW_HAPPY_COOKIE",SHOW_HAPPY,30);
	createCookie("SHOW_OSCAR_COOKIE",SHOW_OSCAR,30);
	createCookie("SHOW_ANGEL_COOKIE",SHOW_ANGEL,30);
	createCookie("SHOW_SUGAR_COOKIE",SHOW_SUGAR,30);
	createCookie("SHOW_KATCHINA_COOKIE",SHOW_KATCHINA,30);
	createCookie("SHOW_JAMBI_COOKIE",SHOW_JAMBI,30);
	createCookie("SHOW_PEPPY_COOKIE",SHOW_PEPPY,30);

	// pet filter cookies

	createCookie("SHOW_BATHROOM_COOKIE",SHOW_BATHROOM,30);
	createCookie("SHOW_STAIRS_COOKIE",SHOW_STAIRS,30);
	createCookie("SHOW_HALLWAY_COOKIE",SHOW_HALLWAY,30);
	createCookie("SHOW_KITCHEN_COOKIE",SHOW_KITCHEN,30);
	createCookie("SHOW_OFFICE_COOKIE",SHOW_OFFICE,30);
	createCookie("SHOW_LEDGE_COOKIE",SHOW_LEDGE,30);
	createCookie("SHOW_OUTSIDE_COOKIE",SHOW_OUTSIDE,30);

}

function readFilterCookies()
{
	// pet filter cookies

	SHOW_HAPPY 		= readFilterCookie("SHOW_HAPPY_COOKIE");
	SHOW_OSCAR 		= readFilterCookie("SHOW_OSCAR_COOKIE");
	SHOW_ANGEL 		= readFilterCookie("SHOW_ANGEL_COOKIE");
	SHOW_SUGAR 		= readFilterCookie("SHOW_SUGAR_COOKIE");
	SHOW_KATCHINA 	= readFilterCookie("SHOW_KATCHINA_COOKIE");
	SHOW_JAMBI 		= readFilterCookie("SHOW_JAMBI_COOKIE");
	SHOW_PEPPY 		= readFilterCookie("SHOW_PEPPY_COOKIE");

	// place filter cookies

	SHOW_BATHROOM 	= readFilterCookie("SHOW_BATHROOM_COOKIE");
	SHOW_STAIRS 	= readFilterCookie("SHOW_STAIRS_COOKIE");
	SHOW_HALLWAY 	= readFilterCookie("SHOW_HALLWAY_COOKIE");
	SHOW_KITCHEN 	= readFilterCookie("SHOW_KITCHEN_COOKIE");
	SHOW_OFFICE 	= readFilterCookie("SHOW_OFFICE_COOKIE");
	SHOW_LEDGE 		= readFilterCookie("SHOW_LEDGE_COOKIE");
	SHOW_OUTSIDE 	= readFilterCookie("SHOW_OUTSIDE_COOKIE");

}

function readThumbCookies()
{
	// image cookies
	currentImage = parseInt(readCookie("IMAGE_INDEX_COOKIE"));
	currentThumb = parseInt(readCookie("THUMB_INDEX_COOKIE"));
}

function readThumbSizeCookie()
{
	var thumbSizeField = document.getElementById("sliderValue3h");			// get the element that holds the thumbs
	var thumbSize = parseInt(readCookie("THUMB_SIZE_COOKIE"));
	thumbSizeField.value = thumbSize;
	//alert("readTHumb = " + thumbSize);
}

function readFilterCookie(name)
{
	var retValue;

	retValue = readCookie(name);

	if(retValue == null)
		return 0;
	else
		return parseInt(retValue);

}




function setFilterFlag(catNum)
{
	//alert("setFilterFlag("+catNum+")");

	switch(catNum)
	{
		// pet filters

		case HAPPY_COL:
			if(SHOW_HAPPY == 1) SHOW_HAPPY = 0; else  SHOW_HAPPY = 1;
			break;

		case OSCAR_COL:
			if(SHOW_OSCAR == 1) SHOW_OSCAR = 0; else SHOW_OSCAR = 1;
			break;
	
		case ANGEL_COL:
			if(SHOW_ANGEL == 1) SHOW_ANGEL = 0; else SHOW_ANGEL = 1;
			break;
	
		case SUGAR_COL:
			if(SHOW_SUGAR == 1) SHOW_SUGAR = 0; else SHOW_SUGAR = 1;
			break;
	
		case KATCHINA_COL:
			if(SHOW_KATCHINA == 1) SHOW_KATCHINA = 0; else SHOW_KATCHINA = 1;
			break;
	
		case JAMBI_COL:
			if(SHOW_JAMBI == 1) SHOW_JAMBI = 0; else SHOW_JAMBI = 1;
			break;

		case PEPPY_COL:
			if(SHOW_PEPPY == 1) SHOW_PEPPY = 0; else SHOW_PEPPY = 1;
			break;
	
		//place filters  
		
		case BATHROOM_COL:
			if(SHOW_BATHROOM == 1) SHOW_BATHROOM = 0; else SHOW_BATHROOM = 1;
			break;

		case STAIRS_COL:
			if(SHOW_STAIRS == 1) SHOW_STAIRS = 0; else SHOW_STAIRS = 1;
			break;

		case HALLWAY_COL:
			if(SHOW_HALLWAY == 1) SHOW_HALLWAY = 0; else SHOW_HALLWAY = 1;
			break;
	
		case KITCHEN_COL:
			if(SHOW_KITCHEN == 1) SHOW_KITCHEN = 0; else SHOW_KITCHEN = 1;
			break;
	
		case OFFICE_COL:
			if(SHOW_OFFICE == 1) SHOW_OFFICE = 0; else SHOW_OFFICE = 1;
			break;
	
		case LEDGE_COL:
			if(SHOW_LEDGE == 1) SHOW_LEDGE = 0; else SHOW_LEDGE = 1;
			break;
	
		case OUTSIDE_COL:
			if(SHOW_OUTSIDE == 1) SHOW_OUTSIDE = 0; else SHOW_OUTSIDE = 1;
			break;
	
	
	
		default:
			break;
	}

}

function loadButtons()
{
	//alert(buttonArray[HAPPY_BUTTON][OFF_BUTTON]);

	// pet buttons

	buttonArray[HAPPY_BUTTON][OFF_BUTTON].src 			= "buttons/happy_button.jpg";
	buttonArray[HAPPY_BUTTON][OVER_BUTTON].src 			= "buttons_over/happy_button.jpg";
	buttonArray[HAPPY_BUTTON][ON_BUTTON].src 				= "buttons_on/happy_button.jpg";
	buttonArray[HAPPY_BUTTON][DISABLE_BUTTON].src 		= "buttons_disable/happy_button.jpg";

	buttonArray[OSCAR_BUTTON][OFF_BUTTON].src 			= "buttons/oscar_button.jpg";
	buttonArray[OSCAR_BUTTON][OVER_BUTTON].src 			= "buttons_over/oscar_button.jpg";
	buttonArray[OSCAR_BUTTON][ON_BUTTON].src 				= "buttons_on/oscar_button.jpg";
	buttonArray[OSCAR_BUTTON][DISABLE_BUTTON].src 		= "buttons_disable/oscar_button.jpg";

	buttonArray[ANGEL_BUTTON][OFF_BUTTON].src 			= "buttons/angel_button.jpg";
	buttonArray[ANGEL_BUTTON][OVER_BUTTON].src 			= "buttons_over/angel_button.jpg";
	buttonArray[ANGEL_BUTTON][ON_BUTTON].src 				= "buttons_on/angel_button.jpg";
	buttonArray[ANGEL_BUTTON][DISABLE_BUTTON].src 		= "buttons_disable/angel_button.jpg";

	buttonArray[SUGAR_BUTTON][OFF_BUTTON].src 			= "buttons/sugar_button.jpg";
	buttonArray[SUGAR_BUTTON][OVER_BUTTON].src 			= "buttons_over/sugar_button.jpg";
	buttonArray[SUGAR_BUTTON][ON_BUTTON].src 				= "buttons_on/sugar_button.jpg";
	buttonArray[SUGAR_BUTTON][DISABLE_BUTTON].src 		= "buttons_disable/sugar_button.jpg";

	buttonArray[KATCHINA_BUTTON][OFF_BUTTON].src 		= "buttons/katchina_button.jpg";
	buttonArray[KATCHINA_BUTTON][OVER_BUTTON].src 		= "buttons_over/katchina_button.jpg";
	buttonArray[KATCHINA_BUTTON][ON_BUTTON].src 			= "buttons_on/katchina_button.jpg";
	buttonArray[KATCHINA_BUTTON][DISABLE_BUTTON].src 	= "buttons_disable/katchina_button.jpg";

	buttonArray[JAMBI_BUTTON][OFF_BUTTON].src 			= "buttons/jambi_button.jpg";
	buttonArray[JAMBI_BUTTON][OVER_BUTTON].src 			= "buttons_over/jambi_button.jpg";
	buttonArray[JAMBI_BUTTON][ON_BUTTON].src 				= "buttons_on/jambi_button.jpg";
	buttonArray[JAMBI_BUTTON][DISABLE_BUTTON].src 		= "buttons_disable/jambi_button.jpg";

	buttonArray[PEPPY_BUTTON][OFF_BUTTON].src 			= "buttons/peppy_button.jpg";
	buttonArray[PEPPY_BUTTON][OVER_BUTTON].src 			= "buttons_over/peppy_button.jpg";
	buttonArray[PEPPY_BUTTON][ON_BUTTON].src 				= "buttons_on/peppy_button.jpg";
	buttonArray[PEPPY_BUTTON][DISABLE_BUTTON].src 		= "buttons_disable/peppy_button.jpg";

	// place buttons

   buttonArray[BATHROOM_BUTTON][OFF_BUTTON].src 		= "buttons/bathroom_button.jpg";
	buttonArray[BATHROOM_BUTTON][OVER_BUTTON].src 		= "buttons_over/bathroom_button.jpg";
	buttonArray[BATHROOM_BUTTON][ON_BUTTON].src 			= "buttons_on/bathroom_button.jpg";
	buttonArray[BATHROOM_BUTTON][DISABLE_BUTTON].src 	= "buttons_disable/bathroom_button.jpg";

	buttonArray[OUTSIDE_BUTTON][OFF_BUTTON].src 			= "buttons/outisde_button.jpg";
	buttonArray[OUTSIDE_BUTTON][OVER_BUTTON].src 		= "buttons_over/outisde_button.jpg";
	buttonArray[OUTSIDE_BUTTON][ON_BUTTON].src 			= "buttons_on/outisde_button.jpg";
	buttonArray[OUTSIDE_BUTTON][DISABLE_BUTTON].src 	= "buttons_disable/outisde_button.jpg";

	buttonArray[KITCHEN_BUTTON][OFF_BUTTON].src 			= "buttons/kitchen_button.jpg";
	buttonArray[KITCHEN_BUTTON][OVER_BUTTON].src 		= "buttons_over/kitchen_button.jpg";
	buttonArray[KITCHEN_BUTTON][ON_BUTTON].src 			= "buttons_on/kitchen_button.jpg";
	buttonArray[KITCHEN_BUTTON][DISABLE_BUTTON].src 	= "buttons_disable/kitchen_button.jpg";

	buttonArray[OFFICE_BUTTON][OFF_BUTTON].src 			= "buttons/office_button.jpg";
	buttonArray[OFFICE_BUTTON][OVER_BUTTON].src 			= "buttons_over/office_button.jpg";
	buttonArray[OFFICE_BUTTON][ON_BUTTON].src 			= "buttons_on/office_button.jpg";
	buttonArray[OFFICE_BUTTON][DISABLE_BUTTON].src 		= "buttons_disable/office_button.jpg";

	buttonArray[STAIRS_BUTTON][OFF_BUTTON].src 			= "buttons/stairs_button.jpg";
	buttonArray[STAIRS_BUTTON][OVER_BUTTON].src 			= "buttons_over/stairs_button.jpg";
	buttonArray[STAIRS_BUTTON][ON_BUTTON].src 			= "buttons_on/stairs_button.jpg";
	buttonArray[STAIRS_BUTTON][DISABLE_BUTTON].src 		= "buttons_disable/stairs_button.jpg";

	buttonArray[HALLWAY_BUTTON][OFF_BUTTON].src 			= "buttons/hallway_button.jpg";
	buttonArray[HALLWAY_BUTTON][OVER_BUTTON].src 		= "buttons_over/hallway_button.jpg";
	buttonArray[HALLWAY_BUTTON][ON_BUTTON].src 			= "buttons_on/hallway_button.jpg";
	buttonArray[HALLWAY_BUTTON][DISABLE_BUTTON].src 	= "buttons_disable/hallway_button.jpg";

	buttonArray[LEDGE_BUTTON][OFF_BUTTON].src 			= "buttons/ledge_button.jpg";
	buttonArray[LEDGE_BUTTON][OVER_BUTTON].src 			= "buttons_over/ledge_button.jpg";
	buttonArray[LEDGE_BUTTON][ON_BUTTON].src 				= "buttons_on/ledge_button.jpg";
	buttonArray[LEDGE_BUTTON][DISABLE_BUTTON].src 		= "buttons_disable/ledge_button.jpg";
}

function loadAllPictures()
{
	var xmlDoc = loadXML("images.xml");
	var pictures = xmlDoc.getElementsByTagName("picture");
	var theImage;
	var img;

	clearElement("thumbs");												// clear the thumb bar of all thumbs
	var thumb_bar = document.getElementById("thumbs");			// get the element that holds the thumbs

	// initialize the image array
	for (var i = 0; i<pictures.length;i++)
	{
		imageArray[i] = new Array(NUMBER_COLS);
		for(var j = 1; j < NUMBER_COLS; j++)
		{
			imageArray[i][j] = 0;
		}
	}

	// initialize the button array

	for (var i = 0; i<NUMBER_BUTTONS;i++)
	{
		buttonArray[i] = new Array(4);
		
		for(var j = 0; j < 4; j++)
		{
			buttonArray[i][j] = new Image();
		}
	}

	
	// set the display flags
	
	for (var i = 0; i<pictures.length;i++)
	{
		theImage = pictures[i].attributes[0].nodeValue;
		//alert(theImage);
		imageArray[imageIndex][IMAGE_COL] = theImage;
		
		var journalID = pictures[i].attributes[2].nodeValue;
		//alert(theImage);
		imageArray[imageIndex][JOURNAL_COL] = journalID;

		// get the cat flags
		var catNum = pictures[i].childNodes[1].attributes.length;
		for(var curCat = 0; curCat < catNum ; curCat++)
		{
			var catName = pictures[i].childNodes[1].attributes[curCat].nodeName;

			// set the cat flags

			if(catName == 'happy') 		imageArray[imageIndex][HAPPY_COL] 		= 1; 
			if(catName == 'angel') 		imageArray[imageIndex][ANGEL_COL] 		= 1; 
			if(catName == 'sugar') 		imageArray[imageIndex][SUGAR_COL] 		= 1; 
			if(catName == 'jambi') 		imageArray[imageIndex][JAMBI_COL] 		= 1; 
			if(catName == 'peppy') 		imageArray[imageIndex][PEPPY_COL] 		= 1; 
			if(catName == 'oscar') 		imageArray[imageIndex][OSCAR_COL] 		= 1; 
			if(catName == 'katchina') 	imageArray[imageIndex][KATCHINA_COL] 	= 1;
			if(catName == 'inkadu') 	imageArray[imageIndex][INKADU_COL] 		= 1;
		}

		// set the location flags

		var locationName = pictures[i].childNodes[3].childNodes[0].nodeValue;
		//alert(locationName);

		if(locationName == 'Bathroom') 	imageArray[imageIndex][BATHROOM_COL] 	= 1; 
		if(locationName == 'Bedroom') 	imageArray[imageIndex][BEDROOM_COL] 	= 1; 
		if(locationName == 'Hallway') 	imageArray[imageIndex][HALLWAY_COL] 	= 1; 
		if(locationName == 'Office') 		imageArray[imageIndex][OFFICE_COL] 		= 1; 
		if(locationName == 'Outside') 	imageArray[imageIndex][OUTSIDE_COL] 	= 1; 
		if(locationName == 'Stairs') 		imageArray[imageIndex][STAIRS_COL] 		= 1; 
		if(locationName == 'Kitchen') 	imageArray[imageIndex][KITCHEN_COL] 	= 1; 
		if(locationName == 'Ledge') 		imageArray[imageIndex][LEDGE_COL] 		= 1;

		// get meta data

		var imageTitle = pictures[i].childNodes[13].childNodes[0].nodeValue;
		imageArray[imageIndex][TITLE_COL] = imageTitle;

		var imageDate = pictures[i].childNodes[11].childNodes[0].nodeValue;
		imageArray[imageIndex][DATE_COL] = imageDate;

		var imageTime = pictures[i].childNodes[5].childNodes[0].nodeValue;
		imageArray[imageIndex][TIME_COL] = imageTime;

		var imageNote = pictures[i].childNodes[15].childNodes[0].data;
		imageArray[imageIndex][NOTE_COL] = imageNote;

		// preload image

		img =new Image();  img.src ="images/" + theImage;
		imageArray[imageIndex][PICTURE_COL] = img;

		// preload thumbs

		img =new Image();  img.src ="thumbs/" + theImage;
		imageArray[imageIndex][THUMB_COL] = img;

		//img =new Image();  img.src ="thumbs_on/" + theImage;
		//imageArray[imageIndex][THUMB_SEL_COL] = img;

		
		imageIndex++;
	}

}

function resizeAllThumbs(size)
{
	//alert("resizeall");
	var baseWidth = 136;
	var baseHeight = 100;

	var newWidth = (136 * size )/100;
	var newHeight = (100 * size )/100;

	for(var i = 0; i < thumbCount; i++)
	{
		var index = thumbArray[i];

		var thumbImage = document.getElementById("thumbImage"+index);			// get the element that holds the thumbs
		var thumb = document.getElementById("thumb"+index);			// get the element that holds the thumbs

		thumbImage.style.height = newHeight+"px";
		thumbImage.style.width = newWidth+"px";

		thumb.style.height = newHeight+"px";
		thumb.style.width = newWidth+"px";
	}

	//createCookie("THUMB_SIZE_COOKIE",size,30);

}

function clearThumbArray()
{
  	thumbArray = new Array();
	thumbCount = 0;
	currentThumb = 9999;
}

function setCurrentThumb(i)
{
	currentThumb = i;
}

function showSelectedThumbs()
{
	clearElement("thumbs");												// clear the thumb bar of all thumbs
	var thumb_bar = document.getElementById("thumbs");			// get the element that holds the thumbs
	//alert(thumb_bar);
	var firstImage;

	var showImage = 0;
	clearThumbArray();

	// fill thumb array

	for (var i = 0; i<imageIndex;i++)
	{
		if(showPicture(i) == 1)
		{
			thumbArray[thumbCount] = i;
  			thumbCount++;
		}
	}

	// thumb size stuff

	var baseWidth = 136;
	var baseHeight = 100;
	
	var thumbSizeField = document.getElementById("sliderValue3h");			// get the element that holds the thumbs
	var size = thumbSizeField.value;

	var newWidth = (136 * size )/100;
	var newHeight = (100 * size )/100;

	/*
	for(var i = 0; i < thumbCount; i++)
	{
		var index = thumbArray[i];

		var thumbImage = document.getElementById("thumbImage"+index);			// get the element that holds the thumbs
		var thumb = document.getElementById("thumb"+index);			// get the element that holds the thumbs

		thumbImage.style.height = newHeight+"px";
		thumbImage.style.width = newWidth+"px";

		thumb.style.height = newHeight+"px";
		thumb.style.width = newWidth+"px";
	}
	*/

	var styleString = 'height: ' + newHeight+'px' + ';' + 'width: ' + newWidth + 'px';
	//alert(styleString);



	// create thumbs from thumb array

	for (var i = 0; i<thumbCount;i++)
	{
		var imageNum = thumbArray[i];
		//var theImage = imageArray[imageNum][IMAGE_COL];
		var theThumb = imageArray[imageNum][THUMB_COL];

		// create div element for thumb array
		var newThumb = document.createElement("div");
		newThumb.className = "thumb";									// set the class to "thumb"
		newThumb.id = "thumb"+imageNum;										// set the id to be specific index
		newThumb.style.height = newHeight+"px";
		newThumb.style.width = newWidth+"px";
		//newThumb.onclick = 'handleThumbButton('+imageNum+','+i+')'										// set the id to be specific index

		// create img element for thumb array
		//var newImage = document.createElement("img");
		//newImage.className = "thumb";									// set the class to "thumb"
		//newImage.id = "thumbImage"+imageNum;
		//newImage.src= theThumb;
		
		//newThumb.appendChild(newImage);								// add the div to the thumb bar

		//newThumb.innerHTML = "<a href=javascript:handleThumbButton("+imageNum+","+i+")><img style='"+styleString+"' class='thumb' id=thumbImage"+imageNum+" src='thumbs/"+theImage+"' BORDER=0></a>";
		newThumb.innerHTML = "<a href=javascript:handleThumbButton("+imageNum+","+i+")><img style='"+styleString+"' class='thumb' id=thumbImage"+imageNum+" BORDER=0></a>";
		thumb_bar.appendChild(newThumb);								// add the div to the thumb bar
	}

	// assign thumb images

	for (var i = 0; i<thumbCount;i++)
	{
		var imageNum = thumbArray[i];
		var theThumb = imageArray[imageNum][THUMB_COL];
		
		var myThumb = document.getElementById("thumbImage"+imageNum);			// get the element that holds the thumbs
		myThumb.src = theThumb.src;

	}

	
	if(thumbCount > 0)
	{
		var myImage = readCookie("IMAGE_INDEX_COOKIE");
		var myThumb = readCookie("THUMB_INDEX_COOKIE");

		//alert("myImage = " + myImage);
		//alert("myThumb = " + myThumb);

		if(myImage != null)
		{
			myImage = parseInt(myImage);
			myThumb = parseInt(myThumb);

			handleThumbButton(myImage,myThumb);
		}
		else
		{
			setSelectedThumb(thumbArray[0]);
			setImage(thumbArray[0],0, "showSelectedThumbs");
		}


	}

	/*
	for (var i = 0; i<imageIndex;i++)
	{
		if(showPicture(i) == 1)
		{
			var theImage = imageArray[i][IMAGE_COL];

			thumbArray[thumbCount] = i;

			if(showImage == 0)
			{
				showImage = 1;
				//setImage("images/"+theImage);
				setImage(i);
				firstImage = i;
				currentImage = i;
				currentThumb = 0;
   			
				
				var newThumb = document.createElement("div");			// create a div element
				newThumb.className = "thumb";									// set the class to "thumb"
				newThumb.id = "thumb"+i;										// set the id to be specific index
				//newThumb.innerHTML = "<a href=javascript:setImage('images/"+theImage+"')><img class='thumb' src='thumbs/"+theImage+"' BORDER=0></a>";  
	
				//newThumb.innerHTML = "<a href=javascript:setImage("+i+");setSelectedThumb("+i+");setCurrentThumb("+thumbCount+")><img class='thumb' id=thumbImage"+i+" src='thumbs/"+theImage+"' BORDER=0></a>";
				newThumb.innerHTML = "<a href=javascript:handleThumbButton("+i+","+thumbCount+")><img class='thumb' id=thumbImage"+i+" src='thumbs/"+theImage+"' BORDER=0></a>";
	
				//var thumb_picture = document.getElementById("thumbImage"+i);			// get the element that holds the thumbs
				//alert(thumb_picture);
	
	
				thumb_bar.appendChild(newThumb);								// add the div to the thumb bar
				//selectedThumb(i);

		 }
			else
			{
			//alert(theImage);
	
				var newThumb = document.createElement("div");			// create a div element
				newThumb.className = "thumb";									// set the class to "thumb"
				newThumb.id = "thumb"+i;										// set the id to be specific index
				//newThumb.innerHTML = "<a href=javascript:setImage('images/"+theImage+"')><img class='thumb' src='thumbs/"+theImage+"' BORDER=0></a>";  
	
				newThumb.innerHTML = "<a href=javascript:handleThumbButton("+i+","+thumbCount+")><img class='thumb' id=thumbImage"+i+" src='thumbs/"+theImage+"' BORDER=0></a>";
	
				//var thumb_picture = document.getElementById("thumbImage"+i);			// get the element that holds the thumbs
				//alert(thumb_picture);
	
	
				thumb_bar.appendChild(newThumb);								// add the div to the thumb bar

			}
  			thumbCount++;
	 }
	}

	//alert("firstImage = " + firstImage);
	//setSelectedThumb(firstImage);

	*/
}

/*

function showSelectedThumbs2()
{
	clearElement("thumbs");												// clear the thumb bar of all thumbs
	var thumb_bar = document.getElementById("thumbs");			// get the element that holds the thumbs
	//alert(thumb_bar);
	var firstImage;

	var showImage = 0;
	clearThumbArray();
	
	for (var i = 0; i<imageIndex;i++)
	{
		if(showPicture(i) == 1)
		{
			var theImage = imageArray[i][IMAGE_COL];

			thumbArray[thumbCount] = i;

			if(showImage == 0)
			{
				showImage = 1;
				//setImage("images/"+theImage);
				setImage(i);
				firstImage = i;
				currentImage = i;
				currentThumb = 0;
   			
				
				var newThumb = document.createElement("div");			// create a div element
				newThumb.className = "thumb";									// set the class to "thumb"
				newThumb.id = "thumb"+i;										// set the id to be specific index
				//newThumb.innerHTML = "<a href=javascript:setImage('images/"+theImage+"')><img class='thumb' src='thumbs/"+theImage+"' BORDER=0></a>";  
	
				//newThumb.innerHTML = "<a href=javascript:setImage("+i+");setSelectedThumb("+i+");setCurrentThumb("+thumbCount+")><img class='thumb' id=thumbImage"+i+" src='thumbs/"+theImage+"' BORDER=0></a>";
				newThumb.innerHTML = "<a href=javascript:handleThumbButton("+i+","+thumbCount+")><img class='thumb' id=thumbImage"+i+" src='thumbs/"+theImage+"' BORDER=0></a>";
	
				//var thumb_picture = document.getElementById("thumbImage"+i);			// get the element that holds the thumbs
				//alert(thumb_picture);
	
	
				thumb_bar.appendChild(newThumb);								// add the div to the thumb bar
				//selectedThumb(i);

		 }
			else
			{
			//alert(theImage);
	
				var newThumb = document.createElement("div");			// create a div element
				newThumb.className = "thumb";									// set the class to "thumb"
				newThumb.id = "thumb"+i;										// set the id to be specific index
				//newThumb.innerHTML = "<a href=javascript:setImage('images/"+theImage+"')><img class='thumb' src='thumbs/"+theImage+"' BORDER=0></a>";  
	
				newThumb.innerHTML = "<a href=javascript:handleThumbButton("+i+","+thumbCount+")><img class='thumb' id=thumbImage"+i+" src='thumbs/"+theImage+"' BORDER=0></a>";
	
				//var thumb_picture = document.getElementById("thumbImage"+i);			// get the element that holds the thumbs
				//alert(thumb_picture);
	
	
				thumb_bar.appendChild(newThumb);								// add the div to the thumb bar

			}
  			thumbCount++;
	 }
	}

	//alert("firstImage = " + firstImage);
	//setSelectedThumb(firstImage);


}

*/


function showPicture(i)
{
  	if(SHOW_HAPPY == 1 && imageArray[i][HAPPY_COL] == 0) return 0;
  	if(SHOW_OSCAR == 1 && imageArray[i][OSCAR_COL] == 0) return 0;
  	if(SHOW_ANGEL == 1 && imageArray[i][ANGEL_COL] == 0) return 0;
  	if(SHOW_SUGAR == 1 && imageArray[i][SUGAR_COL] == 0) return 0;
  	if(SHOW_KATCHINA == 1 && imageArray[i][KATCHINA_COL] == 0) return 0;
  	if(SHOW_JAMBI == 1 && imageArray[i][JAMBI_COL] == 0) return 0;
  	if(SHOW_PEPPY == 1 && imageArray[i][PEPPY_COL] == 0) return 0;
  	if(SHOW_BATHROOM == 1 && imageArray[i][BATHROOM_COL] == 0) return 0;
  	if(SHOW_STAIRS == 1 && imageArray[i][STAIRS_COL] == 0) return 0;
  	if(SHOW_HALLWAY == 1 && imageArray[i][HALLWAY_COL] == 0) return 0;
  	if(SHOW_KITCHEN == 1 && imageArray[i][KITCHEN_COL] == 0) return 0;
  	if(SHOW_OFFICE == 1 && imageArray[i][OFFICE_COL] == 0) return 0;
  	if(SHOW_LEDGE == 1 && imageArray[i][LEDGE_COL] == 0) return 0;
  	if(SHOW_OUTSIDE == 1 && imageArray[i][OUTSIDE_COL] == 0) return 0;


	return 1;
}

function clearImage()
{
	var theImage = document.getElementById("theImage");			// get the element that holds the thumbs
	theImage.src = null; 

	var imageTitle = document.getElementById("imageTitle");
	imageTitle.innerHTML = "<center><h2>No images found</h2></center>";
	
	var imageInfo = document.getElementById("infotext");
	imageInfo.innerHTML = "No images found.<p><br>Please deselect some pet or place filters.";

	var thumbInfo = document.getElementById("thumbNum");
	var thumbText = "";
	thumbInfo.innerHTML = thumbText;

}

function setThumbSizeCookie()
{
	var thumbSizeField = document.getElementById("sliderValue3h");			// get the element that holds the thumbs
	var thumbSize = thumbSizeField.value;
	//alert(thumbSize);
	createCookie("THUMB_SIZE_COOKIE",thumbSize,30);

}

function setImage(imageIndex,thumbIndex, calledFrom)
{
	//alert("setImage(" + imageIndex + "," + thumbIndex + ")" + " Called from: " + calledFrom);

	createCookie("IMAGE_INDEX_COOKIE",imageIndex,30);
	createCookie("THUMB_INDEX_COOKIE",thumbIndex,30);
	setThumbSizeCookie();

	//currentImage = imageIndex;


	var theImage = document.getElementById("theImage");			// get the element that holds the thumbs
	theImage.src = imageArray[imageIndex][PICTURE_COL].src; 

	var imageTitle = document.getElementById("imageTitle");
	imageTitle.innerHTML = "<center><h2>"+imageArray[imageIndex][TITLE_COL]+"</h2></center>";

	var imageInfo = document.getElementById("infotext");
	var infotext = "<p>";

	infotext += "<b>Title:</b> " + imageArray[imageIndex][TITLE_COL] + "<p>";
	infotext += "<b>Time:</b> " + imageArray[imageIndex][TIME_COL] + "<BR>";
	infotext += "<b>Date:</b> " + imageArray[imageIndex][DATE_COL] + "<BR>";
	infotext += "<b>Pets:</b> " + " ";


	if(imageArray[imageIndex][HAPPY_COL] == 1) 		infotext += "Happy" 		+ " ";
	if(imageArray[imageIndex][OSCAR_COL] == 1) 		infotext += "Oscar" 		+ " ";
	if(imageArray[imageIndex][ANGEL_COL] == 1) 		infotext += "Angel" 		+ " ";
	if(imageArray[imageIndex][SUGAR_COL] == 1) 		infotext += "Sugar" 		+ " ";
	if(imageArray[imageIndex][KATCHINA_COL] == 1) 	infotext += "Katchina" 	+ " ";
	if(imageArray[imageIndex][JAMBI_COL] == 1) 		infotext += "Jambi" 		+ " ";
	if(imageArray[imageIndex][PEPPY_COL] == 1) 		infotext += "Peppy" 		+ " ";
	if(imageArray[imageIndex][INKADU_COL] == 1) 		infotext += "Inkadu" 	+ " ";


	infotext += "<BR>";
	infotext += "<b>Place:</b> ";

	if(imageArray[imageIndex][BEDROOM_COL] == 1) 	infotext += "Bedroom" 		+ "<BR>";
	if(imageArray[imageIndex][BATHROOM_COL] == 1) 	infotext += "Bathroom" 		+ "<BR>";
	if(imageArray[imageIndex][HALLWAY_COL] == 1) 	infotext += "Hallway" 		+ "<BR>";
	if(imageArray[imageIndex][STAIRS_COL] == 1) 		infotext += "Stairs" 		+ "<BR>";
	if(imageArray[imageIndex][KITCHEN_COL] == 1) 	infotext += "Kitchen" 		+ "<BR>";
	if(imageArray[imageIndex][OFFICE_COL] == 1) 		infotext += "Office" 		+ "<BR>";
	if(imageArray[imageIndex][LEDGE_COL] == 1) 		infotext += "Ledge" 			+ "<BR>";
	if(imageArray[imageIndex][OUTSIDE_COL] == 1) 	infotext += "Outside" 		+ "<BR>";


	if(imageArray[imageIndex][JOURNAL_COL] >= 0)
	{
		infotext += "<b>Journal: <a href='javascript:passJournalLink("+imageArray[imageIndex][JOURNAL_COL]+")'>Link</a></b> "+ "<BR>";
	}

	infotext += "<BR>";
	infotext += "<b>Note:</b> "+imageArray[imageIndex][NOTE_COL] + "<BR>";

	imageInfo.innerHTML = infotext;

	var thumbInfo = document.getElementById("thumbNum");
	var thumbText = "<p>";
	thumbText += "<b>Image:</b> "+(thumbIndex+1)+" of "+ thumbCount + "<BR>";

	thumbInfo.innerHTML = thumbText;
}

function passJournalLink(id)
{
	createCookie("JOURNAL_ENTRY_COOKIE",id,30);
	window.location = "../journal.html";
}

// createThumbs()
//
// creates a set of thumbs for the thumb bar

function createThumbs()
{
	clearElement("thumbs");												// clear the thumb bar of all thumbs
	
	var thumb_bar = document.getElementById("thumbs");			// get the element that holds the thumbs

	for(i = 0; i < 10; i++)
	{
		var newThumb = document.createElement("div");			// create a div element
		newThumb.className = "thumb";									// set the class to "thumb"
		newThumb.id = "thumb"+i;										// set the id to be specific index
		thumb_bar.appendChild(newThumb);								// add the div to the thumb bar
	}
}

// clearElement(name)
//
// parameters:
//		name:		the name of the element to clear
//
// clears the html of the element indicated by name

function clearElement(name)
{
	var element = document.getElementById(name);					// get the element to clear
	element.innerHTML = "";												// set the html of this element to blank
}


//	loadXML(xmlURL)

function loadXML(xmlURL)
{
   var xmlDoc;
   
   if (document.implementation && document.implementation.createDocument)
   {
      xmlDoc = document.implementation.createDocument("", "", null);
   }
   else
   {
      xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
   }
   xmlDoc.async = false;
   xmlDoc.load(xmlURL);

   return xmlDoc;
} 


