/**
 * <script> // for the PHP syntax highlighter
 */
function AgentAbstractor()
{
	var me = this;
	this.constants = new Array();
	this.constants['thin'] = 1;
	this.constants['medium'] = 2;
	this.constants['thick'] = 3;

	var debug = 0;

	this.isTested = false;
	this.doesBordersOutsideFlag = false;
	this.doesPaddingOutsideFlag = false;
	this.doesScrollingFlag = false;
	this.skipsValignFlag = false;
	this.skipsBordersFlag = false;
	this.skipsMarginsFlag = false;
	
	this.isCSS = function(){
		return (document.body && document.body.style) ? true : false;
	}
	this.isW3C = function(){
		return (this.isCSS() && document.getElementById) ? true : false;
	}
	this.isIE = function(){
		return (this.isCSS() && document.all) ? true : false;
	}
	this.isIE4 = function(){
		return (this.isIE() && !document.documentElement) ? true : false;
	}
	this.isNN4 = function(){
		return (document.layers) ? true : false;
	}
	this.isGekko = function(){
		return (document.addBinding) ? true : false;
	}

	this.runObjectDiscovery = function(hashPrefix, myHash, resultHash, isMe)
	{
		var debug = 0;
		if (hashPrefix != '') {
			hashPrefix +=  ".";
		}
		for (prop in myHash) {
			var elem = myHash[prop];
			// not an array
			var result;
			if (isMe) {
				result = eval(hashPrefix + prop);
				if (debug) logger.dump('isMe result:' + hashPrefix + prop + ' is ' + result);
				result = (result? 'boolean': 'undefined');
			} else {
				result = eval('typeof(' + hashPrefix + prop + ')');
			}
			
			if (typeof(elem) == 'string') {
				resultHash[elem] = (result == 'undefined'? '0' : '1');

				if (debug) logger.dump(hashPrefix + prop+  '=' + result);
				if (debug) logger.dump('stored as :[' + elem + '] value ['
										+ resultHash[elem] + ']');

			} else {
	 			if (result != 'undefined') {
		 			resultHash = me.runObjectDiscovery(hashPrefix + prop, elem, resultHash, (prop == 'aa'));
				}
			}
		}
		return resultHash;
	}

	this.testMeasurements = function() {
//		logger.dump('testing');
		var debug = 0;
		var tagId = 'pdt';
		var NONE = 'none';
		var BRD = 'border';
		var PAD = 'padding';
		var SPC = 'spacing';
		var TOTAL = 'total';
		var SCROLL_TOTAL = 'scrolltotal';
		var TABLE_WIDTH = 'tableWidth';
		var SPAN_WIDTH = 'spanWidth';
		var texts = new Array(NONE, BRD, PAD, SPC);
		var results = new Array();
		
		for (var i = 0; i < texts.length; i ++) {
			var thisArray = new Array();
			var testText = texts[i];
			var t = aa.get(tagId + i);
			var total = 0;
			var scrotal = 0;
			if (typeof(t) == 'undefined') {
				if (debug) alert(tagId + i + ' not found');
				this.isTested = true;
				break;
			}
			var ts = aa.getStyle(t);
			while(t.tagName != "BODY") {
				var myLeft = t.offsetLeft;
				if (typeof(myLeft) == 'undefined') {
					break;
				}
				total += myLeft;
				var myScrollLeft = t.scrollLeft;
				if (typeof(myScrollLeft) == 'number') {
					scrotal += myScrollLeft;
				} else {
					scrotal = null;
				}
				var tableWidth = this.getWidth(aa.get(tagId + 't' + i));
				var spanWidth = this.getWidth(aa.get(tagId + 's' + i));
				var tagWidth = this.getWidth(t);
				if (debug) logger.dump(tagId + i + ' ' + t.offsetParent.tagName
							+ ' W:' + t.offsetWidth 
							+ ' L:' + myLeft 
							+ ' SC:' + myScrollLeft
							+ ' SW:' + spanWidth
							+ ' TW:' + tableWidth
							);
				t = t.offsetParent;
			}
			thisArray[TABLE_WIDTH] = tableWidth;
			thisArray[SPAN_WIDTH] = spanWidth;
			thisArray[TOTAL] = total;
			thisArray[SCROLL_TOTAL] = scrotal;
			results[testText] = thisArray;
			var tb = aa.get(tagId + 't' + i);
			if (debug) logger.dump(tb.id + ' W:' + this.getWidth(tb) );
			if (debug) logger.dump(testText +' total: '+results[testText][TOTAL] 
						+ ' scrotal left: ' + results[testText][SCROLL_TOTAL]+"\n");
		}
		
		// see if scroll left is working if it is all of them need to be the same
		if (debug) logger.dumpHash('results', results);
		this.doesBordersOutsideFlag = (results[BRD][SPAN_WIDTH] > results[BRD][TABLE_WIDTH]);
		this.doesPaddingOutsideFlag = (results[PAD][SPAN_WIDTH] > results[PAD][TABLE_WIDTH]);
		this.doesScrollingFlag = (typeof(results[NONE][SCROLL_TOTAL]) == 'number' &&
								results[NONE][SCROLL_TOTAL] == results[BRD][SCROLL_TOTAL] &&
								results[NONE][SCROLL_TOTAL] == results[PAD][SCROLL_TOTAL] &&
								results[NONE][SCROLL_TOTAL] == results[SPC][SCROLL_TOTAL]);
		// valign test	
		var ot = aa.get(tagId + 'vat_test').offsetTop;
		if (debug) logger.dump(' vat_test.offsetTop:' + ot);
		this.skipsValignFlag = !(typeof(ot) == 'number' && ot > 0);
	
		// test for padding border or margin skipping either needs be greater none
		this.skipsPaddingFlag = !(results[PAD][TOTAL] > results[NONE][TOTAL]);
		this.skipsBordersFlag = !(results[BRD][TOTAL] > results[NONE][TOTAL]);
		this.skipsMarginsFlag = !(results[SPC][TOTAL] > results[NONE][TOTAL]);
		if (debug) logger.dump(' doesScrolling:' + this.doesScrollingFlag
								+ '\n doesBordersOutside:' + this.doesBordersOutsideFlag
								+ '\n doesPaddingOutside:' + this.doesPaddingOutsideFlag
								+ '\n skipsValign:' + this.skipsValignFlag
								+ '\n skipsPadding:' + this.skipsPaddingFlag
								+ '\n skipsBorders:' + this.skipsBordersFlag
								+ '\n skipsMargins:' + this.skipsMarginsFlag);
		this.isTested = true;
	}
	
	
	this.getCssRuleHash = function () {
	//alert(document.styleSheets);
		var ret = new Array();
/*
		var lastSheet = document.styleSheets.length;
		for (var s = 0; s < lastSheet; s++ ){
			var sheet = document.styleSheets[s];
			var myRules = (sheet.cssRules? sheet.cssRules : sheet.rules);
			var lastRule = myRules.length;
			for (var r = 0; r < lastRule; r ++) {
				myRule = myRules[r];
//				if(debug) logger.dump(myRule.selectorText);
				ret[myRule.selectorText] = myRule;
			}
		}
*/		return ret;
	}

}


// **********************************************
/**
 * get(myId) returns reference to the id
 */

	function aa_getDoc(doc){
		if (typeof(doc) == 'undefined' || null == doc) {
			return window.document;
		}
		if (doc.documentElement || doc.body || doc.layers) {
			return doc;
		}
		return this.getDocument(doc);
	}

	function aa_getDocument(tagRef) {
		if(tagRef.ownerDocument) {
			return tagRef.ownerDocument;
		}
		if(tagRef.document) {
			return tagRef.document;
		}
		return null;
	}

	function aa_getObjectFromObjectOrString(thing, doc) {
		if (typeof(thing) != "string") {
			return thing;
		}
		return this.getObject(thing, doc);			
	}


	function aa_getTest(myId, doc) 
	{
	    if (document.images) 
		{
	        if (typeof(document.getElementById) != 'undefined') 
			{
				AgentAbstractor.prototype.getObject = aa_getW3c;
				return this.getObject(myId, doc);
			}
	        if (typeof(document.all) != 'undefined') 
			{
				AgentAbstractor.prototype.getObject = aa_getIE4;
				return this.getObject(myId, doc);
			}
	        if (typeof(document.layers) != 'undefined') 
			{
				AgentAbstractor.prototype.getObject = aa_getNs4;
				return this.getObject(myId, doc);
			}
	    }
		AgentAbstractor.prototype.getObject = function () { return null; };
		return null;
	}
	
	function aa_getW3c(myId, doc)
	{
		doc = this.getDoc(doc);
		return doc.getElementById(myId);
	}
	
	function aa_getIE4(myId, doc)
	{
		doc = this.getDoc(doc);
		return doc.all[myId];
	}

	function aa_getNs4(myId, doc) {
	    var theObj;
		doc = this.getDoc(doc);
	    for (var i = 0; i < doc.layers.length; i++) {
	        if (doc.layers[i].name == myId) {
	            theObj = doc.layers[i];
	            break;
	        }
	        // dive into nested layers if necessary
	        if (doc.layers[i].document.layers.length > 0) {
	            theObj = this.get(myId, document.layers[i].document);
	        }
	    }
		if(typeof(theObj) == 'undefined') {
			return doc.ids[myId];
		}
	    return theObj;
	}

	// Convert object name string or object reference
	// into a valid style (or NN4 layer) reference
	function aa_getStyle(myTag) {
	    if (myTag && this.isCSS()) {
	        return myTag.style;
	    }
	    return myTag;
	}
	

AgentAbstractor.prototype.getDoc = aa_getDoc;
AgentAbstractor.prototype.getDocument = aa_getDocument;
AgentAbstractor.prototype.get = aa_getObjectFromObjectOrString;
AgentAbstractor.prototype.getObject = aa_getTest;
AgentAbstractor.prototype.getStyle = aa_getStyle;


/* end of get */
// **********************************************


// **********************************************
/**
 * getScreenSize returns available screen size
 */
AgentAbstractor.prototype.getScreenSize = aa_getScreenSize;
	
function aa_getScreenSize()
{
	var ret = new Array();
	ret['width'] = screen.availWidth;
	ret['height'] = screen.availHeight;
	return ret;
}

/* end of getScreenSize */
// **********************************************


// **********************************************
/**
 * getWindowSize returns available screen size
 */
AgentAbstractor.prototype.getWindowSize = aa_getWindowSize;

function aa_getWindowSize()
{
	var ret = new Array();
	if (typeof(window) != 'undefined' &&
		typeof(window.innerWidth) != 'undefined' &&
		typeof(window.innerHeight) != 'undefined' ) {
		ret['width'] = window.innerWidth;
		ret['height'] = window.innerHeight;
		return ret;
	}
/*
	alert(document);
	alert(document.body);
	alert(document.body.clientWidth);
*/
	if (typeof(document) != 'undefined' && 
		typeof(document.body) != 'undefined') {
		ret['width'] = document.body.clientWidth;
		ret['height'] = document.body.clientHeight;
		return ret;
	}
	return ret;
}

/* end of getWindowSize */
// **********************************************


// **********************************************
/**
 * Retrieve the rendered dims of an element
 */

AgentAbstractor.prototype.getComputedTop = aa_getComputedTop;
AgentAbstractor.prototype.getComputedLeft = aa_getComputedLeft;
AgentAbstractor.prototype.getComputedTopLeft = aa_getComputedTopLeft;

AgentAbstractor.prototype.getPadding = aa_getPadding;

AgentAbstractor.prototype.getNumberFromConstant = aa_getNumberFromConstant;
AgentAbstractor.prototype.getTop 	= aa_getTop;
AgentAbstractor.prototype.getLeft 	= aa_getLeft;
AgentAbstractor.prototype.getWidth 	= aa_getWidth;
AgentAbstractor.prototype.setWidth 	= aa_setWidth;
AgentAbstractor.prototype.getHeight	= aa_getHeight;
AgentAbstractor.prototype.setHeight	= aa_setHeight;
AgentAbstractor.prototype.getIntFromProp = aa_getIntFromProp;


	function aa_getComputedTop (myTag) {
		return this.aa_getComputedTopLeft(myTag)['top'];
	}
	function aa_getComputedLeft (myTag) {
		return this.getComputedTopLeft(myTag)['left'];
	}
	function aa_getComputedTopLeft (myTag) {
	    var debug = 0;
		var x = 0
		var y = 0;
		var starter = myTag;
		var tn = starter.tagName;
	    var ret = new Array();
	    // find my style.left and top in the scheme of things
	    // stop at the body or the first positioned element 

		// ns 4 is not really working unless this is a layer
		if (this.isNN4()) {
		    ret["top"] = myTag.pageY;
		    ret["left"] = myTag.pageX;
		    return ret;
		}

	
		while (starter.tagName != "BODY" ) {
			if (debug) logger.dump(starter.tagName + " is starter");
			tn = starter.tagName;
			if (this.getStyle(starter).position == "absolute" ) {
				var tx = parseInt(this.getStyle(starter).left, 10);
				if( !isNaN(tx) ){
					x += tx;
				}
				var ty = parseInt(this.getStyle(starter).top, 10);
				if( !isNaN(ty) ){
					y += ty;
				}
				if (debug && (tx || ty)) 
						logger.dump(tn + ' absolute L:' +tx + ' T: ' +ty);
				continue;
			}
			
			if (this.doesScrolling()) {
				if (typeof(starter.scrollLeft) == 'number') {
					x -= starter.scrollLeft;
				}

				if (typeof(starter.scrollTop) == 'number') {
					y -= starter.scrollTop;
				}
				if (debug && (starter.scrollLeft || starter.scrollTop)) 
					logger.dump(tn +' scroll L:'+starter.scrollLeft+ ' T: ' +starter.scrollTop);
			}
			if (debug > 1) logger.dump(tn +' scroll L:'+starter.scrollLeft+ ' T: ' +starter.scrollTop);
			
			if (this.skipsPadding()) {
				var ex = this.getPadding(starter);
				if (debug && (ex['left'] || ex['top'])) 
					logger.dump(tn + ' padding L:' +ex['left'] + ' T: ' +ex['top']);
				y += ex['top'];
				x += ex['left'];
			}
			
			if (this.skipsValign() && typeof(starter.clientTop) != 'undefined') {
				x += starter.clientLeft;
				y += starter.clientTop;
				if (debug && (starter.clientLeft || starter.clientTop)) 
					logger.dump(tn + ' client L:' +starter.clientLeft + ' T: ' +starter.clientTop);
			}
			if (debug > 1) logger.dump(tn + ' client L:' +starter.clientLeft + ' T: ' +starter.clientTop);
			
			x += starter.offsetLeft;
			y += starter.offsetTop;
			if (debug && (starter.offsetLeft || starter.offsetTop)) 
				logger.dump(tn + ' offset L:' +starter.offsetLeft + ' T: ' +starter.offsetTop);
			
			starter = starter.offsetParent;
		}
		if (debug) logger.dump('aa_getComputedTopLeft returning L:' +x + ' T: ' +y);
		ret["top"] = y;
		ret["left"] = x;
		return ret;
	}			

	
	function aa_getPadding (myTag) {
	    var debug = 0;
		var t = 0;
		var l = 0;
		var ret = new Array();
		
		if (typeof(myTag.currentStyle) != 'undefined') {
			
			if (debug > 1) logger.dump('currentStyle.padding:' + myTag.currentStyle.padding);
			t = myTag.currentStyle.paddingTop;
			l = myTag.currentStyle.paddingLeft;
		
		} else if (	typeof(document.defaultView) != 'undefined' && 
					typeof(document.defaultView.getComputedStyle) == 'function') 
		{
			if (debug > 1) logger.dump('document.defaultView.getComputedStyle');
			var ss = document.defaultView.getComputedStyle(starter, "");
			t = ss.getPropertyValue('padding-top');
			l = ss.getPropertyValue('padding-left');
		
		} else if (	typeof(myTag.style) != 'undefined' &&
					typeof(myTag.style.padding) != 'undefined' &&
					myTag.style.padding) 
		{
			if (debug > 1) logger.dump('style.padding:' + myTag.style.padding);
			t = l = myTag.style.padding;
		
		} else if (typeof(myTag.padding) != 'undefined') 
		{
			if (debug > 1) logger.dump('padding:' + myTag.padding);
			t = l = myTag.padding;
/*		
		} else if (typeof(myTag.cellPadding) != 'undefined') 
		{
			if (debug > 1) logger.dump('cellPadding:' + myTag.cellPadding);
			t = l = myTag.cellPadding;
*/		
		}
		ret["top"] = this.getIntFromProp(t);
		ret["left"] = this.getIntFromProp(l);
		if (debug && (ret["top"] || ret["left"])) logger.dump('aa_getPadding t:' + t + ' l:' + l);
		return ret;
	}

	
	function aa_getIntFromProp(prop) {
//				if(debug) logger.dump('aa_getComputedTopLeft ss x: ['+num+']]');
		var i = 0;
		if (prop) {
			i = parseInt(prop, 10);
			if (isNaN(i)) {
				i = this.getNumberFromConstant(prop);
			}
		}
		return i;
	}

	
	function aa_getNumberFromConstant(constant) {
		if (!constant) return 0;
		var num = parseInt(this.constants[constant.toLowerCase()], 10);
		if (isNaN(num)) return 0;
		return num;
	}
	
	
	function aa_getTop(myTag)  {
	    var result = 0;
	    if (document.defaultView &&
			typeof(document.defaultView.getComputedStyle) == 'function') {
	        var style = document.defaultView;
	        var cssDecl = style.getComputedStyle(myTag, "");
	        result = cssDecl.getPropertyValue("top");
	    } else if (myTag.currentStyle) {
	        result = myTag.currentStyle.top;
	    } else if (myTag.style) {
	        result = myTag.style.top;
	    } else if (myTag.top) {
	        result = (myTag.offsetTop) ? myTag.offsetTop : myTag.top
	    }
	    return parseInt(result, 10);
	}
	

	function aa_getLeft(myTag)  {
	    var result = 0;
	    if (document.defaultView &&
			typeof(document.defaultView.getComputedStyle) == 'function') {
	        var style = document.defaultView;
	        var cssDecl = style.getComputedStyle(myTag, "");
	        result = cssDecl.getPropertyValue("left");
	    } else if (myTag.currentStyle) {
	        result = myTag.currentStyle.left;
	    } else if (myTag.style) {
	        result = myTag.style.left;
	    } else if (myTag.left) {
	        result = (myTag.offsetLeft) ? myTag.offsetLeft : myTag.left;
	        result = myTag.left;
	    }
	    return parseInt(result, 10);
	}
	

	function aa_getWidth(myTag)  {
		var debug = 0;
	    var result = 0;
        if (debug) {
			logger.dump('scrollWidth:' + myTag.scrollWidth);
        	logger.dump('offsetWidth:' + myTag.offsetWidth);
        	logger.dump('style.pixelWidth:' + myTag.style.pixelWidth);
			if (myTag.clip) logger.dump('clip.width:' + myTag.clip.width);
	    }
		if (myTag.offsetWidth) {
	        if (myTag.scrollWidth && 
				(myTag.offsetWidth != myTag.scrollWidth)) 
			{
				result = Math.max(myTag.scrollWidth, myTag.offsetWidth);
	            if (debug) logger.dump('Math.max(scroll or offset):' + result);
	        } else {
	            result = myTag.offsetWidth;
	            if (debug) logger.dump('offsetWidth:' + result);
	        }
	    } else if (myTag.clip && myTag.clip.width) {
	        result = myTag.clip.width;
            if (debug) logger.dump('clip.width:' + result);
	    } else if (myTag.style && myTag.style.pixelWidth) {
	        result = myTag.style.pixelWidth;
            if (debug) logger.dump('style.pixelWidth:' + result);
	    }
	    return parseInt(result, 10);
	}
	

	function aa_getHeight(myTag)  {
	    var result = 0;
	    if (myTag.offsetHeight) {
	        if (myTag.scrollHeight && 
				(myTag.offsetHeight != myTag.scrollHeight)) 
			{
				result = Math.max(myTag.scrollHeight, myTag.offsetHeight);
	        } else {
	            result = myTag.offsetHeight;
	        }
	    } else if (myTag.clip && myTag.clip.height) {
	        result = myTag.clip.height;
	    } else if (myTag.style && myTag.style.pixelHeight) {
	        result = myTag.style.pixelHeight;
	    }
	    return parseInt(result, 10);
	}

	function aa_setHeight(myTag, height)  {
		var myStyle = this.getStyle(myTag);
		myStyle.height = height;
	}

	function aa_setWidth(myTag, width)  {
		var myStyle = this.getStyle(myTag);
		myStyle.width = width;
	}


/*  Retrieve the rendered dims of an element */
// **********************************************


// **********************************************
/**
 * Moving objects around
 */
	
AgentAbstractor.prototype.moveBy = aa_moveBy;
AgentAbstractor.prototype.moveTo = aa_moveTo;

	function aa_moveBy(myTag, deltaX, deltaY) {
		myStyle = this.getStyle(myTag);
	    if (myStyle) {
	        if (this.isCSS()) {
	            // equalize incorrect numeric value type
	            var units = (typeof(myStyle.left) == "string") ? "px" : 0 
	            myStyle.left = this.getLeft(myTag) + deltaX + units;
	            myStyle.top = this.getTop(myTag) + deltaY + units;
	        } else if (this.isNN4()) {
	            myStyle.moveBy(deltaX, deltaY);
	        }
	    }
	}

	function aa_moveTo(myTag, x, y) {
		myStyle = this.getStyle(myTag);
        if (this.isCSS()) {
            // equalize incorrect numeric value type
            var units = (typeof(myStyle.left) == "string") ? "px" : 0;
            myStyle.left = x + units;
            myStyle.top = y + units;
        } else if (this.isNN4()) {
            myStyle.moveTo(x,y)
        }
	}

	

/* End of Moving objects around  */
// **********************************************


// **********************************************
/**
 * Event related stuff
 */
	
AgentAbstractor.prototype.getEvent = aa_getEvent;
AgentAbstractor.prototype.getMouseX = aa_getMouseX;
AgentAbstractor.prototype.getMouseY = aa_getMouseY;
AgentAbstractor.prototype.getSrcElement = aa_getSrcElement;

	function aa_getEvent(ev)
	{
		return (ev) ? ev : event;
	}
	
	function aa_getMouseX(ev)
	{
		if (typeof(ev.pageX) == 'number') {
			return ev.pageX;
		} else if (typeof(ev.clientX) == 'number') {
			return ev.clientX + document.body.scrollLeft;
		}
	}
	
	function aa_getMouseY(ev)
	{
		if (typeof(ev.pageY) == 'number') {
			return ev.pageY;
		} else if (typeof(ev.clientY) == 'number') {
			return ev.clientY + document.body.scrollTop;
		}
	}

	function aa_getSrcElement(ev)
	{
	    ev = this.getEvent(ev);
		return (ev.target) ? ev.target : ev.srcElement;
	}
	
/* End of Event related stuff  */
// **********************************************

// **********************************************
/**
 * Start of Setting attributes 
 */
	
	// Get/Set the z-order of an object
	function aa_zIndex(myTag, zOrder) {
		myTag = this.getStyle(myTag);
	    if (myTag) {
			if(typeof(zOrder) == 'number') {
	        	myTag.zIndex = zOrder;
			}
			return myTag.zIndex;
	    }
	}
	
	// Set the background color of an object
	function aa_bgColor_test(myTag, color) {
        if (document.layers) {
			AgentAbstractor.prototype.bgColor = aa_bgColor_ns4;
        } else  {
			AgentAbstractor.prototype.bgColor = aa_bgColor_others;
		}
		return this.bgColor(myTag, color);
	}

	// Set the background color of an object
	function aa_bgColor_ns4(myTag, color) {
		myTag = this.getStyle(myTag);
	    if (myTag) {
			if(typeof(color) == 'number') {
	            myTag.bgColor = color;
    	    }
			return myTag.bgColor;
	    }
	}

	// Set the background color of an object
	function aa_bgColor_others(myTag, color) {
		myTag = this.getStyle(myTag);
	    if (myTag) {
			if(typeof(color) == 'string') {
	            myTag.backgroundColor = color;
    	    }
			return myTag.backgroundColor;
	    }
	}

	// Set the visibility of an object to visible
	function aa_show(myTag) {
		myTag = this.getStyle(myTag);
	    if (myTag) {
	        myTag.visibility = "visible";
	    }
	}
	
	// Set the visibility of an object to hidden
	function aa_hide(myTag) {
		myTag = this.getStyle(myTag);
	    if (myTag) {
	        myTag.visibility = "hidden";
	    }
	}

    function aa_setStyles(myTag, styleHash) {
		for (var key in styleHash) {
			this.setStyle(myTag, key, styleHash[key]);
		}
	}

    function aa_setStyle(myTag, styleProp, value) {
		var myStyle = this.getStyle(myTag);
		eval('myStyle.' + styleProp + ' = "' + value + '"');
	}


AgentAbstractor.prototype.zIndex = aa_zIndex;
AgentAbstractor.prototype.bgColor = aa_bgColor_test;
AgentAbstractor.prototype.hide = aa_hide;
AgentAbstractor.prototype.show = aa_show;
AgentAbstractor.prototype.setStyle = aa_setStyle;
AgentAbstractor.prototype.setStyles = aa_setStyles;


/* End of Setting attributes  */
// **********************************************


// **********************************************
/**
 * Start of data transfer stuff
 */
	
 	function aa_doesInnerHTML() {
//		alert ('css ' + this.isCSS());
//		alert ('body ' + (typeof(document.body.innerHTML) != 'undefined'));
		return (this.isCSS() && typeof(document.body.innerHTML) != 'undefined');
	}
 	
	function aa_innerHTML(myTag, myContent) {
		if (!this.doesInnerHTML()) {
			return false;
		}
		myTag.innerHTML = myContent;
		return true;
	}

AgentAbstractor.prototype.doesInnerHTML = aa_doesInnerHTML;
AgentAbstractor.prototype.innerHTML = aa_innerHTML;

/* End of data transfer stuff  */
// **********************************************


// **********************************************
/**
 * Start of DOM hierachy stuff
 */
	
	function aa_getParent(myTag) {
		if (this.isIE()) {
			return myTag.parentElement;
		}else if (this.isCSS()) {
			return myTag.parentNode;
		} else {
			return null;
		}
	}

	function aa_getChildren(myTag) {
		if (this.isIE()) {
			return myTag.children;
		}else if (this.isCSS()) {
			var kids = myTag.childNodes;
			var last = kids.length;
			var out = new Array();
			for(var i = 0; i < last; i++) {
				if(kids[i].nodeType == document.ELEMENT_NODE) {
					out[out.length] = kids[i];
				}
			}
			return out;
		} else {
			return null;
		}
	}

	function aa_getAttributeValue(myTag, attr) {
		if (eval('myTag.' + attr)) {
			return eval('myTag.' + attr);
		}
		if (myTag.attributes) {
			if (myTag.attributes[attr]) {
				return myTag.attributes[attr].value;
			} else if (myTag.attributes.getNamedItem &&
					   myTag.attributes.getNamedItem(attr) ) {
				return myTag.attributes.getNamedItem(attr).value;
			}
		}
		return null;
	}

	function aa_setAttributeValue(myTag, attr, val) {
		if (eval('myTag.' + attr)) {
			eval('myTag.' + attr + ' = "' + val + '";');
		}
		if (myTag.attributes) {
			if (myTag.attributes[attr]) {
				myTag.attributes[attr].value = val;
			} else if (myTag.attributes.getNamedItem &&
					   myTag.attributes.getNamedItem(attr) ) {
				myTag.attributes.getNamedItem(attr).value = val;
			}
		}
		return null;
	}

	function aa_isWithin(outerTag, innerTag) {
		if (outerTag == null || typeof(outerTag) != 'object' || 
		 	innerTag == null || typeof(innerTag) != 'object') {
			return false;
		}
		var myTag = innerTag;
		while (true) {
/*	
			logger.dump('mytag: ' + myTag);
			logger.dump('mytag.nodeType: ' + myTag.nodeType);
			logger.dump('mytag.tagName: ' + myTag.tagName);
			logger.dump('mytag: ' + myTag.outerHTML.substr(0, 100));
			logger.dump("\n");
*/	
			if (9 == myTag.nodeType) return false;
			if ('BODY' == myTag.tagName) return false;
			if (outerTag == myTag) {
				return true;
			}
			myTag = aa.getParent(myTag);
		}
		return false;
	}
	
	function aa_seekAttribute(myTag, attr, value) {
		if (myTag == null || typeof(myTag) != 'object') {
			return null;
		}
		doValue = typeof(value) == 'string';
		while (true) {
	/*
			logger.dump('mytag: ' + myTag);
			logger.dump('mytag.nodeType: ' + myTag.nodeType);
			logger.dump('mytag.tagName: ' + myTag.tagName);
			logger.dump('mytag: ' + myTag.outerHTML.substr(0, 100));
			logger.dump("\n");
	*/
			if (9 == myTag.nodeType) return null;
			if ('BODY' == myTag.tagName) return null;
			// if we don't do nodes OR
			// node is an element type(1) AND there are attributes
			// AND
			// this thing returns a value
			if ((typeof(myTag.nodeType) == 'undefined' || 
				(1 == myTag.nodeType && myTag.attributes)) &&
				aa.getAttributeValue(myTag, attr) ) 
			{
				var val = aa.getAttributeValue(myTag, attr);
				if (!doValue || val == value) {
					return myTag;
				}
			}
			myTag = aa.getParent(myTag);
		}
		return null;
	}

AgentAbstractor.prototype.isWithin = aa_isWithin;
AgentAbstractor.prototype.seekAttribute = aa_seekAttribute;
AgentAbstractor.prototype.getAttributeValue = aa_getAttributeValue;
AgentAbstractor.prototype.setAttributeValue = aa_setAttributeValue;
AgentAbstractor.prototype.getParent = aa_getParent;
AgentAbstractor.prototype.getChildren = aa_getChildren;
	
/* End of DOM hierachy stuff  */
// **********************************************

// **********************************************
/**
 * Start of DOM hierachy stuff
 */
AgentAbstractor.prototype.skipsValign = aa_skipsValign;

AgentAbstractor.prototype.skipsPadding = aa_skipsPadding;
AgentAbstractor.prototype.skipsBorders = aa_skipsBorders;

AgentAbstractor.prototype.doesScrolling = aa_doesScrolling;
AgentAbstractor.prototype.doesBordersOutside = aa_doesBordersOutside;
AgentAbstractor.prototype.doesPaddingOutside = aa_doesPaddingOutside;


	function aa_skipsValign() {
		if (!this.isTested) {
			this.testMeasurements();
		}
		return this.skipsValignFlag;
	}
	
	function aa_skipsBorders() {
		if (!this.isTested) {
			this.testMeasurements();
		}
		return this.skipsBordersFlag;
	}
	
	function aa_skipsPadding() {
		if (!this.isTested) {
			this.testMeasurements();
		}
		return this.skipsPaddingFlag;
	}
	
	function aa_doesScrolling() {
		if (!this.isTested) {
			this.testMeasurements();
		}
		return this.doesScrollingFlag;
	}

	function aa_doesBordersOutside () {
		if (!this.isTested) {
			this.testMeasurements();
		}
		return this.doesBordersOutsideFlag;
	}
		
	function aa_doesPaddingOutside () {
		if (!this.isTested) {
			this.testMeasurements();
		}
		return this.doesPaddingOutsideFlag;
	}
		
	
 
/* End of Tests  */
// **********************************************


// default instance
var aa = new AgentAbstractor();

 
 
 
