/* show by wrapper */

var TO = null;
var is_image=0;

function show_img(e, self, id_image, wdt, hgt, title, tst_)
{
if (!id_image) return false
is_image=1;

// clear timeout
window.clearTimeout(TO)
TO = null;
//prop(e)

var winWr = _wrapper;
var dshowWr = winWr.getElement("d_show_img");
var ishow = layer("i_show_img");
var parentWr = winWr.getElement(self.id);
var evtWr = new evtWrapper(e, parentWr);

var tdmnu3 = layer('dmnu3');
var dmnu3Wr = null; 
if (tdmnu3) dmnu3Wr = winWr.getElement("dmnu3");
//alert( [dmnu3Wr.getY() ] )
/*, dmnu3Wr.getAbsoluteTop()*/

dshowWr.hide();
//alert([e, self.id, id_image, wdt, hgt,dshow,ishow])

ishow.width=wdt;
ishow.height=hgt;
ishow.src = "/file.php?im="+id_image;

dshowWr.style.position="absolute";
dshowWr.style.width=wdt;
dshowWr.style.height=hgt;

var delta=20;
//var x = e.x - e.offsetX - wdt - delta;
//var y = e.y - e.offsetY + winWr.getScrollY() ;  //document.body.scrollTop
//--
var x = evtWr.absX - evtWr.relX - wdt - delta;
var y = evtWr.absY - evtWr.relY ;

var pos1 = winWr.getWindowHeight()+winWr.getScrollY()
var pos2 = 1*evtWr.absY + 1*hgt + 4
var delta2 = pos2 - pos1

//correct 1
if (delta2>0) y = y-delta2

//correct2 - from flash
//var y_bounds = winWr.getDocumentHeight() - (191 - 131) - (1*hgt - 4) - 120; //dont work in FX
var y_bounds = null; 
if (dmnu3Wr) y_bounds = dmnu3Wr.getY() - (191 - 131) - (1*hgt - 4) - 30;;
if (y_bounds && y > y_bounds) y = y_bounds ;
//alert([y, y_bounds]);

//alert([evtWr.absX ,evtWr.relX, "\n", e.x,e.offsetX, "\n", winWr.getScrollY(),document.body.scrollTop, "\n", x, y])
/** / alert([
'evtWr.absY',              evtWr.absY + "\n",
'evtWr.relY',              evtWr.relY + "\n", 
'e.y',                     e.y + "\n", 
'e.offsetY',               e.offsetY + "\n",
'winWr.getDocumentHeight()', winWr.getDocumentHeight()+"\n",
'winWr.getWindowHeight()', winWr.getWindowHeight() + "\n",
'winWr.getScrollY()',      winWr.getScrollY() + "\n", 
'document.body.scrollTop', document.body.scrollTop + "\n", 
'y',        y + "\n",
'y_bounds', y_bounds + "\n",
''
]) /**/
//alert([x,y])

dshowWr.move(x,y)
//--
//dshowWr.style.left=x;
//dshowWr.style.top=y;

dshowWr.show();
//alert(dshowWr.style.display);
//--
//dshowWr.style.display="block";

//pos1: end of document currrent scroll
/* //test pos
var pos1 = winWr.getWindowHeight()+winWr.getScrollY()
var pos2 = 1*evtWr.absY + 1*hgt + 4
var delta2 = pos2 - pos1
alert([
pos1,pos2,delta2,"\n",

winWr.getDocumentHeight(), winWr.getWindowHeight(), winWr.getScrollY(), "\n",
evtWr.absY, dshowWr.getHeight(), hgt
]);
*/

return false
}

/* hide img */
function hide_img()
{
var d=document;
var dshow = layer("d_show_img");
var ishow = layer("i_show_img");

dshow.style.display="none";
//ishow.src='/images/1x1.gif';
return false
}

function hide_img_tm()
{
   //return false; 
   TO = setTimeout('hide_img()', 2000)
   return false;
}

function switch_img()
{
if (!is_image) return 0;
d=document;
var dshow = layer("d_show_img");
var displ = dshow.style.display;
dshow.style.display= displ=="none"?'block':'none';
}

function test(msg){alert(msg)};
function test1(){test('window.onclick')};
function test2(){test('document.onclick')};
function test3(){test('document.body.onclick')};
//window.onclick = test1;
//document.onclick = test2;
//document.body.onclick = test3;

//document.onclick = hide_img;
document.onclick = switch_img;







/* show - old ver */
/*
function show_img2(e, self, id_image, wdt, hgt, title, tst_)
{
if (!id_image) return false

d=document;
dshow = layer("d_show_img");
ishow = layer("i_show_img");
dshow.style.display="none";
//alert([e,id_image, wdt, hgt,dshow,ishow])

ishow.width=wdt;
ishow.height=hgt;
ishow.src = "/file.php?im="+id_image;

dshow.style.position="absolute";
dshow.style.display="block";
dshow.style.width=wdt;
dshow.style.height=hgt;
var x=e.x - e.offsetX - wdt;
var y=e.y - e.offsetY + (UA==4)?pageYOffset:document.body.scrollTop ;
//alert([x,y])
dshow.style.left=x
dshow.style.top=y
//prop(e)

return false
}

function hide_img2()
{
d=document;
dshow = layer("d_show_img");
ishow = layer("i_show_img");
dshow.style.display="none";

return false
}
*/
