$(document).ready(function(){
	if (document.images){
	  pic1= new Image(1,1); 
	  pic1.src="/resources/design/subnavbg.png"; 
	}
	$('li','#Navigation').each(function(i,d){
		if ( $('ul',this).length > 0 )
			$(this).addClass('Sub');
	});
	$('li','#Navigation').hover(function(){
		if ( $('ul',this) ) {
			var el = this;
			if ( $(this).hasClass('active') ) {
				$('ul',this).show().slideUp( 400,function(){ $(el).removeClass('active'); });
			} else {
				$(el).addClass('active');
				$('ul',this).hide().slideDown(400,function(){  });
			}
		}
	});
	$("a",".gallery-icon").fancybox({
		'titlePosition' 		: 'inside'
	});
	$("a", ".imageShow ul").fancybox({
		'titlePosition' 		: 'inside'
	});
	$('.imageShow').slideShow();
	$('.backtop').click(function(){
		$('body').animate({scrollTop: 0}, 900);
		return false;
	});
});
(function($){
$.fn.slideShow = function(options) {
	var defaults = {
		delay: 4000,
		fader: 700
	};
	var options = $.extend(defaults, options);
	function init(el)
	{
		options.delay = (options.delay + options.fader);
		el.total = parseInt($("li",el).size());
		el.current = 0;
		$("li",el).hide().eq(0).show();
		el.timer = setInterval(function(){ refresh(el,true); }, options.delay);
		$('.leftArrow',el).click(function(){refresh(el,false);return false;});
		$('.rightArrow',el).click(function(){refresh(el,true);return false;});
		$( el ).hover(function(){
			clearTimeout( el.timer );
			$('a', el).filter('.leftArrow,.rightArrow').fadeIn(250);
		}, function() {
			el.timer = setInterval(function(){ refresh(el,true); }, options.delay);
			$('a', el).filter('.leftArrow,.rightArrow').fadeOut(250);
		});
	};
	function refresh(el, direction)
	{
		direction = direction || false;
		el.next = ( direction ? el.current+1 : el.current-1);
		if ( el.next >= el.total ) el.next = 0;
		$("li",el).eq(el.current).fadeOut( options.fader );
		$("li",el).eq(el.next).fadeIn( options.fader );
		el.current = el.next;
		return false;
	};
	this.timeout = 0;
	return this.each(function() {
		init(this);
	});
};
})(jQuery);
