popwin=null;

pStart='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\n<html><head><title>Galerie studentů | Škola kreativní fotografie</title></head><body style="margin: 0; padding: 0; cursor: pointer;"><img src="';
pEnd='" onclick="window.close();" id="image"></body></html>';

function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } 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;
  }
  window.alert( 'Width = ' + myWidth +'\n'+'Height = ' + myHeight );
}

function popopen (url) {
	/*if (popwin!=null && !document.all) {
		popwin.document.getElementById('image').src=url;
	} else {*/
		popwin=window.open ('','a','location=no,menubar=no,resizable=yes,scrollbares=no,toolbar=no,status=no',true);
		popwin.document.write (pStart+url+pEnd);
		popwin.document.close();
		img=popwin.document.getElementById('image');
		img.onload=function () {
			do {
			} while (!img.width);
			//popwin.resizeTo (img.width,img.height);
			popwin.focus();
			popwin.resizeTo (1000,800);
			//
			var myWidth = 0, myHeight = 0;
		  if( typeof( window.innerWidth ) == 'number' ) {
		    //Non-IE
		    myWidth = popwin.innerWidth;
		    myHeight = popwin.innerHeight;
		  } else if( popwin.document.documentElement &&
		      ( popwin.document.documentElement.clientWidth || popwin.document.documentElement.clientHeight ) ) {
		    //IE 6+ in 'standards compliant mode'
		    myWidth = popwin.document.documentElement.clientWidth;
		    myHeight = popwin.document.documentElement.clientHeight;
		  } else if( popwin.document.body && ( popwin.document.body.clientWidth || popwin.document.body.clientHeight ) ) {
		    //IE 4 compatible
		    myWidth = popwin.document.body.clientWidth;
		    myHeight = popwin.document.body.clientHeight;
		  }
			//
			popwin.resizeBy (-(Math.abs(img.width-myWidth)),-(Math.abs(img.height-myHeight)));
			//window.alert( 'Width = ' + myWidth +'\n'+'Height = ' + myHeight );
		}
		popwin.onunload=function () {
			this.opener.popwin=null;
		}
	//}
}
