/*	**************************************
	* FreeXenon Consulting Tool Scripts  *
	************************************** */
	
	/*	**** Constants	**** */

		/* **** 	clsInputStream	**** */
		var FOR_READING	 	= 1; 	// For creating InputFileStream
		var FOR_WRITING 	= 2;	// For creating InputFileStream
		var FOR_APPEDNING 	= 3;	// For creating InputFileStream
		
		var CREATE		= true;		// For creating InputFileStream
		var notCREATE 	= false;	// For creating InputFileStream

	/*	**** 	Watch		**** */
		var POPUP 		= 1;
		var DOCWRITE 	= 2;
//		var ADDTOOBJECT = 3;

		var PADDED = true;
		var NOTPADDED = false;

	function ErrorHandle(message, url,lineNum)
	{
		Watch(message + " " + url + " ", lineNum, DOCWRITE);
		return true;
	}

	function TypeOf(CheckObject)
	/* 	**** 	function TypeOf()	**** 
		Arguments:
			CheckObject: The object that you want to check the Type of
		
		Return:
			Returns a string that tells what data type the object is
		
		Note: cannot catch an undefined object as that will throw and error before it gets here.
		****						****	*/
	{
		if (CheckObject == null) return "Null";
		
		switch ( typeof CheckObject )
		{
			case "number" 	 : return "Number";
			case "string"  	 : return "String";
			case "boolean"   : return "Boolean";
			case "function"	 : if (CheckObject.constructor == RegExp) return "Regular Expression";
								return "Function or Function Operand";
			case "object" : 
					switch ( CheckObject.constructor )
					{
						case Array 	: return "Array";
						case Date 	: return "Date";
						case RegExp : return "Regular Expression";
						default : return "Object:" + CheckObject.constructor;
					} // end of second switch
		} 	// end switch

		return "Unidentified:" + CheckObject.constructor;
	}	// end TypeOf
		
	
	function Watch (Comment, WatchVariable, WatchType, ObjID)
	/* 	**** 	function Watch 	**** 
		Parameters:
			Comment: String comment that will be associated with the Watch Variable
			WatchVariable: variable value that you want to display
			WatchType: Based of the constants declared above
				POPUP (1): creates an alert box with the message and WatchVariable.
					This is the default
				DOCWRITE (2): Writes the Comment and a WatchVariable via a document.write
				ADDTOOBJECT (3): Finds an existing Object via its ObjID that is passed in as 
					a parameter and adds the message to it with a line break. 
		
		Output:
			Writes to the screen a bolded Comment and then the WatchVariable value;
			
		****					****	*/
	{
		switch (WatchType)
		{
			case DOCWRITE: 
				document.write("<strong>" + Comment + "</strong>" + WatchVariable + "<br />");
				break;
			//POPUP
			default		:	alert(Comment + WatchVariable);
				break;
		} // end switch				
	} // end Watch


	function clsInputStream(FilePath)
	/*
		.OpenFile()			// return true if opens
		.CloseFile()		// returns true if closes
		.GetFileStream()	// returns a FileStream
		.FilePath			// returns string
	*/
	{
		var objLogFileStream = null;
		var objFSO = Server.CreateObject("Scripting.FileSystemObject");	// File Access Oject - Input Stream

		function OpenFile(IOMode, Create)
		{
			if ( objFSO.FileExists(FilePath) )
			{
				objLogFileStream = objFSO.OpenTextFile(this.FilePath, IOMode, Create);	// Open Text File Input Stream
				return true;
			}
		}	// end OpenFile
		
		function CloseFile()
		{
			if ( objLogFileStream.close() )
				return true;
		}	// end CloseFile

		function GetFileStream()
		{
			return objLogFileStream;
		}	// end CloseFile
		
		this.FilePath = FilePath;
		this.GetFileStream = GetFileStream;
		this.OpenFile = OpenFile;
		this.CloseFile = CloseFile;
	}	//end clsInputStream
