﻿function startTest(oElm){
    alert('startTest(' + oElm.id + ')');
}

var oStart_divBackground, oStart_divContent;


function startPop(divBackground, divContent){
  oStart_divBackground = document.getElementById(divBackground);
  oStart_divContent = document.getElementById(divContent);
  
  startResize();
  window.onresize = startResize;
}



function startResize() {
    var iTmpSize, iLft, iRgh, iTop, iBtm, iCw, iCh, iEw, iEh;
    /*
    iTop = 50;
    iBtm = iTop;
    iLft = iTop;
    iRgh = iLft;
    */
    
    //var aCnt = startElementPositions(oStart_divContent);
    iEw = oStart_divContent.offsetWidth;  //aCnt[4];
    iEh = oStart_divContent.offsetHeight; //aCnt[5];
    
    iCw = document.documentElement.clientWidth;
    iCh = document.documentElement.clientHeight
    
    oStart_divBackground.style.width = iCw + 'px';
    oStart_divBackground.style.height = iCh + 'px';
    
    iLft = (iCw - iEw) / 2;
    iTop = (iCh - iEh) / 2;
    
    //iTmpSize = startValSize(iCw - iLft - iRgh);
    //oStart_divContent.style.width = iTmpSize + 'px';
    oStart_divContent.style.left = iLft + 'px';
    //iTmpSize = startValSize(iCh - iBtm - iTop);
    //oStart_divContent.style.height = iTmpSize + 'px';
    oStart_divContent.style.top = (iTop - 25) + 'px';
}

function startElementPositions(obj) {
  var curleft = curtop = 0;
  var curright = obj.offsetWidth;
  var curbottom = obj.offsetHeight;
  
  if(obj.offsetParent){
    do{
      curleft += obj.offsetLeft;
      curtop += obj.offsetTop;
    }while(obj = obj.offsetParent);
  }
  return [curtop, curleft, curright+curleft, curbottom+curtop, curright, curbottom];
}

function startValSize(iSize){
    if(iSize < 0){
        return 0;
    }else{
        return iSize;
    }
}