/*

- Sparrow House Counseling
- http://sparrowhousecounseling.com/
- designed by Switch Creative Group
- http://www.groupswitch.com

*/

/* ! ---- Ajaxify the Site ---- */
/* ---------------------------------------------------- */
	
	$(document).ready(function(){
		
		// Array for urls of pages to load
		var pages = new Array('/about-us/',
													'/practice-areas/',
													'/meet-the-team/',
													'/resources/',
													'/contact/'	);
		
		// Array for names of divs to load pages in
		var names = new Array('about-us',
													'practice-areas',
													'meet-the-team',
													'resources',
													'contact'	);
		
		// vars for loading loop
		var $main = $('#right'),
				current_page = 0;
		
		
		function load_page() {
			// create div to load page into
			$main.append('<div id="' + names[current_page] + '" class="page_hldr"></div>');
			// load pages
			$('#' + names[current_page]).load(pages[current_page] + " .page");
		}
		
		load_page();
		
		
		$main.ajaxStop(function() {
				
				book_shadows();
				book_footer();
				
				if (names[current_page] == 'practice-areas') {
					practice_areas();
				}
				else if (names[current_page] == 'meet-the-team') {
					// meet_the_team();
					meet_the_team2();
				}
				
				if (current_page < pages.length-1) {
					current_page++;
					load_page();
				} else {
					if (location.href.indexOf("#") != -1) {
        		// Your code in here accessing the string like this
        		//hash_tag = location.href.substr(location.href.indexOf("#")));
        		var url 			= window.location.href;
        		var url_index = url.indexOf("#");
        		var hashtag		= url.substring(url_index);
        		$("#mn_list a[href='"+hashtag+"']").trigger('click');
    			}
				}
				
			});
		
		
		
	});
