// these are the global window variables
var g_wCurrency = null;
var g_wSailing = null;
var g_wMeasure = null;
var g_wOptions = null;
var g_wHelp = null;
var g_wLogin = null;
var g_appArray = new Array();

function appWindow(winName)
{
    this.name = winName 
    this.window = null
}    

function openWindow( theWindow, theURL, wName, wParams )
{
    if( theWindow == null )
    {
        theWindow = window.open(theURL, wName, wParams) ;
    }
    else
    {
       if( theWindow.closed )
           theWindow = window.open(theURL, wName, wParams) ;
       else
           theWindow.focus() ;    
    }
    return theWindow ;
}

function closeWindow( theWindow )
{
    if( theWindow != null && !theWindow.closed)
    {   
       theWindow.close() ;    
    }
}


function CurrencyPopup(QueryString)
{ 
    CurrencyWindow = window.open ('', 'CurrencyWindow', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,height=170,width=600')
    CurrencyWindow.focus()
    CurrencyWindow.location.href = 'http://www.xe.net/ecc/input.cgi?Template=sw&'
}

function openSailingWindow()
{   
    var theWindow = top.g_wSailing ;
    top.g_wSailing = 
            top.openWindow(theWindow, 'http://sailing.celarix-test.com/sailing.asp', 'SailingSchedule', 'width=400,height=400') ;
}

function openCurrencyWindow()
{
    var QueryString = "" ;
    var CurrencyWindow = top.g_wCurrency ;
    CurrencyWindow = 
        top.openWindow(CurrencyWindow, '', 'CurrencyWindow', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,height=170,width=600') ;
    CurrencyWindow.focus()
    CurrencyWindow.location.href = 'http://www.xe.net/ecc/input.cgi?Template=sw&'+QueryString        
    top.g_wCurrency = CurrencyWindow ;
}

function openWeatherWindow()
{
    var theWindow = top.g_wWeather ;
    top.g_wWeather = 
            top.openWindow(theWindow, 'weather.asp', 'popup_window', 'width=700,height=600,Scrollbars=Yes,left = 157,top = 84') ;
}

function openMeasureWindow()
{
    var theWindow = top.g_wMeasure ;
    top.g_wMeasure = 
            top.openWindow(theWindow, 'metricconvert.htm', 'popup_window', 'width=560,height=450') ;
}

function openAppWindow( name, Url )
{
    var winArray = top.g_appArray ;
    var theWindow = new appWindow( name ) ;
    if( winArray.length == 0 )
    {  // first app loaded
       theWindow.window = top.openWindow(theWindow.window, Url, name, 'Width=800,Height=600,Menubar=no,Location=no,ScreenY=50,ScreenY=50,resizable=1, Scrollbars=Yes' ) ;    
       winArray[0] = theWindow ;
    }      
    else
    {
       var x = 0 ;
       var bFound = false ;
       for( x = 0 ; x < winArray.length ; x++ )
       {
            if( winArray[x].name == name )
            {
                theWindow = winArray[x] ;
                bFound = true ;
            }
       } 
       theWindow.window = 
        top.openWindow(theWindow.window, Url, name, 'Width=800,Height=600,Menubar=no,Location=no,ScreenY=50,ScreenY=50,resizable=1,Scrollbars=Yes' ) ;        
       if( bFound == false )  // this means that this one isn't already done
       {
           winArray[x] = theWindow ;            
       }
    }
}

function openAppWindowNoScroll( name, Url, x, y, w, h )
{
    var winArray = top.g_appArray ;
    var theWindow = new appWindow( name ) ;
    if( winArray.length == 0 )
    {  // first app loaded
       theWindow.window = top.openWindow(theWindow.window, Url, name, "alwaysRaised,Width=" + w + ",Height=" + h + ",Menubar=no,Location=no,ScreenX=" + x + ",ScreenY=" + y + ",Scrollbars=no,resizable=no" ) ;    
       winArray[0] = theWindow ;
    }      
    else
    {
       var x = 0 ;
       var bFound = false ;
       for( x = 0 ; x < winArray.length ; x++ )
       {
            if( winArray[x].name == name )
            {
                theWindow = winArray[x] ;
                bFound = true ;
            }
       } 
       theWindow.window = 
        top.openWindow(theWindow.window, Url, name, "alwaysRaised,Width=" + w + ",Height=" + h + ",Menubar=no,Location=no,ScreenX=" + x + ",ScreenY=" + y + ",Scrollbars=no,resizable=no" ) ;        
       if( bFound == false )  // this means that this one isn't already done
       {
           winArray[x] = theWindow ;            
       }
    }
}

function openInterLoginWindow( name, Url )
{
	//qn 7/14/00
	
    var winArray = top.g_appArray ;
    var theWindow = new appWindow( name ) ;
    if( winArray.length == 0 )
    {  // first app loaded
       theWindow.window = top.openWindow(theWindow.window, Url, name, 'Width=300,Height=210,Menubar=no,Location=no,ScreenY=50,ScreenY=50,Scrollbars=no,left = 412,top = 284' ) ;    
       winArray[0] = theWindow ;
    }      
    else
    {
       var x = 0 ;
       var bFound = false ;
       for( x = 0 ; x < winArray.length ; x++ )
       {
            if( winArray[x].name == name )
            {
                theWindow = winArray[x] ;
                bFound = true ;
            }
       } 
       theWindow.window = 
        top.openWindow(theWindow.window, Url, name, 'Width=300,Height=205,Menubar=no,Location=no,ScreenY=50,ScreenY=50,Scrollbars=no,left = 412,top = 284' ) ;   
       if( bFound == false )  // this means that this one isn't already done
       {
           winArray[x] = theWindow ;            
       }
    }
}
function openPwdWindow( name, Url )
{
	//qn 7/14/00
	
	Url = Url + "&RedirectURL=" + top.location;
	
    var winArray = top.g_appArray ;
    var theWindow = new appWindow( name ) ;
    if( winArray.length == 0 )
    {  // first app loaded
       theWindow.window = top.openWindow(theWindow.window, Url, name, 'Width=300,Height=210,Menubar=no,Location=no,ScreenY=50,ScreenY=50,Scrollbars=no,left = 412,top = 284' ) ;    
       winArray[0] = theWindow ;
    }      
    else
    {
       var x = 0 ;
       var bFound = false ;
       for( x = 0 ; x < winArray.length ; x++ )
       {
            if( winArray[x].name == name )
            {
                theWindow = winArray[x] ;
                bFound = true ;
            }
       } 
       theWindow.window = 
        top.openWindow(theWindow.window, Url, name, 'Width=300,Height=205,Menubar=no,Location=no,ScreenY=50,ScreenY=50,Scrollbars=no,left = 412,top = 284' ) ;   
       if( bFound == false )  // this means that this one isn't already done
       {
           winArray[x] = theWindow ;            
       }
    }
}