// Warn when leaving page with unsaved data
var isDirty = false;
var skipWarning = false;
var fckeditorOnPage = false;
var fckeditorObject;

window.onbeforeunload = function()
{
	if(fckeditorOnPage && fckeditorObject.IsDirty())
	{
		flagDirty();
	}	
	if(isDirty && !skipWarning)
	{
		return "All unsaved information will be lost.";
	}
}

function FCKeditor_OnComplete(editorInstance)
{
	fckeditorOnPage = true;
	fckeditorObject = editorInstance;
}

function flagDirty()
{
	isDirty = true;
}
function flagClean()
{
	skipWarning = true;
}

// Toggle visibility of an object
function vis_toggle(objID)
{
	theobj = document.getElementById(objID);
	if(theobj.style.display == "none")
		theobj.style.display = "";
	else
		theobj.style.display = "none";
}
function obj_clear(objID)
{
	theobj = document.getElementById(objID);
	theobj.value = "";
}

function setIsRevenue(RadioBtnID, Value)
{
	theobj = document.getElementById(RadioBtnID);
	theobj.checked = Value;
}

// Open the passed ms project file
function LaunchMSProject(fileName)
{
	var myApp = new ActiveXObject("msProject.Application");
	if(myApp != null)
	{
		myApp.Visible = true;
		myApp.FileOpen("<{SQL Server}>\\" + fileName);
	}
}
