
	
	$(document).ready(function(){
							   
							   
  var currentPosition = 0;
  var slideWidth = 136;
  var slides = $('.slide');
  var numberOfSlides = 5;

  // Remove scrollbar in JS
  $('#slidesContainer').css('overflow', 'hidden');

  // Wrap all .slides with #slideInner div
  slides
  .wrapAll('<div id="slideInner"></div>')
  // Float left to display horizontally, readjust .slides width
  .css({
    'float' : 'left',
    'width' : slideWidth
  });

  // Set #slideInner width equal to total width of all slides
  $('#slideInner').css('width', slideWidth * numberOfSlides);

  // Insert left and right arrow controls in the DOM
  $('#slideshow')
    .prepend('<span class="control" id="leftControl">Move left</span>')
    .append('<span class="control" id="rightControl">Move right</span>');

  // Hide left arrow control on first load
  manageControls(currentPosition);

  // Create event listeners for .controls clicks
  $('.control')
    .bind('click', function(){
    // Determine new position
      currentPosition = ($(this).attr('id')=='rightControl')
    ? currentPosition+1 : currentPosition-1;

      // Hide / show controls
      manageControls(currentPosition);
      // Move slideInner using margin-left
      $('#slideInner').animate({
        'marginLeft' : slideWidth*(-currentPosition)
      });
    });

  // manageControls: Hides and shows controls depending on currentPosition
  function manageControls(position){
    // Hide left arrow if position is first slide
    if(position==0){ $('#leftControl').hide() }
    else{ $('#leftControl').show() }
    // Hide right arrow if position is last slide
    if(position==numberOfSlides-3){ $('#rightControl').hide() }
    else{ $('#rightControl').show() }
    }

							   
							   
							   
		$("a[rel='colorBox']").colorbox({transition:"none"});

		
		//Flash Header
		$('#movement').flash(
			{ src: '/img/background.swf', width: '100%', height: 260, wmode: 'opaque', bgcolor: '#000000'},
			{ version: '6.0.65' }
		);
		
		$("#aboutSub, #aboutTab").mouseover(function(){
			$(".aboutTab").css({'background-image' : 'url(/img/menu.sel.jpg)'});
			$("#aboutSub").css({'left' : 'auto'});	
		});
		$("#aboutSub, #aboutTab").mouseout(function(){
			$(".aboutTab").css({'background-image' : 'none'});	
			$("#aboutSub").css({'left' : '-9999px'});	
		});
		$("#galleriesSub, #galleriesTab").mouseover(function(){
			$(".galleriesTab").css({'background-image' : 'url(/img/menu.sel.jpg)'});
			$("#galleriesSub").css({'left' : 'auto'});	
		});
		$("#galleriesSub, #galleriesTab").mouseout(function(){
			$(".galleriesTab").css({'background-image' : 'none'});	
			$("#galleriesSub").css({'left' : '-9999px'});	
		});
		
		
		
		
		

	});
	
	
	function flyerFlip (p, id) {
		
		var oldSrc = $("#" + id).attr("src");
		
		$("#" + id).attr("src", p);
		
		setTimeout("flyerFlip('" + oldSrc + "', '" + id + "');", 3000);
		
	}
	
	function flyerFlipMain (p) {
		
		var oldSrc = $(".eventFlyer img").attr("src");
		
		$(".eventFlyer img").attr("src", p);
		
		setTimeout("flyerFlipMain('" + oldSrc + "');", 3000);
		
	}
	
	var mainScrollY = 0;
	
	function mainScroll() {
		if (mainScrollY > 1100) {
			newScroll = 1;
			$("#featured .box-content").scrollTo( newScroll + 'px', 500 );		}
		else
		{
			newScroll = mainScrollY + 353;
			$("#featured .box-content").scrollTo( newScroll + 'px', 2500 );
		}
		
		mainScrollY = newScroll;
		setTimeout('mainScroll();', 5000);
	}
	
	var tickerPos = 0;
	var tickerCount = 0;
	var tickerTotal = 2;
	
	function tickerScroll() {
		if (tickerPos==1) {
			$(".newsContent").scrollTo( $(".newsStart:eq(" + tickerCount + ")"), 2000, {axis:'x'});
			tickerPos=0;
		}
		else
		{
			$(".newsContent").scrollTo( $(".newsEnd:eq(" + tickerCount + ")"), 2000, {axis:'x'});
			tickerPos=1;
		}
		
	}
	
	function gallery() {
		$('ul.gallery').galleria({
				history   : true, // 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
					if(! ($.browser.mozilla && navigator.appVersion.indexOf("Win")!=-1) ) { // FF/Win fades large images terribly slow
						image.css('display','none').fadeIn(1000);
					}
					caption.css('display','none').fadeIn(1000);
					
					// 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
					)
				}
			});	
		
		
			$("a[rel='colorBox']").colorbox({transition:"none"});

		
		
	}
