// JavaScript Document
// CREDITS:
// Flying Popup
// By Urs Dudli and Peter Gehrig
// Copyright (c) 2002 Peter Gehrig and Urs Dudli. All rights reserved.
// Permission given to use the script provided that this notice remains as is.
// Additional scripts can be found at http://www.24fun.com
// info@24fun.com
// 4/24/2002

// IMPORTANT:
// If you add the Flying Popup to a script-library or script-archive
// you have to add a highly visible link to
// http://www.24fun.com on the webpage
// where this script will be featured

var popwindow
var thistoolbar="no"
var thislocation="no"
var thisdirectories="no"
var thisstatus="no"
var thismenubar="no"
var thisscrollbars="no"
var thisresizable="no"
var thisurl="shortpop.htm"
var thiswidth="200"
var thisheight="250"
var thisdirection="horitop"

var thistopposition="200"
var thisleftposition="200"
var thisfullscreen="no"
var pause=20
var stepfactor=10
var stepx
var stepy
var marginpadding=30
var startleft=0
var endleft=0
var starttop=0
var endtop=0
var marginleft=0
var margintop=0
var marginright
var marginbottom
var timer
var i_shakemax=3
var i_shakenow=0
function initpopup() {
setmovevalues()
openpopup()
movewindow()
}

function setmovevalues() {
marginright=screen.width
marginbottom=screen.height
if (thisdirection=="horitop") {
startleft=marginleft
endleft=marginright-thiswidth-marginpadding
starttop=marginpadding
endtop=starttop
stepx=stepfactor
stepy=0
}
if (thisdirection=="horimiddle") {
startleft=marginleft
endleft=marginright-thiswidth-marginpadding
starttop=Math.round((marginbottom-thisheight)/2)
endtop=starttop
stepx=stepfactor
stepy=0
}
if (thisdirection=="horibottom") {
startleft=marginleft
endleft=marginright-thiswidth-marginpadding
starttop=marginbottom-thisheight-2*marginpadding
endtop=starttop
stepx=stepfactor
stepy=0
}
if (thisdirection=="vertileft") {
startleft=marginleft
endleft=startleft
starttop=marginpadding
endtop=marginbottom-thisheight-2*marginpadding
stepx=0
stepy=stepfactor
}
if (thisdirection=="vertimiddle") {
startleft=Math.round((marginright-thiswidth)/2)
endleft=startleft
starttop=marginpadding
endtop=marginbottom-thisheight-2*marginpadding
stepx=0
stepy=stepfactor
}
if (thisdirection=="vertiright") {
startleft=marginright-thiswidth-marginpadding
endleft=marginright-thiswidth-marginpadding
starttop=marginpadding
endtop=marginbottom-thisheight-2*marginpadding
stepx=0
stepy=stepfactor
}
}

function openpopup() {
popwindow=window.open(thisurl, "newwindow", "toolbar="+thistoolbar+",location="+thislocation+",directories="+thisdirectories+",status="+thisstatus+",menubar="+thismenubar+",scrollbars="+thisscrollbars+",resizable="+thisresizable+",width="+thiswidth+",height="+thisheight+",top="+starttop+",left="+startleft+",fullscreen="+thisfullscreen+"")
popwindow.focus()
}

function movewindow() {
window.onerror=shownoerrormessage
popwindow.focus()
if ((starttop<=endtop) && (startleft<=endleft)){
if (popwindow) {
popwindow.moveTo(startleft,starttop)
}
startleft+=stepx
starttop+=stepy
timer=setTimeout("movewindow()",pause)
}
else {
clearTimeout(timer)
if (popwindow) {
popwindow.moveTo(endleft,endtop)
popwindow.focus()
}
}
}

function shownoerrormessage() {
return false;
}
window.onload=initpopup

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
