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

  // 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').css('left','-99999px') }
    else{ $('#leftControl').css('left','auto')  }
    // Hide right arrow if position is last slide
    if(position==numberOfSlides-1){ $('#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'});	
		});
		
		$("#perisSub, #lastMenu").mouseover(function(){
			$(".lastMenu").css({'background-image' : 'url(/img/menu.sel.jpg)'});
			$("#perisSub").css({'left' : 'auto'});	
		});
		$("#perisSub, #lastMenu").mouseout(function(){
			$(".lastMenu").css({'background-image' : 'none'});	
			$("#perisSub").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);
		$(".eventFlyer img").attr("alt", 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
					
					
					
					var href = window.location.toString();
					var str = window.location.hash;
					var exploded = str.split('/');
						
					if (window.location.hash=='') {
						href = (href+"gallery/image/"+exploded[2]+"/");
					} else {
						href = (href.substr(0,href.indexOf("#"))+"gallery/image/"+exploded[2]+"/");
					}
					
					href = href+window.location.hash;				
						
														
					$('#addthis_toolbox').empty();	
					var a = document.createElement('a');
					a.setAttribute('class', 'addthis_button_compact');
					a.setAttribute('addthis:url', href);
					a.setAttribute("onmouseover", "return addthis_open(this, '', '"+href+"', '')");
					a.setAttribute("onclick", "return addthis_sendto()");
					a.setAttribute("onmouseout", "addthis_close()");
					a.innerHTML = '<img src="http://s7.addthis.com/static/btn/v2/lg-share-en.gif" />';
					document.getElementById('addthis_toolbox').appendChild(a);						
					
					
					// 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"});

		
		
	}

