function pageload(hash) {
	if(hash) {
		if($.browser.msie) {
			hash = encodeURIComponent(hash);
		}
		$("#load").load(hash + ".html");
	} else {
		$("#load").empty();
	}
}
$(document).ready(function(){

	try {
	  document.execCommand("BackgroundImageCache",false,true);
	} catch(error){}

	$.historyInit(pageload, "index.html");
	$("a.browseLink").live( 'click', function(e) {
		e.preventDefault();
		var text = '';
		var that = this;
		$.historyLoad(this.href.replace(/^.*#/, ''));
		if($(this).hasClass('expanded') === false) {
			$.ajax({
				  type: 'get',
				  url: '/ajax/0/browseChildBlock.html',
				  data: { cat: $(this).attr('id') },
				  success: function(data) {
						$(that).parent().append( data );
    				}
				});
		}
		else {
			$(this).parent().children("ul").remove();
			$(this).parent().children("h3").remove();
			$(this).parent().children("h1").remove();
			$(this).parent().children("p").remove();
		}
		$(that).toggleClass("expanded");
		if($("#browsediv").hasClass('expanded') === true) {
			$("#browsediv").animate( { height: '100%'}, 100,'linear');
			$("#browseExpandLink").text("collapse");
			$("#browseExpandLink").css({background : 'transparent url(/ccoch/images/collapse_arrow.gif) no-repeat scroll 100% 50%'});
			$("#browsediv").toggleClass("expanded");
		}
	});
	$("#browseExpandLink").bind('click', function(e) {
		e.preventDefault();
		if($("#browsediv").hasClass('expanded') === true) {
			$("#browsediv").animate( { height: '100%'}, 100,'linear');
			$(this).text("collapse");
			$(this).css({background : 'transparent url(/ccoch/images/collapse_arrow.gif) no-repeat scroll 100% 50%'});
		}
		else {
			$("#browsediv").css({overflow : 'hidden'});
			$("#browsediv").animate( { height: '250px'}, 100,'linear');
			$(this).text("expand");
			$(this).css({background : 'transparent url(/ccoch/images/expand_arrow.gif) no-repeat scroll 100% 50%'});
			
			$("a.browseLink").parent().children("ul").remove();
			$("a.browseLink").parent().children("h3").remove();
			$("a.browseLink").parent().children("h1").remove();
			$("a.browseLink").parent().children("p").remove();
			$("a.browseLink").removeClass("expanded");

		}
		$("#browsediv").toggleClass("expanded");
	});
	

	
	
	$("#browseExpandLink").click();



	var userNav = $.cookie('nav');
	if(userNav) {
		var thisNav = userNav;
		var nextNav = '';
		if( userNav.indexOf(',') > -1 ) {
			thisNav = thisNav.substring(0,thisNav.indexOf(','));
			nextNav = userNav.substring(userNav.indexOf(',')+1, userNav.length);
		}
		$.cookie('nav', nextNav);
		$("#"+ thisNav).click();
	}		
	

	$("#browseOtherLink").live('click', function(e) {
		e.preventDefault();
		$("#browseotherdiv").removeClass("hideBrowse");
		$("#browseotherdiv").children().removeClass("hideBrowse");
		$(this).replaceWith("<h3 >" +$(this).text() +"</h3>");
	});
	$("#browseOtherCollapseLink").live('click', function(e) {
		e.preventDefault();
		$("#browseotherdiv").children().addClass("hideBrowse");
		$("#browseotherdiv").addClass("hideBrowse");
		$(".leftContentBottom h3").replaceWith("<p  id='browseOtherLink' ><a href='/view/0/otherBrowseOptions.html'>Other Browse Options</a><p>");

	});

	
	$("#browseotherdiv").children().addClass("hideBrowse");
	$("#browseotherdiv").addClass("hideBrowse");
	$(".leftContentBottom h3").replaceWith("<p  id='browseOtherLink' ><a href='/view/0/otherBrowseOptions.html'>Other Browse Options</a><p>");
	$("<p class='expandOtherButton hideBrowse'><a href='/view/0/index.html' id='browseOtherCollapseLink'>collapse</a></p>").appendTo("#browseotherdiv");
	


});
