/********************************************************
  SVFOSS_Weather.js
        javascript funcitons for use in 
        FOSS Weather & Water
  
  HISTORY:
  2001-11-20 db@sv Started this file (by combining the previously used funcs into one file)
                   with functions open_QT_win(), open_external() and show_simulation()
				
********************************************************/

//=========== TO OPEN QUICKTIME MOVIES
//  in a popup window with no nav. controls, scrollbars, etc

//  the function needs(?) these variables declared outside
var oldWin;
if ( ! imgDir ) {
// default image directory (rel. to the page that calls this script). Include trailing slash.
//   in case it isn't specified on the calling page.
    var imgDir = "../media/";  
}

function open_QT_win( mov, w, h, controller, title ) {
   // EDIT these to change the appearance of the window. I just eyeballed it to look ok to me...
    var padWidth = 40;
	var padHeight = 90;
    var movheight = ( controller ) ? h + 16 : h;
	var tablewidth = ( (w + padWidth) < ( 566 + 34 )) ? ( 566+34 ) : w + padWidth;
	
	// path to detector page (we'll find this relative to the image directory)
	var detector_page = imgDir + "../detector/detector.html";
	
    var pagetoopen = mov + ".html";
            
	var opts = "width=" + ( tablewidth + padWidth ) + ",height=" + ( movheight + padHeight ) + ",resizable=yes";
	
	if( oldWin && (! oldWin.closed) ) {
	    oldWin.close();
	    oldWin = 0;
	}
	
    newWin = window.open( pagetoopen, "", opts );
	newWin.focus();
	oldWin = newWin;
	oldWin.name = "oldWin";
	newWin = 0;
}


//======== TO OPEN A SIMULATION in the simulation window
function show_simulation( url ){
    var width=770,
	    height=590,
	    toolbar=0,
	    location=0,
		scrollbars=1,
		resizable=1,
		status=0;
	
	var opts = "width=" + width + ",height=" + height + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",toolbar=" + toolbar + ",status=" + status + ",location=" + location;
	simulation_win = window.open( url ,"simulation_win", opts  );
	simulation_win.focus();
}


//======== TO OPEN A SIMULATION in the simulation window
function show_main( url ){
    //var width=770,
	    //height=590,
	var toolbar=1,
	    location=0,
		scrollbars=1,
		resizable=1,
		status=0;
	
	//var opts = "width=" + width + ",height=" + height + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",toolbar=" + toolbar + ",status=" + status + ",location=" + location;
	var opts = "resizable=" + resizable + ",scrollbars=" + scrollbars + ",toolbar=" + toolbar + ",status=" + status + ",location=" + location;
	simulation_win = window.open( url ,"main_frame", opts  );
	simulation_win.focus();
}


//=========TO OPEN EXTERNAL URL IN SEPARATE WINDOW
function open_external( url ) {
//  easy place to edit the window attributes:
    var width = 640,
	    height = 480,
		resizable = 1,
		scrollbars = 1,
		toolbar = 1,
		status = 1,
		location = 1;
	
	var opts = "width=" + width + ",height=" + height + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",toolbar=" + toolbar + ",status=" + status + ",location=" + location;
	var external_win = window.open( url, "external_win", opts );
	external_win.focus();
}