Location: PHPKode > scripts > DX0 > dx0/dx0/dx0.inc
<?

   //
   // Introducing DX0 (DhtmlX[crossbrowser]0[core]-php) v1.0
   //   -- abstract all your DHTML away so you don't have to worry about
   //      the browsers anymore.
   //
   
   if (!isset( $GLOBALS['DX0_INCLUDE_DIR'] )) $GLOBALS['DX0_INCLUDE_DIR'] = 'dx0/';
   require $GLOBALS['DX0_INCLUDE_DIR'].'dx0vars.inc'; 
   require $GLOBALS['DX0_INCLUDE_DIR'].'dx0loadable.inc'; 
   $DX0_DIV_TAGS = array('top' => 'top:^0px;', 'y' => 'top:^0px;', 'left' => 'left:^0px;', 'x' => 'left:^0px;',
      'width' => 'width:^0px;', 'height' => 'height:^0px;', 'clip' => 'clip:rect(^1, ^2, ^3, ^0);',
      'z-index' => 'z-index:^0;', 'z' => 'z-index:^0;', 'backImage' => 'background:url(^0);',
      'bgcolor' => 'background-color:^0;', 'visibility' => 'visibility:^0;'); 
   $DX0_LAYER_TAGS = array('top' => 'TOP="^0"', 'y' => 'TOP="^0"', 'left' => 'LEFT="^0"', 'x' => 'LEFT="^0"',
      'width' => 'WIDTH="^0"', 'height' => 'HEIGHT="^0"', 'clip' => 'CLIP="^0, ^1, ^2, ^3"',
      'z-index' => 'Z-INDEX="^0"', 'z' => 'Z-INDEX="^0"', 'backImage' => 'BACKGROUND="^0"',
      'bgcolor' => 'BGCOLOR="^0"');
   $DX0_USER_ELEMENTS = "";
   $DX0_LOAD_ELEMENTS = array();
   $DX0_RECORD_ELEMENTS = "";
   $DX0_RECORD_TAGS = "";
   $DX0_MOUSE_SENSITIVE = "";
   $DX0_JAVASCRIPT_BUFFER = "";
   $DX0_DRAG_FLAG = 0;
   $DX0_MOUSE_STATUS_BAR = 0;
   $DX0_OPEN_TAGS = array();
   $DX0_CHILD_OF = array();
   $DX0_PRELOAD_IMAGES = array();
   $DX0_EVENT_HANDLERS = array();
   $DX0_IMAGE_TRAPLIST = array();
   $DX0_TAG_DEPTH = 0;

   //
   // dx0core class
   //
   class dx0core {
     var $name;
     var $drag = 0;

     var $doneParentCheck = 0;
     var $parent;
     var $tagName;
     var $tagAssoc;
     var $tagProps;
     var $msFunction;
     var $objAssigns = "";  // array to store any user-defined JavaScript assignments
                            // (i.e. $objAssigns["reset"] = "baseObjectResetFunction";
                            //  .. sets thisObj.reset = baseObjectResetFunction;)
     function openTag() {
       $fabBuffer = "\n<".$this->tagName." ".$this->tagAssoc."=\"".$this->name."ID\"";
       $GLOBALS['DX0_RECORD_ELEMENTS'][] = $this->name;
       $GLOBALS['DX0_RECORD_TAGS'][] = $fabBuffer;
       $GLOBALS['DX0_TAG_DEPTH']++;
       if ($GLOBALS['DX0_TAG_DEPTH'] > 1) {
         DX0_DEBUGPASS("tagDepth:".$GLOBALS['DX0_TAG_DEPTH']."<BR>");
         $parentNym = $GLOBALS['DX0_OPEN_TAGS'][$GLOBALS['DX0_TAG_DEPTH'] - 1];
         DX0_DEBUGPASS("parentNym:".$parentNym."<BR>");
         $GLOBALS['DX0_CHILD_OF'][$parentNym][] = $this->name;
       }
       $GLOBALS['DX0_OPEN_TAGS'][$GLOBALS['DX0_TAG_DEPTH']] = $this->name;
       if ($this->tagProps != "") {
         if (strstr($this->tagName,"DIV")) {
           if ($GLOBALS['DX0_INLINE_STYLES']) $fabBuffer .= ereg_replace('0', $this->tagProps, ' STYLE="0"');
         }
         else $fabBuffer .= " ".$this->tagProps;
       }
       $fabBuffer .= ">"; 
       $this->refresh();
       return $fabBuffer; 
     }

     function closeTag() {
       if ($this->doneParentCheck < 1) {
         if (is_array($GLOBALS['DX0_CHILD_OF'][$this->name])) {
           DX0_DEBUGPASS(buildArrayList($GLOBALS['DX0_CHILD_OF'][$this->name]));
           while(list(,$eleChild) = each($GLOBALS['DX0_CHILD_OF'][$this->name])) {
             if (strlen($GLOBALS['DX0_USER_ELEMENTS'][$eleChild]->parent) < 1) {
               $GLOBALS['DX0_USER_ELEMENTS'][$eleChild]->parent = $this->name;
             }
           }
         }
       }
       unset($GLOBALS['DX0_OPEN_TAGS'][$GLOBALS['DX0_TAG_DEPTH']]);
       $GLOBALS['DX0_TAG_DEPTH']--;
       $fabBuffer .= "</".$this->tagName.">";
       $this->refresh();
       return $fabBuffer; 
     }

     function place($HTMLstr = "") {
       $fabBuffer = $this->openTag();      
       $fabBuffer .= $HTMLstr."\n";
       //
       // does this element have children inside of it?
       // if so, assign this element as their parent if they don't have one.
       //
         $objCtr = 0;
         while ($objCtr < count($GLOBALS['DX0_RECORD_ELEMENTS'])) {
           $eleName = $GLOBALS['DX0_RECORD_ELEMENTS'][$objCtr];
           $eleTag = $GLOBALS['DX0_RECORD_TAGS'][$objCtr];
           if (strstr($HTMLstr, $eleTag)) {
             $testForParent = $GLOBALS['DX0_USER_ELEMENTS'][$eleName]->parent;
             if (strlen($testForParent) < 1) { $GLOBALS['DX0_USER_ELEMENTS'][$eleName]->parent = $this->name; }
           }
           $objCtr++;
         }
         $this->doneParentCheck = 1;
       $fabBuffer .= $this->closeTag();
       return $fabBuffer;
     }

     function echoAssigns() {
       $asgBuf = "";
       if (is_array($this->objAssigns)) {
         while (list($left, $right) = each($this->objAssigns)) {
           $asgBuf .= "  ".$this->name.".".$left." = ".$right.";\n";
         }
       }
       $this->refresh();
       return $asgBuf;
     }

     function xprop($props) {
       $tmp = array();
       if ($props['visibility'] == "hidden") {
         $wash = 1;
       }
       while(list($key, $val) = each($props)) {
         $key = strtolower($key);
         switch ($key) {
           case 'liquidx':
             $rx = "dx0browserWidth() - ".$this->name.".getWidth() + ".$val;
             dx0registerFx("onload", $this->name.".moveTo(".$rx.", null);");
             dx0registerFx("onresize", $this->name.".moveTo(".$rx.", null);");
             $tmp['visibility'] = "hidden";
             break;
           case 'liquidy':
             $ry = "dx0browserHeight() - ".$this->name.".getHeight() + ".$val;
             dx0registerFx("onload", $this->name.".moveTo(null, ".$ry.");");
             dx0registerFx("onresize", $this->name.".moveTo(null, ".$ry.");");
             $tmp['visibility'] = "hidden";
             break;
	   case 'drag':
	     $this->setDrag($val);
	     break;
           default:
             $tmp[$key] = $val;
         }
       }
       if (!$wash && ($rx || $ry)) dx0registerFx("onload", $this->name.".show();"); 
       $this->refresh();
       return $tmp;
     }

     function mouseFunction($funct) {
       $this->msFunction = $funct;
       $GLOBALS['DX0_MOUSE_SENSITIVE'][] = $this->name;
       $this->refresh();
     }

     function link($linkObj) {
       $this->objAssigns["linkObj"] = $linkObj;
       $this->refresh();
     }

     function setDrag($dragShell = "", $bounds = "") {
       $GLOBALS['DX0_DRAG_FLAG'] = 1;
       $this->mouseFunction("dx0drag");
       if (strlen($dragShell) > 1) {
         $this->objAssigns["shell"] = $dragShell; 
       }
       if(is_array($bounds)) {
         $this->objAssigns["bounds"] = "['$bounds[0]', '$bounds[1]', '$bounds[2]', '$bounds[3]']";
       }
       $this->refresh();
     }

     function refresh() {
       $GLOBALS['DX0_USER_ELEMENTS'][$this->name] = $this;
     }
   }

   //
   // dx0absElement class for Absolutely-Positioned Elements
   //
   class dx0absElement extends dx0core {
     var $tagName = "DIV";
     var $tagAssoc = "ID";
     function dx0absElement($newName, $newProps = "") {
       $this->name = $newName;
       $this->properties = $this->xprop($newProps);
       if ($GLOBALS['DX0_LAYER_SUPPORT']) {
         if ($GLOBALS['DX0_NS4']) { $this->tagName = "LAYER"; $this->tagAssoc = "NAME"; }
       }
       if (strstr($this->tagName,"DIV")) { $this->tagProps = 'position:absolute; '; }
       if (is_array($this->properties)) $this->tagProps .= dx0assemblePropTag($this->tagName, $this->properties);
       $this->refresh();
     }
   }

   //
   // dx0relElement class for Relatively-Positioned Elements
   //
   class dx0relElement extends dx0core {
     var $tagName = "DIV";
     var $tagAssoc = "ID";
     function dx0relElement($newName, $newProps = "") {
       $this->name = $newName;
       $this->properties = $this->xprop($newProps);
       if ($GLOBALS['DX0_NS4']) { $this->tagName = "ILAYER"; $this->tagAssoc = "NAME"; }
       if (strstr($this->tagName,"DIV")) { $this->tagProps = 'position:relative; '; }
       if (is_array($this->properties)) $this->tagProps .= dx0assemblePropTag($this->tagName, $this->properties);
       $this->refresh();
     }
   }

   //
   // generates STYLE attr for DIVs and TOP=,LEFT=,etc. for ILAYERs
   //
   function dx0assemblePropTag($typeOfTag, $propArray) {
     global $DX0_LAYER_TAGS;
     global $DX0_DIV_TAGS;
     $propBuffer = "";
     while (list($propName, $propVal) = each($propArray)) {

       //
       // use ereg_replace() and the lookup arrays to make LAYER-specific
       //   and CSS-specific attribute tags
       //
       $propName = strtolower($propName);
       if (strstr($typeOfTag, "LAYER")) $tagEreg = $DX0_LAYER_TAGS[$propName];
       else $tagEreg = $DX0_DIV_TAGS[$propName];
       if (strlen($tagEreg) > 0) {
         if (is_array($propVal)) {
           for ($i = 0; $i < count($propVal); $i++) {
              $next = "\^".$i;
              $tagEreg = ereg_replace($next, strval($propVal[$i]), $tagEreg); 
           }
           $propBuffer .= " ".$tagEreg;
         }
         else $propBuffer .= " ".ereg_replace("\^0", strval($propVal), $tagEreg); 
       } else {
         
         //
         // handle variations on visibility 
         //
         if ($propName == "visibility" && strstr($typeOfTag, "LAYER")) {
           $propBuffer .= ' VISIBLE="'.(($propVal == "visible") ? "SHOW" : "HIDE").'"';
         }
        
         //
         // handle standard opacity and other non-Netscape styles
         //
         else if (!$GLOBALS['DX0_NS4']) {
           if ($propName == "opacity") {
             if ($GLOBALS['DX0_IE4UP']) $propBuffer .= " filter:alpha(opacity=".$propVal.");";
             else $propBuffer .= " opacity:".$propVal.";";
           }
           else $propBuffer .= " ".$propName.":".$propVal.";"; 
         }
       }
     }
     return $propBuffer;
   }

   function dx0registerFx($event, $scriptLine) {
     $event = strtolower($event);
     $GLOBALS['DX0_EVENT_HANDLERS'][$event][] = $scriptLine;
   }

   //
   // dx0cacheImages - takes an associative array, where the key is a
   //   storage name for a JavaScript image() object and the value is the filename
   //
   function dx0cacheImages($imageTuples) {
     while(list($objName, $fileLoc) = each($imageTuples)) {
       $GLOBALS['DX0_PRELOAD_IMAGES'][$objName] = $fileLoc;
     }
   }
     
   //
   // dx0rollover - creates <IMG> tag and <A>nchor tag appropriate to the browser
   //
   function dx0rollover($name, $w, $h, $imageOff, $imageOn, $imageDown = "", $href = "", $nestEle = "") {
     if (strlen($nestEle) > 0) $GLOBALS['DX0_IMAGE_TRAPLIST'][$name] = $nestEle;
     if (eregi("^javascript", $href)) {
       $ondown = substr($href, 11)." ";
       $href = "javascript:void(0);";
     }
     if ($href == "" && !$GLOBALS['DX0_IE4UP']) {
       $href = "javascript:void(0);";
     }
     $roBuf = "<A ".($href ? "HREF=\"".$href."\" " : "")
       ."onMouseOver=\"dx0swap('".$name."', '".$imageOn."'); return false;\" "
       ."onMouseUp=\"dx0swap('".$name."', '".$imageOff."'); return false;\" "
       ."onMouseDown=\""
       .(strlen($imageDown) > 0 ? "dx0swap('".$name."', '".$imageDown."'); " : "")
       .$ondown."return false;\"><IMG NAME=\"".$name."\" "
       .($GLOBALS['DX0_IE4UP'] ? "STYLE=\"cursor:hand\" " : "")."SRC=\""
       .$GLOBALS['DX0_PRELOAD_IMAGES'][$imageOff]."\" BORDER=\"0\" WIDTH=\""
       .$w."\" HEIGHT=\"".$h."\"></A>";
     return $roBuf;
   }
  
   //
   // dx0prep - writes style sheets and javascript if necessary
   //
   function dx0prep() {
     echo dx0stylesheet();
     echo '
<SCRIPT LANGUAGE="JavaScript">
<!--

var pageLoadFlag = 0;

// -->
</SCRIPT>
';
   }

   function dx0stylesheet() {
     //
     // write style sheets
     //
     $prepBuffer = '';
     if (!$GLOBALS['DX0_INLINE_STYLES']) {
       $prepBuffer .= '
<STYLE TYPE="text/css">
<!--   ';
       for (reset($GLOBALS['DX0_USER_ELEMENTS']); $eleIt = key($GLOBALS['DX0_USER_ELEMENTS']); next($GLOBALS['DX0_USER_ELEMENTS'])) {
         $eleName = $GLOBALS['DX0_USER_ELEMENTS'][$eleIt]->tagName;
	 if (strstr($eleName, "DIV")) {
           $prepBuffer .= '
#'.$eleIt.'ID { '.$GLOBALS['DX0_USER_ELEMENTS'][$eleIt]->tagProps.' } ';
         }
       }
       $prepBuffer .= '
-->
</STYLE>
'; 
     } 
     return $prepBuffer;
   }

   //
   // this function makes a Netscape-style layer-recursing string based on the parent properties of each instance
   //  (ex. "document.dx0Grandpa.document.dx0Parent.")
   //
   function dx0getParentStr($eleName) {
     eval('$eleParent = $GLOBALS['.$eleName.']->parent;');
     //if (strlen($eleParent) > 1) {
     //  $parentStr = "document.".$eleParent;
     //  eval('$eleGrandpa = $GLOBALS['.$eleParent.']->parent;');
     //  if (strlen($eleGrandpa) > 1) $parentStr = dx0getParentStr($eleParent).$parentStr;
     //  return $parentStr.".";
     //} else return "";
     return $parentStr;
   }

   function dx0stripPosAttr($propList) {
     $ret = explode("position", $propList);
     $loc = strpos($ret[1], ";");
     return $ret[0].substr($ret[1],$loc+1);
   }

   //
   // push and pop onto a pipe-delimited string
   //
   function dx0pushInPipe($pipeStr, $addStr) {
       if (strlen($pipeStr) > 0) $pipeStr .= "|";
       return $pipeStr.$addStr;
   }

   function dx0popFromPipe($pipeStr) {
     $depthCtr = strlen($pipeStr);
     while ($depthCtr > 0) {
       $depthCtr--;
       if ($pipeStr[$depthCtr] == "|") break;
     }
     return substr($pipeStr, 0, $depthCtr);  
   }

   function writeObjectInit($eleName) {
     $jsBuf .= '  '.$eleName.' = new baseObject("'.$eleName.'ID"';
     $pStr = $GLOBALS['DX0_USER_ELEMENTS'][$eleName]->parent;
     if (strlen($pStr) > 1) {
       if (!isset($GLOBALS['DX0_ELEMENTS_DONE'][$pStr])) {
         $GLOBALS['DX0_ELEMENTS_SKIPPED'][$pStr][] = $eleName;
	 return "";
       } else {
         $jsBuf .= ', '.$pStr;
       }
     }
     $jsBuf .= ');
'; 
     $GLOBALS['DX0_ELEMENTS_DONE'][$eleName] = 1;
     if (isset($GLOBALS['DX0_ELEMENTS_SKIPPED'][$eleName])) {
       while(list(,$v) = each($GLOBALS['DX0_ELEMENTS_SKIPPED'][$eleName])) {
         $jsBuf .= writeObjectInit($v);
       }
     }
     return $jsBuf;
   }

   //
   // sorry this function looks kind of messy
   //
   function dx0basic($jsOptions = "") {
     echo dx0javascript($jsOptions);
   }

   function dx0javascript($jsOptions = "") {
     $jsBuf = "";
     if ($GLOBALS['DX0_DHTML'] > 0) {
       $jsBuf .= '<SCRIPT LANGUAGE="JavaScript" SRC="'.$GLOBALS['DX0_WEB_DIR'].$GLOBALS['DX0_BASIC_JS'].'?'.time().'&'.$jsOptions.'"></SCRIPT>';
       if ($jsOptions == "LOAD_ON") {
         if ($GLOBALS['DX0_IE4UP'] || $GLOBALS['DX0_NS6']) { 
           $jsBuf .= '
<IFRAME ID="catcherID" NAME="catcherFrame" STYLE="position:absolute; left: 0px; top:-1px; display:none;" BORDER="0" WIDTH="1" HEIGHT="1"></IFRAME>
';       }
       } 
       $jsBuf .= '
<SCRIPT LANGUAGE="JavaScript">
<!--
';     //
       // Write JavaScript global buffer
       //
       $jsBuf .= $GLOBALS['DX0_JAVASCRIPT_BUFFER'];

       if ($jsOptions == "LOAD_ON") {
       //
       // optional element-loading script
       //
       $jsBuf .= '
// DX0 Load Flags and Stacks
var dx0eleLoading = 0;
var dx0eleLoadName;
var dx0nextPage = new Array();
var dx0nextObj = new Array();
var dx0nextPlacer = 0;

baseObject.prototype.load = baseObjectLoad;
function baseObjectLoad(pageURL)
{
  if (dx0eleLoading) {
    dx0nextPage[dx0nextPlacer] = pageURL; dx0nextObj[dx0nextPlacer++] = this;
  } else {
    dx0eleLoadName = this;
    dx0eleLoading = 1;
'; if ($GLOBALS['DX0_NS4']) { $jsBuf .= ' 
    this.style.load(pageURL,this.divWidth);
'; } else if ($GLOBALS['DX0_IE4UP']) { $jsBuf .= ' 
    self.catcherFrame.document.location = pageURL;
'; } else if ($GLOBALS['DX0_DOM']) { $jsBuf .= ' 
    document.getElementById(\'catcherID\').src = pageURL;
'; } $jsBuf .= ' 
  }
}

function dx0childBorn() {
'; if ($GLOBALS['DX0_IE4UP']) { $jsBuf .= '
  if (typeof(dx0eleLoadName) != "undefined") dx0eleLoadName.write(self.catcherFrame.document.body.innerHTML);
'; } else if ($GLOBALS['DX0_DOM']) { $jsBuf .= ' 
  dx0eleLoadName.write(getInner(document.getElementById("catcherID")));
'; } $jsBuf .= '
  dx0eleLoading = 0;
  dx0tryLoadFromStack();
}

function dx0tryLoadFromStack() {
  if (dx0nextPlacer > 0) {
    var tempObj, tempPage;
    tempObj = dx0nextObj[0];
    tempPage = dx0nextPage[0];
    if (dx0nextPlacer > 1) {
      for (i = 1; i < dx0nextPlacer; i++) {
        dx0nextObj[i-1] = dx0nextObj[i];
        dx0nextPage[i-1] = dx0nextPage[i];
      }
    }
    dx0nextPlacer--;
    eval(tempObj+\'.load("\' +tempPage+ \'")\');
  }
}

';     } $jsBuf .= ' 

// DX0 Global Mouse Properties
var dx0m_x, dx0m_y;
dx0Active = null; 

function dx0hMsMv(e) {
  dx0m_x = '.(($GLOBALS['DX0_NS4'] || $GLOBALS['DX0_NS6']) ? 'e.pageX' : 'event.clientX + document.body.scrollLeft').';
  dx0m_y = '.(($GLOBALS['DX0_NS4'] || $GLOBALS['DX0_NS6']) ? 'e.pageY' : 'event.clientY + document.body.scrollTop').';
  if (dx0Active != null) dx0Active.mouseListener("MOVE");
  '.($GLOBALS['DX0_IE4UP'] ? "return false;\n" : '').'}

function dx0hMsUp(e) {
  if (dx0Active != null) { dx0Active.mouseDownFlag = 0; dx0Active.mouseListener("UP"); }
}

'; if ($GLOBALS['DX0_DRAG_FLAG']) { $jsBuf .= '

var dx0winX, dx0winY;
function dx0drag(eleAction) {
  if (dx0Active.shell) dragShell = dx0Active.shell;
  else dragShell = dx0Active;
  if (eleAction == "DOWN") {
    dx0winX = dx0m_x - dragShell.getLeft();
    dx0winY = dx0m_y - dragShell.getTop();
    dx0Active.dragFlag = 1;
  } else if (eleAction == "MOVE") {
    if (dx0Active.dragFlag) {
      newX = dx0m_x - dx0winX;
      newY = dx0m_y - dx0winY;
      if (dx0Active.bounds.length == 4) {
        if (newX < eval(dx0Active.bounds[0])) newX = eval(dx0Active.bounds[0]);
        if (newY < eval(dx0Active.bounds[1])) newY = eval(dx0Active.bounds[1]);
        if (newX + dx0Active.getWidth() > eval(dx0Active.bounds[2])) newX = eval(dx0Active.bounds[2]) - dx0Active.getWidth();
        if (newY + dx0Active.getHeight() > eval(dx0Active.bounds[3])) newY = eval(dx0Active.bounds[3]) - dx0Active.getHeight();
      }
      dragShell.moveTo(newX, newY);
    }
  } else if (eleAction == "UP") {
    dx0Active.dragFlag = 0;
  }
}

'; } $jsBuf .= '

dx0spacerSrc = "' . $GLOBALS['DX0_WEB_DIR'] . 'spacer.gif";
dx0imageCache = {};
'.($GLOBALS['DX0_NS4'] ? 'dx0imageTrapList = {};
' : '').'
function dx0imageLoader() {
  for (i = 0; i < dx0imageLoader.arguments.length; i += 2) {
    dx0imageCache[dx0imageLoader.arguments[i]] = new Image();
    dx0imageCache[dx0imageLoader.arguments[i]].src = dx0imageLoader.arguments[i + 1];
  }
}

function dx0swap(imName, imObj) {
  if (!pageLoadFlag) return;
'; if ($GLOBALS['DX0_NS4']) { $jsBuf .= '
  nest = "";
  if (dx0imageTrapList[imName]) nest = dx0imageTrapList[imName].nestDiv + "document." + dx0imageTrapList[imName].divId; 
  eval(nest + ".document[\"" + imName + "\"].src = dx0imageCache[\"" + imObj + "\"].src;");
'; } else { $jsBuf .= '
  document[imName].src = dx0imageCache[imObj].src;
'; } $jsBuf .= '
}

';

if ($GLOBALS['DX0_NS4']) {
  $rszBuf .= '  window.location = window.location;
';
}
if (is_array($GLOBALS['DX0_EVENT_HANDLERS']["onresize"]) && !$GLOBALS['DX0_NS4']) {
while(list(, $scrLine) = each($GLOBALS['DX0_EVENT_HANDLERS']["onresize"])) {
 $rszBuf .= '  '.$scrLine.'
'; } } 
if (strlen($rszBuf) > 0) {
$jsBuf .= '
function dx0hResize() {
'.$rszBuf.'
}

'; } $jsBuf .= '
function dx0setup() {
';  if (count($GLOBALS['DX0_PRELOAD_IMAGES']) > 0) {
    $jsBuf .= '  dx0imageLoader(';
    $i = 0;
    while(list($imObj, $fileLoc) = each($GLOBALS['DX0_PRELOAD_IMAGES'])) {
      if ($i > 0) $jsBuf .= ', '; 
      $jsBuf .= '"'.$imObj.'", "'.$fileLoc.'"';
      $i++;
    }
    $jsBuf .= ');
'; }
if (count($GLOBALS['DX0_USER_ELEMENTS']) > 0) { 
  for (end($GLOBALS['DX0_USER_ELEMENTS']); $eleName = key($GLOBALS['DX0_USER_ELEMENTS']); prev($GLOBALS['DX0_USER_ELEMENTS'])) {
    $jsBuf .= writeObjectInit($eleName);
  }
  while (list($lele, $ele) = each($GLOBALS['DX0_LOAD_ELEMENTS'])) {
    $jsBuf .= "  $lele = $ele;\n";
  }
  for (reset($GLOBALS['DX0_USER_ELEMENTS']); $eleName = key($GLOBALS['DX0_USER_ELEMENTS']); next($GLOBALS['DX0_USER_ELEMENTS'])) {
      $jsBuf .= $GLOBALS['DX0_USER_ELEMENTS'][$eleName]->echoAssigns();
    }
  } 
  if (is_array($GLOBALS['DX0_MOUSE_SENSITIVE'])) {
  $eleIt = 0;
   reset($GLOBALS['DX0_MOUSE_SENSITIVE']);
   while (list(,$eleName) = each($GLOBALS['DX0_MOUSE_SENSITIVE'])) { $jsBuf .= ' 
  '.$eleName.'.setMouseListener("'.$GLOBALS['DX0_USER_ELEMENTS'][$eleName]->msFunction.'");';
  } if (is_array($GLOBALS['DX0_IMAGE_TRAPLIST']) && $GLOBALS['DX0_NS4']) {
$jsBuf .= '
  dx0imageTrapList = {';
$i = 0;
reset($GLOBALS['DX0_IMAGE_TRAPLIST']);
while(list($imName, $trapDiv) = each($GLOBALS['DX0_IMAGE_TRAPLIST'])) {
 if ($i++ > 0) $jsBuf .= ', ';
 $jsBuf .= '"'.$imName.'": '.$trapDiv;
}
$jsBuf .= '};
'; }
} $jsBuf .= ' 
  document.onmouseup = dx0hMsUp;
  document.onmousemove = dx0hMsMv;
'; if ($GLOBALS['DX0_NS4']) { $jsBuf .= ' 
  document.captureEvents(Event.MOUSEUP | Event.MOUSEMOVE);   // | Event.KEYDOWN | Event.KEYUP);
'; } $jsBuf .= ' 
'; if ($GLOBALS['DX0_MOUSE_STATUS_BAR']) { $jsBuf .= '
  reportStatus();
'; } if (is_array($GLOBALS['DX0_EVENT_HANDLERS']["onload"])) {
while(list(, $scrLine) = each($GLOBALS['DX0_EVENT_HANDLERS']["onload"])) {
 $jsBuf .= '  '.$scrLine.'
'; } } $jsBuf .= '
  pageLoadFlag = 1;
}

'; if ($GLOBALS['DX0_MOUSE_STATUS_BAR']) { $jsBuf .= ' 
function reportStatus() {
  window.status = "x : " + dx0m_x + " | y : " + dx0m_y + " | active : " + dx0Active;
  setTimeout("reportStatus()",100);
}
'; } $jsBuf .= '

'; if ($GLOBALS['DX0_NS4'] || strlen($rszBuf) > 0) { $jsBuf .= '
window.onresize = dx0hResize;
'; } if ($GLOBALS['DX0_AUTO_ONLOAD'] > 0) { $jsBuf .= '
window.onload = dx0setup;
'; } $jsBuf .= '

// -->
</SCRIPT>
';     

     }
     return $jsBuf;
   } 

   // DX0 DEBUGGING
   function DX0_DEBUGPASS($debugMsg) {
     if ($GLOBALS['DX0_DEBUG'] != 1) return;
     echo $debugMsg;
     // instead of just echoing, I might try opening a socket that could be telnetted
     // to that's spitting out debug data
   }

//
// outputs array as a <ul> list
//
function buildArrayList($searchArray)
{
  $ulBUFFER = "\n\n<ul>";
  while (list($key, $value) = each($searchArray)) {
    $ulBUFFER .= "\n    <li>\$$key =&gt; $value</li>\n";
    if (is_array($value)) $ulBUFFER .= buildArrayList($value);
  }
  $ulBUFFER .= "\n</ul>";
  return $ulBUFFER;
}
   //
   // uncomment this next echo line if you're putting dx0 at the top of your file anyways
   //
   // echo '<!DOCTYPE PUBLIC HTML="-//W3C DTD HTML 4.0 Transitional//EN">';   
?>
Return current item: DX0