﻿////////////////////////////////////////////////////////////////////////////////////////////
// Page client-side script
////////////////////////////////////////////////////////////////////////////////////////////

Page = Base.extend(
{
	constructor: function()
	{
		this.help = new Page.HelpClass(this);
	}
},
{
	print: function()
	{
		if (confirm("Are you sure you want to print this page?"))
			window.print();
	},
	
	showLoginForm: function(submitUrl)
	{
		var div = $("logon");
		var form = $("logonForm");
		
		if (form == null || !form)
		{
			alert("Logon form not found!");
			return;
		}
		
		if (submitUrl != null)
			form.action = submitUrl;
		
		if (div == null)
			return;
		
		if (div.style.display == "")
		{
			Page.hideLoginForm();
			return;
		}
		
		new Effect.SlideDown(div, 
			Object.extend(
			{
				duration: 0.5,
				
				afterFinishInternal: function(effect)
				{
					setTimeout("new Effect.Highlight('" + div.id + "')", 250);
				}
			}, arguments[1] || {})
		);
	},
	
	hideLoginForm: function()
	{
		var div = $("logon");
		
		if (div != null)
		{
			div.focus();
			new Effect.Fold(div);
		}
	}
});

Page.HelpClass = Base.extend(
{
	constructor: function(page)
	{
		this.page = page;
		this.dynamicHelp = true;
		this.feedbackUrl = "Feedback.aspx";
		this.feedbackWindow = null;
	},
	
	toggleDynamicHelp: function()
	{
		this.dynamicHelp = !this.dynamicHelp;
		
		var menu = ctl00_PageMenu;
		if (!menu) return;
		
		var menuItem = menu.findItemById("ToggleDynamicHelpMenuItem");
		if (!menuItem) return;
		
		//menuItem.text = this.dynamicHelp ? "Turn off dynamic help" : "Turn on dynamic help";
		//menu.render();
	},
	
	sendFeedback: function(source)
	{
		var url = this.feedbackUrl + "?referrer=" + document.location.href;
		
		if (source != null)
			url += "&source=" + source;
		
		this.feedbackWindow = window.open(url, "feedback", "width=500,height=370,directories =no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
	}
});

window.thisPage = new Page();

