/* functions to set look and feel to items in layout */

function showTreeView() {
	$("#nav2xc").treeview({
		persist: "location",
		collapsed: true
	});
	$("#nav2xcloading").remove();
	$("#nav2xc").show();
	/*$("#nav2xc").css("z-index", "300");
	$("#nav2xc").removeClass("treeview");*/
	$("#nav2xc").css("display", "inline");
	$("#nav2xc").css("width", "300px");
	$("#nav2").css("width", "300px");
	$("#nav2").css("display", "inline");
	
};

$(document).ready(function(){
	if($("#nav2xc")){
		$("#nav2xc").hide();
		$("#nav2xcloading").css("visibility", "visible");
		$("#nav2xcloading").css("display", "inline");
		setTimeout(showTreeView, 200); 		
		/*
		$("#nav2xc").hide()
		$("#nav2xcloading").css("visibility", "visible")
		$("#nav2xcloading").css("display", "block")
		$("#nav2xc").treeview({
			persist: "location",
			collapsed: true
		});
		$("#nav2xcloading").hide()
		$("#nav2xc").show()
		*/
	};
	
	if(gIsPublic && gIsGovNet) {
		if(gIsEditMode) {
			if($("#variationdropdown")) {
				$("#variationdropdown").css("visibility", "visible");
			}
			if(document.location.href.indexOf("/shared/") != -1) {
			
			} else {
				$("input[title='Title']").parent().parent().parent().hide();
				$("input[title='Title']").parent().parent().parent().parent().prepend('<div id="sharedtitle"></div>');
				var value = $("input[title='Title']").val();
				$("#sharedtitle").html(value);
				$("#ctl00_PlaceHolderMain_Content__ControlWrapper_RichHtmlField").hide();
				$("#ctl00_PlaceHolderMain_Content__ControlWrapper_RichHtmlField").parent().prepend('<div id="sharedcontent"></div>');		
				var content = $("#ctl00_PlaceHolderMain_Content_ctl00_RichHtmlField_displayContent").html();
				$("#sharedcontent").html(content);
				$(".editmodepanel").hide();				
			}
		}
	}
	
	if($('div.qgcio-event-link-item')){
		$('div.qgcio-event-link-item:even').addClass('event-even');
		$('div.qgcio-event-link-item:odd').addClass('event-odd');
	};
	// toggle content
	$('.ms-rteCustom-ToggleContainer').find('.ms-rteCustom-ToggleContainerInner').hide();
	$('.ms-rteCustom-ToggleContainer .ms-rteCustom-ToggleContainerHeader').each(function(){
		$(this).removeClass('toggle-close').addClass('toggle-open');
	});
	$('.ms-rteCustom-ToggleContainer').find('.ms-rteCustom-ToggleContainerHeader').toggle(function(){
		$(this).parent().find('.ms-rteCustom-ToggleContainerInner').show();
		$(this).removeClass('toggle-open').addClass('toggle-close');
	},function(){
		$(this).parent().find('.ms-rteCustom-ToggleContainerInner').hide();
		$(this).removeClass('toggle-close').addClass('toggle-open');
	});

	$('.ms-rteCustom-ToggleContent').find('.ms-rteCustom-ToggleInner').hide();
	$('.ms-rteCustom-ToggleContent .ms-rteCustom-ToggleHeader').each(function(){
		$(this).removeClass('toggle-close').addClass('toggle-open');
	});
	$('.ms-rteCustom-ToggleContent').find('.ms-rteCustom-ToggleHeader').toggle(function(){
		$(this).parent().find('.ms-rteCustom-ToggleInner').show();
		$(this).removeClass('toggle-open').addClass('toggle-close');
	},function(){
		$(this).parent().find('.ms-rteCustom-ToggleInner').hide();
		$(this).removeClass('toggle-close').addClass('toggle-open');
	});

	$('.gethelp').each(function(){
		if(document.location.href.indexOf("/govnet/") != -1) {
			$(this).attr('href',$(this).attr('href').replace("/qgcio/", "/govnet/"));			
		}
	});	
});
