function show_control_panel() {
   document.writeln('<div style="padding: 0.7em 0 0;">');
   document.write('Картинка: ' + img_w + 'x' + img_h + ' pix, ' + img_size + ' kb' + ' | Ваш экран: ' + screen.width + 'x' + screen.height + ' pix');
   document.write(' | Масштаб:');
   document.write(' <img id="OriginalSizeImg" src="/main/img/option_1.gif" width="10" height="10"> <a href="#" onClick="to_original_size();return false;">100%</a> /');
   document.write(' <img id="FitToWindowImg" src="/main/img/option_0.gif" width="10" height="10"> <a href="#" onClick="fit_to_window();return false;">вписать в окно</a> /');
   document.write(' <img src="/main/img/option_0.gif" width="10" height="10"> <a href="#" onClick="expanding_window();return false;">во весь экран</a>');
   document.write(' | <a href="javascript:window.close();">Закрыть окно</a> |');
   document.write('</div>');
}

function expanding_window() {
   var imgObj = document.getElementById("img_id");
   var img_src = imgObj.getAttribute("src");
   var img_w = imgObj.style.width;
   var img_h = imgObj.style.height;
   var win_params = "screenX=0,screenY=0,left=0,top=0,width=" + screen.availWidth + ",height=" + screen.availHeight + ",menubar=0,status=0,location=0,directories=0,scrollbars=1,channelmode=0,toolbar=0,fullscreen=1,resizable=1,dependent=1";
   sizer = window.open("","MegaWindow",win_params);
   sizer.document.open();
   sizer.document.writeln('<html><head>');
   sizer.document.writeln('<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">');
   sizer.document.writeln('<meta http-equiv="Content-Language" content="ru">');
   sizer.document.writeln('<link rel="stylesheet" href="/zzz/com/wallpapers.css" type="text/css">');
   sizer.document.writeln('</head><body style="margin 0; background: #000;">');
   sizer.document.writeln('<a href="javascript:window.close();" onClick="window.close();return false;"><img alt="кликните по изображению, чтобы &#10;вернуться в обычный режим" src=' + img_src + ' style="width: ' + img_w + '; height: ' + img_h + ';"></a>');
   sizer.document.writeln('</body></html>');
   sizer.document.close();
}

function to_original_size() {
   var imgObj = document.getElementById("img_id");
   imgObj.style.width = img_w;
   imgObj.style.height = img_h;
   document.getElementById("OriginalSizeImg").src = '/main/img/option_1.gif';
   document.getElementById("FitToWindowImg").src  = '/main/img/option_0.gif';

   var imgObj = document.getElementById("img_id2");
   if (imgObj) {
   	imgObj.style.width = img_w;
   	imgObj.style.height = img_h;
   }
}


function fit_to_window() {

   var w_max = 0;
   if (window.innerWidth) {
      w_max = window.innerWidth;
   } else if (document.documentElement && document.documentElement.clientWidth) {
      w_max = document.documentElement.clientWidth;
   } else if (document.body && document.body.clientWidth) {
      w_max = document.body.clientWidth;
   }
   w_max = Math.round(w_max*0.9);

   var h_max = 0;
   if (window.innerHeight) {
      h_max = window.innerHeight;
   } else if (document.documentElement && document.documentElement.clientHeight) {
      h_max = document.documentElement.clientHeight;
   } else if (document.body && document.body.clientHeight) {
      h_max = document.body.clientHeight;
   }
   h_max = Math.round(h_max*0.9);

	var fit_w = w_max;
	if ( img_w < w_max ) {
		fit_w = img_w;
	}
	
	var fit_h = Math.round(img_h / img_w * fit_w);
	if ( fit_h > h_max ) {
		fit_h = h_max;
	} else if ( img_h < h_max ) {
		fit_h = img_h;
	}
	var fit_w = Math.round(img_w / img_h * fit_h);
	  	 
   var imgObj = document.getElementById("img_id");
   imgObj.style.width = fit_w;
   imgObj.style.height = fit_h;

   var imgObj = document.getElementById("img_id2");
   if (imgObj) {
   	imgObj.style.width = fit_w;
   	imgObj.style.height = fit_h;
   }
   
   document.getElementById("OriginalSizeImg").src = '/main/img/option_0.gif';
   document.getElementById("FitToWindowImg").src  = '/main/img/option_1.gif';

}
