function createRequestObject() 
{

	var req;
	
	if(window.XMLHttpRequest)
	{
		req = new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		alert('There was a problem. You will be unable to use this website. Please upgrade to a modern browser.');
	}
	
	return req;

}

var http_r = createRequestObject();

function fd_set_main_nav_images_to_default_state()
{

		document.getElementById("main_nav1").src = 'images/fd_nav1.gif';
		document.getElementById("main_nav2").src = 'images/fd_nav2.gif';
		document.getElementById("main_nav3").src = 'images/fd_nav3.gif';
		document.getElementById("main_nav4").src = 'images/fd_nav4.gif';
		document.getElementById("main_nav5").src = 'images/fd_nav5.gif';
		
		document.getElementById("nav_href_1").onmouseover = function(){ navOver('main_nav1', 'main_nav1_on') }
		document.getElementById("nav_href_2").onmouseover = function(){ navOver('main_nav2', 'main_nav2_on') }
		document.getElementById("nav_href_3").onmouseover = function(){ navOver('main_nav3', 'main_nav3_on') }
		document.getElementById("nav_href_4").onmouseover = function(){ navOver('main_nav4', 'main_nav4_on') }
		document.getElementById("nav_href_5").onmouseover = function(){ navOver('main_nav5', 'main_nav5_on') }
		
		document.getElementById("nav_href_1").onmouseout = function(){ navOver('main_nav1', 'main_nav1_off') }
		document.getElementById("nav_href_2").onmouseout = function(){ navOver('main_nav2', 'main_nav2_off') }
		document.getElementById("nav_href_3").onmouseout = function(){ navOver('main_nav3', 'main_nav3_off') }
		document.getElementById("nav_href_4").onmouseout = function(){ navOver('main_nav4', 'main_nav4_off') }
		document.getElementById("nav_href_5").onmouseout = function(){ navOver('main_nav5', 'main_nav5_off') }
		
}

function fd_set_themes_nav_images_to_default_state()
{
		
		document.getElementById("nav1").src = 'images/fd_theme1.gif';
		document.getElementById("nav2").src = 'images/fd_theme2.gif';
		document.getElementById("nav3").src = 'images/fd_theme3.gif';
		document.getElementById("nav4").src = 'images/fd_theme4.gif';
		document.getElementById("nav5").src = 'images/fd_theme5.gif';
		document.getElementById("nav6").src = 'images/fd_theme6.gif';
		document.getElementById("nav7").src = 'images/fd_theme7.gif';
		document.getElementById("nav8").src = 'images/fd_theme8.gif';
		document.getElementById("nav9").src = 'images/fd_theme9.gif';
		document.getElementById("nav10").src = 'images/fd_theme10.gif';
		document.getElementById("nav11").src = 'images/fd_theme11.gif';
		document.getElementById("nav12").src = 'images/fd_theme12.gif';
		document.getElementById("nav13").src = 'images/fd_theme13.gif';
		document.getElementById("nav14").src = 'images/fd_theme14.gif';
		
		document.getElementById("theme_href_1").onmouseover = function(){ navOver('nav1', 'nav1_on') }
		document.getElementById("theme_href_2").onmouseover = function(){ navOver('nav2', 'nav2_on') }
		document.getElementById("theme_href_3").onmouseover = function(){ navOver('nav3', 'nav3_on') }
		document.getElementById("theme_href_4").onmouseover = function(){ navOver('nav4', 'nav4_on') }
		document.getElementById("theme_href_5").onmouseover = function(){ navOver('nav5', 'nav5_on') }
		document.getElementById("theme_href_6").onmouseover = function(){ navOver('nav6', 'nav6_on') }
		document.getElementById("theme_href_7").onmouseover = function(){ navOver('nav7', 'nav7_on') }
		document.getElementById("theme_href_8").onmouseover = function(){ navOver('nav8', 'nav8_on') }
		document.getElementById("theme_href_9").onmouseover = function(){ navOver('nav9', 'nav9_on') }
		document.getElementById("theme_href_10").onmouseover = function(){ navOver('nav10', 'nav10_on') }
		document.getElementById("theme_href_11").onmouseover = function(){ navOver('nav11', 'nav11_on') }
		document.getElementById("theme_href_12").onmouseover = function(){ navOver('nav12', 'nav12_on') }
		document.getElementById("theme_href_13").onmouseover = function(){ navOver('nav13', 'nav13_on') }
		document.getElementById("theme_href_14").onmouseover = function(){ navOver('nav14', 'nav14_on') }
		
		document.getElementById("theme_href_1").onmouseout = function(){ navOver('nav1', 'nav1_off') }
		document.getElementById("theme_href_2").onmouseout = function(){ navOver('nav2', 'nav2_off') }
		document.getElementById("theme_href_3").onmouseout = function(){ navOver('nav3', 'nav3_off') }
		document.getElementById("theme_href_4").onmouseout = function(){ navOver('nav4', 'nav4_off') }
		document.getElementById("theme_href_5").onmouseout = function(){ navOver('nav5', 'nav5_off') }
		document.getElementById("theme_href_6").onmouseout = function(){ navOver('nav6', 'nav6_off') }
		document.getElementById("theme_href_7").onmouseout = function(){ navOver('nav7', 'nav7_off') }
		document.getElementById("theme_href_8").onmouseout = function(){ navOver('nav8', 'nav8_off') }
		document.getElementById("theme_href_9").onmouseout = function(){ navOver('nav9', 'nav9_off') }
		document.getElementById("theme_href_10").onmouseout = function(){ navOver('nav10', 'nav10_off') }
		document.getElementById("theme_href_11").onmouseout = function(){ navOver('nav11', 'nav11_off') }
		document.getElementById("theme_href_12").onmouseout = function(){ navOver('nav12', 'nav12_off') }
		document.getElementById("theme_href_13").onmouseout = function(){ navOver('nav13', 'nav13_off') }
		document.getElementById("theme_href_14").onmouseout = function(){ navOver('nav14', 'nav14_off') }
		
}

function fd_set_thumbs_to_default_state()
{
	document.getElementById("thumb1").style.border = '1px solid #fff;';
	document.getElementById("thumb2").style.border = '1px solid #fff;';
	document.getElementById("thumb3").style.border = '1px solid #fff;';
	document.getElementById("thumb4").style.border = '1px solid #fff;';
	document.getElementById("thumb5").style.border = '1px solid #fff;';
}

function fd_r(theme,nav_id,nav_id_image,nav_href) 
{
	fd_set_main_nav_images_to_default_state();
	fd_set_themes_nav_images_to_default_state();
	document.getElementById(nav_id).src = 'images/' + nav_id_image;
	document.getElementById(nav_href).onmouseover = '';
	document.getElementById(nav_href).onmouseout = '';
  http_r.open('get', '_content/' + theme);
  http_r.onreadystatechange = handleResponse;
  http_r.send(null);
}

function fd_image_caption(theme,img) 
{
  http_r.open('get', '_content/captions/' + theme + '/' + img + '.txt');
  http_r.onreadystatechange = image_caption_response;
  http_r.send(null);
}

function image_response(theme,img) 
{
	//document.getElementById("main_image").src = 'images/' + theme + '/' + img + '.jpg';
	document.getElementById("main_image_href").href = 'JavaScript:myLightbox.start(\'images/' + theme + '/' + img + '_f.jpg\',\'\')';
	document.getElementById("fd_image_main").style.background = '#fff url(images/' + theme + '/' + img + '.jpg) no-repeat';
	fd_image_caption(theme,img);
}

function nav_image_response(nav_id,img) 
{
	document.getElementById(nav_id).src = 'images/' + img;
}

function image_caption_response() 
{
	if(http_r.readyState == 4 && http_r.status == 200)
	{
		var response = http_r.responseText;
		if(response) 
		{
			
				document.getElementById("fd_image_caption").innerHTML = response;
		}
	}
}

function handleResponse() 
{
	if(http_r.readyState == 4 && http_r.status == 200)
	{
		var response = http_r.responseText;
		if(response) 
		{
			
				document.getElementById("fd_content").innerHTML = response;
		}
	}
}

function addLoadEvent(func)
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}
}

/*
*
*		Function: openWindow
*		Open a page in a new window.
*
* 			url: URL of page you want to open.
* 			name: Unique name for the pop-up window.
* 			width: Width of the pop-up window.
* 			height: Height of the pop-up window.
* 			scroll: Window scrolling on and off. (0,1)
*
*				openWindow('image_viewer.asp?my_image=image_name.jpg','my_new_window','800','600',0);
*
*/

function openWindow(url,name,width,height,scroll)
{
	var win;
	win = window.open('' + url + '','' + name + '','width=' + width + ',height=' + height + ',scrollbars=' + scroll + ',resizable=1,status=1,menubar=0');
}

function navOver(arg1,arg2)
{
	if(document.images)
	{
		document[arg1].src = eval(arg2 + ".src");
	}
}
	
if (document.images)
{
		
			nav1_on = new Image();
			nav1_on.src = "images/fd_theme1_on.gif";

			nav1_off = new Image();
			nav1_off.src = "images/fd_theme1.gif";
			
			nav2_on = new Image();
			nav2_on.src = "images/fd_theme2_on.gif";

			nav2_off = new Image();
			nav2_off.src = "images/fd_theme2.gif";
			
			nav3_on = new Image();
			nav3_on.src = "images/fd_theme3_on.gif";

			nav3_off = new Image();
			nav3_off.src = "images/fd_theme3.gif";
			
			nav4_on = new Image();
			nav4_on.src = "images/fd_theme4_on.gif";

			nav4_off = new Image();
			nav4_off.src = "images/fd_theme4.gif";
			
			nav5_on = new Image();
			nav5_on.src = "images/fd_theme5_on.gif";

			nav5_off = new Image();
			nav5_off.src = "images/fd_theme5.gif";
			
			nav6_on = new Image();
			nav6_on.src = "images/fd_theme6_on.gif";

			nav6_off = new Image();
			nav6_off.src = "images/fd_theme6.gif";
			
			nav7_on = new Image();
			nav7_on.src = "images/fd_theme7_on.gif";

			nav7_off = new Image();
			nav7_off.src = "images/fd_theme7.gif";
			
			nav8_on = new Image();
			nav8_on.src = "images/fd_theme8_on.gif";

			nav8_off = new Image();
			nav8_off.src = "images/fd_theme8.gif";
			
			nav9_on = new Image();
			nav9_on.src = "images/fd_theme9_on.gif";

			nav9_off = new Image();
			nav9_off.src = "images/fd_theme9.gif";
			
			nav10_on = new Image();
			nav10_on.src = "images/fd_theme10_on.gif";

			nav10_off = new Image();
			nav10_off.src = "images/fd_theme10.gif";
			
			nav11_on = new Image();
			nav11_on.src = "images/fd_theme11_on.gif";

			nav11_off = new Image();
			nav11_off.src = "images/fd_theme11.gif";
			
			nav12_on = new Image();
			nav12_on.src = "images/fd_theme12_on.gif";

			nav12_off = new Image();
			nav12_off.src = "images/fd_theme12.gif";
			
			nav13_on = new Image();
			nav13_on.src = "images/fd_theme13_on.gif";

			nav13_off = new Image();
			nav13_off.src = "images/fd_theme13.gif";
			
			nav14_on = new Image();
			nav14_on.src = "images/fd_theme14_on.gif";

			nav14_off = new Image();
			nav14_off.src = "images/fd_theme14.gif";
			
			main_nav1_on = new Image();
			main_nav1_on.src = "images/fd_nav1_on.gif";

			main_nav1_off = new Image();
			main_nav1_off.src = "images/fd_nav1.gif";
			
			main_nav2_on = new Image();
			main_nav2_on.src = "images/fd_nav2_on.gif";

			main_nav2_off = new Image();
			main_nav2_off.src = "images/fd_nav2.gif";
			
			main_nav3_on = new Image();
			main_nav3_on.src = "images/fd_nav3_on.gif";

			main_nav3_off = new Image();
			main_nav3_off.src = "images/fd_nav3.gif";
			
			main_nav4_on = new Image();
			main_nav4_on.src = "images/fd_nav4_on.gif";

			main_nav4_off = new Image();
			main_nav4_off.src = "images/fd_nav4.gif";
			
			main_nav5_on = new Image();
			main_nav5_on.src = "images/fd_nav5_on.gif";

			main_nav5_off = new Image();
			main_nav5_off.src = "images/fd_nav5.gif";
			
}