  var g_d;
	 //getElementById
	 function id( realId ) { return g_d.getElementById(realId); }
	
 	//get child i
  function cn( o, i ) { return o.childNodes.item(i); }	

		function av( o, name ) { return o.attributes[name].nodeValue; }
		function setav( o, name, value ) { o.attributes[name].nodeValue = value; }		
	 function init()
	 {
	 	 g_d = document;
				//might be better if this line was not here
				//pages might load faster without it...
				//perhaps it could be done after a delay or down on first alt keydown???
				try { overrideAltKeys(); } catch(e) {}
	 }
	
		//Update Form Element, required when stealth has added a form element as its not part of form.elements
		function ufe( formName, elementName, elementValue )
		{
					var n = id(formName).childNodes;
					for ( c = 0; c<n.length;c++)
					  if ( n[c].name == elementName ) n[c].value=elementValue;
		}
		
  function cancelBubble(evt) 
  {
			 try 
				{
      if (typeof evt == 'undefined') evt=event;
      evt.returnValue = false; 
      evt.cancelBubble = true; 
				} catch(e) {}
    return false; 	 
  }	
		
		function fillFakeBrowse(e, id)
		{
	   switch (e.keyCode) { case 37: case 39: case 16: return; }
		 	document.all[id+"_Fake"].value=document.all[id].value;
				document.all[id].title=document.all[id].value;
		}
		
  function cssRemoveProperty( rule, propertyName ) 
		{
	  var csst = rule.style.cssText;
	  var idx = csst.indexOf(propertyName.toUpperCase());
   if ( idx < 0 ) idx = csst.indexOf(propertyName);  if ( idx < 0 ) return;
	  var edx = csst.indexOf(";",idx);
	  if ( edx == -1 ) edx = csst.length-1;	  
	  rule.style.cssText = csst.substring(0,idx) + " " + csst.substring(edx+1);
  }		
		
		function importScript(url, d)
		{
			 if ( containsScript(url, d) ) return false;
				d = !d ? document : d;
	   var scriptElem = d.createElement('script');
	   scriptElem.setAttribute('src',url);
	   scriptElem.setAttribute('type','text/javascript');
	   d.getElementsByTagName('head')[0].appendChild(scriptElem);	
				return true;
		}
		function containsScript(url, d)
		{
			 d = !d ? document : d;
				var c = d.getElementsByTagName('head')[0].childNodes;
				for ( i = 0; i<c.length;i++ )
				{
					  if ( c[i].src==url) return true;
				}			
				return false;
		}

		function importCss(href, doc)
		{
				if ( !doc ) doc = document;
			 if ( containsCss(href, doc) ) return;
	   var cssElem = doc.createElement('link');
	   cssElem.setAttribute('rel','stylesheet');
	   cssElem.setAttribute('href',href);				
	   cssElem.setAttribute('type','text/css');
	   doc.getElementsByTagName('head')[0].appendChild(cssElem);	
		}
		function containsCss(href, doc)
		{
			 if ( !doc ) doc=document;
				var c = doc.getElementsByTagName('head')[0].childNodes;
				for ( i = 0; i<c.length;i++ )
				{
					  if ( c[i].href==href) return true;
				}			
				return false;
		}				
  function noReply(data){} 		
		
		function getParentWithTag(o,tag)
		{
			  return o.nodeName==tag || o.nodeName=='BODY'? o : getParentWithTag(o.parentNode,tag);
		}
		function getParentWithStyle(o,name,val)
		{
			  return o.style[name]==val || o.nodeName=='BODY'? o : getParentWithStyle(o.parentNode,name,val);
		}		
		function getParentWithAttributeValue(o,att,val)
		{
			  return o.getAttribute(att)==val || o.nodeName=='BODY'? o : getParentWithAttributeValue(o.parentNode,att,val);
		}		
		function getParentWithAttribute(o,att)
		{
			  return o.getAttribute(att) != null || o.nodeName=='BODY'? o : getParentWithAttribute(o.parentNode,att);
		}
		function getChildWithTag(o,tag)
		{
		   if ( !o ) return false;
			  if ( o.childNodes.length < 1 && o.tagName!=tag ) return false;
					if ( o.tagName==tag ) return o;
					var cn = o.childNodes;
					var cn_idx=0;
					for ( cn_idx=0; cn_idx<cn.length; cn_idx++ )
					{
					  var obj = getChildWithTag(cn.item(cn.idx), tag);
							if ( obj ) return obj;
					}
					return false;
		}	
		function getChildWithAttribute(o,att)
		{
		   if ( !o ) return false;
			  if ( o.childNodes.length < 1 && !o.getAttribute(att) ) return false;
					if ( o.getAttribute(att) ) return o;
					var cn = o.childNodes;
					var cn_idx=0;
					for ( cn_idx=0; cn_idx<cn.length; cn_idx++ )
					{
					  var obj = getChildWithAttribute(cn.item(cn_idx), att);
							if ( obj ) return obj;
					}
					return false;
		}		
		function getChildWithAttributeValue(o,att,val)
		{
		   if ( !o || o.nodeName=='#text' ) return false;
			  if ( o.childNodes.length < 1 && (!o.getAttribute(att) || o.getAttribute(att) != val ) ) return false;
					if ( o.getAttribute(att) == val ) return o;
					var cn = o.childNodes;
					var cn_idx=0;
					for ( cn_idx=0; cn_idx<cn.length; cn_idx++ )
					{
					  var obj = getChildWithAttributeValue(cn[cn_idx], att, val);
							if ( obj ) return obj;
					}
					return false;
		}		
		
		g_curFocus=false;
		function focusFirst( frm )
		{
			//TEMP FIX.  FormDesginer focus code sometime passes control to formless panes (ie..the toolsScroller)
			//however would be good if the code could search the container for focusable elements if passed the event object.
			  if ( !frm ) return;
			//END TEMP FIX
			  var nodes = "input,select,textarea";
					var notTypes = "hidden";
			  var els = frm.elements;					
					for ( e=0;e<els.length;e++)
					{
						  if ( nodes.indexOf(els[e].nodeName.toLowerCase()) > -1 )
								{
									  if ( (els[e].nodeName.toLowerCase()=='input' && els[e].type.toLowerCase() != 'hidden') || els[e].nodeName.toLowerCase() != 'input' ) 
											{
												 if ( els[e].style.display != 'none' && els[e].style.visibility != 'hidden' )
													{
														 var a = frm.getElementsByTagName("A");
															if ( a.length > 0 ) 
															{
															  var ax=getElementPosX(a[0]);
															  var ay=getElementPosY(a[0])+5;
															  var ex=getElementPosX(els[e]);
															  var ey=getElementPosY(els[e]);															
															  if ( ay < ey ) 
																	{
																		a[0].focus();
																		g_curFocus=a[0];
																	} else if ( ay == ey && ax < ex )
																	{ 
																	  a[0].focus();
																			g_curFocus=a[0];
																	}
															  else
																	{
												       els[e].focus();
																			g_curFocus=els[e];
																	}
															} else
															{
															  els[e].focus();
																	g_curFocus=els[e];
															}//end if href
													  return;
													}//end if not none and not hidden
											}//end if input and not hidden or not input
								}//end if nodes
					}//end for
					//didn't find anything to focus on so focus on first href if any
					if ( frm.getElementsByTagName("A").length > 0 ) 
					{
						 frm.getElementsByTagName("A")[0].focus(); 
					}
		}//end funtion
		
		function focusElement( id )
		{
			 try
				{
					 g_dontFireHelp=true;
						if ( document.all[id] && document.all[id].nodeName=='IMG' && document.all[id].parentNode.nodeName=='A' )
						{
							 document.all[id].parentNode.focus(); 
								g_curFocus=document.all[id].parentNode;
						} else
						{
						  if ( !document.all[id] || document.all[id].type=='hidden' )
								{
									 if ( document.all[id+"_CalImage"] ) id += "_CalImage_HRef";
										else id += "_Ignore";
								} else if ( document.all[id].length > 1 )
								{
			       document.all[id][0].focus();
								  g_curFocus=document.all[id][0];									
										return;
								}
			     document.all[id].focus();
								g_curFocus=document.all[id];
						}						
				} catch (e) {}
		}
		
		function formFieldEquals( formObject, fieldName, equalTo )
		{
			 var val = null;
			 try 
				{ 
				  val = formObject.elements[fieldName].value; 
				} catch (e)
				{
					  try
							{
								  val = formObject.document.all[formObject.name+"_"+fieldName].value;
							} catch (ee){}
				}
				if ( val == equalTo ) return true;
				return false;
		}
		
		function moveNode( moveNode, newParent )
		{
			 insertAdjacentHTML( newParent, "BeforeEnd", "<div id='"+moveNode.id+"_MoveMarker' style='display:none;'>&nbsp;</div>");
				swapNode( document.all[moveNode.id+"_MoveMarker"], moveNode );
				rn( document.all[moveNode.id+"_MoveMarker"] );			
		}
		
		var g_error=0;
		var g_warn=1;
		var g_info=2;
		var g_debug=3;
		
		function elog( type, msg )
		{
			 var dontShowAdmin = getParameter( document.cookie, "dontShowAdmin", ";" );
				if ( dontShowAdmin == "true" && ( !containsScript(top.g_root+"scripts/tPane.js", top.document) || top.getTPane("AdminConsole_Div").dat.style.visibility == 'hidden' ) ) return;			
				if ( !msg || msg.length < 1 ) { msg=type; type=g_info; }
			 var stamp = new Date().toTimeString().substring(0,8);
				var color;
			 switch ( type )
				{
					  case g_error : color='red'; break;
							case g_warn : color='green'; break;
							case g_info : color='black'; break;
							case g_debug :color='blue'; break;
				}
 			top.logArea.value = "<div style='width:100%;color:"+color+";'><span style='width:60px;float:left;'>"+stamp+"</span><span style='font-weight:bold;'>"+msg+"</span></div>"+top.logArea.value;
		}
		
		var g_prevFoc;
		function highlight( o )
		{		
		   g_prevFoc=o;
			  o.style.position='relative';
					o.style.margin='-2px';
					o.border=2;
					o.style.backgroundColor='yellow';					
		}
		
		function normal( o )
		{
 			 o.style.position='static';
					o.border=0;
					o.style.margin='0';
					cssRemoveProperty( o, "background-color" );
		}	
		
		function focusHighlight(o)
		{
			 o.style.backgroundColor='yellow';
		}
		function focusNormal(o)
		{
			 cssRemoveProperty( o, "background-color" );
		}		
		
		function sizeSelects( name )
		{
			 if ( document.all[ name + "_Ignore_OptLength" ] ) 
				{
			   var wd = document.all[ name + "_Ignore_OptLength" ].offsetWidth;
      if ( wd == 0 ) 
						{
							 setTimeout("sizeSelects('"+name+"')", 40 );
								return;
						}						
			   document.all[ name + "_Ignore"].parentNode.style.width=(wd+(document.all[ name + "_Ignore"].parentNode.lastChild.width))+'px';
      rn( document.all[ name + "_Ignore_OptLength" ] );
			 }			
		}
		
  function getFuncName(fnc)
		{
		  return fnc.toString().substring(0,fnc.toString().indexOf("(")).replace(/function /g,'')
		}	
		
		function getEm( px )
		{
			  return (( parseFloat(px)/10.0)*parseFloat(top.userEM));
		}
		
		function fv(sFormName,sValueName)
		{
			 return document.getElementById(sFormName).elements[sValueName].value;
		}
		
		function focusEnd( o )
		{
				o.focus();				
				var range = o.createTextRange();	
				range.expand("textedit");
				range.collapse(false);
				range.select();
		}

function getParentWithAttributeValueLike(o,att,valLike)
		{
			  return o.getAttribute(att).indexOf(valLike) > -1 || o.nodeName=='BODY'? o : getParentWithAttributeValueLike(o.parentNode,att,valLike);
		}	