// set the popup window width and height

var windowW=250  // wide
var windowH=210 // high

// set vertical offset if you want the popup
// to rise above or stop below screen bottom;

var Yoffset=0   // in pixels, negative values allowed

// set the vertical motion parameters

var windowStep=2 // move increment (pixels)
var moveSpeed=8 // move speed (larger is slower)

// set the horizontal positioning of the window
// choices are left, center, right

Xmode="right";

// in left or right Xmode, set any offset from
// the screen edge here, if desired

Xoffset=0;

// set the url of the page to show in the popup

var urlPop = "/peeker.htm"

// set the title of the page

var title =  "Fuck Finder";

// set this to true if the popup should close
// upon leaving the launching page; else, false

var autoclose = false

// ============================
// do not edit below this line
// ============================

var windowX = (screen.width/2)-(windowW/2);
if (Xmode=="left") windowX=0+Xoffset;
if (Xmode=="right") windowX=screen.availWidth-Xoffset-windowW;
var windowY = (screen.availHeight);
var windowYstop = windowY-windowH-Yoffset;
var windowYnow = windowY;

s = "width="+windowW+",height="+windowH;
var beIE = document.all?true:false

function GetCookie (name) {
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen) {
      var j = i + alen;
      if (document.cookie.substring(i, j) == arg) return true;
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0) break; 
   }
   return null;
}

function openPeeker(){
  if (beIE){
//    PFW = window.open("","popFrameless","fullscreen,"+s)     
    PFW = window.open("","popFrameless",s)
    PFW.blur()
//    window.focus()
    PFW.resizeTo(windowW,windowH)
    PFW.moveTo(windowX,windowY)
    var frameString=""+
"<html>"+
"<head>"+
"<title>"+title+"</title>"+
"</head>"+
"<frameset rows='*' framespacing=0 border=0 frameborder=0>"+
"<frame src='"+urlPop+"' scrolling=no>"+
"</frameset>"+
"</html>"
    PFW.document.open();
    PFW.document.write(frameString)
    PFW.document.close()
  } else {
    PFW=window.open(urlPop,"popFrameless","scrollbars,"+s)
    PFW.blur()
//    window.focus() 
    PFW.resizeTo(windowW,windowH)
    PFW.moveTo(windowX,windowY)
  }   
  PFW.focus()   
  if (autoclose){
//    window.onunload = function(){PFW.close()}
  }
  setTimeout("movePFW()",10000);
  var today = new Date();
  var expire = new Date(today.getYear(),today.getMonth() + 1,today.getDate(),today.getHours(),today.getMinutes(),today.getSeconds());
  document.cookie = "peeker=true; expires="+expire.toGMTString();
}

function movePFW(){
  if (document.all){
    if (windowYnow>=windowYstop){
      PFW.moveTo(windowX,windowYnow);
      PFW.focus();
      windowYnow=windowYnow-windowStep;
      timer=setTimeout("movePFW()",moveSpeed);
    }else{
      clearTimeout(timer);
      PFW.moveTo(windowX,windowYstop);
      PFW.focus();
    }
  }else{
    PFW.moveTo(windowX,windowYstop);
  }
}

document.cookie = "run=yes";
if (GetCookie("run")) {
  if (! GetCookie("peeker")) { setTimeout('openPeeker()', 30000); }
}
