var ScrollTop=0; var ScrollLeft=0; var InnerWidth; var InnerHeight; function SetParam(){ /*Width,Height*/ if (window.innerWidth){ InnerWidth=window.innerWidth; InnerHeight=window.innerHeight; } else if (document.documentElement.offsetWidth){ InnerWidth=document.documentElement.offsetWidth; InnerHeight=document.documentElement.offsetHeight; } else { InnerWidth=document.body.offsetWidth; InnerHeight=document.body.offsetHeight; } /*Scroll left,top*/ if (window.pageXOffset || window.pageYOffset){ ScrollLeft=window.pageXOffset; ScrollTop=window.pageYOffset; } else if (document.documentElement.scrollLeft || document.documentElement.scrollTop){ ScrollLeft=document.documentElement.scrollLeft; ScrollTop=document.documentElement.scrollTop; } else if (document.body.scrollLeft || document.body.scrollTop){ ScrollLeft=document.body.scrollLeft; ScrollTop=document.body.scrollTop; } } /*Show Element(id) CenterX,CenterY*/ function showWin(id) { SetParam(); var x,y; node=document.getElementById(id); x = InnerWidth+ScrollLeft; y = InnerHeight+ScrollTop;; node.style.left = ((x-node.offsetWidth)/2)+'px'; node.style.top = y-((node.offsetHeight+InnerHeight)/2)+'px'; } /*Hide Element(id) */ function hideWin(id) { node=document.getElementById(id); node.style.top = -5000+'px'; } /*Show Element X,Y*/ function showWinXY(id, x, y, scroll) { SetParam(); if (scroll){ x=x+ScrollLeft; y=y+ScrollTop; } node=document.getElementById(id); node.style.left = (x)+'px'; node.style.top = (y)+'px'; } /*Show Element & insert HTML */ function showWinHtml(id,HTML,x,y,scroll){ node=document.getElementById(id); node.innerHTML=HTML; if (!scroll) scroll=0; if (!isNaN(x) && !isNaN(y)) showWinXY(id,x,y,scroll); else showWin(id); } /*Show Element & insert PHP */ function showWinPhp(id,php,x,y,scroll){ $('#'+id).load(php); if (!scroll) scroll=0; if (!isNaN(x) && !isNaN(y)) showWinXY(id,x,y,scroll); else showWin(id); }