/********************************************************
  svfoss_window.js
        javascript window funcitons for use in FOSS multimedia
  
  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()
  2/3/2005   cc@sv Modified for FOSS mm titles
				
********************************************************/

var undefined; // for older browsers that don't support undefined

var offsetX = 0;
var offsetY = 0;

//=========== 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/";  
}


//======== To open a binder page in a large window
function open_binder( url, winName ){
    var width=770,
	    height=590,
	    toolbar=1,
		menubar=1,
	    location=1,
		scrollbars=1,
		resizable=1,
		status=0;
		
		if (winName == undefined) winName = "binder_win";
	
	var opts = "width=" + width + ",height=" + height + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",toolbar=" + toolbar + ",menubar=" + menubar + ",status=" + status + ",location=" + location;
	simulation_win = window.open( url ,winName, opts  );
	simulation_win.focus();
}

function open_external( url, winName ){
    var width=770,
	    height=590,
	    toolbar=1,
		menubar=1,
	    location=1,
		scrollbars=1,
		resizable=1,
		status=0;
		
		if (winName == undefined) winName = "external_win";
	
	var opts = "width=" + width + ",height=" + height + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",toolbar=" + toolbar + ",menubar=" + menubar + ",status=" + status + ",location=" + location;
	simulation_win = window.open( url ,winName, opts  );
	simulation_win.focus();
	
}

//======== To open an activity in a large window
function open_activity( url, winName ){
    var width=770,
	    height=590,
	    toolbar=1,
	    location=1,
		scrollbars=0,
		resizable=1,
		status=0;
		
		if (winName == undefined) winName = "activity_win";
	
	var opts = "width=" + width + ",height=" + height + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",toolbar=" + toolbar + ",status=" + status + ",location=" + location;
	simulation_win = window.open( url ,winName, opts  );
	simulation_win.focus();
}

//======== To open sand photo zoom windows
function open_sandzoom( url, winName ){
    var width=770,
	    height=590,
	    toolbar=1,
	    location=1,
		scrollbars=0,
		resizable=1,
		status=0;
		
		if (winName == undefined) winName = "activity_win";
	
	var opts = "width=" + width + ",height=" + height + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",toolbar=" + toolbar + ",status=" + status + ",location=" + location;
	simulation_win = window.open( url ,winName, opts  );
	simulation_win.focus();
	if (offsetX == undefined) {
		offsetX = 0;
		offsetY = 0;
	} else {
		offsetX += 20;
		offsetY += 20;
	}
	simulation_win.moveBy(offsetX ,offsetY);
}

//======== To open an activity in a small window
function open_activitySM( url, winName ){
    var width=640,
	    height=480,
	    toolbar=1,
	    location=1,
		scrollbars=0,
		resizable=1,
		status=0;
		
		if (winName == undefined) winName = "activity_win_sm";
	
	var opts = "width=" + width + ",height=" + height + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",toolbar=" + toolbar + ",status=" + status + ",location=" + location;
	simulation_win = window.open( url ,winName, opts  );
	simulation_win.focus();
}

//=========To open an activity window at fixed size, but resizable (
function open_sw_activity( url, winName ){
    var width=640,
	    height=480,
	    toolbar=0,
	    location=0,
		scrollbars=0,
		resizable=1,
		status=0;
		
		if (winName == undefined) winName = "activity_win";
	
	var opts = "width=" + width + ",height=" + height + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",toolbar=" + toolbar + ",status=" + status + ",location=" + location;
	simulation_win = window.open( url ,winName, opts  );
	simulation_win.focus();
}
//=========To open an activity window at fixed size (
function open_sw_activity_fixed( url, winName ){
    var width=640,
	    height=480,
	    toolbar=0,
	    location=0,
		scrollbars=0,
		resizable=0,
		status=0;
		
		if (winName == undefined) winName = "activity_win";
	
	var opts = "width=" + width + ",height=" + height + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",toolbar=" + toolbar + ",status=" + status + ",location=" + location;
	simulation_win = window.open( url ,winName, opts  );
	simulation_win.focus();
}

//=========To open a help window at fixed size (
function open_help( url, winName ){
    var width=640,
	    height=480,
	    toolbar=0,
	    location=0,
		scrollbars=0,
		resizable=0,
		status=0;
		
		if (winName == undefined) winName = "help_win";
	
	var opts = "width=" + width + ",height=" + height + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",toolbar=" + toolbar + ",status=" + status + ",location=" + location;
	simulation_win = window.open( url ,winName, opts  );
	simulation_win.focus();
}

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 binder page window large
function show_mainx( 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();
}


