
function GetWindowCLT(iObjW,iObjH){
  var iBodyWidth  = f_clientWidth();
  var iBodyHeight = f_clientHeight();
  var iScrollLeft = f_scrollLeft();
  var iScrollTop  = f_scrollTop();
  var aWC = new Array(2);
  aWC[0] = (iBodyWidth  / 2) + iScrollLeft.valueOf();
  aWC[1] = (iBodyHeight / 2) + iScrollTop.valueOf();
  var aResult = new Array(2);
  aResult[0] = Math.floor(aWC[0].valueOf() - iObjW.valueOf() / 2);
  aResult[1] = Math.floor(aWC[1].valueOf() - iObjH.valueOf() / 2);
  var iScrollLeft = f_scrollLeft();
  var iScrollTop  = f_scrollTop();
  if (iScrollLeft > aResult[0]){ aResult[0] = iScrollLeft; }
  if (iScrollTop > aResult[1]){ aResult[1] = iScrollTop; }
  var isWW  = window.innerWidth; // offsetWidth ?
  var isWH = window.innerHeight; // offsetHeight ?
  if (isWW < iBodyWidth){isWW=iBodyWidth;}
  if (isWH < iBodyHeight){isWH=iBodyHeight;}
  if ((isWW- iObjW) < aResult[0]){aResult[0] = (isWW- iObjW);}
  if ((isWH- iObjH) < aResult[1]){aResult[1] = (isWH- iObjH);}
  aResult[2] = iBodyWidth + iScrollLeft.valueOf();
  aResult[3] = iBodyHeight + iScrollTop.valueOf();
  return aResult;
}
function f_clientWidth(){
  return f_filterResults (
    window.innerWidth ? window.innerWidth : 0,
    document.documentElement ? document.documentElement.clientWidth : 0,
    document.body ? document.body.clientWidth : 0
  );
}
function f_clientHeight(){
  return f_filterResults (
    window.innerHeight ? window.innerHeight : 0,
    document.documentElement ? document.documentElement.clientHeight : 0,
    document.body ? document.body.clientHeight : 0
  );
}
function f_scrollLeft(){
  return f_filterResults (
    window.pageXOffset ? window.pageXOffset : 0,
    document.documentElement ? document.documentElement.scrollLeft : 0,
    document.body ? document.body.scrollLeft : 0
  );
}
function f_scrollTop(){
  return f_filterResults (
    window.pageYOffset ? window.pageYOffset : 0,
    document.documentElement ? document.documentElement.scrollTop : 0,
    document.body ? document.body.scrollTop : 0
  );
}
function f_scrollHeight(){
  return (
    window.scrollHeight ? window.scrollHeight : 0,
    document.documentElement ? document.documentElement.scrollHeight : 0,
    document.body ? document.body.scrollHeight : 0
  );
}
function f_filterResults(n_win, n_docel, n_body){
  var n_result = n_win ? n_win : 0;
  if (n_docel && (!n_result || (n_result > n_docel))){
    n_result = n_docel;
  }
  return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
function SunglassPopupShow(pUrl,tt,iW,iH){
 var glaSS=document.getElementById('SunglassDiv');
 var popSS=document.getElementById('popIFrameDiv');
 var popIF=document.getElementById('popupIFrame');
 var centerXY = GetWindowCLT(iW,iH);
 var tvs=f_scrollHeight();
 if(tvs>centerXY[3]){centerXY[3]=tvs;}
 glaSS.style.position = 'absolute';
 glaSS.style.left = '0px';
 glaSS.style.top = '0px';
 glaSS.style.width = centerXY[2]+'px';
 glaSS.style.height = centerXY[3]+'px';
 glaSS.style.zIndex = '1500';
 glaSS.style.backgroundColor = '#332100';
 glaSS.style.visibility = 'visible';
 glaSS.style.display = 'block';
 glaSS.style.opacity = '0.70';
 glaSS.style.filter = 'Alpha(Opacity=70)';
 popSS.style.position = 'absolute';
 popSS.style.width = (2+iW) + 'px';
 popSS.style.height = (20+iH) + 'px';
 popSS.style.left = centerXY[0]+'px';
 popSS.style.top = (centerXY[1]-28)+'px';
 popSS.style.zIndex = '1605';
 popSS.style.visibility = 'visible';
 popSS.style.display = 'block';
 popIF.style.border = '#CC9900 1px solid';
 popIF.src = pUrl;
 popIF.width = iW + 'px';
 popIF.height = iH + 'px';
 // popIF.scrolling='auto';
 if(tt!=''){document.getElementById('popTT').innerHTML=tt;}
 window.onresize = function (){ SunglassPopupShow(pUrl,tt,iW,iH); };
}
function SunglassPopupHide(){
 var glaSS=document.getElementById('SunglassDiv');
 var popSS=document.getElementById('popIFrameDiv');
 var popIF=document.getElementById('popupIFrame');
 glaSS.style.left = popSS.style.left = '0px';
 glaSS.style.top = popSS.style.top = '0px';
 glaSS.style.width = popSS.style.width = popIF.width = '1px';
 glaSS.style.height = popSS.style.height = popIF.height = '1px';
 glaSS.style.backgroundColor='';
 glaSS.style.visibility = popSS.style.visibility = 'hidden';
 glaSS.style.display = popSS.style.display = popIF.style.border = 'none';
 popIF.src = 'img/spc.gif';
 // popIF.scrolling='no';
 document.getElementById('popTT').innerHTML='';
 window.onresize = function (){ return false; };
}

