// Instructions:

// Step 1.
// Paste *this* script into the head of
// the launching page.

// Step 2.
// To launch *this* script, put this in 
// the body tag of the launch page:
// <body onload="doFlyMe()">

// Step 3.
// You *must* put onload event in the page
// that opens in the popup window (holds
// focus), like this:
// <body onblur="self.focus()">

// Step 4.
// Edit the variables as indicated below.

// Set url of popup page
var URL= "/popup.htm";


// Set size of popup
var W= 390; // not less than 100
var H= 560; // not less than 100

// Set margin from edge of screen
var M= 30;

// Set speed
var speed = 25;

// Set increment of motion
var increment = 16;

// Do not edit below this line
//============================
var nowY=M;var nowX=M;
var theWidth=window.screen.width;
var theHeight=window.screen.height;
var limitX=theWidth-W-M;
var limitY=theHeight-H-M;
var s="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,  resizable=no,width="+W+",height="+H;

function doFlyMe(){
	P=window.open(URL,"A",s);  
	P.resizeTo(W,H);
	P.moveTo(M,M);
	P.focus(); 
	D();
}

function D(){
	if (nowY<=limitY){
		P.moveTo(nowX,nowY);
		P.focus();
		nowY+=increment;
		T=setTimeout("D()",speed);
	} else {
		clearTimeout(T);
		nowY=limitY;
		P.moveTo(nowX,nowY);
		P.focus();
		U();
	}
}

function R(){
	if (nowX<=limitX){
		P.moveTo(nowX,nowY);
		P.focus();
		nowX+=increment;
		T=setTimeout("R()",speed);
	}else{
		clearTimeout(T);
		nowX=limitX;
		P.moveTo(nowX,nowY);
		P.focus();
		U();
	}
}

function U(){
	if (nowY>=M){
		P.moveTo(nowX,nowY);
		P.focus();
		nowY-=increment;
		T=setTimeout("U()",speed);
	}else{
		clearTimeout(T)
		nowY=M;
		P.moveTo(nowX,nowY);
		P.focus();
		L();
	}
}

function L(){
	if (nowX>=M){
		P.moveTo(nowX,nowY);
		P.focus();
		nowX-=increment;
		T=setTimeout("L()",speed);
	}else{
		clearTimeout(T);
		nowX=M;
		P.moveTo(nowX,nowY);
		P.focus();
	}
}

doFlyMe();
