// Preload rollovers
image011= new Image(119,29)
image011.src="images/mainnews.png" // Plain
image012= new Image(119,29)
image012.src="images/mainnews2.png" // Hover

image021= new Image(66,29)
image021.src="images/rips.png"
image022= new Image(66,29)
image022.src="images/rips2.png"

image031= new Image(150,29)
image031.src="images/wip.png"
image032= new Image(150,29)
image032.src="images/wip2.png"

image041= new Image(66,29)
image041.src="images/icons.png"
image042= new Image(66,29)
image042.src="images/icons2.png"

image051= new Image(115,29)
image051.src="images/cheat.png"
image052= new Image(119,29)
image052.src="images/cheat2.png"

buttons = new Array("maintop","ripstop","wiptop","iconstop","cheattop");
imageup = new Array(image012,image022,image032,image042,image052);
imagedown = new Array(image011,image021,image031,image041,image051);

// Cross Platform Pop-up script by Paul Priest
var ns4=document.layers
var ie4=document.all
var ns6=document.getElementById&&!document.all

var popWin_closed = true;
var popWin = null;

var buttonClicked = false;

function buttonIn(button) {
	document.images[buttons[button-1]].src=imageup[button-1].src;
	return true;
}

function buttonOut(button) {
	if(buttonClicked==true) return true;
	
	document.images[buttons[button-1]].src=imagedown[button-1].src;
	return true;
}

function buttonDown(button) {
	var i;

	// Popup all other buttons
	for(i=1;i<=5;i++) {
		if (i != button) document.images[buttons[i-1]].src=imagedown[i-1].src;
	}
	buttonClicked=true;
	return true;
}

function popup(mypage,w,h,scroll,pos) {

	closePopup();

	if(pos=="random") {
		LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
		TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
	}
	if(pos=="topleft") {
		LeftPosition=20;
		TopPosition=20;
	}
	else if((pos!="topleft" && pos!="random") || pos==null) {
		LeftPosition=(screen.width)?(screen.width-w)/2:100;
		TopPosition=(screen.height)?(screen.height-h)/2:100;
	}
	settings="width="+w+",height="+h+",top="+TopPosition+",left="+LeftPosition+",scrollbars="+scroll+",location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes";
	popWin=window.open("popup/"+mypage,"Flight",settings);
	popWin.focus();
	popWin_closed = false;
}

function closePopup() {
	if (!popWin_closed) {
		if(!popWin.closed) {
			popWin.close();
		}
		popWin_closed = true;
	}
}
