var hideProgress;
var schools = 1;
var employment = 1;
var current_gallery_image = 0;

function hideProgressBox()
{
	Element.hide('progress_box');
}

function showGalleryImage(gallery_id)
{
	if ( gallery_id != current_gallery_image )
	{
		grayOut(true);
		$('gallery_image_first').innerHTML = '';

		var url = 'gallery_ajax.php';

		/* make the ajax request for the information */
		new Ajax.Request(url, {
			method: 'post',
			parameters: 'gallery_id=' + gallery_id,
			onSuccess: function(xhrResponse) {
				var response = xhrResponse.responseText;
				var response_position = response.indexOf('-eboltajaxmedia-');
				var response_plus = (response_position + 16); // 16 because -eboltajaxmedia- is 16 chars

				var browser_width = 0
				var browser_height = 0;
				if ( typeof (window.innerWidth) == 'number' ) // Non-IE browsers.
				{
					browser_width = parseInt(window.innerWidth);
					browser_height = parseInt(window.innerHeight);
				}
				else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) // All IE except version 4
				{
					browser_width = parseInt(document.documentElement.clientWidth);
					browser_height = parseInt(document.documentElement.clientHeight);
				}
				else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) // IE 4
				{
					browser_width = parseInt(document.body.clientWidth);
					browser_height = parseInt(document.body.clientHeight);
				}

				var find_width = 0;
				var find_height = 0;
				var find_dimensions = response.substring(0, response_position);
				var find_width_string = find_dimensions.substring(0, find_dimensions.indexOf('px;'));
				find_width = parseInt(find_width_string.replace('width: ', ''));

				var next_spot = (find_dimensions.indexOf('px;') + 3);
				var find_height_string = find_dimensions.substring(next_spot, (find_dimensions.length - 4));
				find_height = parseInt(find_height_string.replace('height: ', ''));

				$('gallery_image_first').innerHTML = response.substring(response_plus, response.length);
				var new_width_half = ((browser_width - find_width)/2);
				var new_height_half = ((browser_height - find_height)/2) - 20;

				document.getElementById('gallery_image').style.marginLeft = new_width_half + 'px';
				document.getElementById('gallery_image').style.marginTop = new_height_half + 'px';
				Element.show('gallery_image');

				$('gallery_image_text').innerHTML = '';

				setTimeout("showImageGallery()", 1000);
				new Effect.Morph('gallery_image_text', { style: response.substring(0, response_position), duration: 1.0 });

				current_gallery_image = gallery_id;
			},
			onFailure: function(xhrResponse) {
				$('progress_text').innerHTML = 'Error: ' + xhrReponse.statusText;
			}
		});
	}
	else
	{
		grayOut(true);
		Element.show('gallery_image');
		Element.show('gallery_image_close');
	}
}

function showImageGallery()
{
	Element.show('gallery_image_close');
	$('gallery_image_text').innerHTML = $('gallery_image_first').innerHTML;
	$('gallery_image_first').innerHTML = '';
}

function closeGalleryImage()
{
	grayOut(false);
	Element.hide('gallery_image');
	Element.hide('gallery_image_close');
}
