<HTML>
<HEAD>
<!-- Copyright 2001, 2002, 2003, 2004 Macromedia, Inc. All rights reserved. -->
<SCRIPT LANGUAGE="javascript">

//--------------------------------------------------------------------
// FUNCTION:
//   getServerModelDisplayName
//
// DESCRIPTION:
//   Returns the name that should be displayed in the UI for
//   this Server Model
//
//   This value can be accessed from JavaScript by calling the
//   function:
//     dom.serverModel.getDisplayName()
//
// ARGUMENTS:
//   None
//
// RETURNS:
//   string
//--------------------------------------------------------------------

function getServerModelDisplayName()
{
  return "ASP.NET VB";
}


//--------------------------------------------------------------------
// FUNCTION:
//   getServerModelFolderName
//
// DESCRIPTION:
//   Returns the folder name that will be used for this Server Model
//   within the Configuration folder
//
//   This value can be accessed from JavaScript by calling the
//   function:
//     dom.serverModel.getFolderName()
//
// ARGUMENTS:
//   None
//
// RETURNS:
//   string
//--------------------------------------------------------------------


function getServerModelFolderName()
{
  return "ASP.NET_VB";
}


//--------------------------------------------------------------------
// FUNCTION:
//   getServerInfo
//
// DESCRIPTION:
//   Returns a JavaScript Object, which can be accessed from within
//   the JavaScript code.
//
//   The entire object can be retreived through the JavaScript function:
//     dom.serverModel.getServerInfo();
//
//   The properties: serverName, serverLanguage, and serverVersion
//   are special properties, which can also be accessed with the
//   JavaScript functions:
//     dom.serverModel.getServerName()
//     dom.serverModel.getServerLanguage()
//     dom.serverModel.getServerVersion();
//
// ARGUMENTS:
//   None
//
// RETURNS:
//   Object
//--------------------------------------------------------------------

function getServerInfo()
{
  var obj = new Object();

  obj.serverName = "ASP.NET";
  obj.serverLanguage = "VB";
  obj.serverVersion = "1.0";
  obj.recordsetDisplayName = MM.LABEL_TitleDataSet;
  obj.recordsetBaseName = MM.LABEL_DataSetBaseName;

  return obj;
}


//--------------------------------------------------------------------
// FUNCTION:
//   getServerModelExtDataNameUD4
//
// DESCRIPTION:
//   Returns the Server Model Implementation name that should be used
//   when accessing UD4 extension data files that live in the folder:
//     Configurations/ExtensionData
//
// ARGUMENTS:
//   None
//
// RETURNS:
//   string
//--------------------------------------------------------------------

function getServerModelExtDataNameUD4()
{
  return "ASP.NET/VB";
}


//--------------------------------------------------------------------
// FUNCTION:
//   getFileExtensions
//
// DESCRIPTION:
//   Returns a JavaScript Array of the file extensions which will
//   be listed as potential default file extensions on the Application
//   Server configuration page within the Site definition dialog.
//
// ARGUMENTS:
//   None
//
// RETURNS:
//   Array
//--------------------------------------------------------------------

function getFileExtensions()
{
  FileExtensionArray = new Array();

  FileExtensionArray[0] = ".aspx";
  FileExtensionArray[1] = ".ascx";
  FileExtensionArray[2] = ".asmx";
  FileExtensionArray[3] = ".vb";
  FileExtensionArray[4] = ".htm";
  FileExtensionArray[5] = ".html";
  FileExtensionArray[6] = ".inc";
  FileExtensionArray[7] = ".js";
  FileExtensionArray[8] = ".config";

  return FileExtensionArray;
}


//--------------------------------------------------------------------
// FUNCTION:
//   getServerSupportsCharset
//
// DESCRIPTION:
//   Returns true if the current server supports the given charset
//
//   The CharSet support be accessed from JavaScript by calling the
//   function:
//     dom.serverModel.getServerSupportsCharset(metaCharSetString)
//
// ARGUMENTS:
//   metaCharSetString - string - the value of the documents "charset="
//
// RETURNS:
//   Array
//--------------------------------------------------------------------

function getServerSupportsCharSet( metaCharSetString )
{
  //Dot net running on a 2000 or greater server should support all characters
  return true;
}


//--------------------------------------------------------------------
// FUNCTION:
//   updatePageDirective
//
// DESCRIPTION:
//   This function is called when a user changes their document encoding
//	 or the document type of their document.
//
// ARGUMENTS:
//   dom - The Document DOM of the document to be opened.
//
// RETURNS:
//   none
//--------------------------------------------------------------------

function updatePageDirective(dom)
{
  if (dom)
  {
    encoding = dom.getCharSet();
    if (encoding)
    {
      var docStr = dom.documentElement.outerHTML;
      var pageDirectiveStart = docStr.search( /<%@\s*Page/i );

      if( pageDirectiveStart > -1 )
      {
        var pageDirectiveEnd = 0;
        pageDirectiveEnd = docStr.indexOf("%>", pageDirectiveStart) + 2;

        if(pageDirectiveEnd > 1 && pageDirectiveEnd > pageDirectiveStart)
        {
          var oldLangStr = docStr.substring(pageDirectiveStart, pageDirectiveEnd);
          var newLangStr = oldLangStr;
          newLangStr = newLangStr.replace(/(ResponseEncoding=)"[\w-]*"/i, "$1\"" + encoding + "\""); // double quotes
          newLangStr = newLangStr.replace(/(ResponseEncoding=)'[\w-]*'/i, "$1'" + encoding + "'");   // single quotes
          if (newLangStr != oldLangStr)
          {
            var newDocStr = docStr.substring(0, pageDirectiveStart) +
                            newLangStr +
                            docStr.substring(pageDirectiveEnd);
            dom.documentElement.outerHTML = newDocStr;
          }
        }
      }
    }
  }
}


//--------------------------------------------------------------------
// FUNCTION:
//   getServerModelDelimiters
//
// DESCRIPTION:
//   Returns the script delimiters which are used by the application
//   server, and states whether each can or cannot participate in
//   merging of code blocks.
//
//   This value can be accessed from JavaScript by calling the
//   function:
//     dom.serverModel.getDelimiters()
//
// ARGUMENTS:
//   None
//
// RETURNS:
//   Array
//--------------------------------------------------------------------

function getServerModelDelimiters()
{
	DelimArray = new Array();

	DelimObject = new Object();
	DelimObject["startPattern"]="<%";
	DelimObject["endPattern"]="%>";
	DelimObject["participateInMerge"]=true;
	DelimArray[0]=DelimObject;

	DelimObject = new Object();
	DelimObject["startPattern"]="<%\\s*=";
	DelimObject["endPattern"]="%>";
	DelimObject["participateInMerge"]=false;
	DelimArray[1]=DelimObject;

	DelimObject = new Object();
  // Note the extra (?!@) in pattern below. This means do not match <%@ if it is
  //   followed by another @. Also, the character matched by (?!@) is not extracted
  //   in the regexp. This case is needed in case we see a participant like:
  //   "<% @@param1@@ ...". We still want to strip the <% in this case.
	DelimObject["startPattern"]="<%\\s*@(?!@)";
	DelimObject["endPattern"]="%>";
	DelimObject["participateInMerge"]=false;
	DelimArray[2]=DelimObject;

	DelimObject = new Object();
	DelimObject["startPattern"]="<%\\s*#";
	DelimObject["endPattern"]="%>";
	DelimObject["participateInMerge"]=false;
	DelimArray[3]=DelimObject;

	return DelimArray;
}

//*-------------------------------------------------------------------
// FUNCTION:
//   getLanguageSignatures
//
// DESCRIPTION:
//   Returns the method and array signatures used by the scripting
//   language.
//
// ARGUMENTS:
//   None
//
// RETURNS:
//   Array
//--------------------------------------------------------------------

function getLanguageSignatures()
{
	Signatures = new Object();

	// method signature
	Signatures["Method"] = "$$RETURNTYPE $$METHODNAME($$ARGUMENT, $$ARGUMENT) $$THROWS $$EXCEPTION, $$EXCEPTION";
//	Signatures["Method"] = "$$METHODNAME($$ARGUMENT, $$ARGUMENT) $$THROWS $$EXCEPTION, $$EXCEPTION, $$RETURNTYPE";

	// constructor signature
	Signatures["Constructor"] = "$$METHODNAME($$ARGUMENT, $$ARGUMENT) $$THROWS $$EXCEPTION, $$EXCEPTION";

	// dropcode signatures
	Signatures["Dropcode"] = "dim a$$RETURNVALUE as $$RETURNTYPE = $$OBJECTNAME.$$METHODNAME($$ARGUMENT, $$ARGUMENT)"
	Signatures["ConstructorDropcode"] = "dim a$$RETURNVALUE as new $$METHODNAME($$ARGUMENT, $$ARGUMENT)"
	Signatures["VoidDropcode"] = "$$OBJECTNAME.$$METHODNAME($$ARGUMENT, $$ARGUMENT)"

	// array signature
	Signatures["Array"] = "$$ARRAYNAME[]";
	Signatures["ArrayBracket"] = "[]";

	// reference signature
	Signatures["Reference"] = "";

	//throws signature
	Signatures["Throws"] = "throws";

	// try signature
	Signatures["Try"] = "try{";
	Signatures["EndTry"] = "}";

	// catch signature
	Signatures["Catch"] = "catch($$EXCEPTION e){";
	Signatures["EndCatch"] = "}";

//	Signatures["BeginBlockComment"] = "/*";
//	Signatures["EndBlockComment"] = "*/";

	// data type mappings
	PrimitiveTypes = new Object();
	Signatures["PrimitiveTypes"] = PrimitiveTypes;
	PrimitiveTypes["VOID"] = "void";
	PrimitiveTypes["BOOLEAN"] = "Boolean";
	PrimitiveTypes["I1"] = "Byte";	// 8-bit signed integer
	PrimitiveTypes["U1"] = "Byte";	// 8-bit unsigned integer
	PrimitiveTypes["I2"] = "Short";	// 16-bit signed integer
	PrimitiveTypes["U2"] = "Short";	// 16-bit unsigned integer
	PrimitiveTypes["CHAR"] = "Char";	// character
	PrimitiveTypes["I4"] = "Int";	// 32-bit signed integer
	PrimitiveTypes["U4"] = "Int";	// 32-bit unsigned integer
	PrimitiveTypes["I8"] = "Long";	// 64-bit signed integer
	PrimitiveTypes["U8"] = "Long";	// 64-bit unsigned integer
	PrimitiveTypes["R4"] = "Single";	// 32-bit floating point
	PrimitiveTypes["R8"] = "Double";	// 64-bit floating point

	return Signatures;
}


//--------------------------------------------------------------------
// FUNCTION:
//   canRecognizeDocument
//
// DESCRIPTION:
//   This function is called when a user attempts to open a document
//   whose file extension matches two or more Document Types.
//
// ARGUMENTS:
//   dom - The Document DOM of the document to be opened.
//
// RETURNS:
//   integer +ve integer if document is identified.
//           -ve integer if not.
//--------------------------------------------------------------------

function canRecognizeDocument(dom)
{
  var retVal = (-1);
  var langRE = /<%\s*@\s*page(\s*.*\s*)language\s*=\s*(\"|\')?vb(\"|\')?/i;
  var wslangRE = /<%\s*@\s*webservice(\s*.*\s*)language\s*=\s*(\"|\')?vb(\"|\')?/i;
  var uclangRE = /<%\s*@\s*control(\s*.*\s*)language\s*=\s*(\"|\')?vb(\"|\')?/i;	

  var oHTML = dom.documentElement.outerHTML;

  if ((oHTML.search(langRE) > (-1)) || (oHTML.search(wslangRE) > (-1)) || (oHTML.search(uclangRE) > (-1)))
  {
    retVal = 1;
  }
  if(retVal == (-1))
  {
	// There isn't an @ page language directive on the page.
	// Look for a server-side script language tag.
	var scriptTags = dom.getElementsByTagName("script")

	for(var i=0; i < scriptTags.length; i++)
	{
	  // Check if it's a server side script tag.
	  if(scriptTags[i].getAttribute("runat") && scriptTags[i].getAttribute('language')){

	    // Check if it's VB.
	    if(scriptTags[i].getAttribute("language").toLowerCase() == "vb")
		{
		  retVal = 1;
		  // We only care about the first one. Exit the loop.
		  break;
		}
	  }
	}
  }
  if((retVal == (-1)) && (dom != null) && (dom.URL != null))
  {
    //  As is pointed out in http://bugapp/bugapp/detail.asp?ID=159326
    //  ASP.NET allows a page, user control, web service, etc., to omit
    //  the keyword immediately after the @.  So, for example, it is perfectly
    //  OK to have the following in an aspx page:
    //
    //  <%@ language="c#" %>
    //
    //  This is completely equivalent to:
    //
    //  <%@page language="c#" %>
    //
    //  In an ascx file, the keyword "control" after the @ is implied if
    //  missing and so on.  This is spelled out here:
    //
    //  http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconpagedirectives.asp
    //
    //  In the code below we try to detect that situation.  Note that we
    //  are a little careful to only do this special processing if we know
    //  that we have a file with the right kind of extension.  Otherwise,
    //  we might pick up a false positive if the content of another file
    //  (like an inc file) happens to have the "magic" string that we are
    //  looking for.  By only searching in cases where we know that the
    //  file extension is right we limit the cases where we might screw up.

    var lastDot = dom.URL.lastIndexOf(".");
    if (lastDot > -1)
    {
      var fileExt = dom.URL.substring(lastDot).toLowerCase();
      if ((fileExt == ".aspx") || (fileExt == ".ascx") || (fileExt == ".asmx"))
      {
        var genericLangRE = /<%\s*@(\s*.*\s*)language\s*=\s*(\"|\')?vb(\"|\')?/i;
        if (oHTML.search(genericLangRE) > (-1))
        {
          retVal = 1;
        }
        else
        {
          //  We are obviously working with an ASP.NET file.  We know that
          //  by simply looking at the extension (aspx, ascx, asmx, etc.).
          //  It is legal to omit all language declarations (either using
          //  directives with an @ character like @page or using server-side
          //  script tags that declare a language.  Pages that provide no
          //  hints to .Net are assumed (by the .Net framework) to use VB.
          //  Here, we are going to look for a very simple signature
          //  "language=" and if it isn't found anywhere in the document
          //  then we can assume it is missing from all directives and all
          //  script tags and we will simply assign the VB language to the
          //  file.

          var langAttrRE = /\s+language\s*=/i;
          if (oHTML.search(langAttrRE) == (-1))
          {
            retVal = 1;
          }
        }
      }
    }
  }

  return retVal;
}

</SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>
