// -----------------------------------------------------------------------------------
//	┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
//	┃                                                                ┗┓
//	┃   imgviewer.js v2.03               				     15/06/07   ┃
//	┃                                                                  ┃
//	┃   INFORMATION                                                    ┃
//	┃    - Version  :v2.03                                             ┃
//	┃    - Author   :Kaoru Ishikura                                    ┃
//	┃    - E-Mail   :ishikura@sakura-creative.com                      ┃
//	┃    - HomePage :http://www.sakura-creative.com/                   ┃
//	┃                                                                  ┃
//	┃   Copyright (C) 2007 SAKURA CREATIVE.Inc All Rights Reserved.    ┃
//	┃                                                                  ┃
//	┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
// -----------------------------------------------------------------------------------


window.onerror = SymError;

var imgPre = new Image();

function imgViewer(img){
	
	var aName = navigator.appName.toUpperCase();
    var uName = navigator.userAgent.toUpperCase();
	imgPre.src = img;// image is a set
	
	if(!imgPre.complete || uName.indexOf("FIREFOX") || aName.indexOf("NETSCAPE")){
		imgPre.onload = function (){
			writeViewer();
		}
	}else{
		writeViewer();
	}
}

function writeViewer(){
	var imgWidth = 0;
	var imgHeight = 0;
	
	if(!imgPre){ return;}
	
	if((imgPre.width >= 620) || (imgPre.height >= 620)){
		if(imgPre.width > imgPre.height){
			imgWidth = 620;
			imgHeight = Math.round((imgPre.height / imgPre.width) * 620);
		}else if(imgPre.width < imgPre.height){			
			imgWidth = Math.round((imgPre.width / imgPre.height) * 620);
			imgHeight = 620;
		}else{
			imgWidth = 620;
			imgHeight = 620;
		}
	}else{
		imgWidth = imgPre.width;
		imgHeight = imgPre.height;
	}
	
	var opt = "";
	/*opt += 'top=0,left=0';*/
	opt += 'width=640,height=640,';
	opt += 'directories=no,toolbar=no,menubar=no,scrollbars=no,status=yes,resizable=no';
	
	viewer=window.open('','viewer',opt);
	viewer.focus();
	viewer.document.open();
	
	htm  = '<!DOCTYPE html PUBLIC "-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN" "http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd">\n';
	htm += '<html xmlns="http:\/\/www.w3.org\/1999\/xhtml" xml:lang="ja" lang="ja" dir="ltr">\n<head>\n';
	htm += '<meta http-equiv="Content-Type" content="text\/html; charset=utf-8" \/>\n'; 
	htm += '<meta http-equiv="Content-Language" content="ja" \/>\n';
	htm += '<meta http-equiv="Content-Style-Type" content="text\/css" \/>\n';
	htm += '<meta http-equiv="imagetoolbar" content="no" />\n';
	htm += '<meta name="Copyright" content="Copyright(c) 2007 Kansai Real Estate Information Center All Right Reserved." \/>\n';
	htm += '<link rev="made" href="m&#x61;&#x69;&#x6c;t&#111;&#x3a;&#x69;nf&#111;&#x40;&#x6b;ri&#x63;&#x2e;&#x63;o&#46;&#106;&#112;" \/>\n';
	htm += '<link rel="start" href="http:\/\/www.kric.co.jp" \/>\n';
	htm += '<script type="JavaScript"> image = new Image(); image.src="\/favicon.ico"; <\/script>\n';
	htm += '<link rel="shortcut icon" type="\/image\/ico" href="\/image\/shared\/favicon.ico" \/>\n';
	
	htm += '<title>関西不動産情報センター／KRIC（クリック）<\/title>\n';
	
	htm += '<\/head>\n<body style=" margin:0; padding:0;">\n';
	htm += '<div><img src="' + imgPre.src + '" alt="" width="' + imgWidth + '" height="' + imgHeight + '" style="display:block; position:absolute; left:50%; top:50%; margin:' + -(Math.round(imgHeight/2)) + 'px 0 0 ' + -(Math.round(imgWidth/2)) + 'px;" \/><\/div>\n';
	htm += '<\/body>\n<\/html>\n';
		
	viewer.document.write(htm);
	viewer.document.close();
}

function SymError()
{
  return true;
}

