$(document).ready(function(){
	
	//page name
	var url = window.location.href.split("/");
	var page = url[3];
	if (page=='') {page='index.php'}
	
	//flash
	page_name = page.replace('.php', '').replace('#', '');
	$(document).ready(function(){
		$('#flash_content').flash({src: '../images/'+page_name+'.swf', width: 300, height: 630});
	});
	
	//side_nav	
	var menu = page.substring(0, 4);
	if (menu=='menu') {
		$("#left_col ul#side_nav ul").css("display", "block");
	}	
	$("#side_nav li a#menu").toggle(
	function(){
		$(this).parent("li").children("ul").show();
	},
	function(){
		$(this).parent("li").children("ul").hide();
	}
	);
	
	//locations & gallery---------------------------
	
	$("#gallery #thumbs ul li div.shad").css("opacity", "0.5");
	$("#gallery #thumbs ul li div.shad").css("top", "0");	
	$("#gallery #thumbs ul li a").hover(
		function(){
			$(this).children("div.shad").css("top", "84px");
		},
		function(){
			$(this).children("div.shad").css("top", "0");
		}	
	);
	
	var num_of_images = $("#thumbs ul > li").length;
	var image_width = 85;//with + margin
	var list_width = num_of_images * image_width;
	
	$("#thumbs ul").css("width", list_width);

	var left = 0;
	
	$("#arrow_prev").click(function(){
		if (left<0) {
			$("#gallery #thumbs ul").animate({"left": "+=85px"}, 1);
			left+=85;
		}
		return false;
	});

	$("#arrow_next").click(function(){
		if (Math.abs(left) < (list_width-427)) {
			$("#gallery #thumbs ul").animate({"left": "-=85px"}, 1);
			left-=85;
		}
		return false;
	});
	
	$("#thumbs ul li a").click(function () {
		//hide map
		$("#location_map").hide();
		//display image from gallery
		var img_class = $(this).children("img").get(0).className;		
		$("#image_holder img").removeClass("visible");
		$("#image_holder img."+img_class+"").addClass("visible");
		return false;
	});
	$("#gallery #map a").click(function () {
		$("#image_holder img").removeClass("visible");
		$("#location_map").show();
	});
	
	//lightbox---------------------------
	
	$("ul.press a").lightBox();
	$("ul.gallery a").lightBox();

	//faq--------------------------------
	$('.faq a').toggle(
		function(){
			$(this).next('.answer').slideDown();
		},
		function(){
			$(this).next('.answer').slideUp();
		}
	)
	
	//menu images ------------------------
	$(".menu_images li .name a").hover(
		function () {
			$(".menu_image").hide();
			$(this).parent(".name").next(".menu_image").show();
		}, 
		function () {
			$(this).parent(".name").next(".menu_image").hide();
		}
	);
	
 });