// ra.2mcl.com

var zoom = 'fill';

function SetBG(color) {
   document.bgColor = color;
}

function show_control_panel() {
   document.writeln('<div style="text-align: center; padding: 4px;font-size:10px">');
   document.write('Picture: ' + img_w + 'x' + img_h + ' pix, ' + img_size + ' kb' + ' | Your screen resolution: ' + screen.width + 'x' + screen.height + ' pix<br />');
   document.write(' <b>Scope:</b>');
   document.write(' <img id="OriginalSizeImg" src="/i/option_1.gif" width="10px" height="10px"> <a href="#" onClick="to_original_size();return false;">100%</a> /');
   document.write(' <img id="FitToWindowImg" src="/i/option_0.gif" width="10px" height="10px"> <a href="#" onClick="fit_to_window();return false;">Fill Width</a> /');
   document.write(' <img src="/i/option_0.gif" width="10" height="10"> <a href="#" onClick="expanding_window();return false;">Full Screen</a>');
   document.write(' | <a href="javascript:window.close();">Close Window</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(' <title>Picture [zoom] click on picture for close</title>');
   sizer.document.writeln('</head><body style="margin 0; background: #000;">');
   sizer.document.writeln('<table width="100%" height="100%" border=0><tr valign=middle align=center><td><a href="javascript:window.close();"><img border=0 alt="click on picture, &#10;for rerurn on normal view" src=' + img_src + '></a></td></tr></table>');
   sizer.document.writeln('</body></html>');
   sizer.document.close();
}

function fit_to_window() {
   var win_size_X = 0;
   if (window.innerWidth) {
      win_size_X = window.innerWidth;
   } else if (document.documentElement && document.documentElement.clientWidth) {
      win_size_X = document.documentElement.clientWidth;
   } else if (document.body && document.body.clientWidth) {
      win_size_X = document.body.clientWidth;
   }
   win_size_X = win_size_X - 160; ///////////// my fix
   var optimal_w  = (win_size_X > img_w) ? img_w : win_size_X;
   var optimal_h = Math.round(optimal_w*img_h/img_w);
   var imgObj = document.getElementById("img_id");
   imgObj.style.width = optimal_w;
   imgObj.style.height = optimal_h;
   document.getElementById("OriginalSizeImg").src = '/i/option_0.gif';
   document.getElementById("FitToWindowImg").src  = '/i/option_1.gif';
   zoom = 'fill';
}

function to_original_size() {
   var imgObj = document.getElementById("img_id");
   imgObj.style.width = img_w;
   imgObj.style.height = img_h;
   document.getElementById("OriginalSizeImg").src = '/i/option_1.gif';
   document.getElementById("FitToWindowImg").src  = '/i/option_0.gif';
   zoom = '100';
}

function unzoom() {
   if (zoom == 'fill')
       to_original_size();
   else
       fit_to_window();
}

