// JavaScript Document
function scroll()
{
  popupImg = new Image();
  popupImg.src = document.getElementById('popupimg').src;
  		var imgHeight = popupImg.height;
			var imgWidth = popupImg.width;
			var screenWidth = getSize(true);
      var screenHeight = getSize(false);
  document.getElementById('popupimgcont').style.left = screenWidth/2 - imgWidth/2 + getScrollPosition(true) + 'px';
  document.getElementById('popupimgcont').style.top = screenHeight/2 - imgHeight/2 + getScrollPosition(false) + 'px';
  document.getElementById('popuptransparent').style.left = getScrollPosition(true) + 'px';
  document.getElementById('popuptransparent').style.top = getScrollPosition(false) + 'px';
}


function showFullImage(pic)
{
	popupImg = new Image();
	popupImg.src = pic;
	document.getElementById('popupimg').src = pic;
	waitUntilPopupImageLoaded();
}

function waitUntilPopupImageLoaded()
{
	if(popupImg.complete)
  {
		var imgHeight = popupImg.height;
		var imgWidth = popupImg.width;
		var screenWidth = getSize(true);
    var screenHeight = getSize(false);

    //Auf IE6 prüfen
    switch(navigator.appName)
    {
      case 'Microsoft Internet Explorer':
        var myregex = 'MSIE [789]';
        var myArray = navigator.appVersion.match(myregex);
        if(!myArray)
        {
          var browser = 'ie6';
        }
        else
        {
          var browser = 'ie6+';
        }
      break;
      default:
        var browser = 'notie';
    }

    
    if(browser == 'ie6')
    {
      document.getElementById('popupimgcont').style.left = screenWidth/2 - imgWidth/2 + getScrollPosition(true) + 'px';
      document.getElementById('popupimgcont').style.top = screenHeight/2 - imgHeight/2 + getScrollPosition(false) + 'px';
      document.getElementById('popuptransparent').style.left = getScrollPosition(true) + 'px';
      document.getElementById('popuptransparent').style.top = getScrollPosition(false) + 'px';
      document.getElementById('popuptransparent').style.height = screenHeight + 'px';
      document.getElementById('popuptransparent').style.width = screenWidth + 'px';
      document.getElementById('popuptransparent').style.position = 'absolute';
      document.getElementById('popupimgcont').style.position = 'relative';
    }
    if(browser != 'ie6')
    {
      document.getElementById('popupimgcont').style.left = screenWidth/2 - imgWidth/2 + 'px';
      document.getElementById('popupimgcont').style.top = screenHeight/2 - imgHeight/2 + 'px';
      document.getElementById('popuptransparent').style.left = '0px';
      document.getElementById('popuptransparent').style.top = '0px';
      document.getElementById('popuptransparent').style.height = screenHeight + 'px';
      document.getElementById('popuptransparent').style.width = screenWidth + 'px';
      document.getElementById('popuptransparent').style.position = 'fixed';
      document.getElementById('popupimgcont').style.position = 'fixed';
    }

    document.getElementById('popuptransparent').style.visibility = 'visible';
    document.getElementById('popupimgouter').style.visibility = 'visible';
    document.getElementById('popupimg').style.visibility = 'visible';
	}
  else
  {
		setTimeout("waitUntilPopupImageLoaded();",100);
	}
}


function closePopup()
{
  document.getElementById('popupimg').src = '';
  document.getElementById('popupimg').style.visibility = 'hidden';
  document.getElementById('popuptransparent').style.visibility = 'hidden';
  document.getElementById('popupimgouter').style.visibility = 'hidden';
}

function getScrollPosition(is_width)
{
  switch(navigator.appName)
  {
    case 'Microsoft Internet Explorer':
      scrollX = document.documentElement.scrollLeft;
      scrollY = document.documentElement.scrollTop;
    break;
    default:
      scrollX = window.pageXOffset;
      scrollY = window.pageYOffset;
  }

  if(is_width) return scrollX
  else return scrollY;
}

function getSize(is_width)
{
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' )
  {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
    //alert(document.height);
  }
  else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
  {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  }
  else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
  {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  if(is_width) return myWidth
  else return myHeight;
}