<!-- // <%

//---------------------------------------------------------------------- 
// PAGE: SiteUtils.js
//
// DESC: UI
//
// DATE: 15 February 2000
//
// AUTHOR: @Campus.com, Inc.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (C) 1999,2000 @Campus.com, Inc.  All Rights Reserved
//---------------------------------------------------------------------- 

	//Config param:{{var kSite= "/[[SiteName]]";}}
	var kSite= "/bccsched";
	var kSiteLen= kSite.length;
	
	function getSiteLocation( URL )
	{
		//	Determine where this site has been installed. For example,
		//	if the URL passed in is: http://myserver.com/classes/schedule/courses/2045.html
		//	the result would be: http://myserver.com/classes/schedule/
		var pos= URL.indexOf( kSite );
		if (-1==pos)
			return URL;
		
		return URL.substring( 0, pos + kSiteLen ) +"/";
	}
	
	function makeLocation( URL, Protocol )
	{
		//	Make a URL based on the protocol and the site location.
		//	If I want a URL for the foo folder using the secure http protocol,
		//	I might use: makeLocation( "foo", "https" ) and get
		//	http://myserver.com/classes/schedule/foo
		
		if (Protocol)
			return Protocol + "://" + getSiteLocation( document.location.host + document.location.pathname ) + URL;
		else
			return getSiteLocation( document.location.href ) + URL;
	}
			
	function getAspLocation( Protocol )
	{
		//	Determine where the ASP is installed. Based on the
		//	SERVER_NAME and URL server variables.
		var URL= "";

		if (Protocol)
			URL+= Protocol + "://";
		else
		{
			if (Request.ServerVariables("HTTPS")=="on")
				URL+= "https://";
			else
				URL+= "http://";
		}
		
		URL+= Request.ServerVariables("SERVER_NAME") + 
			  Request.ServerVariables("URL");
		return getSiteLocation( URL );
	}

	function writeDocLocation()
	{
		//	Write a base tag for the install point of the site.
		document.write( '<base href="'+ getSiteLocation( document.location.href ) +'">\n' );
	}

	function aspWriteStyleSheet()
	{
		//	For an ASP, write out a link tag for the style sheet.
		//	Uses different style sheets for Mac or Windows.
		var agt= String(Request.ServerVariables("HTTP_USER_AGENT")).toLowerCase();
		var win= (agt.indexOf('win')!=-1)?true:false;
		Response.write( '<link rel=stylesheet HREF="' + (win?'site.win.css':'site.mac.css') + '">' );
	}
	
	function writeStyleSheet()
	{
		//	Write out a link tag for the style sheet.
		//	Uses different style sheets for Mac or Windows.
		var agt= navigator.userAgent.toLowerCase();
		var win= (agt.indexOf('win')!=-1)?true:false;
	
		document.write( '<link rel=stylesheet HREF="' + (win?'output.css':'output.mac.css') + '">' );
	}
	
	// %> -->
