/*popup functions
 *created by Dean Spirov
 *requires showdiv(),hidediv()
 */
var img,fx,fy;
function popup(message,pwidth,pheight){
showdiv('popup');showdiv('popup_tint');
document.getElementById('innerpopup').innerHTML=message
document.getElementById('popup').style.marginTop='-'+(pheight+15+34)/2+'px'
document.getElementById('popup').style.marginLeft='-'+(pwidth+30)/2+'px'
document.getElementById('innerpopup').style.width=pwidth+'px'
document.getElementById('innerpopup').style.height=pheight+'px'
}
function imgpopup(fname){
showdiv('popup_tint');showdiv('loading');
img=new Image();img.src=fname;
if(img.width>0){img2(fname,false)}
else{
img.onload=function(){
img.onload=null
img2(fname,true)
} }
}
function img2(id,dia){
fx=img.width;fy=img.height
var a=75;
if(fx==0||fy==0){fx='',fy=''}
while(fx+30+a>window.innerWidth||fy+15+34+a>window.innerHeight){fx=fx*0.95;fy=fy*0.95}
popup('<img src="'+id+'" width="'+fx+'" height="'+fy+'" onclick="hidepopup()" />',fx,fy)
hidediv('loading')
}
function hidepopup(){
hidediv('loading');hidediv('popup');hidediv('popup_tint');
}
var iwidth,iheight
function iframedpopup(src,width,height){
showdiv('popup_tint');showdiv('loading');
popup('<iframe src="'+src+'" width="'+width+'" height="'+height+'"></iframe>',width,height)
}
