//common functions
	var isIE=navigator.appVersion.toUpperCase().indexOf("MSIE")!=-1;
	var isIE7=isIE ? (parseFloat(navigator.appVersion.split("MSIE")[1])==7): false;
	var needPNGFix=(isIE && !isIE7);

	function echoStylesInit(){
		if(!isIE) protomozfix();
		if(document.getElementsByTagName('*').length<5000) fixLegacyLinkTips(); //as to not break the old linktip function
		
		prepareScriptedStyles();
		changeFontSize();
		fixPNGs(); //this should be the last function, always
	}
	
	addLoadEvent(function(){echoStylesInit();});
	
	function prepareScriptedStyles(){
		//much faster than doing getelementsbyclass over and over
		var elms = document.getElementsByTagName('*');
		var startTimeMS=new Date().valueOf();
		for(var x=0;x<elms.length;x++) {
			if(elms[x].className) {
				//if(elms[x].nodeName=='A') alert('anchor found');
				var testClass=' ' + elms[x].className + ' ';
				if(testClass.search(/ urlcontent /ig)!=-1)			ajaxUpdate(elms[x].getAttribute('src'),elms[x]);
				if(testClass.search(/ infoportal /ig)!=-1)		makeInfoPortalInput(elms[x]);
				if(testClass.search(/ infoportaldiv /ig)!=-1)	makeInfoPortalDiv(elms[x]);
				if(testClass.search(/ agentscript /ig)!=-1)		makeAgentScript(elms[x]);
				if(testClass.search(/ businessrules /ig)!=-1)	makeBusinessRule(elms[x]);
				if(testClass.search(/ sorttable /ig)!=-1)		makeSortTable(elms[x]);
				if(testClass.search(/ rightcontent /ig)!=-1)	makeRightContent(elms[x]);
				if(testClass.search(/ procedure /ig)!=-1)		makeProcedure(elms[x]);
				if(testClass.search(/ tooltip /ig)!=-1)			makeTip(elms[x]);
				if(testClass.search(/ TabContent /ig)!=-1)		makeContentTab(elms[x]);
				if(testClass.search(/ SideTab /ig)!=-1)			makeSideTab(elms[x]);
				if(testClass.search(/ imageView /ig)!=-1)			makeImageView(elms[x]);
			}
			if((new Date().valueOf()-startTimeMS)>5000) break; //already taken 5 seconds to run, cancel out of this.
		}
		//var nowMS=new Date().valueOf();
		//status='took ' + (nowMS-startTimeMS) + 'ms for ' + x + ' nodes; avg ' + (nowMS-startTimeMS)/x + 'ms per node';
	}

	function addLoadEvent(func) {
		if (typeof(window.onload)!= 'function') window.onload = func;
		else {
			var olold = window.onload;
			window.onload = function() {
				if (olold) olold();
				func();
			}
		}
	}

	function protomozfix(){
		if (isIE) return;
		//this fixes firefox for 'innerText' 'OuterText' & 'OuterHTML'
		HTMLElement.prototype.__defineSetter__("innerText", function (sText) {
			this.innerHTML = sText.replace(/\&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
		});
		
		HTMLElement.prototype.__defineGetter__("innerText", function () {
			var r = this.ownerDocument.createRange();
			r.selectNodeContents(this);
			return r.toString();
		});
		
		var _emptyTags = {
			"IMG":   true,
			"BR":    true,
			"INPUT": true,
			"META":  true,
			"LINK":  true,
			"PARAM": true,
			"HR":    true
		};
	
		HTMLElement.prototype.__defineSetter__("outerHTML", function (sHTML) {
			var r = this.ownerDocument.createRange();
			r.setStartBefore(this);
			var df = r.createContextualFragment(sHTML);
			this.parentNode.replaceChild(df, this);
		});
	
		HTMLElement.prototype.__defineGetter__("outerHTML", function () {
			var attrs = this.attributes;
			var str = "<" + this.tagName;
			for (var i = 0; i < attrs.length; i++) str += " " + attrs[i].name + "=\"" + attrs[i].value + "\"";
			if (_emptyTags[this.tagName]) return str + ">";
			return str + ">" + this.innerHTML + "</" + this.tagName + ">";
		});
		
		HTMLElement.prototype.__defineSetter__("outerText", function (sText) {
			this.outerHTML = sText.replace(/\&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
		});
	}
	
	function getElementsByClass(searchClass, node, tag){
		// getElementsByClass(strClass,objNode,strTag) -> obj OR obj[]
		var classElements = new Array();
		if(node == null) node = document;
		if(tag == null) tag = '*';
		var els = node.getElementsByTagName(tag);
		var elsLen = els.length;
		var pattern = new RegExp("(^|\s)"+searchClass+"(\s|$)");
		for (i = 0, j = 0; i < elsLen; i++) if(pattern.test(els[i].className)) classElements.push(els[i]);
	
		return classElements;
	}
	
	function $$(searchClass, node, tag){
		//shorthand getelementsbyclass
		return getElementsByClass(searchClass, node, tag);
	}
	  
	function $(element) {
		//$(id) -> obj
		//$(id, [id, ...]) -> obj[]
		if (arguments.length > 1) {
			for (var i = 0, elements = [], len = arguments.length; i < len; i++) elements.push($(arguments[i]));
			return elements;
		}
		
		if (typeof element == 'string') element = document.getElementById(element);
		return element;
	}
	
	function fixPNGs(){
		//this only fixes IMG tags. Background images are too hard to fix - too many problems with repeat, position, etc.
		if (!needPNGFix) return;
		elms=document.getElementsByTagName('img');
		var x=0;
		for(var x=0, len=elms.length; x<len; x++) {
			if(!elms[x].onload && elms[x].src && elms[x].src.toUpperCase().indexOf('SPACER.PNG')==-1 && elms[x].src.toUpperCase().indexOf('.PNG')!=-1 &&!elms[x].getAttribute('nopngfix')){
				fixPNG(elms[x]);
			}
		}
		return;
	}

	function fixPNG(imgobj){
		if (!needPNGFix && !imgobj.getAttribute('forcepngfix')) return;
		if(imgobj.src.toUpperCase().indexOf('SPACER.PNG')==-1 && imgobj.src.toUpperCase().indexOf('.PNG')!=-1 && !imgobj.getAttribute('nopngfix')){
			src=String(imgobj.src); //non enum
			var simg=new Image;
			simg.src=src;
			//status=(src + ': ' + simg.width + 'x' + simg.height);

			imgobj.src='/echostyle/images/spacer.png';
			if (imgobj.getAttribute('sizingmethod')) imgobj.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' + src + ', sizingMethod=' + imgobj.getAttribute('sizingmethod') + ')';
			else imgobj.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' + src + ')';
			
			if (!imgobj.style.pixelWidth) {
				imgobj.style.pixelWidth=simg.width;
				imgobj.style.pixelHeight=simg.height;
			}
		}
	}

	function addEvent(obj, eventName, func) {
		/*
		
		var elem=$('someid');
		addEvent(elem,'click',function(){
			obj=(this==window)? event.srcElement : this;
			
			//obj will be the owner element
			alert(obj.id);
		});
		
		*/
		
		var eventN=eventName.toLowerCase();
		if (eventN.substr(0,2)=='on') eventN=eventN.substr(2); //remove the 'on' prefix, if it exists

		if(obj.addEventListener) obj.addEventListener(eventN,func,false)
		else obj.attachEvent ('on' + eventN, func);
	}
	
	function makeSortTable(table, noHeadMod){ //this sets up the table
		if(typeof(table)!='object' || !table.firstChild || table.firstChild.nodeName!='TBODY') return false;
		if(table.getAttribute('sortTable')) return table; //don't re-setup the table
		
		table.setAttribute('sortTable',true);
		table.sortBy=function(sortby,casesensitive){
			if(this.nodeName!='TABLE') return false;
			a=this.firstChild.childNodes; //all the rows: this.tbody.tr[]
			
			if(!casesensitive) casesensitive=false //default to no
			if(!sortby) sortby=0; //default to column 0
		
			if(a[0].firstChild.nodeName=='TH') var header=this.firstChild.removeChild(a[0]); //is first row a header? if so lets store it in a safe place
		
			if(typeof(sortby)=='string') {
				if(!header) return false; //specified to sort by a string, but there is no header! maybe should default to sort by column 0
				for(var x=0;x<header.childNodes.length;x++){
					if (header.childNodes[x].innerText.toLowerCase()==sortby.toLowerCase()){
						sortby=x; 
						break;
					}
				}
				if (typeof(sortby)=='string') return false; //no match found, break		
			} else if(!a[0].childNodes[sortby]) return false; //don't sort if the column doesn't exist
			
			//now set the ascending/descending image
			if(header){
				ancs=header.childNodes;
				for(var x=0, len=ancs.length; x<len; x++){
					if(x==sortby) {
						ancs[x].firstChild.blankImg.style.display='none';
						ancs[x].firstChild.ascendingImg.style.display='';
						ancs[x].firstChild.descendingImg.style.display='none';
					}else{
						ancs[x].firstChild.blankImg.style.display='';
						ancs[x].firstChild.ascendingImg.style.display='none';
						ancs[x].firstChild.descendingImg.style.display='none';
					}
				}
			}
			
			swapNodes = function(nodea, nodeb) { //setup support function
				var ab = nodea.nextSibling;
				var ap = nodea.parentNode;
				nodeb.parentNode.replaceChild(nodea, nodeb);
				ap.insertBefore(nodeb, ab);  
			}
			
			//shell sort
			for (var incr = a.length / 2; incr > 0; incr = (incr == 2 ? 1 : Math.round(incr / 2.2))) {
				for (var i = incr; i < a.length; i++) {
					if(!casesensitive) for (var j = i; j >= incr && a[j - incr].childNodes[sortby].innerText.toLowerCase() > a[j].childNodes[sortby].innerText.toLowerCase(); j -= incr) swapNodes(a[j],a[j - incr]);
					else for (var j = i; j >= incr && a[j - incr].childNodes[sortby].innerText > a[j].childNodes[sortby].innerText; j -= incr) swapNodes(a[j],a[j - incr]);
				}
			}
		
			if(header) this.firstChild.insertBefore(header,this.firstChild.firstChild); //add the header back to the top row
		};	
		
		//now make the header
		
		if(!noHeadMod && table.firstChild.firstChild.firstChild.nodeName=='TH'){ //1st row is header, lets link-ify it
			var cells=table.firstChild.firstChild.childNodes;
	
			for (var x=0; x<cells.length; x++){
				var anc=document.createElement('a');
				while(cells[x].hasChildNodes()) anc.appendChild(cells[x].removeChild(cells[x].firstChild)); //move all the cell's contents into the anchor
				anc.href='javascript:void(0)';
				anc.title='Sort by ' + anc.innerText;
				anc.onclick=function(){
					this.parentNode.parentNode.parentNode.parentNode.sortBy(this.innerText);
				}
				cells[x].appendChild(anc);
				var imgobj=cells[x].appendChild(document.createElement('img'));
				imgobj.style.cssText='margin:0px 3px;vertical-align:middle;display:none;width:5px;height:6px;';
				imgobj.src='/echostyle/images/ascending.png';
				anc.ascendingImg=imgobj;

				var imgobj=cells[x].appendChild(document.createElement('img'));
				imgobj.style.cssText='margin:0px 3px;vertical-align:middle;display:none;width:5px;height:6px;';
				imgobj.src='/echostyle/images/descending.png';
				anc.descendingImg=imgobj;

				var imgobj=cells[x].appendChild(document.createElement('img'));
				imgobj.style.cssText='margin:0px 3px;vertical-align:middle;width:5px;height:6px;';
				imgobj.src='/echostyle/images/spacer.png';
				anc.blankImg=imgobj;


			}
		}
		return table;
	}
	
	function makeInfoPortalDiv(obj){ //obj needs attribute query="how do i find my location?"
		if(obj.getAttribute('infoportal') || !obj.getAttribute('query')) return obj; //don't prepare again, don't prepare if no query!
		obj.setAttribute('infoportal',true);
		
		var found=false;
		
		for(x in qarray) if(obj.getAttribute('query').search(eval('/' + qarray[x].keywords.replace(/; /gi,';').replace(/;/g,'|').replace(/\//g,'\\/') + '/ig'))!=-1){
			found=true;
			var div=obj.appendChild(document.createElement('div'));
			div.style.cssText='padding-left:35px;overflow:auto;margin:6px 0px;';
	
			var strExt=qarray[x].url.split('.')[qarray[x].url.split('.').length-1].split("?")[0].split("#")[0]
			strExt=(strExt.search(/doc|html|msg|pdf|ppt|txt|xls/gi))?'html':strExt;
			var img=div.appendChild(document.createElement('img'));
			img.style.cssText='float:left;margin-left:-35px;width:32px;height:32px;';
			img.src='/echostyle/images/filetypes/' + strExt + '.png';
			img.setAttribute('sizingmethod','scale');
			
			var anc=div.appendChild(document.createElement('a'));
			anc.appendChild(document.createTextNode(qarray[x].question));
			anc.className='infodlink';
			anc.href=qarray[x].url;
			anc.target=qarray[x].target;
	
			div.appendChild(document.createElement('br'));
	
			var anc=div.appendChild(document.createElement('a'));
			anc.appendChild(document.createTextNode(qarray[x].url));
			anc.style.cssText='margin-left:15px;font-style:italic;font-size:80%;';
			anc.className='infodsublink';
			anc.href=qarray[x].url;
			anc.target=qarray[x].target;
			
			if (isIE && !isIE7 && div.offsetHeight<=35) div.style.pixelHeight=35; //fix ie6
		}
		
		if(!found){
			var spanobj=obj.appendChild(document.createElement('span'));
			spanobj.style.cssText='font-style:italic;';
			spanobj.appendChild(document.createTextNode('No InfoPortal Results Found'));
		}
		
		return obj;
	}

	function makeInfoPortalInput(obj){
		//options
		var borderColor='#555';
	
		if(obj.nodeName!='INPUT') return false; //only works on input boxes
		if(obj.getAttribute('infoportal')) return obj; //don't prepare again
		obj.setAttribute('infoportal',true);
		
		obj.style.border='1px solid ' + borderColor;
	
		obj.actualLeft=function(){
			loc = this.offsetLeft;
			var obj=this;
			while (obj=obj.offsetParent) loc += obj.offsetLeft;
			return loc;
		}
			
		obj.actualTop=function(){
			loc = this.offsetTop;
			var obj=this;
			while (obj=obj.offsetParent) loc += obj.offsetTop;
			return loc;
		}
	
		infoLink=function(qObj){ //this function creates the link
			var obj=document.createElement('a');
			//obj.appendChild(document.createTextNode(qObj.question));
			obj.innerHTML=qObj.question; 
			obj.href=qObj.url;
			obj.style.cssText='display:block;padding:3px;';
			obj.className='infoplink';
			if (qObj.newWindow) obj.target='_blank';
			return obj;
		}
	
		//create the answers box
		var ansBox=document.body.appendChild(document.createElement('div'));
		obj.ansBox=ansBox; //give reference to answer box
	
		obj.ansBox.inpBox=obj; //give reference back to input box
		obj.ansBox.style.cssText='background-color:#fff;display:none;position:absolute;border:1px solid ' + borderColor +';';
	
		obj.ansBox.positionMe=function(){
			this.style.left=this.inpBox.actualLeft() + 'px';
			this.style.top=(this.inpBox.actualTop() + this.inpBox.clientHeight + 1)  + 'px';
			this.style.width=this.inpBox.clientWidth + 'px';
		}
		
		obj.ansBox.show=function(){
			this.positionMe();
			this.style.display='';
		}
		
		obj.ansBox.hide=function(){
			//eventually replace this with a fadeout
			this.style.display='none';
		}
	
		obj.showQuestions=function(){
			var found=false;
			while(this.ansBox.firstChild) this.ansBox.removeChild(this.ansBox.firstChild); //remove all previous entries
			for(x in qarray) if(this.value.search(eval('/' + qarray[x].keywords.replace(/; /gi,';').replace(/;/g,'|').replace(/\//g,'\\/') + '/ig'))!=-1){
				var found=true;
				this.ansBox.appendChild(infoLink(qarray[x]));
			}
			
			if (this.getAttribute('searchurl')){
				this.ansBox.appendChild(document.createElement('div')).style.cssText='height:2px;width:98%;margin-left:auto;margin-right:auto;border-bottom:1px solid ' + borderColor + ';margin-bottom:1px;';

				if (this.getAttribute('searchquestion')) var searchQuestion=this.getAttribute('searchquestion').replace(/%query%/g,this.value)
				else var searchQuestion='Search for <strong>' + this.value + '</strong>'
				
				this.ansBox.appendChild(infoLink({
					question:	searchQuestion,
					url:		this.getAttribute('searchurl').replace(/%query%/g,encodeURIComponent(this.value)),
					newWindow:	false
				}));
			}
			
			var imgobj=document.createElement('img');
			imgobj.src='/echostyle/images/infoportalshadow.png';
			imgobj.style.cssText='position:absolute;bottom:-7px;height:6px;';
			imgobj.style.width=this.clientWidth + 'px';
			imgobj.setAttribute('sizingmethod','scale');
			fixPNG(imgobj);
			this.ansBox.appendChild(imgobj);
			
			if(found) this.ansBox.show();
			else this.ansBox.hide();
		}
		
		addEvent(obj,'onblur',function(){
			obj=(this==window)? event.srcElement : this;
			setTimeout(function(){obj.ansBox.hide();},500);
		});

		addEvent(obj,'onfocus',function(){
			obj=(this==window)? event.srcElement : this;
			obj.showQuestions();
		});
		
		addEvent(obj,'onkeyup',function(){
			obj=(this==window)? event.srcElement : this;
			obj.showQuestions();
		});		
		
		return obj;
	}
	
	function tryThese(){
		var toReturn;
		
		for (var x=0, len=arguments.length; x<len; x++) {
			var func = arguments[x];
			try {
				toReturn = func();
				break;
			} catch (err) {}
	    }

    	return toReturn;
	}
	
	function changeFontSize(fs){
		//fs can be small, medium, large, or null (to read value from cookie, or use default if no cookie found)
		var smallFont='8pt';
		var mediumFont='9.25pt';
		var largeFont='10.5pt';
		
		var obj=$$('fontsize')[0];
		if(!obj) return;

		
		if(!fs) fs=readCookie('fontsize');
		else writeCookie('fontsize',fs,{expires:'Jan 1 2020', path:'/'});
	
		if(!fs || fs=='') var fs='small';


		var ss=document.styleSheets;
		
		//no stylesheets? add one.
		if(ss.length==0) document.getElementsByTagName('head')[0].appendChild(document.createElement('style'));

		switch(fs.toLowerCase()){
			default: //small
				if(isIE){
					ss[ss.length-1].addRule('body', 'font-size:' + smallFont + ' ;');
					ss[ss.length-1].addRule('table', 'font-size: ' + smallFont + ' ;');
					ss[ss.length-1].addRule('th', 'font-size: ' + smallFont + ' ;');
					ss[ss.length-1].addRule('td', 'font-size: ' + smallFont + ' ;');
				}else ss[ss.length-1].insertRule('body,table,th,td {font-size: ' + smallFont + ' ;}',ss[ss.length-1].cssRules.length);
				break;
			case 'medium':
				if(isIE){
					ss[ss.length-1].addRule('body', 'font-size: ' + mediumFont + ' ;');
					ss[ss.length-1].addRule('table', 'font-size: ' + mediumFont + ' ;');
					ss[ss.length-1].addRule('th', 'font-size: ' + mediumFont + ' ;');
					ss[ss.length-1].addRule('td', 'font-size: ' + mediumFont + ' ;');					
				}else ss[ss.length-1].insertRule('body,table,th,td {font-size: ' + mediumFont + ' ;}',ss[ss.length-1].cssRules.length);
				break;
			case 'large':
				if(isIE){
					ss[ss.length-1].addRule('body', 'font-size: ' + largeFont + ' ;');
					ss[ss.length-1].addRule('table', 'font-size: ' + largeFont + ' ;');
					ss[ss.length-1].addRule('th', 'font-size: ' + largeFont + ' ;');
					ss[ss.length-1].addRule('td', 'font-size: ' + largeFont + ' ;');					
				}else ss[ss.length-1].insertRule('body,table,th,td {font-size: ' + largeFont + ' ;}',ss[ss.length-1].cssRules.length);
				break;
		}

		//now update the fontsize class with proper links
		while(obj.firstChild) obj.removeChild(obj.firstChild);
		
		fs=readCookie('fontsize');
		if(!fs) fs='small';
		
		if(fs.toLowerCase()=='small') obj.appendChild(document.createTextNode('Small | '));
		else {
			var anc=obj.appendChild(document.createElement('a'));
			anc.appendChild(document.createTextNode('Small'));
			anc.href='javascript:changeFontSize("small");';
			obj.appendChild(document.createTextNode(' | '));
		}

		if(fs.toLowerCase()=='medium') obj.appendChild(document.createTextNode('Medium | '));
		else {
			var anc=obj.appendChild(document.createElement('a'));
			anc.appendChild(document.createTextNode('Medium'));
			anc.href='javascript:changeFontSize("medium");';
			obj.appendChild(document.createTextNode(' | '));
		}

		if(fs.toLowerCase()=='large') obj.appendChild(document.createTextNode('Large'));
		else {
			var anc=obj.appendChild(document.createElement('a'));
			anc.appendChild(document.createTextNode('Large'));
			anc.href='javascript:changeFontSize("large");';
		}
	}
	
	function writeCookie(name, value, opts) {
		/*
		name - name of the cookie
		value - value of the cookie
		opts{
			.expires - date object expiration date of the cookie  (defaults to end of current session)
			.path - path for which the cookie is valid (defaults to path of calling document)
			.domain - domain for which the cookie is valid (defaults to domain of calling document)
			.secure - Boolean value indicating if the cookie transmission requires a secure transmission
		}
		*/
		document.cookie = name + "=" + escape(value) +
			((opts.expires) ? "; expires=" + new Date(opts.expires).toGMTString() : "") +
			((opts.path) ? "; path=" + opts.path : "") +
			((opts.domain) ? "; domain=" + opts.domain : "") +
			((opts.secure) ? "; secure" : "");
	}
	
	function readCookie(name){
		if(!name) return;
		var cookies=document.cookie.replace(/\; /g,';').split(';');
		for (x in cookies) if (cookies[x].split('=')[0].toLowerCase()==name.toLowerCase()) return unescape(cookies[x].split('=')[1]);
		return null;
	}
	
//ajax functions
	
	function ajaxTransport(){
		return tryThese(
			function() {return new XMLHttpRequest()},
			function() {return new ActiveXObject('Msxml2.XMLHTTP')},
			function() {return new ActiveXObject('Microsoft.XMLHTTP')}
		);
	}
	
	function ajaxIt(url){
		var req=ajaxTransport();
		if(req){
			req.open("GET", url, false);
			req.send(null);	
			return req.responseText
		}
	}
	
	var ajaxReq; //this transport needs to be available in the global scope, due to the timeout
	function ajaxUpdate(url,obj,delay){
		//after delay miliseconds, this will update OBJ.innerHTML with the contents of URL
		//then execute any new javascript
		var ajaxReq=ajaxTransport();
		if(ajaxReq) {
			if(obj) ajaxReq.onreadystatechange = function (){
				//set obj to the url and parse any scripts inside
				if(ajaxReq.readyState==4) obj.innerHTML=ajaxReq.responseText;
				var scripts=obj.getElementsByTagName('SCRIPT');
				if(scripts) for(var x=0, len=scripts.length; x<len; x++) eval(scripts[x].innerHTML);
			};
			ajaxReq.open("GET", url, true);
			if(!delay) ajaxReq.send(null);
			else setTimeout(function(){ajaxReq.send(null)},delay);
		}
	}	
	
	
//Style Functions
	function makeProcedure(obj){
		if(obj.getAttribute('makeProc')) return; //don't prepare again
		obj.setAttribute('makeProc',true);

		var p1 = document.createElement("div");
		p1.className = "procContainer";
		txt = document.createTextNode(obj.getAttribute("title"));
		obj.parentNode.replaceChild(p1, obj);
		
		var p2 = document.createElement("span");
		p2.className = "procIcon";
		
		if(needPNGFix) p2.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=/echostyle/images/procedure.png, sizingMethod='scale')";
		else p2.style.background = "url(/echostyle/images/procedure.png) top left no-repeat";
		
		var p3 = document.createElement("b");
		p3.appendChild(txt);
		p3.style.paddingLeft = "8px"
		p1.appendChild(p2);
		p1.appendChild(p3);
		p1.appendChild(obj);
	}
	
	function makeRightContent(obj){
		if(obj.getAttribute('rightcontentprepared')) return;
		obj.setAttribute('rightcontentprepared',true);
		
		var r1 = document.createElement("div");                  //container
		r1.className = "container";
		var r2 = document.createElement("div");                  //top
		r2.className = "rctopright";
		if(needPNGFix)r2.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=/echostyle/images/right_content_top.png, sizingMethod='scale')";
		else r2.style.background = "url(/echostyle/images/right_content_top.png) top left no-repeat";
	
		var r3 = document.createElement("div");                  //bottom
		r3.className = "rcbottomright";
		if(needPNGFix) r3.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=/echostyle/images/right_content_bottom.png, sizingMethod='scale')";
		else r3.style.background = "url(/echostyle/images/right_content_bottom.png) bottom left no-repeat";
	
		obj.parentNode.replaceChild(r1, obj);                //replace original with container node
		r1.appendChild(r2);                                       //add top node to container
		if(obj.getAttribute("title")) {               //if title, insert text node into top
			var txt = document.createTextNode(obj.getAttribute("title"));
			r2.appendChild(txt);
		}
		r1.appendChild(obj);                                   //add original node to container
		r1.appendChild(r3);                                       //add bottom node to container
	}

	function makeBusinessRule(obj){
		if(obj.getAttribute('businessruleprepared')) return;
		obj.setAttribute('businessruleprepared',true);

		var applystyle=obj.style.cssText;
		obj.style.cssText='';
		var newobj=document.createElement('div');
		newobj.style.cssText='background-color:#CCCCFF; border:1px solid #9933FF;width:90%;padding:5px;min-height:65px;' + applystyle;
		newobj.innerHTML='<div style="width:100px;float:left"><img src="/echostyle/images/business_rule.png" style="display:table-cell;display:inline-block;width:90px;height:64px;"></div><div style="display:table-cell;display:inline-block; padding-left:2px;">' + obj.innerHTML + '</div>';

		obj.innerHTML='';
		//obj.appendChild(document.createElement('br'));

		obj.appendChild(newobj);
	}
	
	function makeAgentScript(obj){
		if(!obj.getAttribute('scriptprepared')){
			obj.setAttribute('scriptprepared',true);
			
			if($$('moreinfo',obj)[0]) var moreinfo=obj.removeChild($$('moreinfo',obj)[0]);
			
			var content=document.createElement('div');
			content.style.cssText='width:394px;padding-left:85px;padding-top:5px;padding-right:15px;overflow:auto;';
			
			if (!needPNGFix) content.style.backgroundImage='url(/echostyle/images/script_middle.png)';
			else content.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src=/echostyle/images/script_middle.png, sizingMethod=scale)';
			
			var imgobj=content.appendChild(document.createElement('img'));
			imgobj.style.cssText='float:left;margin-left:-80px;';
			if (obj.getAttribute('mandatory')) {
				imgobj.src='/echostyle/images/scriptm.png';
				imgobj.style.width='80px';
				imgobj.style.height='51px';					
			}else{
				imgobj.src='/echostyle/images/script.png';
				imgobj.style.width='80px';
				imgobj.style.height='37px';
			}
			
			var imgobj=content.appendChild(document.createElement('img'));
			imgobj.setAttribute('nopngfix',true);
			imgobj.style.marginRight='5px';
			imgobj.src='/echostyle/images/script_qo.png';
		
			while(obj.firstChild) content.appendChild(obj.removeChild(obj.firstChild));

			var imgobj=content.appendChild(document.createElement('img'));
			imgobj.setAttribute('nopngfix',true);
			imgobj.src='/echostyle/images/script_qc.png';
			
			var imgobj=obj.appendChild(document.createElement('img'));
			imgobj.src='/echostyle/images/script_top.png';
			imgobj.style.cssText='position:absolute;top:-29px;left:0px;width:494px;height:29px;';
			
			obj.appendChild(content);
			
			var div=obj.appendChild(document.createElement('div'));
			div.style.cssText='height:21px;width:494px;left:0px;bottom:-21px;';

			var cimg;
			if(moreinfo) cimg='script_bottom_c2.png';
			else cimg='script_bottom_c1.png';

			if (!needPNGFix) div.style.backgroundImage='url(/echostyle/images/' + cimg + ')';
			else div.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src=/echostyle/images/' + cimg + ', sizingMethod=scale)';
			
			if(moreinfo){
				//setup more info button				
				var div=div.appendChild(document.createElement('div'));
				div.style.cssText='width:80px;text-align:center;float:right;';
				var anc=div.appendChild(document.createElement('a'));
				anc.innerText='Learn More';
				anc.className='scriptlm';
				anc.href='javascript:void(0);';
				//setup handler to show/hide moreinfobox
				anc.onclick=function(){
					if (this.innerText=='Learn More'){
						this.innerText='Less Info';
						this.style.top='3px';
						this.parentNode.parentNode.nextSibling.style.display='';

						if (!needPNGFix) this.parentNode.parentNode.style.backgroundImage='url(/echostyle/images/script_bottom_e1.png)';
						else this.parentNode.parentNode.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src=/echostyle/images/script_bottom_e1.png, sizingMethod=scale)';
					} else {
						this.innerText='Learn More';					
						this.style.top='';
						this.parentNode.parentNode.nextSibling.style.display='none';

						if (!needPNGFix) this.parentNode.parentNode.style.backgroundImage='url(/echostyle/images/script_bottom_c2.png)';
						else this.parentNode.parentNode.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src=/echostyle/images/script_bottom_c2.png, sizingMethod=scale)';
					}
			
			
				}
				//build more info box, currently it puts the box outside the main agentscript element, doesn't inherit style
				//from it... need to do something about that (try float:right on your agentscript div)
				var div=obj.appendChild(document.createElement('div')); //obj.parentNode.insertBefore(document.createElement('div'),obj.nextSibling);
				div.style.cssText='display:none;width:494px;';
				
				moreinfo.style.cssText+=';padding:0px 10px;width:474px;';
				if (!needPNGFix) moreinfo.style.backgroundImage='url(/echostyle/images/script_bottom_e2.png)';
				else moreinfo.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src=/echostyle/images/script_bottom_e2.png, sizingMethod=scale)';
				
				div.appendChild(moreinfo);
				var imgobj=div.appendChild(document.createElement('img'));
				imgobj.src='/echostyle/images/script_bottom_e3.png';
				imgobj.setAttribute('scalemode','scale');
				imgobj.style.height='5px';
				imgobj.style.width='494px';
			}
		}
	}
	
	//tooltip init stuff, needed for showtt querystring, scope needs to be global
	var tooltipcount=0;
	var qs=location.search.substring(1,location.search.length).replace(/\+/g, ' ').split('&');
	for (x in qs) if (qs[x].split('=')[0].toLowerCase()=='showtt') var showtt=qs[x].split('=')[1];

	function makeTip(obj){
		//obj should be an anchor (with either tiptext attribute, or div tiptext class inside) or div with tooltip class
		//set prepared flag
		if(obj.getAttribute('tipprepared')) return obj;
		obj.setAttribute('tipprepared',true);
		
		var closeButton=false;
		
		switch (obj.nodeName){
			case 'A':
				var imgprefix='link';
				break;
			case 'DIV':
				var imgprefix='tip';
				//convert tooltip to linktip, what a messy routine here
				var tiptextdiv=obj;
				tiptextdiv.className=tiptextdiv.className.replace(/tooltip/i,'tiptext'); //convert the tooltip div to a tiptext div

				var tiptextquestion=tiptextdiv.insertBefore(document.createElement('div'),tiptextdiv.firstChild);
				tiptextquestion.style.cssText='font-weight:bold;margin-bottom:.5em;'
				tiptextquestion.appendChild(document.createTextNode(tiptextdiv.getAttribute('question')));
				
				var linkobj=document.createElement('a'); //create the link
				linkobj.href='javascript:void(0);';
				linkobj.appendChild(document.createTextNode(tiptextdiv.getAttribute('question')));

				tiptextdiv.parentNode.replaceChild(linkobj,tiptextdiv); //replace the tiptext with the link
				linkobj.appendChild(tiptextdiv); //put the tiptext in the link
			
				if (obj.getAttribute('inline')){
					var container=document.createElement('span');
				}else{
					var container=document.createElement('div'); //creating the hanging 
					container.style.cssText='padding-left:1em;text-indent:-1em;margin-bottom:4px;';
					//fix teh tiptext div so it doesn't jack up
				}
				
				
				linkobj.parentNode.replaceChild(container,linkobj);
				container.appendChild(linkobj);
			
				if (!obj.getAttribute('inline')) container.insertBefore(document.createTextNode('\u2022\u00A0'),linkobj);
				
				obj=linkobj;
				
				tooltipcount++;
				if (tooltipcount==parseInt(showtt)) var closeButton=true;
				break;
			default:
				return false;
				break;
		}
		
		//get the tiptext either from  tiptext attribute or tiptext class div within the A
		if(obj.getAttribute('tiptext')) {
			var tipcontent=document.createElement('div');
			tipcontent.innerHTML=obj.getAttribute('tiptext');
		} else if($$('tiptext',obj,'div')[0]) var tipcontent=obj.removeChild($$('tiptext',obj,'div')[0]);
		else return false;


		if(isIE){
			//mouseover fix, gotta put the content in a table->tbody->tr->td element
			tipcontent=document.createElement('table').appendChild(document.createElement('tbody')).appendChild(document.createElement('tr')).appendChild(document.createElement('td')).appendChild(tipcontent).parentNode.parentNode.parentNode.parentNode;
			tipcontent.firstChild.firstChild.firstChild.style.padding='0px 15px';
			tipcontent.cellSpacing=0;
			tipcontent.style.width='307px';
		}else tipcontent.style.cssText+=';width:277px;padding:0px 15px;';
		
		if(isIE) tipcontent.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=/echostyle/images/tips/' + imgprefix + 'middle.png, sizingMethod=scale)';
		else tipcontent.style.backgroundImage='url(/echostyle/images/tips/' + imgprefix + 'middle.png)';
		
		var tip=obj.parentNode.insertBefore(document.createElement('div'),obj);
		tip.style.cssText='z-index:1000;width:307px;position:absolute;text-indent:0px;padding-left:0px;';
		
		if((isIE || imgprefix=='link') && imgprefix!='tip') tip.style.marginTop='1em'; //put teh popup below the link, except for faq style tips
		tip.setAttribute('tiptype',imgprefix);
		
		if (!closeButton) tip.style.display='none';
		else tip.setAttribute('nohide',true);
		
		var imgobj=tip.appendChild(document.createElement('img'));
		imgobj.src='/echostyle/images/tips/' + imgprefix + 'top.png';
		imgobj.style.height='13px';
		imgobj.style.width='307px';
		imgobj.style.border='0px';

		if(isIE7){
			//gosh, ie sux, gotta do the png fix even in ie7 to make the fade work
			imgobj.setAttribute('forcepngfix',true);
			fixPNG(imgobj);
		}
		
		tip.appendChild(document.createElement('br'));
		tip.appendChild(tipcontent);
		var imgobj=tip.appendChild(document.createElement('img'));
		imgobj.src='/echostyle/images/tips/' + imgprefix + 'bottom.png';
		imgobj.style.height='17px';
		imgobj.style.width='307px';
		imgobj.style.border='0px';
		
		if(isIE7){
			imgobj.setAttribute('forcepngfix',true);
			fixPNG(imgobj);
		}
		
		//setup close button
		if(closeButton){
			var cbdiv=tipcontent.parentNode.insertBefore(document.createElement('div'),tipcontent.nextSibling);
			cbdiv.style.cssText='padding:0px 15px;text-align:right;width:277px;font-weight:bold;text-decoration:none;display:block;';
			if(isIE) cbdiv.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=/echostyle/images/tips/' + imgprefix + 'middle.png, sizingMethod=scale)';
			else cbdiv.style.backgroundImage='url(/echostyle/images/tips/' + imgprefix + 'middle.png)';
			var cbanchor=cbdiv.appendChild(document.createElement('a'));
			cbanchor.relTip=tip;
			cbanchor.href='javascript:void(0)';
			cbanchor.appendChild(document.createTextNode('Close'));
			cbanchor.onclick=function(){
				this.relTip.setAttribute('nohide',false);
				this.relTip.hide(true);
				obj=this;
				if(isIE) setTimeout(function(){obj.parentNode.parentNode.removeChild(obj.parentNode);},500);
				else obj.parentNode.parentNode.removeChild(obj.parentNode);
			}
		}
		
		//setup associations
		obj.tip=tip;
		tip.anchor=obj;
		
		//setup functions
		obj.onmouseover=function(){this.tip.show()};
		obj.onmouseout=function(){this.tip.hide()};
		
		obj.actualLeft=function(){
			loc = this.offsetLeft;
			var obj=this;
			while (obj=obj.offsetParent) loc += obj.offsetLeft;
			return loc;
		};

		tip.hide=function(nodelay){
			if(this.getAttribute('nohide')=='true') return;
			var obj=this;
			if (nodelay==true){
				if(isIE) {
					if(!obj.style.filter) obj.style.filter = "progid:DXImageTransform.Microsoft.Fade(duration=.3)";
					obj.filters[0].Apply();	
					obj.style.visibility='hidden';
					obj.filters[0].Play();
					setTimeout(function(){
						obj.style.display='none';
						obj.style.visibility='';
					},500);
				} else obj.style.display='none';
			}else{
				this.setAttribute('timeoutid',setTimeout(function(){
					if(isIE) {
						if(!obj.style.filter) obj.style.filter = "progid:DXImageTransform.Microsoft.Fade(duration=.3)";
						obj.filters[0].Apply();	
						obj.style.visibility='hidden';
						obj.filters[0].Play();
						setTimeout(function(){
							obj.style.display='none';
							obj.style.visibility='';
						},100);
					} else obj.style.display='none';				
	
				},200));			
			}
		};

		tip.show=function(){
			//cancel any pending fadeout
			if(this.getAttribute('timeoutid')) clearTimeout(this.getAttribute('timeoutid'));
			this.alignMe();
			this.style.display='';
		};

		tip.alignMe=function(){	
			var offset=document.body.scrollWidth-(this.anchor.actualLeft() + 307);
			if(offset<0) this.style.left=this.anchor.actualLeft()+offset + 'px';
			else {
				this.style.left=this.anchor.actualLeft()+'px';
				if (this.getAttribute('tiptype')=='tip') this.style.left=parseInt(this.style.left.replace(/px/i,''))+40 + 'px';
			}
		};
		
		tip.onmouseover=tip.show;
		tip.onmouseout=tip.hide;
		tipcontent.onmouseover=function(){this.parentNode.show;};
		
		if(closeButton) {
			tip.alignMe(); //since we're already showing, lets align up.
			tip.anchor.scrollIntoView();
		}
	}
	
	function fixLegacyLinkTips(){
		var elms=document.getElementsByTagName('a');
		for(var x=0, len=elms.length;x<len;x++){
			if(elms[x].getAttribute('tiptext')){
				var testClass=' ' + elms[x].className + ' ';
				if(testClass.search(/ tooltip /ig)==-1) if(elms[x].className) elms[x].className+=' tooltip';
				else elms[x].className='tooltip';
			}
		}
	}

//hybrid styles
	function makeContentTab(obj){
		if(obj.getAttribute('TabContentprepared')==true) return;
		obj.setAttribute('TabContentprepared',true);
	
		var imgPreloader=new Image();
		imgPreloader.src='/echostyle/images/contenttab/loading.gif';
	
		var tabs=new Array();
		while(obj.getElementsByTagName('div')[0]) tabs.push(obj.removeChild(obj.getElementsByTagName('div')[0]));
			
		//make the tab nav
		var tabNav=obj.appendChild(document.createElement('div'));
		tabNav.className='TabContentlink';
		if(isIE7) tabNav.style.marginBottom='-1px';
		else if(isIE) tabNav.style.marginBottom='-3px';
		else tabNav.style.marginBottom='2px';
		
		linkToTab=function(text, tabnum){
			var a=document.createElement('a');
			a.href='javascript:void(0);';
			a.setAttribute('tabNumber',x);
			
		
			if(isIE) {
				a.style.cssText='cursor:pointer;position:relative;display:inline-block;height:20px;';
				var img=a.appendChild(document.createElement('img'));
				if(tabnum!=0) img.src='/echostyle/images/contenttab/tab_left.png';
				else img.src='/echostyle/images/contenttab/atab_left.png';
				img.style.cssText='border:0px;height:20px;width:5px';
				
				var span=a.appendChild(document.createElement('span'));
				span.style.cssText='padding-top:3px;vertical-align:top;display:inline-block;height:17px;';
				if(tabnum!=0) span.style.backgroundImage='url(/echostyle/images/contenttab/tab_mid.png)';
				else span.style.backgroundImage='url(/echostyle/images/contenttab/atab_mid.png)';
				
				var span=span.appendChild(document.createElement('span'));
				span.style.cssText='padding-bottom:3px;';
				span.appendChild(document.createTextNode(text));
				
				var img=a.appendChild(document.createElement('img'));
				if(tabnum!=0) img.src='/echostyle/images/contenttab/tab_right.png';
				else img.src='/echostyle/images/contenttab/atab_right.png';
				img.style.cssText='border:0px;height:20px;width:7px;';		
				
			}else {
				
				a.style.cssText='position:relative;height:20px;margin-right:3px;padding:2px 0px;padding-left:5px;padding-right:5px;border:1px solid;background-color:#96b4d3;border-color:#142988';
				if(tabnum==0){
					a.style.borderBottom='1px solid #e9f3fe';
					a.style.backgroundColor='#e9f3fe';
				}
				a.appendChild(document.createTextNode(text));
			}
			
			a.hilite=function(){
				if(!isIE) {
					this.style.borderBottom='1px solid #e9f3fe';
					this.style.backgroundColor='#e9f3fe';
				}else{
					if(!needPNGFix) {
						this.firstChild.src='/echostyle/images/contenttab/atab_left.png';
						this.firstChild.nextSibling.nextSibling.src='/echostyle/images/contenttab/atab_right.png';
					}else {
						this.firstChild.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src=/echostyle/images/contenttab/atab_left.png)';
						this.firstChild.nextSibling.nextSibling.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src=/echostyle/images/contenttab/atab_right.png)';
					}
					this.firstChild.nextSibling.style.backgroundImage='url(/echostyle/images/contenttab/atab_mid.png)';
				}
			}
			
			a.unHilite=function(){
				if(!isIE) {
					this.style.borderBottom='1px solid #142988';
					this.style.backgroundColor='#96b4d3';
				}else{
					if(!needPNGFix) {
						this.firstChild.src='/echostyle/images/contenttab/tab_left.png';
						this.firstChild.nextSibling.nextSibling.src='/echostyle/images/contenttab/tab_right.png';
					}else {
						this.firstChild.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src=/echostyle/images/contenttab/tab_left.png)';
						this.firstChild.nextSibling.nextSibling.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src=/echostyle/images/contenttab/tab_right.png)';
					}
					this.firstChild.nextSibling.style.backgroundImage='url(/echostyle/images/contenttab/tab_mid.png)';
				}
			}
			
			a.onclick=function(){this.parentNode.parentNode.showTab(parseInt(this.getAttribute('tabNumber')));}
			return a;
		};
		for(x in tabs) {
			tabNav.appendChild(linkToTab(tabs[x].getAttribute('tabname'),x));
			
			tabs[x].loadMe=function(){
				if(!this.getAttribute('src') || this.getAttribute('loaded')) this.style.display='';
				else {
					this.style.display='';
					this.setAttribute('loaded',true);
					this.innerHTML='<div style="text-align:center"><br><br><img src="/echostyle/images/contenttab/loading.gif" style="vertical-align:middle"> Loading...<br><br><br></div>';
					ajaxUpdate(this.getAttribute('src'),this,650);
				}
			}
			
			tabs[x].unloadMe=function(){
				this.style.display='none';
			}
			
			if(x==0) tabs[x].loadMe();
			else tabs[x].unloadMe();
		}

		obj.tabs=tabNav.childNodes; //reference to all the tabs
		
		//make the main area now
		var table=obj.appendChild(document.createElement('table'));
		
		if(obj.style.width) table.style.width='100%';
		table.cellPadding=0;
		table.cellSpacing=0;
		
		var tbody=table.appendChild(document.createElement('tbody'));
		
		var tr=tbody.appendChild(document.createElement('tr'));

		var td=tr.appendChild(document.createElement('td'));
		td.style.cssText='height:5px;width:5px;';
		var imgobj=td.appendChild(document.createElement('img'));
		imgobj.src='/echostyle/images/contenttab/top_left.png';
		imgobj.style.cssText='width:5px;height:5px;';
		
		var td=tr.appendChild(document.createElement('td'));
		td.style.cssText='height:5px;background-image:url(/echostyle/images/contenttab/top_mid.png);';
		td.appendChild(document.createElement('img')).src='/echostyle/images/spacer.png';
		
		var td=tr.appendChild(document.createElement('td'));
		td.style.cssText='height:5px;width:9px;';
		var imgobj=td.appendChild(document.createElement('img'));
		imgobj.src='/echostyle/images/contenttab/top_right.png';
		imgobj.style.cssText='height:5px;width:9px;';

		var tr=tbody.appendChild(document.createElement('tr'));

		var td=tr.appendChild(document.createElement('td'));
		td.style.cssText='width:5px;background-image:url(/echostyle/images/contenttab/mid_left.png);';
		td.appendChild(document.createElement('img')).src='/echostyle/images/spacer.png';

		var td=tr.appendChild(document.createElement('td'));
		td.style.cssText='background-color:#e9f3fe';
		for(x in tabs) td.appendChild(tabs[x]); //append content tabs
		obj.tabdivs=td.childNodes;//reference to all the divs
		
		var td=tr.appendChild(document.createElement('td'));
		td.style.cssText='width:9px;';
		if(!needPNGFix) td.style.backgroundImage='url(/echostyle/images/contenttab/mid_right.png)';
		else td.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src=/echostyle/images/contenttab/mid_right.png,sizingMethod=scale)';
		td.appendChild(document.createElement('img')).src='/echostyle/images/spacer.png';
		
		
		var tr=tbody.appendChild(document.createElement('tr'));
		
		var td=tr.appendChild(document.createElement('td'));
		td.style.cssText='height:10px;width:5px;';
		var imgobj=td.appendChild(document.createElement('img'));
		imgobj.src='/echostyle/images/contenttab/bottom_left.png';
		imgobj.style.cssText='width:5px;height:10px';

		var td=tr.appendChild(document.createElement('td'));
		td.style.cssText='height:10px;';
		if(!needPNGFix) td.style.backgroundImage='url(/echostyle/images/contenttab/bottom_mid.png)';
		else td.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src=/echostyle/images/contenttab/bottom_mid.png,sizingMethod=scale)';
		td.appendChild(document.createElement('img')).src='/echostyle/images/spacer.png';

		var td=tr.appendChild(document.createElement('td'));
		td.style.cssText='height:10px;width:9px;';
		var imgobj=td.appendChild(document.createElement('img'));
		imgobj.src='/echostyle/images/contenttab/bottom_right.png';
		imgobj.style.cssText='height:10px;width:9px;';

		//now to set up the main function! Huzzah!
		obj.showTab=function(tab){
			var tabnum=tab;
			if(typeof(tabnum)=='string') for(var x=0, len=this.tabs.length; x<len; x++) if(this.tabs[x].innerText==tabnum) var tabnum=x; //find the tab#
			if(typeof(tabnum)=='string') return false;
			
			for(var x=0, len=this.tabs.length; x<len; x++){
				if(x==tabnum) {
					this.tabs[x].hilite();
					this.tabdivs[x].loadMe();
				}else {
					this.tabs[x].unHilite();
					this.tabdivs[x].unloadMe();
				}
			}
		}
		obj.style.display='block';
	}
	
	function makeSideTab(obj){
		if(obj.getAttribute('SideTabprepared')==true) return;
		obj.setAttribute('SideTabprepared',true);

		obj.style.position='relative';
		var table=document.createElement('table');
		table.style.position='relative';
		table.cellPadding=0;
		table.cellSpacing=0;
		table.border=0;
		
		//create the table and cells
		var tr=table.appendChild(document.createElement('tbody')).appendChild(document.createElement('tr'));
		
		var leftside=tr.appendChild(document.createElement('td'));
		leftside.style.cssText='width:144px;position:relative;z-index:1;';
		leftside.vAlign='top';

		var rightside=tr.appendChild(document.createElement('td'));
		rightside.style.cssText='width:454px;left:-1px;position:relative;';
		rightside.vAlign='top';
		
		//add the top image to the content side
		var topimg=rightside.appendChild(document.createElement('img'));
		topimg.src='/echostyle/images/sidetabs/ctop.png';
		topimg.style.cssText='height:10px;width:454px;';
		
		rightside.appendChild(document.createElement('br'));

		obj.showTab = function(tabNum){
			for(x in this.tabButtons) this.tabButtons[x].hide();
			this.tabButtons[tabNum].show();
		}
		
		obj.tabButtons=new Array();
		
		//add the tabs to the left side, move the content divs to the right side
		elms=obj.getElementsByTagName('div');

		var idx=0;
		while(elms.length>0){
			var tabbutton=leftside.appendChild(document.createElement('div'));
			
			obj.tabButtons.push (tabbutton);
			
			tabbutton.setAttribute('idx',idx);
			tabbutton.style.cssText='margin:3px 0px;width:144px;height:19px;text-align:center;';
			
			tabbutton.activeImage=tabbutton.appendChild(document.createElement('img'));
			tabbutton.activeImage.src='/echostyle/images/sidetabs/active.png';
			tabbutton.activeImage.style.cssText='position:absolute;left:0px;z-index:-1;width:144px;height:19px;visibility:hidden;';
			
			tabbutton.inactiveImage=tabbutton.appendChild(document.createElement('img'));
			tabbutton.inactiveImage.src='/echostyle/images/sidetabs/inactive.png';
			tabbutton.inactiveImage.style.cssText='position:absolute;left:0px;z-index:-1;width:144px;height:19px;';
			
			tabbutton.contentDiv=elms[0];
			
			tabbutton.show=function(){
				this.contentDiv.style.display='';
				this.inactiveImage.style.visibility='hidden';
				this.activeImage.style.visibility='visible';
			}
			
			tabbutton.hide=function(){
				this.contentDiv.style.display='none';
				this.inactiveImage.style.visibility='visible';
				this.activeImage.style.visibility='hidden';
			}		
			
			var a=tabbutton.appendChild(document.createElement('a'));
			a.href='javascript:void(0);';
			a.innerHTML=elms[0].getAttribute('tabname');
			a.onclick=function(){
				this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.showTab(this.parentNode.getAttribute('idx'));
			};

			tabbutton.contentDiv.setAttribute('cHeight',tabbutton.contentDiv.scrollHeight);
			rightside.appendChild(obj.removeChild(elms[0]));  //move the div from the parent div to the rightside
			tabbutton.contentDiv.style.cssText+=';padding:0px 10px;background-image:url(/echostyle/images/sidetabs/cbg.png);*margin-bottom:-3px;display:none;';
			
			idx++;
		}
		
		//finally add the bottom image
		var bottomimg=rightside.appendChild(document.createElement('img'));
		bottomimg.src='/echostyle/images/sidetabs/cbottom.png';
		bottomimg.style.cssText ='height:10px;width:454px;';

		obj.appendChild(table);
		
		//fix the size
		minheight=table.clientHeight-17;
		for(x in obj.tabButtons) if(Math.floor(obj.tabButtons[x].contentDiv.getAttribute('cHeight'))<minheight) obj.tabButtons[x].contentDiv.style.height=minheight+'px';

		obj.showTab(0);
	}	
	
	function makeImageView(obj) {
		if(obj.getAttribute('ImageViewprepared') == 'true') return;
		obj.setAttribute('ImageViewprepared', 'true');
	
		//create container div
		co = document.createElement("div");
		
		if(obj.style.cssText) {
			co.style.cssText = obj.style.cssText;
		} else {
			co.style.width = obj.width + "px";
		}
	
		//clone original element
		ithumb = obj.cloneNode(false);
		ithumb.style.display = "block"; //takes care or strange IE margin thing 
		ithumb.style.cursor = "pointer";
	
		//clone original element for fullscreen image
		iscreen = obj.cloneNode(false);
		
		if (obj.getAttribute("fullsizeclass")) {
			iscreen.className = obj.getAttribute("fullsizeclass");
		} else {
			iscreen.className = "bigImageView";
		}
		
		//create fullscreen table
		tbl = document.createElement("table");
		tbl.className = "bigImageViewTable"
		tbl.style.cssText = "position:absolute; vertical-align:middle; text-align:center; border-collapse:collapse; display:none;";
			//table rows, cells
			tb = document.createElement("tbody"); //IE will not render table added to DOM if not in <tbody>
			tr1 = document.createElement("tr"); // make one row with 3 cells
				td1 = document.createElement("td");
				td1.style.padding = "0";
				td1.style.border = "none";
				td2 = td1.cloneNode(false);
				td3 = td1.cloneNode(false);
				tr1.appendChild(td1);
				tr1.appendChild(td2);
				tr1.appendChild(td3);
			tr2 = tr1.cloneNode(true); //clone that row twice
			tr3 = tr1.cloneNode(true);
			tb.appendChild(tr1); // add all 3 rows to <tbody>
			tb.appendChild(tr2);
			tb.appendChild(tr3);
			tbl.appendChild(tb); // add <tbody> to <table>

		if(ithumb.getAttribute("fullsizestyle")) {
			iscreen.style.cssText = ithumb.getAttribute("fullsizestyle");
		} else {
			iscreen.removeAttribute("style");
		}

		b = document.createElement("br");
		lbl = document.createElement("div");
		if(ithumb.getAttribute("title")) {
			lbl.style.cssText = "width:100%; padding-top:15px;"; // IE wraps text unless width is defined
			lbl.appendChild(document.createTextNode(ithumb.getAttribute("title")));
		}
			
		//assemble fullscreen table
		tr2.childNodes[1].appendChild(iscreen);
		tr2.childNodes[1].appendChild(b);
		tr2.childNodes[1].appendChild(lbl);
		
		//table dimensions
		tr1.childNodes[0].style.height = "30px";
		tr1.childNodes[0].style.width = "30px";
		tr3.childNodes[2].style.height = "30px";
		tr3.childNodes[2].style.width = "30px";
		
		if(isIE) {
			//IE does not render empty TDs
			pad1 = document.createElement("div");
			pad1.style.width = "30px";
			pad2 = pad1.cloneNode(false);
			tr1.childNodes[0].appendChild(pad1);
			tr3.childNodes[2].appendChild(pad2);
		
			//IE PNG goodness
			tr1.childNodes[0].style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=/echostyle/images/thumbnail/imgthumb_01.png, sizingMethod=scale)';
			tr1.childNodes[1].style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=/echostyle/images/thumbnail/imgthumb_02.png, sizingMethod=scale)';
			tr1.childNodes[2].style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=/echostyle/images/thumbnail/imgthumb_03.png, sizingMethod=scale)';
			
			tr2.childNodes[0].style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=/echostyle/images/thumbnail/imgthumb_04.png, sizingMethod=scale)';
			tr2.childNodes[1].style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=/echostyle/images/thumbnail/imgthumb_05.png, sizingMethod=scale)';
			tr2.childNodes[2].style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=/echostyle/images/thumbnail/imgthumb_06.png, sizingMethod=scale)';
			
			tr3.childNodes[0].style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=/echostyle/images/thumbnail/imgthumb_07.png, sizingMethod=scale)';
			tr3.childNodes[1].style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=/echostyle/images/thumbnail/imgthumb_08.png, sizingMethod=scale)';
			tr3.childNodes[2].style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=/echostyle/images/thumbnail/imgthumb_09.png, sizingMethod=scale)';
		} else {
			tr1.childNodes[0].style.background = "url(/echostyle/images/thumbnail/imgthumb_01.png)";
			tr1.childNodes[1].style.background = "url(/echostyle/images/thumbnail/imgthumb_02.png)";
			tr1.childNodes[2].style.background = "url(/echostyle/images/thumbnail/imgthumb_03.png)";
			
			tr2.childNodes[0].style.background = "url(/echostyle/images/thumbnail/imgthumb_04.png)";

			tr2.childNodes[1].style.background = "url(/echostyle/images/thumbnail/imgthumb_05.png)";
			tr2.childNodes[2].style.background = "url(/echostyle/images/thumbnail/imgthumb_06.png)";
			
			tr3.childNodes[0].style.background = "url(/echostyle/images/thumbnail/imgthumb_07.png)";
			tr3.childNodes[1].style.background = "url(/echostyle/images/thumbnail/imgthumb_08.png)";
			tr3.childNodes[2].style.background = "url(/echostyle/images/thumbnail/imgthumb_09.png)";
		}
		
		co.appendChild(ithumb); //add thumbnail to container div
		co.appendChild(tbl);		//add full view to container div
		
		//replace original element with container div
		obj.parentNode.replaceChild(co, obj);
		
		//if style has not been defined in the style, lets get it from the image
		if (!(iscreen.style.pixelHeight || iscreen.style.height)){
			iscreen.onload = function() {
				// IE can't find the height/width of hidden elements
				// parentNode returns null if the node has just been created and is not yet attached to the tree (IE7 only)
				this.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes[1].style.display = ""; 
				//pass h, w to container div waaaaay up there
				this.parentNode.parentNode.parentNode.parentNode.parentNode.setAttribute("hpos", this.height);
				this.parentNode.parentNode.parentNode.parentNode.parentNode.setAttribute("wpos", this.width);
				this.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes[1].style.display = "none";
			};
		} else {
			co.setAttribute("hpos", parseInt(iscreen.style.height));
			co.setAttribute("wpos", parseInt(iscreen.style.width));
		}
		
		//IE7 will not fire the onload event if the src is changed before the onload is defined
		if(ithumb.getAttribute("fullsizesrc")) iscreen.setAttribute("src", ithumb.getAttribute("fullsizesrc"));
		
		function ImgAction(e) {
			if(this.childNodes[1].style.visibility == "") {
				if(this.childNodes[1].style.display == "none") {
					// get viewable window dimensions
					if (self.innerHeight) // !IE
					{
						xwin = self.innerWidth;
						ywin = self.innerHeight;
					}
					else if (document.documentElement && document.documentElement.clientHeight) // IE6
					{
						xwin = document.documentElement.clientWidth;
						ywin = document.documentElement.clientHeight;
					}
					else if (document.body)
					{
						xwin = document.body.clientWidth;
						ywin = document.body.clientHeight;
					}
					//MOUSE POSITION
					var posx = 0;
					var posy = 0;
					if (!e) var e = window.event;
					if (e.pageX || e.pageY) 	{
						posx = e.pageX;
						posy = e.pageY;
					}
					else if (e.clientX || e.clientY) 	{
						posx = e.clientX + document.body.scrollLeft
							+ document.documentElement.scrollLeft;
						posy = e.clientY + document.body.scrollTop
							+ document.documentElement.scrollTop;
					}
					//SCROLL POSITION
					var xscroll, yscroll;
					if (self.pageYOffset) // !IE
					{
						xscroll = self.pageXOffset;
						yscroll = self.pageYOffset;
					}
					else if (document.documentElement && document.documentElement.scrollTop) // IE6
					{
						xscroll = document.documentElement.scrollLeft;
						yscroll = document.documentElement.scrollTop;
					}
					else if (document.body)
					{
						xscroll = document.body.scrollLeft;
						yscroll = document.body.scrollTop;
					}
					
					//POSITION ELEMENT
					this.childNodes[1].style.top = ((ywin / 2 - this.getAttribute("hpos") / 2) + yscroll - 30) + "px";
					this.childNodes[1].style.left = ((xwin / 2 - this.getAttribute("wpos") / 2) + xscroll) + "px";
					//hide tables to prevent stacking
					hdtbl = $$('bigImageViewTable', null, 'table');
					for(i=0; i<hdtbl.length; i++) {
							hdtbl[i].style.display = "none";
							hdtbl[i].style.visibility = "";
					}
					this.childNodes[1].style.display = "";
				} else {
					this.childNodes[1].style.display = "none";
				}
			}
			return false;
		};
		function ImgMouseout() {
			if(this.childNodes[1].style.visibility == "") {
				this.childNodes[1].style.display = "none";
			}
			return false;
		};
		function ImgMousedown() {
			if(this.childNodes[1].style.visibility == "") {
				this.childNodes[1].style.visibility = "visible";
			} else {
				this.childNodes[1].style.visibility = "";
				this.childNodes[1].style.display = "none";
			}
			return false;
		};
		//allows choice between rollover and onclick trigger	
		if(ithumb.getAttribute("action") == "onmouseover") {
			co.onclick = ImgMousedown;
			co.onmouseout = ImgMouseout;
			co.onmouseover = ImgAction;
		} else {
			co.onclick = ImgAction;
		}
	}