function popup(filename, width, height, windowname, alt, url){

  if(width > screen.width){
    height = height * screen.width / width;
    width = screen.width;
  }else if(height > screen.height){
    width = width * screen.height / height;
    height = screen.height;
  }

if (navigator.userAgent.indexOf("SV1") == -1 && navigator.userAgent.indexOf("7.0") == -1 && navigator.userAgent.indexOf("8.0") == -1) {

	  windowheight = parseInt(height) +28;
	  width_bar = width + 25;

 	 var win=window.open("", windowname, "width=" + width_bar + ",height=" + windowheight +",scrollbars=yes");

  	 win.document.open("text/html");
 	 win.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
 	 win.document.write('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">');
	 win.document.write('<head><meta http-equiv="content-language" content="ja" />');
  	 win.document.write('<title>' + alt + '</title></head>');
  	 win.document.write('<body style="margin:0px;">');
	 
	 if(url == ""){
	 
  	 win.document.write('<img src="' + filename + '" border="0" width="' + width + '" height="' + height + '" alt="' + alt + '" />');
  	 
	 }else{
		 
	 win.document.write('<a href="' + url + '" target="_blank"><img src="' + filename + '" border="0" width="' + width + '" height="' + height + '" alt="' + alt + '" /></a>');
	
	 }
	 
	 win.document.write('<div style="height:3px; margin:0px; font-size:1px;"><img src="../img/spacer.gif border="0" width="1" height="1" alt="" /></div>');
  	 win.document.write('<div style="height:25px; margin:0px; text-align:center; vertical-align:middle;"><input type="button" value="[X]CLOSE" onclick="javascript:window.close();" /></div>');
  	 win.document.write('</body></html>');
  	 win.document.close();


  	if(navigator.userAgent.indexOf("Mac")!=-1){
    	windowheight += 35;
    	win.resizeTo(width_bar, windowheight);
  	}
	
}else{
	
	wOBJ = window.createPopup();
	popOBJ = wOBJ.document.body;
	
	popOBJ.document.body.style.backgroundColor = "white";
	popOBJ.innerHTML = "<center><img src='" + filename + "'></center>";		
	popOBJ.document.body.style.overflowY = "AUTO";
	popOBJ.style.border = "solid blue 2px";
	wOBJ.show(30,30,width,parseInt(height)+20,document.body);
	
}

	
}

