
	
	var Sitemap = Class.create();

	Sitemap.prototype = {
		initialize: function() {},
		
		expand: function(el, containerId) {
			$(el);
			var nextTree = $('subPagesLI' + containerId).down('ul');
			if(nextTree)
			{
				if(nextTree.visible())
				{
					new Effect.BlindUp(nextTree,{duration:0.2});
					el.update('(+)');
				}
				else
				{
					new Effect.BlindDown(nextTree,{duration:0.2});
					el.update('(-)');
				}		
			}
		},
		
		/*
		 * Public preview
		 */
		makePublic: function(el, projectId) {
			if($(el).checked == true)
				var confirmation = confirm("By making this a public sitemap, it will be accessible online without a login. Are you sure you want to continue?");
			else
				var confirmation = true;

			if(confirmation)
			{
				this.projectId = projectId;
				var checked = (el.checked) ? 1 : 0;
				new Ajax.Request(ajaxUrl, { parameters: 'ajaxAction=sitemapMakePublicPreview&projectId=' + projectId + '&checked=' + checked, onComplete: this.makePublic_callback.bindAsEventListener(this) });
			}
			else
				$(el).checked = false;
		},

		makePublic_callback: function(request) {
			if(request.responseText == 'no-access')
				alert("You don't have permission to access this function.");
			else if(request.responseText == 'false')
				alert("There was an error processing your request.");
			else if(request.responseText == 'true')
			{
				if($('shareableAt'))
					new Effect.Fade('shareableAt', { afterFinish: function() {$('shareableAt').remove();}});
			}
			else
				$('makeSitemapPublic').down().insert({'bottom':'<span id="shareableAt"> &ndash; Shareable at: <a href="' + request.responseText + '">' + request.responseText + '</a></span>'});
				
		}
	};

	var sitemap = new Sitemap();
	
