$(document).ready(function() {	


	/* shows comment fields when clicked */
    $('.comment_drop a.drop').click(function(){
		
		$(this).hide();
		$(this).siblings('#respond').toggle(this);
		
		return false;
    	}
    );    

	/* moves 100 stories thumb on hover */
	$('.thumb_preview').hover(
		function() {
			$(this).css('background-position', '0px 0px');
		},
		function() {
			$(this).css('background-position', '0px -126px');
		}
	);

	/* slideshow on frontpage */

	var thumb_num = $('#slides > li').size(); // Counts number of thumbs
	var list_width = thumb_num * 300; // Multiply number of thumbs by thumb width to get width of list
	$('#slides').css('width', list_width+"px");
	
	var img_title = $('.pic img').attr('title'); //grabs desciption and puts it in a span on next line
	$('.pic').append('<span id="img-title">'+img_title+'</span>');	
	
	
	// set selected thumbnail on load
		var set_thumb = parseInt($('li.ngg-thumbnail-list.selected span.thumb-count').text());

	// set selected thumbnail on load
		    
    var thumb_pos = ((set_thumb * 192) - 950);
    if(thumb_pos <= 320){thumb_pos = 0}
    $('ul#slides').css('margin-left', -thumb_pos);   
	
	var window_width = 960;
	var slide_amount = 192;
	var min = 0;
    var max = (thumb_num * 192); 
	var min_margin = 0;
	var max_margin = window_width - max;
	
	
	// gallery thumbnail slide controls
	
	// if user clicked on prev button  
    $('#arrow_left').click(function() {
    	var current_margin = parseInt($('ul#slides').css('margin-left'));
		var new_margin = current_margin + slide_amount;
    	
    	if(current_margin >= -slide_amount){new_margin = 0}
			$('ul#slides').animate({'margin-left': new_margin}, 250);
	    return false;
    }); 
    
    // if user clicked on next button  
    $('#arrow_right').click(function() {
    	var current_margin = parseInt ($('ul#slides').css('margin-left'));
    	var new_margin = current_margin - slide_amount;  

        if(max_margin <= current_margin && current_margin < max_margin + slide_amount){new_margin = max_margin}
		$('ul#slides').animate({'margin-left': new_margin}, 250);

        return false;
    });
    // hover over slide image makes click to view show up
    $('#slides li ul').hover(function(){
    	$(this).find('li.slide_link').toggleClass('show');
    });
    
    /* end of slideshow */ 
	      
/* isotope filters */
	
	    $("#filters_age").change(function () {
          var selector = "";
          $("select option:selected").each(function () {
                selector += $(this).attr('data-filter');
              });
			$('#container').isotope({ filter: selector });
			   return false;

        });
        
        
        $("#filters_location").change(function () {
          var selector = "";
          $("select option:selected").each(function () {
                selector += $(this).attr('data-filter');
              });
			$('#container').isotope({ filter: selector });
			   return false;

        });

	    $("#filters_industry").change(function () {
          var selector = "";
          $("select option:selected").each(function () {
                selector += $(this).attr('data-filter');
              });
			$('#container').isotope({ filter: selector });
			   return false;

        });
        
        
	
});
