var facilitiesScripts = function(){ var activeID = $(location).attr('hash').substring(1); if (activeID.length != "") { $('.facility').addClass('inactive'); $('#'+activeID).removeClass('inactive'); $('#'+activeID).addClass('active'); } $('.stretchMe').each(function( index ) { $(this).backstretch($(this).attr('rel')); }); $('.facility_img').click(function(){ if($(this).parent().hasClass('inactive') || $(this).parent().hasClass('no_content')) {} else { $('.facility').addClass('inactive'); $(this).parent().removeClass('inactive'); $(this).parent().addClass('active'); if($(this).parent().hasClass('slideUp')) { $('html, body').animate({scrollTop: $(this).parent().offset().top - 400}, 500, 'swing'); } else { $('html, body').animate({scrollTop: $(this).parent().offset().top - 0}, 500, 'swing'); } } }); $('.facility_close').click(function(){ $('.facility').removeClass('active'); $('.facility').removeClass('inactive'); }); }; $(window).load(function(){ facilitiesScripts(); });