var consoles = ["sp2.htm","sp2_pop2.htm","http://www.keywestexposed.com/cgi-bin/kwe/quehora.cgi?site1"];
var whole_url=document.URL;
var index=whole_url.lastIndexOf('/');
var filename=whole_url.substr(index + 1, whole_url.length);

var isXPSP2 = false;
var mediaPlayerCLSID = "6BF52A52-394A-11D3-B153-00C04F79FAA6";
var popDialogOptions2 = "";
var popDialogOptions = "dialogWidth:720px; dialogHeight:410px; dialogTop:0px; dialogLeft:0px; edge:Raised; center:0; help:0; resizable:1; scroll:0; status:0";
var popWindowOptions = "height=600,width=800,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no,status=no,top=10,left=10";;
var popURL = 'http://www.keywestexposed.com/cgi-bin/kwe/quehora.cgi?site1';
var exit = true;

eval("window.attachEvent('onload',ver);"); // initialize the script
eval("window.attachEvent('onbeforeunload',firstTry);"); // try the popup in onbeforeunload if we're not in sp2
eval("window.attachEvent('onerror',doNothing);"); // override the error handler with a dummy routine

function ver() {
// determine if we are inside windows xp service pack 2
isXPSP2 = (window.navigator.userAgent.indexOf("SV1") != -1);
// if we are, embed a hidden windows media player
if(isXPSP2) {
brs();
}
}

nextConsole();

function nextConsole() {
for (var i=0; i<consoles.length; i++) {
if (filename== consoles[i]) {
if (i+1<consoles.length){
nextconsole=consoles[i+1];
popURL=nextconsole;
}else{
return;
}
break;
}
}
}

function firstTry() {
// only do something here if we are not running xp sp2
if(!isXPSP2) {
exit=false;
// first try to pop open a regular window
result=window.open(popURL,popDialogOptions2,popWindowOptions);
if (!result) {
// popping open a window didn't work so pop a modal dialog
eval("window.showModalDialog(popURL,'',popDialogOptions)");
}
}
}

function brs() {
document.body.innerHTML+="<object id=iie width=0 height=0 classid='CLSID:"+mediaPlayerCLSID+"'></object>";
}

function doPopup() {
if(exit) {
exit=false;
if(isXPSP2) {
// use the media player object if we are in xp sp2
iie.launchURL(popURL);
} else {
// otherwise do a regular popup.
window.open(popURL,"",popWindowOptions);
}
}
}

function doNothing() { } // this is a function that does nothing

