function popup(url,width,height,isscroll)
	{
	fenetre=window.open('about:blank', '_blank', 'width='+width+', height='+height+', status=0, scrollbars='+isscroll+', left=50, top=30, location=0, menubar=0, toolbar=0, resizable=1');
	with (fenetre.document)
		{
		writeln('<html><head><title>'+url+'</title><style>body{margin:0px;}</style><body bgcolor=#000000><div align=center><img src="'+url+'" onClick="window.close();" title="Click to close the window"></div></body></html>');
		close();
		}
	}
	
function popup2(url,width,height,popupnumber)
	{
	current_number=popupnumber;
	scr_margin=25;
	if (screen.availWidth)
		{
		scr_width=screen.availWidth;
		scr_height=screen.availHeight;
		}
	else
		{
		scr_width=1024;
		scr_height=768;
		}
	isscroll=0;
	if (width*1+2*scr_margin<=scr_width)
		{
		pop_width=width;
		}
	else
		{
		pop_width=scr_width-2*scr_margin;
		isscroll=1;
		}
	if (height*1+2*scr_margin<=scr_height)
		{
		pop_height=height;
		}
	else
		{
		pop_height=scr_height-2*scr_margin;
		isscroll=1;
		//alert('height='+height+' scr_margin'+scr_margin+' height*1+2*scr_margin='+(height*1+2*scr_margin));
		}
	fenetre=window.open('', '', 'width='+pop_width+', height='+pop_height+', status=0, scrollbars='+isscroll+', left='+((scr_width-pop_width)/2)+', top='+((scr_height-pop_height)/2)+', location=0, menubar=0, toolbar=0, resizable=1');
	with (fenetre.document)
		{
		writeln('<html><head>');
		writeln('<title>'+url+'</title>');
		writeln('<style>body{margin:0px;}</style>');
	    	if (navigator.userAgent.indexOf("MSIE") > 0)
		{
		writeln('<script language="javascript" type="text/javascript">');
		//writeln('document.attachEvent("onkeypress",onKeyPressIE);');
		//action='window.close();';
		//title1="Click to close";
		action='opener.next();';
		title1="Click to see next image";
		writeln('</script>');
		}
		else
		{
		writeln('<script language="javascript" type="text/javascript" src="popupnav.js">');
		writeln('</script>');
		writeln('<script language="javascript" type="text/javascript">');
		writeln('document.addEventListener("keypress",onKeyPress,false);');
	    	action='window.close();';
	    	title1="Click to close, press space to see next image";
	    	writeln('</script>');
	    	}
    		writeln('</head>');
		//writeln('<body bgcolor="#000000" onload="loaded()">');
		//writeln('<body bgcolor="#000000" onKeyPress="microsoftKeyPress()">');
		//writeln('<body bgcolor="#000000" onUnload="javascript:opener.reset_var();">');
		writeln('<body bgcolor="#000000">');
		
		write('<table width=100% height=100% border=0 cellpadding=0 cellspacing=0><tr><td align=center valign=middle>');
		write('<img src="'+url+'" onClick="javascript:'+action+'" title="'+title1+'">');
		writeln('</td></tr></table>');
		
		//writeln('<div align=center valign=center><img src="'+url+'" onClick="javascript:'+action+'" title="'+title1+'"></div>');
		
		writeln('</body></html>');
		close();
		}
	}
	
function previous()
	{
	fenetre.close();
	if (current_number>0)
		{
		current_number=current_number-1;
		}
	else
		{
		current_number=image_number-1;
		}
	popup2(image_path[current_number],image_x[current_number]*1,image_y[current_number]*1,current_number);
	}

function next()
	{
	fenetre.close();
	if (current_number<image_number-1)
		{
		current_number=current_number+1;
		}
	else
		{
		current_number=0;
		}
	popup2(image_path[current_number],image_x[current_number]*1,image_y[current_number]*1,current_number);
	}

function reset_var()
	{
	fenetre=null;
	}

var current_number=-1;
var fenetre=null;