// JAVASCRIPT (jQuery) file for vampa.org
// Author: Alex Stomp

// SIDE LINKS

$(function(){
	
	$("a#twitter-button").click(function(){
		$('.side-box').hide();
		$("#twitter-box").show(500);
	});
	
	$("a#order-button").click(function(){
		$('.side-box').hide();
		$("#order-box").show(500);
	});
	
	$("a#quote-button").click(function(){
		$('.side-box').hide();
		$("#quote-box").show(500);
	});
	
	// MouseOff glitch fix
	$("#side-links-wrap").hover(function(){
	}, function(){
		$(".side-box").hide('fast');
	});
});


// PORTFOLIO SLIDESHOW 

$(function(){
  var currentPosition = 0;
  var slideWidth = 1000;
  var slides = $('.portslide');
  var numberOfSlides = slides.length;

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

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

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

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

  // Create event listeners for .controls clicks
  $('.control2')
    .bind('click', function(){
    // Determine new position
	currentPosition = ($(this).attr('id')=='rightControl2') ? currentPosition+1 : currentPosition-1;
    
	// Hide / show controls
    manageControls(currentPosition);
    // Move slideInner using margin-left
    $('#slideInner2').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){ $('#leftControl2').hide() } else{ $('#leftControl2').show() }
	// Hide right arrow if position is last slide
    if(position==numberOfSlides-1){ $('#rightControl2').hide() } else{ $('#rightControl2').show() }
  }	
});

// PORTFOLIO HOVER EFFECT

$(function(){
	$('.portpostImage').hover(function(){
		$(this).children('.overlay').slideDown().hover(function(){},function(){
			$(this).slideUp();
		});
	}, function(){
		$(this).children('.overlay').slideUp();
	});
});

// LIGHTBOX ACTIVATION

$(function() {
	// Use this example, or...
	$('a[@rel*=lightbox]').lightBox();
});
