// JScript source code
var wb;
var edApplet;
var eds;
var eda;

function edSectionScope ()
{
   this.leftPane = null;
   this.rightPane = null;
   this.currentView = "";
   this.timeInterval = 0;
   this.document = null;
   this.Graph = null;

}

var edsect = null;
edsect = new edSectionScope();

edSectionScope.prototype.resize = function()
{
var x = 1;
var y = 2;
	eda.LeftPaneWidth = document.all.left.width;
}


edSectionScope.prototype.window_onload = function ()
{
//debugger;
   // Go get the WB, Engg Data Applet; Script; and namespace
	wb			=  window.external;
	edApplet =  wb.AppletList.Applet( "EDApplet").App;
	eds = edApplet.Script;
   eda = eds.eda;

   eda.OverloadDefaultEvents(document);
	if (eda.LeftPaneWidth != -1)
		EDSectionWorksheet.cols = "" + eda.LeftPaneWidth + ",*";
   eda.SectionScope = edsect;
   eda.ActiveScript = edsect;
   this.Graph = eds.CreateActiveXObject(GenWBProgId("WBGraphUtility.WBGraph"));

   // This determines Internet Explorer's major version number,
   // or 0 for others. It works by finding the "MSIE " string and
   // extracting the version number following the space, up to the decimal
   // point, ignoring the minor version number
   var ieVersion = 0;
   var ua = window.navigator.userAgent;
   var msie = ua.indexOf ( "MSIE " );

   if ( msie > 0 )      // The version for Internet Explorer is available
      ieVersion = parseInt (ua.substring (msie+5, ua.indexOf (".", msie )));
      
   if(ieVersion < 6)
   {
	   edsect.timeInterval = window.setInterval("edsect.PageLoaded()", 250);
	}
	else
	{
	   edsect.PageLoaded();
	}
}

edSectionScope.prototype.window_onunload = function ()
{
   eda.SectionScope = null;
   if (eda.ActiveScript == edsect)
      eda.ActiveScript = null;

   this.document = null;
   this.currentView = "";
   this.Graph = null;
}

edSectionScope.prototype.PageLoaded = function ()
{
	try
	{
		if( !isNaN(edsect.timeInterval) )
			window.clearInterval(edsect.timeInterval);
		edsect.timeInterval = 0;
      if ( left )
      {
         edsect.document = document;
         edsect.SwitchView("summary");
      }
	}
	catch (e)
	{
//	debugger;
		if( !isNaN(edsect.timeInterval))
			window.clearInterval(edsect.timeInterval);
		edsect.timeInterval = window.setInterval("edsect.PageLoaded()", 250);
	}
}


edSectionScope.prototype.SwitchView = function ( view )
{
	try
	{
	   if (this.currentView == view) return;
	   switch (view)
	   {
	      case "summary":
	         //this.document.all.EDMaterialWorksheet.cols="40%,60%";
            this.document.all.left.src = eda.HTMLDirNoLocale + "SectionEditor.htm";
            this.document.all.right.src = eda.HTMLDirNoLocale + "SectionBitmaps.htm";
            break;
         case "edit":
            this.document.all.left.src = eda.HTMLDirNoLocale + "SectionEditor.htm";
            this.document.all.right.src = eda.HTMLDirNoLocale + "SectionBitmaps.htm";
	         //this.document.all.EDMaterialWorksheet.cols="30%,70%";
            break;
         default:
            break;
      }
      this.currentView = view;
	}
	catch (e)
	{
//		debugger;
	}
}


edSectionScope.prototype.RefreshView = function (dataItem)
{
   try
   {
      if (eda.PropSummaryScript)
         eda.PropSummaryScript.UpdateSummary();
      if (eda.PropImgScript)
         eda.PropImgScript.UpdateImages();
      if (eda.SectEditScript)
		   eda.SectEditScript.RefreshView(dataItem);
   }
   catch (error)
   {
debugger;
   }
}

edSectionScope.prototype.GotoSummary = function ( )
{
	try
	{
      this.SwitchView("summary");
	}
	catch (e)
	{
	}
}

edSectionScope.prototype.updateBreadcrumbs = function ( node )
{
	try
	{
	   if (eda.PropSummaryScript)
	         eda.PropSummaryScript.updateBreadcrumbs(node);
	}
	catch (e)
	{
	}
	try
	{
      if (eda.PropEditScript)
	         eda.PropEditScript.updateBreadcrumbs(node);
	}
	catch (e)
	{
	}
}


