$(document).ready(function(){
	
	// Placeholder for old broswers
	$('input[placeholder], textarea[placeholder]').placeholder();
	
	// Slider Side Nav
	$('a.nav').live('click',function(){
		curClick = $(this).attr('href');
		slideLeft = $(curClick).attr('title');			
		slideExists = $('#sliders').children('div').hasClass('active');	
		if(slideExists){
			curSlide = '#'+$('#sliders').children('div.active').attr('id');
			curLeft = $(curSlide).attr('title');
			if(curClick == curSlide){
				$(curSlide).removeClass('active');
				$('#overlay').hide();
				$(curSlide).animate({
					left: curLeft
				},200);
				return false;
			}else{
				$(curSlide).removeClass('active');
				$(curSlide).animate({
					left: curLeft
				},200,function(){
					$(curClick).animate({
					    left: '200'
					  }, 800);
					$(curClick).addClass('active');
				});
			}
		}else{
			$(curClick).animate({
			    left: '200'
			  }, 800);
			$(curClick).addClass('active');
			$('#overlay').show();
		}
		return false;
	});
	
	// Slide Close Button
	$('a.slider_close_button').live('click',function(){
		curSlide = $(this).closest('.slider');
		curLeft = $(curSlide).attr('title');
		$(curSlide).removeClass('active');
		$('#overlay').hide();
		$(curSlide).animate({
			left: curLeft
		},200);
		return false;
	});
	
	// Colorbox
	$(".colorbox_photo").colorbox({
		maxWidth: "95%", 
		maxHeight: "95%", 
		photoScaling: "true", 
		opacity: .75});
	$(".colorbox").colorbox({
		opacity: .75
	});
	$(".colorbox_iframe").colorbox({width:"940px", height:"750px", iframe:true});
	
	// Expand Inventory
	$('.expand').live('click',function(){
		var inv = '#'+$(this).closest('.inventory').attr('id');
		var invImage = '#'+$(this).closest('.inventory_image').attr('id');
		$(invImage).activity({segments: 8, steps: 3, opacity: 0.5, width: 4, space: 0, length: 5, color: '#fff', speed: 1.5});
		$($(inv).next('.expanded_content')).load($(this).attr('href'),function(){
			$(inv).next('.expanded_content').slideDown('500',function(){
				$('html,body').animate({scrollTop: $($(inv).closest('.inventory').next('.expanded_content')).offset().top},'slow',function(){$(invImage).activity(false);});
			});
		});
		return false;
	});
	
	// Close Expand
	$('.close_button').live('click',function(){
		$(this).closest('.expanded_inventory').slideUp('500',function(){$(this).closest('.expanded_inventory').remove();});
		return false;
	});
	
})

