
	Stenstrom.NET.Web.DocType				= function(){
	
	// inherit the System.Object class properties and methods 
		Stenstrom.NET.System.Object.call(this);
		
	// create the prototype so that this class may be inherited 
		Stenstrom.NET.Web.DocType.prototype				= new Stenstrom.NET.System.Object();
		Stenstrom.NET.Web.DocType.prototype.constructor	= Stenstrom.NET.Web.DocType;
		
	// static properties - defined as public but not intended for public consumption
		this.Type		= "Stenstrom.NET.Web.DocType";
		
		DocType_Initialize(this);
	}
	function DocType_Initialize(obj){
		
		obj._doctype	= (function(){
		
			var doctype	= null;
			
			// MSIE
				if(obj.IsMSIE){
					if(document.firstChild.tagName == "!"){
						doctype	= document.firstChild;
					}
				}
			// MOZILLA
				else{					
					doctype = ( document.doctype!= null && typeof(document.doctype)!= 'undefined')? document.doctype : null;
				}
				
			return( doctype );
		})();
		
		obj.PublicId	= (function(){
			
			var pubId	= null;
			// MSIE
				if(obj.IsMSIE){
					if(obj._doctype!=null){
						var pieces = obj._doctype.text.split("\"");
						pubId = pieces[1];
					}
				}
			// MOZILLA
				else{					
					pubId = ( obj._doctype!=null )? obj._doctype.publicId : null;
				}
				
			return( pubId );
		})();		
		obj.SystemId	= (function(){
		
			var sysId	= null;
			
			// MSIE
				if(obj.IsMSIE){
					if(obj._doctype!=null){
						var pieces = obj._doctype.text.split("\"");
						sysId = pieces[3];
					}
				}
			// MOZILLA
				else{
					sysId = ( obj._doctype!=null )? obj._doctype.systemId : null;
				}
				
			return( sysId );
		})();
	
		obj.TopElement			= "HTML*";
		obj.Availability		= "PUBLIC*";
		obj.Registration		= "";
		obj.Organization		= "";
		obj.Class				= "";
		obj.Label				= "HTML*"; 
		obj.Version				= "";
		obj.Definition			= "";
		obj.Language			= "";
		obj.URL					= "";
		obj.StandardsCompliant	= (document.compatMode == "CSS1Compat")? true : false; 
	
		(function(){
			var outerPieces 	= obj.PublicId.split("//");
			var innerPieces		= outerPieces[2].split(" ");
			obj.Registration	= (outerPieces[0] == "-")? "Un-Registered" : "Registered";
			obj.Organization	= outerPieces[1];
			obj.Class			= (innerPieces.length >= 1)? innerPieces[0] : "DTD*";
			obj.Label			= (innerPieces.length >= 2)? innerPieces[1] : "HTML*";
			obj.Version			= (innerPieces.length >= 3)? innerPieces[2] : "n/a*";
			obj.Definition		= (innerPieces.length >= 4)? innerPieces[3] : "n/a*";
			obj.Language		= (outerPieces.length >= 4)? outerPieces[3] : "EN*";
			obj.URL				= obj.SystemId;
		})();
	}
	
	Stenstrom.NET.Web.HTMLElement			= function( tag ){
	
	// inherit the Stenstrom.NET.Web.HTMLBase class properties and methods 
		Stenstrom.NET.System.Object.call(this);
		
	// create the prototype so that this class may be inherited 
		Stenstrom.NET.Web.HTMLElement.prototype				= new Stenstrom.NET.System.Object();
		Stenstrom.NET.Web.HTMLElement.prototype.constructor	= Stenstrom.NET.Web.HTMLElement;
		
	// static properties - defined as public but not intended for public consumption
		this.Type		= "Stenstrom.NET.Web.HTMLElement";
		
	// initialize the core element as an object. If the 'tag' argument is a tagName then create the tag now.
		if(typeof(tag) == 'object' && typeof(tag.tagName) != 'undefined'){
		
			this.Element = tag;
			HTMLElement_Initialize(this);
		}
		else if(typeof(tag) == 'string'){
		
			this.Element = document.createElement(tag);
			HTMLElement_Initialize(this);
		}
		else{
			
			var sMsg = "";
				sMsg += "typeof: "+ typeof(tag) +"\n";
				sMsg += "typeof(tag.tagName): "+ typeof(tag.tagName) +"\n";
			alert("Invalid HTML element" + "\n\n"+ sMsg);
			return;
		}
	}
	function HTMLElement_Initialize(obj, tag){
	
	// properties
	// obj.Element = ""; defined in constructor function
		for(var name in obj.Element){
			try{ obj[name] = obj.Element[name]; }catch(err){}
		}
	
	// inherit the properties of the base HTML element
		obj._isCompliant		= (document.compatMode == "CSS1Compat")? true : false; 
		obj.currentStyle		= (function(){
			
			if(obj.Element.currentStyle){
				return(obj.Element.currentStyle);
			}
			else if(window.getComputedStyle){
				return( window.getComputedStyle(obj.Element, '') );
			}
		})();

	// methods 
		obj.getProperty				= function(sName){
			
			for(var name in this){
				if(name == sName){
					return(this.Element[name]);
					break;
				}
			}
		}
		obj.setProperty				= function(sName, sValue){
			
			for(var name in this){
				if(name == sName){
					this[name] 			= sValue;
					this.Element[name] 	= sValue;
					break;
				}
			}
		}
		obj.getAttribute			= function(sName){
		
			var attrNode	= this.attributes[sName];
		
			if(attrNode != null && attrNode.nodeValue){
					return( attrNode.nodeValue );
			}
			else if(attrNode != null && attrNode.value){
					return( attrNode.value );
			}
		}
		obj.setAttribute			= function(sName, sValue){
		
			for(var attribute in this.attributes){
				
				if(attribute.name && attribute.name.toLowerCase() == sName.toLowerCase()){
					attribute.value = sValue;
					break;
				}
				else if(attribute.nodeName && attribute.nodeName.toLowerCase() == sName.toLowerCase()){
					attribute.nodeValue = sValue;
					break;
				}
			}
			
			this.Element.setAttribute(sName, sValue);
		}
		obj.getOccupiedDimensions	= function(){
			var nHeight 		= this.Element.offsetHeight;
			var nWidth			= this.Element.offsetWidth;
			
			var marginLeft		= parseInt(this.currentStyle.marginLeft);
				marginLeft		= (isNaN(marginLeft))? 0 : marginLeft;
			var marginRight		= parseInt(this.currentStyle.marginRight);
				marginRight		= (isNaN(marginRight))? 0 : marginRight;
			var marginTop		= parseInt(this.currentStyle.marginTop);
				marginTop		= (isNaN(marginTop))? 0 : marginTop;
			var marginBottom	= parseInt(this.currentStyle.marginBottom);
				marginBottom	= (isNaN(marginBottom))? 0 : marginBottom;
		
			nHeight	+=  (marginTop + marginBottom);
			nWidth	+= (marginLeft + marginRight);
			
			return{ height:nHeight, width: nWidth };
		}
		obj.getInnerDimensions		= function(){
			var nHeight 		= this.Element.offsetHeight;
			var nWidth			= this.Element.offsetWidth;		
			
			var paddingLeft		= parseInt(this.currentStyle.paddingLeft);
				paddingLeft		= (isNaN(paddingLeft))? 0 : paddingLeft;
			var paddingRight	= parseInt(this.currentStyle.paddingRight);
				paddingRight	= (isNaN(paddingRight))? 0 : paddingRight;
			var paddingTop		= parseInt(this.currentStyle.paddingTop);
				paddingTop		= (isNaN(paddingTop))? 0 : paddingTop;
			var paddingBottom	= parseInt(this.currentStyle.paddingBottom);
				paddingBottom	= (isNaN(paddingBottom))? 0 : paddingBottom;
			var borderLeft		= parseInt(this.currentStyle.borderLeftWidth);
				borderLeft		= (isNaN(borderLeft))? 0 : borderLeft;
			var borderRight		= parseInt(this.currentStyle.borderRightWidth);
				borderRight		= (isNaN(borderRight))? 0 : borderRight;
			var borderTop		= parseInt(this.currentStyle.borderTopWidth);
				borderTop		= (isNaN(borderTop))? 0 : borderTop;
			var borderBottom	= parseInt(this.currentStyle.borderBottomWidth);
				borderBottom	= (isNaN(borderBottom))? 0 : borderBottom;
		
			nHeight	-=  (paddingTop + paddingBottom + borderTop + borderBottom);
			nWidth	-= (paddingLeft + paddingRight + borderLeft + borderRight);
			
			return{ height:nHeight, width: nWidth };
		}
		obj.getOuterDimensions 		= function(){
			
			var nHeight 		= this.Element.offsetHeight;
			var nWidth			= this.Element.offsetWidth;
			return{ height:nHeight, width: nWidth };
		}
		obj.getScreenPosition		= function(){
			
			var left = 0;
			var top  = 0;
			var target	= this.Element;
			
			while(target.offsetParent){
				
				left 	+= target.offsetLeft;
				top  	+= target.offsetTop;	
				target 	= target.offsetParent;
			}
			
			left += (target.offsetLeft);
			top  += (target.offsetTop);
			
			return{ x:left, y:top };
		}
		obj.attachEvent				= function(sEvent, fpHandler){
			
		// validate arguments
			if(fpHandler == null || typeof(fpHandler) != "function"){
				var err = new Error("Invalid Event Handler defined");
				throw err;
			}
			
			if(obj.Element.attachEvent){
				sEvent = (sEvent.toLowerCase().substring(0,2) != "on")? "on"+sEvent : sEvent;
				obj.Element.attachEvent(sEvent, fpHandler);
				obj[sEvent] = obj.Element[sEvent];
			}
			else{
				sEvent = (sEvent.toLowerCase().substring(0,2) == "on")? sEvent.substring(2) : sEvent;
				obj.Element.addEventListener(sEvent, fpHandler, false);
			}
		}
		obj.detachEvent				= function(sEvent, fpNotify){
			
		// validate arguments
			if(fpHandler == null || typeof(fpHandler) != "function"){
				var err = new Error("Invalid Event Handler defined");
				throw err;
			}
			
			if(obj.Element.detachEvent){
				sEvent = (sEvent.toLowerCase().substring(0,2) != "on")? "on"+sEvent : sEvent;
				obj.Element.detachEvent(sEvent, fpHandler);
				obj[sEvent] = obj.Element[sEvent];
			}
			else{
				sEvent = (sEvent.toLowerCase().substring(0,2) == "on")? sEvent.substring(2) : sEvent;
				obj.Element.removeEventListener(sEvent, fpHandler, false);
			}
		}
		obj.getOuterHTML			= function(){
		
			if(this.outerHTML){
				
				return(this.Element.outerHTML);
			}
			else{
			
				var openingTag 	= "<"+ this.nodeName +" ";
				
				// Add defined attributes
					for(var sName in this.attributes){
						
						var attrNode	= this.attributes[sName];
						var attrName	= "";
						var attrValue	= "";
									
						if(attrNode != null && attrNode.nodeValue){
							attrName	= attrNode.nodeName;
							attrValue 	= attrNode.nodeValue;
						}
						else if(attrNode != null && attrNode.value){							
							attrName	= attrNode.name;
							attrValue 	= attrNode.value;
						}
						
						if(attrNode != null && attrValue != null && typeof(attrValue) != 'undefined' && attrValue != "")
							openingTag += (attrName +"=\""+ attrValue +"\" ");
					}				
				
				// Add inline style
					if(this.style.cssText != "")
						openingTag += " style=\""+ this.style.cssText +"\"";
				
					openingTag = openingTag.trim() + ">";
				var closeTag	= "</"+this.nodeName+">";
				
				return(openingTag + this.Element.innerHTML + closeTag);
			}
			
		}
		obj.appendChild				= function(oElem){
			
		// validate that the Node is a vlid ELEMENT or TEXT node
		// constants defined in Constants.js
			if(typeof(oElem) != "object" || oElem.nodeType == undefined || (oElem.nodeType != ELEMENT_NODE && oElem.nodeType != TEXT_NODE)){
				
				var sErrMsg = "Invalid Argument in appendChild()";
				var err		= new Error(sErrMsg);
				throw err;
			}
			
			this.Element.appendChild( oElem );
			
		}
		obj.getWindowDimensions		= function(){
		
			var nHeight	= 0;
			var nWidth 	= 0;
			if(window.screen) // NS/Firefox
			{
				nHeight = window.screen.availHeight;
				nWidth  = window.screen.availWidth;
			}
			else				// MSIE
			{
				nHeight = document.body.offsetHeight;
				nWidth  = document.body.offsetWidth;
			}
			
			return{ height:nHeight, width:nWidth };
		};

	
	};
	
	Stenstrom.NET.Web.WebPage				= function(){
	// inherit the Stenstrom.NET.Web.HTMLBase class properties and methods 
		Stenstrom.NET.System.Object.call(this);
		
	// create the prototype so that this class may be inherited 
		Stenstrom.NET.Web.HTMLElement.prototype				= new Stenstrom.NET.System.Object();
		Stenstrom.NET.Web.HTMLElement.prototype.constructor	= Stenstrom.NET.Web.WebPage;
		
	// static properties - defined as public but not intended for public consumption
		this.Type		= "Stenstrom.NET.Web.WebPage";
	}
	function WebPage_Initialize(obj){
	}
	
	
	