$(document).ready(function(){
	var tab_class = window.location.hash.substring(1); //str
	var current_element = ''; //str
	var current_count = 0; //int
	
	$('div.content_container div').each(function(){
		current_element = $(this).attr('class'); //Get the current divs class
		if(tab_class.length > 1){ //If it isn't blank or just a hash continue
		    $('div.home').css({display:'none'}); //If it isn't blank it's a sub page, hide home
    		if(tab_class !== current_element){ // If the current element in the loop doesn't match the hash in the url hide it
    			$(this).css({display:'none'});
    		}
    		if(current_element == tab_class){
    		  $('div.inline_links a[href="#'+current_element+'"]').wrap('<div id="current"></div>');//Mark current tab with a current class on a refresh or fresh page load
    		}
		    
		}
		else{
		    $(this).css({display:'none'}); //Hide all divs if the URL shows nothing or just a hash
		}
	});
	
	$('.inline_links #current').each(function(){current_count++;});
	
	$('div.inline_links a').click(function(){
		$('div.home').css({display:'none'});
			var clicked_element = $(this).attr('href').substring(1);
			$('div.content_container div:visible').css({display:'none'});
			$('div.content_container div.'+clicked_element).css({display:'block'});

			if(current_count < 1){
				$('div.inline_links a[href="#'+clicked_element+'"]').wrap('<div id="current"></div>');
				current_count++;
			}
			else {
				$('.inline_links #current').attr('id','').animate({zIndex:'1'},1,function(){ //This will stop the bug where it would delete the current class and add it at the exact same time
					$('div.inline_links a[href="#'+clicked_element+'"]').wrap('<div id="current"></div>');
			});
		}
	});
	
	//Slideshow stuff
	x=1;
	//total=3;
	while(x<=total){
		$('.slideshow').append('<li><a rel="cssc" href="images/slideshow/'+x+'_full.png" class="thickbox"><img src="images/slideshow/'+x+'_thumb.png" alt="Image '+x+'" /></a></li>');
		x++;
	}
	$('.slideshow').cycle({pause:1}).css({listStyle:'none',margin:'0 0 0 0'}) //UL styles.children().children().children().css({border:'2px solid #efeef4'}); //images
});