$(document).ready(function() { 
    var hash = window.location.hash.substr(1);
    var href = $('.sub_nav_list li a').each(function(){
        var href = $(this).attr('href');
        if(hash==href.substr(0,href.length-5)){
            var toLoad = hash+'.html #content_wrap';
            $('#content_wrap').load(toLoad)
        }                                                                                                                                                                     
    });
    $('.sub_nav_list li a').click(function(){
		$('.sub_nav_list a').each(function(){
			$(this).removeClass("active");});
		$(this).addClass("active");
        content_load($(this));
		setTimeout('evalLinks()', 1000);
        return false;
    });
});

function content_load(id) {                                        
    var toLoad = id.attr('href')+' #content_wrap';
    $('#content_wrap').animate({opacity: 0}, 500, loadContent); 
    function loadContent() {
        $('#content_wrap').load(toLoad,showNewContent);
        $('#load').remove();
        $('#container').append('<span id="load">LOADING...</span>');
         $('#load').animate({opacity: 100}, 500);                              
    }
    function showNewContent() {
        $('#content_wrap').animate({opacity: 100}, 500,hideLoader());
        hideLoader();                                                                                                           
    }
    function hideLoader() {
        $('#load').animate({opacity: 0}, 500);
                                                  
    }         
    return false;                             
}

function title_load(id) {
    var ttl = id.attr('href')+' #page_title';
    $('title').html($('#page_title').val());
}

/*$(document).ready(function() {
	var hgt = document.getElementById('content_copy').clientHeight;				   
	var hash = window.location.hash.substr(1);
	var href = $('.sub_nav_list a').each(function(){
		var href = $(this).attr('href');
		if(hash==href.substr(0,href.length-5)){
			var toLoad = hash+'.html #content_wrap';
			$('#content_wrap').load(toLoad)
		}											
	});

	$('.sub_nav_list li a').click(function(){
		//document.getElementById('content_copy').style.height = hgt + 'px';					  
		var toLoad = $(this).attr('href')+' #content_wrap';
		$('.sub_nav_list a').each(function(){
			$(this).removeClass("active");});
		$(this).addClass("active");
		$('#content_wrap').animate({opacity: 0,}, 500,loadContent);
		$('#load').remove();
		$('#container').append('<span id="load">LOADING...</span>');j
		$('#load').animate({opacity: 100,}, 500);
		setTimeout('evalLinks()', 1000);
		
		
		function loadContent() {
			$('#content_wrap').load(toLoad,'',showNewContent())
		}
		function showNewContent() {
		$('#content_wrap').animate({opacity: 100,}, 500,hideLoader());
			
		}
		function hideLoader() {
			$('#load').animate({opacity: 0,}, 500);
		}
		
		return false;
		
	});

});*/

function evalLinks() {
	 $('#content_wrap a').click(function(){
		var content = "div ."+$(this).attr('class');
		$('#popUpMessage div').hide();
		$(content).fadeIn('slow');
		$('#content_wrap a').removeClass('active_content_list');
		$(this).addClass('active_content_list');
		
    });
}

