function print_r(theObj){
  var ret = '';
  if(theObj.constructor == Array ||
     theObj.constructor == Object){
    ret += "<ul>";
    for(var p in theObj){
      if(theObj[p].constructor == Array||
         theObj[p].constructor == Object){
        ret += "<li>["+p+"] => "+typeof(theObj)+"</li>";
        ret += "<ul>";
        ret += print_r(theObj[p]);
        ret += "</ul>"
      } else {
        ret += "<li>["+p+"] => "+theObj[p]+"</li>";
      }
    }
    ret += "</ul>";
  }
  return ret;
}

function closePop(obj) {
  for( i=0; i<obj.childNodes.length; i++ ) {
    if( obj.childNodes[i].nodeName == 'IFRAME' ) {
      obj.childNodes[i].src = '/blank.html';
    }
  }
  obj.style.display = 'none';
}

function displayPopIFrame(obj_id, left, top, width, height, url, scrolling, bgColor) {
  obj = document.getElementById(obj_id);
  if( left == 'center' ) {
    left = (document.body.offsetWidth - width) / 2;
  }
  obj.style.top = (document.body.scrollTop + top);
  obj.style.left = left - 20;
  obj.style.width = width + 40;
  obj.style.height = height + 50;

  for( i=0; i<obj.childNodes.length; i++ ) {
    if( obj.childNodes[i].nodeName == 'IFRAME' ) {
      obj.childNodes[i].style.display = 'none';
      if( obj.childNodes[i].id == 'popFrameS' && scrolling ) {
        frameObj = obj.childNodes[i];
        frameObj.style.display = 'inline';
      }
      if( obj.childNodes[i].id == 'popFrame' && !scrolling ) {
        frameObj = obj.childNodes[i];
        frameObj.style.display = 'inline';
      }
    }
    if( obj.childNodes[i].nodeName == 'TABLE' && bgColor ) {
      obj.childNodes[i].style.backgroundColor = bgColor;
    }
  }
  //alert(frameObj.scrolling);
  frameObj.style.width = width + 20;
  frameObj.style.height = height + 20;
  if( url ) {
    frameObj.src = url;
    //checkIframeLoading(frameObj.id);
  }
  //if( bgColor ) {
    //frameObj.style.backgroundColor = 'white';
  //}
  //if( scrolling ) {
    //frameObj.style.overflow = 'hidden';
  //}
  obj.style.display = 'inline';
}

function checkIframeLoading(frameObj) {
   // Get a handle to the iframe element
   var iframe = document.getElementById(frameObj);

   // Check if loading is complete
   if ( iframe.contentDocument.readyState == 'complete' ) {
      // The loading is complete, call the function we want executed once the iframe is loaded
      //functionToCallAfterLoading();
      return;
   }

   // If we are here, it is not loaded. Set things up so we check   the status again in 100 milliseconds
   window.setTimeout('checkIframeLoading("'+frameObj+'");', 100);      
}

function windowSize()
{
  var w = 0;
  var h = 0;
  //IE
  if(!window.innerWidth)
  {
    //strict mode
    if(!(document.documentElement.clientWidth == 0))
    {
      w = document.documentElement.clientWidth;
      h = document.documentElement.clientHeight;
    }
    //quirks mode
    else
    {
      w = document.body.clientWidth;
      h = document.body.clientHeight;
    }
  }
  //w3c
  else
  {
    w = window.innerWidth;
    h = window.innerHeight;
  }
  return new Array(w,h);
}

function centerDiv(w, h)
{
  var _x = 0;
  var _y = 0;
  var offsetX = 0;
  var offsetY = 0;
  var window = windowSize();
  w = parseInt(w);
  h = parseInt(h);
  //IE
  if(!window.pageYOffset)
  {
    //strict mode
    if(!(document.documentElement.scrollTop == 0))
    {
      offsetY = document.documentElement.scrollTop;
      offsetX = document.documentElement.scrollLeft;
    }
    //quirks mode
    else
    {
      offsetY = document.body.scrollTop;
      offsetX = document.body.scrollLeft;
    }
  }
  //w3c
  else
  {
    offsetX = window.pageXOffset;
    offsetY = window.pageYOffset;
  }
  _x = ((window[0]-w)/2)+offsetX;
  _y = ((window[1]-h)/2)+offsetY;
  return new Array(Math.round(_y),Math.round(_x));
}


