function getPageSize(){
var xScroll,yScroll;
if(window.innerHeight&&window.scrollMaxY){
xScroll=document.body.scrollWidth;
yScroll=window.innerHeight+window.scrollMaxY;
}else if(document.body.scrollHeight>document.body.offsetHeight){
xScroll=document.body.scrollWidth;
yScroll=document.body.scrollHeight;
}else{
xScroll=document.body.offsetWidth;
yScroll=document.body.offsetHeight;
}
var windowWidth,windowHeight;
if(self.innerHeight){
windowWidth=self.innerWidth;
windowHeight=self.innerHeight;
}else if(document.documentElement&&document.documentElement.clientHeight){
windowWidth=document.documentElement.clientWidth;
windowHeight=document.documentElement.clientHeight;
}else if(document.body){
windowWidth=document.body.clientWidth;
windowHeight=document.body.clientHeight;
}
if(yScroll<windowHeight){
pageHeight=windowHeight;
}else{
pageHeight=yScroll;
}
if(xScroll<windowWidth){
pageWidth=windowWidth;
}else{
pageWidth=xScroll;
}
arrayPageSize=new Array(pageWidth,pageHeight,windowWidth,windowHeight)
return arrayPageSize;
}
function loosePx(value)
{
var str=new String(value);
str.replace(/px/gi,'');
return value;
}
function getPageSize2()
{
var xScroll,yScroll;
if(window.innerHeight&&window.scrollMaxY)
{
xScroll=window.innerWidth+window.scrollMaxX;
yScroll=window.innerHeight+window.scrollMaxY;
}
else if(document.body.scrollHeight>document.body.offsetHeight)
{
xScroll=document.body.scrollWidth;
yScroll=document.body.scrollHeight;
}
else
{
xScroll=document.body.offsetWidth;
yScroll=document.body.offsetHeight;
}
var windowWidth,windowHeight;
if(self.innerHeight)
{
if(document.documentElement.clientWidth)
{
windowWidth=document.documentElement.clientWidth;
}else
{
windowWidth=self.innerWidth;
}
windowHeight=self.innerHeight;
}
else if(document.documentElement&&document.documentElement.clientHeight)
{
windowWidth=document.documentElement.clientWidth;
windowHeight=document.documentElement.clientHeight;
}else if(document.body)
{
windowWidth=document.body.clientWidth;
windowHeight=document.body.clientHeight;
}
if(yScroll<windowHeight)
{
pageHeight=windowHeight;
}
else
{
pageHeight=yScroll;
}
if(xScroll<windowWidth)
{
pageWidth=xScroll;
}
else
{
pageWidth=windowWidth;
}
return[pageWidth,pageHeight];
}
function getScroll(){
var scrOfX=0,scrOfY=0;
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[scrOfY,scrOfX];
}
var popupStatus=0;
function POPUP(ahref)
{
ahref = window.location.href + ahref;
var myAjax=new Ajax.Request(
ahref,
{
method:'get',
onComplete:function(response){
var scroll=getScroll();
var size=getPageSize();
var height=size[1];
var width=size[0];
new Effect.Morph('canvas',{style:'display:block;background:#000;width: '+width+'px;height: '+height+'px;top: 0px;left: 0px;',duration:0.3});
var popup=document.getElementById('popup');
height=size[3];
width=size[0];
var top=((loosePx(height)-189)/2)+scroll[0];
var left=(loosePx(width)-375)/2;
new Effect.Morph('popup',{style:'display:block;background:#FFFFFF;width: 375px;height: 189px;top: '+top+'px;left: '+left+'px;',duration:0.3});
document.getElementById('popup').innerHTML=response.responseText;
popupStatus=1;
}
});
}
function initPOPUP()
{
if(popupStatus===0)
{
var body=document.getElementsByTagName('body')[0];
body.setAttribute('onresize','adaptPOPUP();');
var canvas=document.getElementById('canvas');
var scroll=getScroll();
var size=getPageSize();
var height=size[3]+scroll[0];
var width=size[0];
var top=loosePx(height)/2;
var left=loosePx(width)/2;
new Effect.Morph('canvas',{style:'top: '+top+'px;left: '+left+'px;',duration:0.1});
}
}
function hidePOPUP()
{
popupStatus=0;
var scroll=getScroll();
var size=getPageSize();
var height=size[3]+scroll[0];
var width=size[0];
var top=loosePx(height)/2;
var left=loosePx(width)/2;
document.getElementById('popup').innerHTML='';
new Effect.Morph('popup',{style:'background:transparent;width: 0px;height: 0px;top: '+top+'px;left: '+left+'px;',duration:0.2});
new Effect.Morph('canvas',{style:'background:transparent;width: 0px;height: 0px;top: '+top+'px;left: '+left+'px;',duration:0.2});
}
function adaptPOPUP()
{
if(popupStatus==1)
{
var size=getPageSize2();
var width=size[0];
var height=size[1];
new Effect.Morph('canvas',{style:'background:#000;width: '+width+'px;height: '+height+'px;top: 0px;left: 0px;',duration:0.1});
var popup=document.getElementById('popup');
height=getPageSize();
height=height[3];
var top=(loosePx(height)-474)/2;
var left=(loosePx(width)-723)/2;
new Effect.Morph('popup',{style:'top: '+top+'px;left: '+left+'px;',duration:0.1});
}
}