	GLOBALS = {};
	GLOBALS.slide_show_on = false;

	try {
		document.execCommand("BackgroundImageCache", false, true); 
	} catch (err) {}

	function $(name)
	{
		return document.getElementById(name);
	}

	function slideShowStart()
	{
		if (!GLOBALS.slide_show_on) {
			GLOBALS.slide_show_on = true;
			$('play_button').src = $('play_button').src.replace(/_n\.gif/, '_a.gif');
			$('stop_button').src = $('stop_button').src.replace(/_a\.gif/, '_n.gif');
			showNextImage();
		}
	}

	function slideShowStop()
	{
		if (GLOBALS.slide_show_on) {
			GLOBALS.slide_show_on = false;
			$('play_button').src = $('play_button').src.replace(/_a\.gif/, '_n.gif');
			$('stop_button').src = $('stop_button').src.replace(/_n\.gif/, '_a.gif');
		}
	}

	function showNextImage()
	{
		if (GLOBALS.slide_show_on) {
			$('elevator').src = '/upload/image/366x267/' + (image_order[selected_image].n) + '.jpg';
		}
	}

	function setIntervalValue(obj, i)
	{
		$('photo_session').value = i;
		$(selected_interval).style.color = '#ffffff';
		selected_interval = obj.id;
		obj.style.color = '#6297b6';
	}

	function goToStage(step)
	{
		var x = parseInt($('elevator_box').style.left);
		if (x < 0) {
			var undef;
			if (typeof(undef) == typeof(step)) {
				step = 1;
			}
			if ((x + step) > 0) {
				step = 0 - x;
			}
			$('elevator_box').style.left = (x + step) + 'px';
			if (x > -186) {
				setTimeout('goToStage(' + (step - 1) + ');', 10);
			} else {
				setTimeout('goToStage(' + (step + 1) + ');', 10);
			}
		} else {
			showImage(image_order[selected_image].n, true);
			var interval = $('photo_session').value * 1000;
			setTimeout('$("elevator_box").style.left = "-372px";', (interval / 2));
			setTimeout('showNextImage();', interval);
		}
	}

	function showImage(id, hard)
	{
		var undef;
		if (typeof(undef) == typeof(hard)) {
			hard = false;
		}
		if (!GLOBALS.slide_show_on || hard) {
			$('big_image').src = '/upload/image/366x267/' + id + '.jpg';
			$('image_button_' + id).className = 'sel';
			$('image_button_' + selected_image).className = '';
			selected_image = id;
		}
	}

	function sendSearchQuery(entity)
	{
		var tmp = '/' + entity + '/';
		for (var i in GLOBALS.search_fields) {
			if (!$(GLOBALS.search_fields[i])) {
				alert(GLOBALS.search_fields[i]);
			}
			if ($(GLOBALS.search_fields[i]).getAttribute('type') == 'radio') {
				if ($(GLOBALS.search_fields[i]).checked) {
					tmp += 'Y/';
				} else if ($(GLOBALS.search_fields[i] + '_off').checked) {
					tmp += 'N/';
				} else {
					tmp += '-' + GLOBALS.search_fields[i] + '/';
				}
			} else {
				if ($(GLOBALS.search_fields[i]).value == '') {
					tmp += '-' + GLOBALS.search_fields[i] + '/';
				} else {
					tmp += $(GLOBALS.search_fields[i]).value + '/';
				}
			}
		}
		document.location.href = tmp;
	}
