//-------------------------------------------------------------------
// THIS MAKES ALL GEOMETRY BLACK
//-------------------------------------------------------------------
function makeGeometryBlack()
{
	Eview.Viewer.RestoreColors();
	Eview.Viewer.SetBlackAndWhite ();
	forceRedraw();
}

//-------------------------------------------------------------------
// THIS MAKES ALL GEOMETRY GREYSCALE
//-------------------------------------------------------------------
function makeGeometryGrayscale()
{
	Eview.Viewer.RestoreColors();
	Eview.Viewer.SetClearScale ();
	forceRedraw();
}

//-------------------------------------------------------------------
// THIS RESTORES ORIGINAL COLORS
//-------------------------------------------------------------------
function restoreColor()
{
	Eview.Viewer.RestoreColors();
	forceRedraw();
}

//-------------------------------------------------------------------
// THIS HELPER FUNCTION REDRAWS THE DWF AFTER A COLOR CHANGE
//-------------------------------------------------------------------
function forceRedraw()
{
	Eview.Viewer.SetView (Eview.Viewer.View.Left, Eview.Viewer.View.Bottom, Eview.Viewer.View.Right, Eview.Viewer.View.Top);
}

//-------------------------------------------------------------------
// THIS DISPLAYS THE CURRENT VIEW IN PAPER COORDINATES
//-------------------------------------------------------------------
function showView()
{
	alert('Your current view coordinates are:\n\nLeft:\t' + Eview.Viewer.View.Left +
	      '\nBottom:\t' + Eview.Viewer.View.Bottom +
	      '\nRight:\t' + Eview.Viewer.View.Right +
	      '\nTop:\t' + Eview.Viewer.View.Top);
}

function panView()
{
	xdelta = (((Eview.Viewer.View.Right) - (Eview.Viewer.View.Left)) * 0.2);
	ydelta = (((Eview.Viewer.View.Top) - (Eview.Viewer.View.Left)) * 0.2);
	Eview.Viewer.SetView (Eview.Viewer.View.Left + xdelta,
						  Eview.Viewer.View.Bottom + ydelta,
						  Eview.Viewer.View.Right + xdelta,
						  Eview.Viewer.View.Top + ydelta);
}

function zoomView()
{
	xdelta = (((Eview.Viewer.View.Right) - (Eview.Viewer.View.Left)) * 0.4);
	ydelta = (((Eview.Viewer.View.Top) - (Eview.Viewer.View.Left)) * 0.4);
	Eview.Viewer.SetView (Eview.Viewer.View.Left - xdelta,
						  Eview.Viewer.View.Bottom - ydelta,
						  Eview.Viewer.View.Right + xdelta,
						  Eview.Viewer.View.Top + ydelta);
}


//-------------------------------------------------------------------
// THESE ARE USED FOR PRINTING
//-------------------------------------------------------------------
function PrintCurrentViewWB()
{
	Eview.Viewer.WaitForPageLoaded();
	Eview.Viewer.SimplePrint (false, true);
}
function PrintCurrentView()
{
	Eview.Viewer.WaitForPageLoaded();
	Eview.Viewer.SimplePrint (false, false);
}
function PrintFullPageWB()
{
	Eview.Viewer.WaitForPageLoaded();
	Eview.Viewer.SimplePrint (true, true);
}
function PrintFullPage()
{
	Eview.Viewer.WaitForPageLoaded();
	Eview.Viewer.SimplePrint (true, false);
}
//-------------------------------------------------------------------
// Start api calls - These are the main calls for some of the toolbar
// functionality and a few others.
//-------------------------------------------------------------------

function ShowSourcePath()
{
	alert(Eview.SourcePath)
}

// This function is not currently working.
// It does not bring up the file open dialog as it should.
function Open()
{
	alert("call to OPEN command - why isn't this working?")
	Eview.Viewer.ExecuteCommand("OPEN")
}

function Copy()
{
	Eview.Viewer.ExecuteCommand("COPY")
}

function Save ()
{
	Eview.Viewer.ExecuteCommand("SAVE")
}

function Print()
{
	Eview.Viewer.ExecuteCommand("PRINT")
}

function Pan()
{
	Eview.Viewer.ExecuteCommand("PAN")
}

function Zoom()
{
	Eview.Viewer.ExecuteCommand("ZOOM")
}

function ZoomRect()
{
	Eview.Viewer.ExecuteCommand("ZOOMRECT")
}

function FitToWindow()
{
	Eview.Viewer.ExecuteCommand("FITTOWINDOW")
}

function Views()
{
	Eview.Viewer.ExecuteCommand("VIEWS")
}

function Layers()
{
 	Eview.Viewer.ExecuteCommand("LAYERS")
}

function Select()
{
	Eview.Viewer.ExecuteCommand("SELECT")
}

function SaveAs ()
{
	Eview.Viewer.WaitForPageLoaded();
	Eview.Viewer.ExecuteCommand("SAVEAS")
}

function Navigation()
{
	Eview.Viewer.WaitForPageLoaded();
 	Eview.Viewer.ExecuteCommand("NAVIGATION")
}

function Properties()
{
	Eview.Viewer.WaitForPageLoaded();
	Eview.Viewer.ExecuteCommand("PROPERTIES")
}

function NextSheet()
{
	Eview.Viewer.WaitForPageLoaded();
	Eview.Viewer.ExecuteCommand("NEXT")
}

function PreviousSheet()
{
	Eview.Viewer.WaitForPageLoaded();
	Eview.Viewer.ExecuteCommand("PREVIOUS")
}

function StopLoad()
{
	Eview.Viewer.ExecuteCommand("ABORT")
}

function Help()
{
	Eview.Viewer.ExecuteCommand("HELP")
}

// This function seems to have no effect
function Exit()
{
	alert("call to EXIT command - why isn't this working?")
	Eview.SourcePath = "";
	forceRedraw();
	Eview.Viewer.ExecuteCommand("EXIT")
}

function ShowToolbar(boolean1)
{
    Eview.Viewer.ToolbarVisible = boolean1;
}

function UserInterfaceEnabled(boolean1)
{
	Eview.Viewer.UserInterfaceEnabled = boolean1;
}

function PaperVisible(boolean1)
{
	Eview.Viewer.WaitForPageLoaded();
    Eview.Viewer.PaperVisible = boolean1;
}

function getLink()
{
	Eview.Viewer.WaitForPageLoaded();
	fileName = Eview.SourcePath;
	sheetName = "page=" + Eview.Viewer.Page.Name;
	viewState = "view=" + Eview.Viewer.View.Left + "," + Eview.Viewer.View.Bottom + "," + Eview.Viewer.View.Right + "," + Eview.Viewer.View.Top;
	layerState = "layersOff=" + GetActiveLayerState();
	rclickState = "UserInterfaceEnabled=" + Eview.Viewer.UserInterfaceEnabled;
	toolbarState = "toolbarVisible=" + Eview.Viewer.ToolbarVisible;

	linkUrl = fileName + "?" + sheetName + "&" + viewState + "&" + layerState + "&" + rclickState + "&" + toolbarState;

    oText.innerText = linkUrl;

//	oText.innerText= Eview.SourcePath + "?page=" + Eview.Viewer.Page.Name + "&view=" + Eview.Viewer.View.Left + "," + Eview.Viewer.View.Bottom + "," + Eview.Viewer.View.Right + "," + Eview.Viewer.View.Top + "&layersOff=" + GetActiveLayerState() + "&" + rclickEnabled + "&" + toolbar;
}


function openFileView()
{
	ViewFileName = document.FauxOpen.openPath.value;
	Eview.SourcePath = ViewFileName;
	Navigation();
}

function calcView()
{
	a = ((Eview.Viewer.View.Top) - (Eview.Viewer.View.Left));
	b = ((Eview.Viewer.View.Right) - (Eview.Viewer.View.Left));
	c = ((a)^2) + ((b)^2);
	alert(c);
}