﻿
var popupInitialized=false;var activeDivID=null;var popupDivID="mPopupOverlay";function getWindowSize()
{var myWidth=0,myHeight=0;if(typeof(window.innerWidth)=='number'){myWidth=window.innerWidth;myHeight=window.innerHeight;}else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){myWidth=document.documentElement.clientWidth;myHeight=document.documentElement.clientHeight;}else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){myWidth=document.body.clientWidth;myHeight=document.body.clientHeight;}
return{width:myWidth,height:myHeight}}
function getScrollXY()
{var scrOfX=0,scrOfY=0;if(typeof(window.pageYOffset)=='number'){scrOfY=window.pageYOffset;scrOfX=window.pageXOffset;}else if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){scrOfY=document.body.scrollTop;scrOfX=document.body.scrollLeft;}else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){scrOfY=document.documentElement.scrollTop;scrOfX=document.documentElement.scrollLeft;}
return{x:scrOfX,y:scrOfY};}
function getIEVersion()
{if(navigator.appVersion.indexOf("MSIE")==-1)return false;var p1=navigator.appVersion.indexOf("MSIE");var p2=navigator.appVersion.indexOf(";",p1);return navigator.appVersion.substr(p1+5,p2-(p1+5));}
function addEventTo(obj,event,handler)
{var altEN='on'+event;if(obj.attachEvent)
obj.attachEvent(altEN,handler);else if(obj.addEventListener)
obj.addEventListener(event,handler,false);else
alert("You browser doesn't support "+altEN+" event.");}
function removeEvent(obj,event,handler)
{var altEN='on'+event;if(obj.detachEvent)
obj.detachEvent(altEN,handler);else if(obj.removeEventListener)
obj.removeEventListener(event,handler,false);else
alert("You browser doesn't support "+altEN+" event.");}
function InitializePopup()
{var div=document.createElement("div");div.id=popupDivID;div.style.display="none";div.style.backgroundColor="#000000";div.style.width="100%";div.style.left="0px";div.style.top="0px";div.style.position=(navigator.appName=="Microsoft Internet Explorer"&&getIEVersion()=="6.0")?"absolute":"fixed";div.style.filter="Alpha(Opacity=10)";div.style.MozOpacity=0.1;div.style.opacity=0.1;document.body.appendChild(div);if(navigator.appName=="Microsoft Internet Explorer"&&getIEVersion()=="6.0")
addEventTo(window,"scroll",CorrectPosition);addEventTo(window,"resize",function(){if(activeDivID!=null)ShowDivAsPopup(activeDivID);});addEventTo(div,"click",function(){HidePopup();});popupInitialized=true;}
function ShowDivAsPopup(divID)
{if(!popupInitialized)InitializePopup();var div=document.getElementById(divID);var mOverlay=document.getElementById(popupDivID);activeDivID=divID;mOverlay.style.display="block";mOverlay.style.zIndex=99;mOverlay.style.height=getWindowSize().height+"px";div.style.position="fixed"
div.style.display="block";div.style.zIndex=1000;div.style.left=(getWindowSize().width-div.offsetWidth)/2+"px";if(navigator.appName=="Microsoft Internet Explorer"&&getIEVersion()=="6.0")
{mOverlay.style.top=getScrollXY().y+"px";div.style.position="absolute";div.style.top=(getWindowSize().height-div.offsetHeight)/2+getScrollXY().y+"px";}
else
{mOverlay.style.top="0px";div.style.position="fixed"
div.style.top=(getWindowSize().height-div.offsetHeight)/2+"px";}}
function HidePopup()
{if(document.getElementById(activeDivID))document.getElementById(activeDivID).style.display="none";if(document.getElementById(popupDivID))document.getElementById(popupDivID).style.display="none";activeDivID=null;}
function CorrectPosition()
{if(activeDivID!=null)
{document.getElementById(popupDivID).style.top=getScrollXY().y+"px";document.getElementById(activeDivID).style.top=(getWindowSize().height-document.getElementById(activeDivID).offsetHeight)/2+getScrollXY().y+"px";}}
