//############ Alternative Browser Support ##############//
/*
  Thanks go to: 
    Erik Arvidsson of WebFX.eae.net
  for the use of some of these Mozilla extensions.  
  
*/

var isMoz = false;

if (!(document.all) && document.getElementById) 
{
	isMoz = true;    
	//Emulate the IE box model
	var NSstyle = document.createElement("style");
	NSstyle.id = "MOZStyle"
	NSstyle.type = "text/css";
	document.getElementsByTagName("head")[0].appendChild(NSstyle);
	document.styleSheets[document.styleSheets.length-1].insertRule("P, H1, H2, H3, H4, H5, H6, UL, OL, DIR, MENU, PRE, DL, DIV, CENTER, NOSCRIPT, NOFRAMES, BLOCKQUOTE, FORM, ISINDEX, HR, TABLE, FIELDSET, ADDRESS  {-moz-box-sizing: border-box;}", 0);

//############# DOCUMENT ###################

	//add document.all
	Document.prototype.all = function (sId) {
	    return document.getElementById(sId);
	};
	
	HTMLDocument.prototype.all = function (sId) {
	    return document.getElementById(sId);
	}; 

	HTMLDocument.prototype.__defineGetter__('all', function() {
    var all = document.getElementsByTagName("*");

    all.tags = function (sTagName) {
        return document.getElementsByTagName(sTagName);
  	};

    return all;
	});

	HTMLTableColElement.prototype.all = function (sId) {
	    return this.getElementById(sId);
	}; 
  HTMLTableColElement.prototype.__defineGetter__('all', function() {
    var all = this.getElementsByTagName("*");

    all.tags = function (sTagName) {
        return this.getElementsByTagName(sTagName);
  	};

    return all;
	});

	//~ add the getElementsByName Ie Only method to the document
	HTMLDocument.prototype.getElementsByName = function (sId) {
	  var returnArray = new Array();
	  var el = document.getElementById(sId);
	  if (el){
	    var els = document.getElementsByTagName(el.tagName);
	    if (els){
	      for (var i=0; i<els.length;i++)
	        if (els[i].id == sId)
	          returnArray[returnArray.length] = els[i];
	    }
	  }
	  return returnArray;
	};

	// define xml getter for document and element
	Document.prototype.__defineGetter__("xml", function (){ 
		return (new XMLSerializer()).serializeToString(this); 
	});

	Document.prototype.__defineGetter__("parentWindow", function (){ 
		return this.defaultView; 
	});
  
	XMLDocument.prototype.__defineGetter__("xml", function (){ 
		return (new XMLSerializer()).serializeToString(this); 
	});

	//adding the parseError object to emulate IE xml wrapper
	XMLDocument.prototype.__defineGetter__("parseError", function () {
	 var hasError = 
	 		!this.documentElement || this.documentElement.localName == "parsererror" && 
	 		this.documentElement.getAttribute("xmlns") == "http://www.mozilla.org/newlayout/xml/parsererror.xml";

	 var tempParseError = {
	  errorCode: 0,
	  filepos: 0, // not supported
	  line:  0,
	  linepos: 0,
	  reason:  "",
	  srcText: "",
	  url:  ""
	 };

	 if (hasError) {
	  tempParseError.errorCode = -1;
	  try {
	   tempParseError.srcText = this.getElementsByTagName("sourcetext")[0].firstChild.data;
	   tempParseError.srcText = tempParseError.srcText.replace( /\n\-\^$/, "");
	  } catch (ex) {
	   tempParseError.srcText = "";
	  }
	
	  try {
	   // now we need to parse the first text node
	   var s = this.documentElement.firstChild.data;
	
	   var re = /XML Parsing Error\: (.+)\nLocation\: (.+)\nLine Number (\d+)\, Column (\d+)/;
	   var a = re.exec( s );
	   tempParseError.reason = a[1];
	   tempParseError.url = a[2];
	   tempParseError.line = a[3];
	   tempParseError.linepos = a[4];
	  }
	  catch (ex) {
	   tempParseError.reason = "Uknown";
	  }
	 }
	
	 return tempParseError;
	});
  
//################  EVENTS ##################

	//add event.keyCode
	Event.prototype.__defineGetter__("keyCode", function () {
		return this.which;
	});

	//add event canceling
	Event.prototype.__defineSetter__("returnValue", function (param) {
		if (!param) this.preventDefault();
		return param;
	});

	Event.prototype.__defineSetter__("cancelBubble", function (param) {
		if (param) this.stopPropagation();
		return param;
	});

	//allow attach and detach to work the same as IE
	HTMLElement.prototype.attachEvent = function (typ, func) {
		var trimType = typ.replace(/on/, "");
		func.__pseudoFunc = function (e) {
			return func(e);
		};
		this.addEventListener(trimType, func.__pseudoFunc, false);
	};
	
	HTMLElement.prototype.detachEvent = function (typ, func) {
		var trimType = typ.replace(/on/, "");
		if (typeof func.__pseudoFunc == "function")
			this.removeEventListener(trimType, func.__pseudoFunc, false);
		else   
			this.removeEventListener(trimType, func, true);
	};

	//add srcElement to Event
	Event.prototype.__defineGetter__("srcElement", function () {
		var node = this.target;
		while (node.nodeType != 1) node = node.parentNode;
		return node;
	});

	HTMLElement.prototype.fireEvent = function fireEvent(evtName, evt) {
		if (!evt) evt = this.ownerDocument.createEventObject();
		var trimType = evtName.replace(/on/, "");
		evt.initEvent(trimType, false, false);
		this.dispatchEvent(evt);
	};

	HTMLDocument.prototype.createEventObject = function createEventObject() {
		return document.createEvent("Events");
	};

	HTMLElement.prototype.setCapture = function() {
	  //element.addEventListener( type, listener, useCapture )
		window.hotElement = this;
    window.addEventListener("mousemove", this.onmousemove, false);
    window.addEventListener("mouseup", this.onmouseup, false);
		var ifrm
    for (var i = 0;i < document.getElementsByTagName("iframe").length;i++){
			ifrm = document.getElementsByTagName("iframe")[i];
      ifrm.contentWindow.hotElement = this;
			ifrm.contentWindow.addEventListener("mousedown", this.onmousedown, false);
      ifrm.contentWindow.addEventListener("mousemove", this.onmousemove, false);
      ifrm.contentWindow.addEventListener("mouseup", this.onmouseup, false);
    }
	};
  
	HTMLElement.prototype.releaseCapture = function() {
		window.hotElement = null;
    window.removeEventListener("mousemove", this.onmousemove, false);
    window.removeEventListener("mouseup", this.onmouseup, false);
		var ifrm
    for (var i = 0;i < document.getElementsByTagName("iframe").length;i++){
			ifrm = document.getElementsByTagName("iframe")[i];
      ifrm.contentWindow.hotElement = null;
			ifrm.contentWindow.removeEventListener("mousedown", this.onmousedown, false);
      ifrm.contentWindow.removeEventListener("mousemove", this.onmousemove, false);
      ifrm.contentWindow.removeEventListener("mouseup", this.onmouseup, false);
    }
	};

  //~ mozilla "focus" is a property - convert to function
  HTMLElement.prototype.tmpFocus=HTMLElement.prototype.focus;
	HTMLElement.prototype.focus = function() {
		this.tmpFocus;
	};
  
  //~ mozilla "blur" is a property - convert to function
  HTMLElement.prototype.tmpBlur=HTMLElement.prototype.blur;
	HTMLElement.prototype.blur = function() {
		this.tmpBlur;
	};


//TODO: untested code; uncomment if necessary (probably for drag-n-drop)
//	Event.prototype.__defineGetter__("fromElement", function () {
//		var node;
//		if (this.type == "mouseover")
//			node = this.relatedTarget;
//		else if (this.type == "mouseout")
//			node = this.target;
//		if (!node) return;
//		while (node.nodeType != 1) node = node.parentNode;
//		return node;
//	});
//
//	Event.prototype.__defineGetter__("toElement", function () {
//		var node;
//		if (this.type == "mouseout")
//			node = this.relatedTarget;
//		else if (this.type == "mouseover")
//			node = this.target;
//		if (!node) return;
//		while (node.nodeType != 1) node = node.parentNode;
//		return node;
//	});
//
//	Event.prototype.__defineGetter__("offsetX", function () {
//		return this.layerX;
//	});
//	Event.prototype.__defineGetter__("offsetY", function () {
//		return this.layerY;
//	});

//############### ELEMENTS ##################

  //~ prototype the contains method on to all elements (looks for elements within elements)
  HTMLElement.prototype.contains = function (element) {
	  return Boolean(element == this || (element && this.contains(element.parentElement)));
  };

	Element.prototype.__defineGetter__("text", function () {
	  try{
	    if(this.textContent!="")
	      return this.textContent;
	    else
	      return this.firstChild.textContent;
	  }catch(e){
	    return null;
	  }
	});
	
	//add innerText to an element
	Element.prototype.__defineGetter__("innerText", function() {
		for (var i = this.childNodes.length - 1; i >= 0; i--) {
			if (this.childNodes[i].nodeName == "#text")
				return this.childNodes[i].nodeValue;
		}
	});
	
	Element.prototype.__defineSetter__("innerText", function(newTextVal)
	{
		for (var i = this.childNodes.length - 1; i >= 0; i--) {
			if (this.childNodes[i].nodeName == "#text")
			this.removeChild(this.childNodes[i]);
		}
		this.appendChild(this.ownerDocument.createTextNode(newTextVal));
	});

	HTMLElement.prototype.__defineGetter__("innerText", function() {
	  if(this.tagName=="TEXTAREA"){
	    return this.value;
	  }else{
  		for (var i = this.childNodes.length - 1; i >= 0; i--) {
  			if (this.childNodes[i].nodeName == "#text")
  				return this.childNodes[i].nodeValue;
  		}
  	}	
	});
	
	HTMLElement.prototype.__defineSetter__("innerText", function(newTextVal){
	  if(this.tagName=="TEXTAREA"){
	    this.value=newTextVal;
	  }else{
  		for (var i = this.childNodes.length - 1; i >= 0; i--) {
  			if (this.childNodes[i].nodeName == "#text")
  			this.removeChild(this.childNodes[i]);
  		}
  		this.appendChild(this.ownerDocument.createTextNode(newTextVal));
  	}	
	});
	
	// define getter and setter for outerHTML
	HTMLElement.prototype.__defineSetter__("outerHTML", function (sHTML) {
	   var r = this.ownerDocument.createRange();
	   r.setStartBefore(this);
	   var df = r.createContextualFragment(sHTML);
	   this.parentNode.replaceChild(df, this);
	   
	   return sHTML;
	});

  Element.prototype.__defineGetter__("xml", function(){
      return (new XMLSerializer()).serializeToString(this);
  });

	HTMLElement.prototype.__defineGetter__("canHaveChildren", function () {
		switch (this.tagName) {
			case "AREA":
			case "BASE":
			case "BASEFONT":
			case "COL":
			case "FRAME":
			case "HR":
			case "IMG":
			case "BR":
			case "INPUT":
			case "ISINDEX":
			case "LINK":
			case "META":
			case "PARAM":
				return false;
		}
		return true;
	});

	HTMLElement.prototype.__defineGetter__("outerHTML", function () {
		var attr, attrs = this.attributes;
		var str = "<" + this.tagName;
		for (var i = 0; i < attrs.length; i++) {
			attr = attrs[i];
			if (attr.specified)
				str += " " + attr.name + '="' + attr.value + '"';
		}
		if (!this.canHaveChildren)
			return str + ">";
		
		return str + ">" + this.innerHTML + "</" + this.tagName + ">";
	});

	// overload the getElementsByTagName 
	// - Reason: non-HTML elements like XML or LIST are not found by the normal getElementsByTagName on a DOM document
	//           they ARE found on XMLDocuments however.
	HTMLDivElement.prototype.tempGetElementsByTagName = HTMLDivElement.prototype.getElementsByTagName;
	HTMLDivElement.prototype.getElementsByTagName = function(tag){
	  var origCollection = this.tempGetElementsByTagName(tag);
	  if (origCollection.length > 0)
	    return origCollection;
	  var decendents = new Array();
	  no_cb_port_getDecendentsByTagName(this,tag,decendents);
	  return decendents;
	}

  //~ part of the overloaded getElementsByTagName;
  function no_cb_port_getDecendentsByTagName(node,tag,decendents){
    for(var i=0;i<=node.childNodes.length-1;i++){
      if (node.childNodes[i].tagName && node.childNodes[i].tagName.toUpperCase() == tag.toUpperCase())
        decendents[decendents.length] = node.childNodes[i];
      // recursively add children of children to the return array
      no_cb_port_getDecendentsByTagName(node.childNodes[i],tag,decendents);  
      window.status += decendents.length + ":";
    }
  }	

  // add more prototype functionality to Mozilla
  HTMLElement.prototype.insertAdjacentElement = function(insertLoc, item) {
    switch (insertLoc.toLowerCase()) {
      case "beforebegin":
        this.parentNode.insertBefore(item, this);
        break;
      case "afterbegin":
        this.insertBefore(item, this.firstChild);
        break;
      case "beforeend":
        this.appendChild(item);
        break;
      case "afterend":
        this.parentNode.insertBefore(item, this.nextSibling);
        break;
    }
  }

	Element.prototype.__defineGetter__("xml", function (){ 
		return (new XMLSerializer()).serializeToString(this); 
	});

  //This is Erik Arvidsson's emulation of IE's insertAdjacentHTML:
  HTMLElement.prototype.insertAdjacentHTML = function (sWhere, sText) {
    var r = document.createRange();
    switch (sWhere) {
     case "beforeBegin":
      r.setStartBefore(this);
      this.parentNode.insertBefore(r.createContextualFragment(sText), this);
      break;
 
     case "afterBegin":
      r.setStartBefore(this.firstChild);
      this.insertBefore(r.createContextualFragment(sText), this.firstChild);
      break;
 
     case "beforeEnd":
      r.setStartAfter(this.lastChild);
      this.appendChild(r.createContextualFragment(sText));
      break;
 
     case "afterEnd":
      r.setStartAfter(this);
      this.parentNode.insertBefore(r.createContextualFragment(sText), this.nextSibling);
 
      break;
    }
  }


	//add parentElement and children and document
	Element.prototype.__defineGetter__("parentElement", function() {
		return (this.parentNode == this.ownerDocument) ? null : this.parentNode;
	});

	HTMLElement.prototype.__defineGetter__("parentElement", function() {
		return this.parentNode;
	});

	HTMLElement.prototype.__defineGetter__("children", function () {
		return this.childNodes;
	});
	
	HTMLElement.prototype.__defineGetter__("document", function() {
		return this.ownerDocument;
	});
	
  //~ mozilla previousSibling and nextSibling MAY be text elements...
	HTMLElement.prototype.__defineGetter__("previousNonTextSibling", function() {
		if (this.previousSibling.nodeType == 3)
		  return this.previousSibling.previousSibling;
		else
		  return this.previousSibling;  
	});
  
	HTMLElement.prototype.__defineGetter__("nextNonTextSibling", function() {
		if (this.nextSibling.nodeType == 3)
		  return this.nextSibling.nextSibling;
		else
		  return this.nextSibling;  
	});

  //~ mozilla "setActive" - make active but do not give focus???
	HTMLElement.prototype.setActive = function() {
		//~ divs and spans cannot accept focus nor the non-existing active flag
		this.fireEvent("onclick");
	};
	
	HTMLElement.prototype.__defineSetter__("noWrap", function (bTF) {
    if (bTF)
      this.style.whiteSpace="nowrap";
    else  
      this.style.whiteSpace="";
	});  

	//editable content areas
	HTMLElement.prototype.__defineSetter__("contentEditable", function(val) {
		if (val) //turn it on
		{
			var BORDER_BUFFER = 3;
			var OFFSET_BUFFER = 0;
			//create a X and place it over the html element
			var inpt = document.createElement("input");
			inpt.setAttribute("type", "text");
			inpt.style.backgroundColor="lightgrey";
			if (this.innerText)
				inpt.value = this.innerText;
			inpt.style.position="absolute";
			
			inpt.style.top = 1;
			inpt.style.left = this.offsetLeft;
 
			inpt.style.width = this.parentNode.offsetWidth-this.offsetLeft-BORDER_BUFFER;
			inpt.style.height = this.offsetHeight;
			
			if (this.style.top == "" && this.parentNode.style.position == "") 
				inpt.style.top = cb_sys_getRealTop(this)+OFFSET_BUFFER;
			if (this.style.left == "" && this.parentNode.style.position == "") 
				inpt.style.left = cb_sys_getRealLeft(this)+OFFSET_BUFFER;

			inpt.style.border="0px";
			
			// save a reference to the original element
			inpt.originalElement = this;
			
			// when we blur from this input - run this function
			inpt.onblur = setContentEditableFalse;
			inpt.onkeyup = setContentEditableFalse;
			
			this.parentNode.appendChild(inpt);
			inpt.focus();
		}
		else 
		{
			//alert("setting contentEditable = false");
			//do we need to do anything here?  probably not.
		}
	});

	function setContentEditableFalse(evt){
		if (evt.type == "blur" || (evt.type == "keyup" && evt.keyCode==13))
		{
		
			//~ this = the input item that was dynamically placed over the span/div;
			var origEl = this.originalElement;
			var newText = this.value;
			
			//~ if we set the elements inner text to "" then we can never edit it again!!!
			//~ so set it to non breaking blanks;
			origEl.innerHTML = newText;
			
			this.originalElement = null;
			origEl.parentNode.removeChild(this);
			cb_port_spanWidthEqualizer(origEl.parentNode);
			origEl.fireEvent("onblur");
		}	
	}

//############### ATTRIBUTES ##################
	
	//add text to attr and element
	Attr.prototype.__defineGetter__("text", function () {
		return this.textContent;
	});

//############### CSS STYLE ##################

	CSSStyleDeclaration.prototype.__defineGetter__("pixelTop", function(){
	  return parseInt(this.top, 10);
	});
	CSSStyleDeclaration.prototype.__defineSetter__("pixelTop", function(val){
	  this.top = parseInt(val, 10);
	});

	CSSStyleDeclaration.prototype.__defineGetter__("pixelLeft", function(){
	  return parseInt(this.left, 10);
	});
	CSSStyleDeclaration.prototype.__defineSetter__("pixelLeft", function(val){
	  this.left = parseInt(val, 10);
	});

	CSSStyleDeclaration.prototype.__defineGetter__("posTop", function(){
	  return parseInt(this.top, 10);
	});
	CSSStyleDeclaration.prototype.__defineSetter__("posTop", function(val){
	  this.top = parseInt(val, 10);
	});

	CSSStyleDeclaration.prototype.__defineGetter__("posLeft", function(){
	  return parseInt(this.left, 10);
	});
	CSSStyleDeclaration.prototype.__defineSetter__("posLeft", function(val){
	  this.left = parseInt(val, 10);
	});

	CSSStyleDeclaration.prototype.__defineGetter__("posWidth", function(){
	  return parseInt(this.width, 10);
	});
	CSSStyleDeclaration.prototype.__defineSetter__("posWidth", function(val){
	  this.width = parseInt(val, 10);
	});

	CSSStyleDeclaration.prototype.__defineGetter__("posHeight", function(){
	  return parseInt(this.height, 10);
	});
	CSSStyleDeclaration.prototype.__defineSetter__("posHeight", function(val){
	  this.height = parseInt(val, 10);
	});

	CSSStyleDeclaration.prototype.__defineSetter__("filter", function(strFilter){
	  // - possible value patterns sent - //
	  //"alpha(opacity=" + val + ")";
	  //progid:DXImageTransform.Microsoft.Alpha(style=2,opacity=80,finishOpacity=' +fop+ ')
	  //progid:DXImageTransform.Microsoft.BasicImage(grayscale=0, xray=0, mirror=0, invert=0, opacity=0.75, rotation=0)

	  var val = 1; //default value of 100% opacity or 0% transparency
	  with(strFilter.toLowerCase()){
	    if(indexOf("alpha") != -1){
	      if(indexOf("opacity=")){
	        val = split("opacity=")[1];
	        if (val.indexOf(",")!=-1)
	          val = val.substring(0,val.indexOf(","));
	        else if (val.indexOf(")")!=-1)
	          val = val.substring(0, val.indexOf(")") );
	      }    
	      if (val != NaN)
	        val = parseInt(val,10)/100;
	        
	    }else{
  	    if(indexOf("basicimage")!=-1){
  	      if(indexOf("opacity=")){
  	        val = split("opacity=")[1];
  	        if (val.indexOf(",")!=-1)
  	          val = val.substring(0,val.indexOf(","));
  	        else if (val.indexOf(")")!=-1)
  	          val = val.substring(0,val.indexOf(")"));
          }
  	      if (val != NaN)
  	        val = parseFloat(val,10);
  	    }    
	    }
	  }  
    this.cssText += ";-moz-opacity:" + val + ";"; 	  
	});
	
//#################  MISC ###################

  //~ we return some collections as arrays - IE's collections have the item iterator - mimic it here
  Array.prototype.item = function(i){
    return this[i];
  }
  
	//~ Unknown elements are like XML and LIST found inside HTML
	HTMLUnknownElement.prototype.__defineGetter__("XMLDocument", function(){
	  var xmldoc = {};
	  xmldoc.ownerElement = this;
	  xmldoc.selectSingleNode = function(sPath)
    {
	    var xml;
	    if(!this.ownerElement.xml)
	      xml = (new XMLSerializer()).serializeToString(this.ownerElement);
	    else
	      xml = this.ownerElement.xml;
  
      var tmpDoc = (new DOMParser()).parseFromString(xml, "text/xml");      
      if (sPath.substring(0,2)!="//"){
        if (sPath.substring(0,1)!="/")
          sPath = "//" + sPath
        else
          sPath = "/" + sPath
      }    
	    return tmpDoc.evaluate(sPath, tmpDoc, tmpDoc.createNSResolver(tmpDoc.documentElement), 9, null).singleNodeValue
    }
    
	  return xmldoc;    	
	});
	
  //tmpDoc.evaluate("//HEADERLIST", tmpDoc, tmpDoc.createNSResolver(tmpDoc.documentElement), 9, null).singleNodeValue
	//var xslResult = tmpDoc.evaluate(sPath, tmpDoc, tmpDoc.createNSResolver(tmpDoc.documentElement), XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
	//var nodeList = new Array(xslResult.snapshotLength);
	//nodeList.expr = sPath;
	//for(i=0;i<nodeList.length;i++)
	//	nodeList[i] = xslResult.snapshotItem(i);
	//return nodeList[0];

	
//########## SUPPORTING FUNCTIONS ############
  
  //~ popup factory ~
  function no_cb_AltBrowserCreatePopup()
  {
    return new no_cb_obj_Popup();
  }

  //~ add the popup object and methods to the window
	window.createPopup=no_cb_AltBrowserCreatePopup;

  //~ popup object ~
  function no_cb_obj_Popup()
  {
    //~ create iframe
    var iFrameText = '<iframe name="popup" id="popup" style="position:absolute;width:0;height:0;visibility:hidden;border:none;" src=""></iframe>';
    var range = document.createRange();
  	range.setStartAfter(document.body);
  	var parsedHTML = range.createContextualFragment(iFrameText);
  	document.body.appendChild(parsedHTML);
  
    //~ assign members
    this.iframe=document.body.lastChild;
    this.iframe.jsObj=this;
    this.iframe.style.position='absolute';
    this.iframe.style.visibility='hidden';
   
    //~ create member document directly on object 
    //~ add close to the write method - otherwise doc stays open and keeps spinning 
    this.document = this.iframe.contentWindow.document;
    this.document.underWrite=this.document.write;
    this.document.write=function(html){this.underWrite(html);this.close()};
     
    //~ set only property
    this.isOpen=false;
  
    this.show=function(top,left,width,height,relativeEl)
      {
        this.iframe.style.top=cb_sys_getRealTop(relativeEl)+relativeEl.offsetHeight;
        this.iframe.style.left=cb_sys_getRealLeft(relativeEl);
        this.iframe.style.width=width;
        this.iframe.style.height=height;
        this.iframe.style.zIndex=10000;
        this.iframe.style.visibility='visible';
        this.isOpen=true;
        this.iframe.onmouseout=function(event){this.jsObj.hide();}; 
      };
      
    this.hide=function()
      {
        this.iframe.style.visibility='hidden';
        this.iframe.style.zIndex=0;
        this.isOpen=false;
      };
  }

} // closing if !doc.all

//############# GLOBAL PORT FUNCTIONS #############

//~ Xml Http object global function
function cb_port_getXmlHttp()
{
  if (!isMoz)
  	return new ActiveXObject("microsoft.xmlhttp");
  else
  	return new XMLHttpRequest();
}

//~ Mozilla spans are W3C compliant and do not fill a specified width 
//  - add a image to justify the span's width
function cb_port_spanWidthEqualizer(domEl){
	if (!isMoz)
		return;

	var spanArray = domEl.getElementsByTagName("span");
	var span, spanWidth, imgWidth, html, imgArray

	for (var i = 0; i <	spanArray.length; i++){
		span = spanArray[i];
		if (span.style.width != ""){
			imgArray = span.getElementsByTagName("img");
			for (var j = imgArray.length-1; j >= 0; j--){
				if (imgArray[j].getAttribute("filler"))
					span.removeChild(imgArray[j]);
			}		
			spanWidth = span.offsetWidth;
			imgWidth = parseInt(span.style.width, 10) - spanWidth;
			html = "<img xsrc='/cb/res/img/cb_blank_img.gif' filler='1' style='width:" + imgWidth + "px;height:1px;'>";
			if (!span.lastChild)
				span.appendChild(document.createElement("text"))	;
				
			span.insertAdjacentHTML("beforeEnd", html);				
		}	
	}
}

//################### DEBUG WIN ##################
var debugWin;
var debugWinLoading = false;
function debugMsg(msg){
  if (debugWinLoading) {
    setTimeout("debugMsg('" + msg + "')", 100);
    return;
  }
    
  if (!debugWin){
    debugWinLoading = true;
    debugWin = window.open("","","top=1,left=1,width=400,height=300");
    debugWin.document.write("<textarea id='ta' style='width:100%;height:100%'></textarea>");
    debugWin.onunload = function(){this.opener.debugWin = null;};
  }
  var ta = debugWin.document.getElementById("ta");
  ta.value += msg + "\n";
  ta.scrollTop = ta.scrollHeight + ta.offsetHeight;
  debugWinLoading = false;
  
}
