function getPageSize(parent){
    parent = parent || document.body;              
    var windowWidth, windowHeight;
    var pageHeight, pageWidth;
    if (parent != document.body) {
      windowWidth = parent.getWidth();
      windowHeight = parent.getHeight();                                
      pageWidth = parent.scrollWidth;
      pageHeight = parent.scrollHeight;                                
    } 
    else {
      var xScroll, yScroll;

      if (window.innerHeight && window.scrollMaxY) {  
        xScroll = document.body.scrollWidth;
        yScroll = window.innerHeight + window.scrollMaxY;
      } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
      } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
      }


      if (self.innerHeight) {  // all except Explorer
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
      } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
      } else if (document.body) { // other Explorers
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
      }  

      // for small pages with total height less then height of the viewport
      if(yScroll < windowHeight){
        pageHeight = windowHeight;
      } else { 
        pageHeight = yScroll;
      }

      // for small pages with total width less then width of the viewport
      if(xScroll < windowWidth){  
        pageWidth = windowWidth;
      } else {
        pageWidth = xScroll;
      }
    }             
    return {pageWidth: pageWidth ,pageHeight: pageHeight , windowWidth: windowWidth, windowHeight: windowHeight};
  }
  
function getMeWinHeight() {
  var myHeight = 0;
  if( typeof( window.innerHeight ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && document.documentElement.clientHeight ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && document.body.clientHeight) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
	return myHeight;
}
  
function getMeScrollY()
{
	var scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
  } else if( document.body && document.body.scrollTop ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
  } else if( document.documentElement && document.documentElement.scrollTop ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
  }
  return  scrOfY;
}
  
function swiderKliker(widthP, heightP, src)
{
		document.getElementsByTagName('html')[0].style.overflow="hidden";
		var DarkSize = getPageSize($('swiderPopUp').parentNode);
			var obszarHeight = getMeWinHeight();
			var obszarHeightScroll = getMeScrollY();
		$('swiderPopUp').setStyle({ width: widthP + 'px', height: heightP + 'px' });
		$('swiderPopUp').style.top = parseInt((obszarHeight - heightP) / 2 + obszarHeightScroll) + 'px';
		$('swiderPopUp').style.left = parseInt((DarkSize.pageWidth - widthP) / 2) + 'px';
        $('overlay').setStyle({ width: DarkSize.pageWidth + 'px', height: DarkSize.pageHeight + 'px' });
		 new Effect.Appear('overlay', { duration: 0.2, from: 0.0, to: 0.8 });
		 $('overlay').stopObserving();
		 new Effect.Appear('swiderPopUp', { duration: 0.2, from: 0.0, to: 1 });
		 $('swiderPopUp').src = src; //last to set cause of IE js errors :/
}
function swiderKlikerKiller()
{
		new Effect.Fade('swiderPopUp', { duration: 0.2 });
		new Effect.Fade('overlay', { duration: 0.2 });
		$('overlay').observe('click', (function() { this.end(); }).bind(this));
		$('swiderPopUp').src = "";	//to hide last content
		document.getElementsByTagName('html')[0].style.overflow="auto";
}
