// DISABLE RIGHT-CLICK
var message="";
///////////////////////////////////
	function clickIE() {if (document.all) {(message);return false;}}
	function clickNS(e) {if 
	(document.layers||(document.getElementById&&!document.all)) {
	if (e.which==2||e.which==3) {(message);return false;}}}
	if (document.layers) 
	{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
	else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
	
	document.oncontextmenu=new Function("return false")


// DROPDOWN MENU
var timeout         = 0;
var closetimer		= 0;
var ddmenuitem      = 0;

function jsddm_open()
{	jsddm_canceltimer();
	jsddm_close();
	ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');
	$(this).addClass('open_menu');
}
	
function jsddm_close() {	
	if(ddmenuitem) {
			ddmenuitem.css('visibility', 'hidden');
			$('li').removeClass("open_menu");
	}
}

function jsddm_timer()
{	closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{	if(closetimer)
	{	window.clearTimeout(closetimer);
		closetimer = null;}}

$(document).ready(function() {	
						   
		$('#jsddm > li').bind('mouseover', jsddm_open);
		$('#jsddm > li').bind('mouseout',  jsddm_timer);
	
		$('.gallery_demo_unstyled').addClass('gallery_demo'); // adds new class name to maintain degradability
		$('ul.gallery_demo li:eq(0)').addClass('active');
		$('ul.gallery_demo').galleria({
			history   : false, // activates the history object for bookmarking, back-button etc.
			clickNext : true, // helper for making the image clickable
			insert    : '#main_image', // the containing selector for our main image
			onImage   : function(image,caption,thumb) { // let's add some image effects for demonstration purposes
				
				// fade in the image & caption
				image.css('display','none').fadeIn(1000);
				caption.css('display','none');
				
				// fetch the thumbnail container
				var _li = thumb.parents('li');
				
				// fade out inactive thumbnail
				_li.siblings().children('img.selected').fadeTo(500,0.3);
				
				// fade in active thumbnail
				thumb.fadeTo('fast',1).addClass('selected');
				
				// add a title for the clickable image
				image.attr('title','Next image >>');
			},
			onThumb : function(thumb) { // thumbnail effects goes here
				
				// fetch the thumbnail container
				var _li = thumb.parents('li');
				
				// if thumbnail is active, fade all the way.
				var _fadeTo = _li.is('.active') ? '1' : '0.3';
				
				// fade in the thumbnail when finnished loading
				thumb.css({display:'none',opacity:_fadeTo}).fadeIn(1500);
				
				// hover effects
				thumb.hover(
					function() { thumb.fadeTo('fast',1); },
					function() { _li.not('.active').children('img').fadeTo('fast',0.3); } // don't fade out if the parent is active
				)
			}
		});
	$('.caption_toggle').click(function() {
		$(".caption").slideToggle();
	});
	
	//START JOE SCRIPT
	
	$("li.page-item-16 > a").click(function() {
										  return false;
										  });
	
	imageList = $("ul.galleria");
	imageListItems = $("ul.galleria li");
	
	totalImages = imageListItems.size();
	
	maxScroll = -(Math.floor(totalImages / 9) * 425);
	
	$("span.move_down").click(function() {
		if (imageList.css("top") != maxScroll+"px") {
			imageList.animate({top: "-=425px"}, "fast");
		}
	});
	
	$("span.move_up").click(function() {
		if (imageList.css("top") != "0px") {
			imageList.animate({top: "+=425px"}, "fast");
		}
	});
	
	/*listHeight = $("#thumbnails ul").height();
	listHeight = listHeight - 40;
	listPos = $("#thumbnails ul").css("top");
	$("#offset").html(listPos);
	$("#status").html(listHeight);
	
	function moveUp() {
		if ($("#thumbnails ul").css("top") > "-480px") {
			$("#thumbnails ul").animate({top: "-=50px"}, "fast", moveUp);
		}
	listPos = $("#thumbnails ul").css("top");
	$("#offset").html(listPos);
	}
	function moveDown() {
		if ($("#thumbnails ul").css("top") < "0px") {
			$("#thumbnails ul").animate({top: "+=50px"}, "fast", moveDown);
	listPos = $("#thumbnails ul").css("top");
	$("#offset").html(listPos);
		}
	}
	function stopScroll() {
			$("#thumbnails ul").stop();
	}

	$("#move_up").hover(function(){
		moveUp();
	}, function(){
		stopScroll();
	});
	$("#move_down").hover(function(){
		moveDown();
	}, function(){
		stopScroll();
	});*/

  
  	});
document.onclick = jsddm_close;
