function resizeSliders() {
	windowHeight = $(window).height();
	$("div.p7VSC03").each(function(i) {
		targetHeight = windowHeight - ($(this).attr("offsetTop") + 75);
		upHeight = $("div.p7VSC_up", this).height();
		downHeight = $("div.p7VSC_dn", this).height();
		$("div.p7VSC_scrollbox", this).css("height",(targetHeight)+"px");
		$("div.p7VSCdragbar", this).css("height",(targetHeight-(upHeight+downHeight))+"px");
		$("div.p7VSCdragchannel", this).css("height",(targetHeight)+"px");
	});
}

function addTooltips() {
	$("div.detailed.has-tooltip").each( function(i) {$(this).tooltip({tip:'#tooltip-'+$(this).attr("id").split("-")[1]}); });
	resizeSliders();
	$(".tooltip").hide();		
}

function loadLinks(organID, doScroll) {
	$typeID = $("div.part.type.selected").attr("id").split("-")[1] ;
	$("div#active-links").load(app+'links/index/'+organID+'/'+$typeID+'/1',{},addTooltips);
	if (doScroll) { P7_VSCctrl('goTo','p7VSCb_3','start'); }
}

$(document).ready(function() { 
	organID = $("div.part.primary").attr("id").split("-")[1];

	// Set up resizing on the sheet list
	$(window).bind('resize', function() {
		resizeSliders();
	});

	$("div.part.type").click(function() {
		$("div.part.type.selected").removeClass("selected");
		$(this).addClass("selected");
		loadLinks(organID, true);
	});
	
	$("div.part.type:first").trigger('click');

});


