$(document).ready(
	function()
	{
		if( $("#gallery_links") ){

			// global path to gallery images
			var gallery_path = 'pics/';

			function getPath(link)
			{
				return link = (link.indexOf('http://') > -1) ? jQuery.trim(link) : gallery_path + jQuery.trim(link);
			}

			$("#gallery_nav > a").each(
				function(index)
				{
					if(index){
						$tmpArray = this.name.split(',', 3);
						$("#gallery_links").append("<a href='" + getPath($tmpArray[1]) + "' title='" + 	$tmpArray[2] + "' class='thickbox' rel='gallery-pic'></a>");
					}
				}
			);

			$("#gallery_nav > a").click(
				function()
				{
					$("#gallery_nav > a").each(function(){	this.className = ''; });
					$("#gallery_links > a").empty();
					var $tmpArray = $(this).attr("name").split(',', 3);
					$("#gallery_links > a").each(
						function()
						{
							if( this.href.indexOf(getPath($tmpArray[1])) > -1 ){
								$(this).append("<img src='" + getPath($tmpArray[0]) + "' height='303' width='288' border='0' alt='" + $tmpArray[2] + "'>");
							}
						}
					);
					$(this).addClass("active");
					$(this).blur();
				}
			);

			tb_init('a.thickbox, area.thickbox, input.thickbox');
			imgLoader = new Image();
			imgLoader.src = tb_pathToImage;
		}

        //objects subsections
		function showSection(section)
		{
			$("div.cat_srv").find("a").removeClass('active');
			$(section).addClass('active');
            $(section).blur();
			var target = $(section).attr('href').slice(1,15);
			$("div.objects > div.object_item").css("display", "none");
			$("div." + target).fadeIn("slow");
		}
		$("div.cat_srv").find("a").click(
			function(event){
				event.preventDefault();
				showSection(this);
			}
		);
	}
);
