// displaying advertisments into iframes
//  by http://www.nsl.cz

ajax_x=function(){try{return new ActiveXObject('Msxml2.XMLHTTP')}catch(e){try{return new ActiveXObject('Microsoft.XMLHTTP')}catch(e){return new XMLHttpRequest()}}};
ajax_get=function(u,f){var x=ajax_x();x.open('GET',u,true);x.onreadystatechange=function(){if(x.readyState==4)f(x.responseText)};x.send(null)};

function _rE(e) { e.parentNode.removeChild(e); }
function closeAdv() { _rE(document.getElementById('advWnd')); _rE(document.getElementById('closeBtn')); }

function openWindow(url)
{
  try { closeAdv(); } catch(e) {}
  var sizes = getPageSize();
  var advHeight = 584;
  var advWidth = 832;
  var div = document.createElement('div');
  div.setAttribute('id', "advWnd");
  div.className = 'popUp';
  var pleft = Math.round(sizes[4] + (sizes[2]-advWidth)/2)
  var ptop = Math.round(sizes[5] + (sizes[3]-advHeight)/2);
  div.style.left = pleft+'px';
  div.style.top = ptop+'px';
  div.style.display = 'none';
  div.innerHTML = '<iframe width="'+advWidth+'" height="'+advHeight+'" src="'+url+'" allowtransparency="true" style="border:1px solid black;"></iframe>';
  document.body.appendChild(div);
  div.style.display = 'block';
  var div2 = document.createElement('div');
  div2.setAttribute('id', "closeBtn");
  div2.onclick = closeAdv;
  div2.innerHTML = '<img src="http://contextlist.com/files/close.png" border="0" />';
  div2.style.left = (pleft + advWidth - 21) + 'px';
  div2.style.top = (ptop-25) + 'px';
  div2.style.display = 'block';
  document.body.appendChild(div2);
  return false;
}

function getPageSize()
{
 var xScroll, yScroll, xOffset, yOffset;
 if( typeof( window.pageYOffset ) == 'number' ) { xOffset = window.pageXOffset; yOffset = window.pageYOffset; }
 else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) { yOffset = document.body.scrollTop; xOffset = document.body.scrollLeft; }
 else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) { yOffset = document.documentElement.scrollTop; xOffset = document.documentElement.scrollLeft; }
 if (window.innerHeight && window.scrollMaxY) { xScroll = window.innerWidth + window.scrollMaxX; yScroll = window.innerHeight + window.scrollMaxY;}
 else if (document.body.scrollHeight > document.body.offsetHeight) { xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight; }
 else { xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight; }
 var windowWidth, windowHeight;
 if (self.innerHeight) { if(document.documentElement.clientWidth){ windowWidth = document.documentElement.clientWidth; } else { windowWidth = self.innerWidth; } windowHeight = self.innerHeight; }
 else if (document.documentElement && document.documentElement.clientHeight) { windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight; }
 else if (document.body) { windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight; }
 if(yScroll < windowHeight){ pageHeight = windowHeight; } else { pageHeight = yScroll; }
 if(xScroll < windowWidth){ pageWidth = xScroll; } else { pageWidth = windowWidth; }
 arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight,xOffset,yOffset);
 return arrayPageSize;
}

