// ///////////////////////////////////////////////////////////////////////////////////////////
//      SCRIPT NAME:	newWin.js
//    SCRIPT AUTHOR:	Mark Vega
//      SCRIPT DATE:	March 2007
//  SCRIPT LOCATION:	pitcairn://target1s3/Web2/htdocs/www/libraries/grunigen/scripts/
//  SCRIPT FUNCTION:	Reusable object for opening pop-up windows.	
//     SCRIPT NOTES:	Creates new pop-up window object when passed the following 
//                  	parameters:
//						newwinurl	(url of page to display)
//						newwintype	(currently alert,flash,im,info,link,lookup,map,monitor)
//                  	
//                  	To add a new newwintype, create a new empty variable (e.g., alertWin)
//                   	and a corresponding attribute string (e.g., alertwinatts).  Function
//                   	can be called from any 'a' tag by assigning
//                   	
//                   	javascript:newWin(newwinurl,newwintype);
//
//                   	as the value of the href property.                 
// OTHER FILES USED:
//    LAST MODIFIED:	Changed all paths for new home on pitcairn.  06/13/2007 MFV
//                  	Added 'core' window type to open Core Resources links in new window 
//                  	  without reusing window.  10/02/2007 MFV
//
// ///////////////////////////////////////////////////////////////////////////////////////////
//
// initialize global variables
var alertWin = '';
var flashWin = '';
var imWin = '';
var infoWin = '';
var linkWin = '';
var lookupWin = '';
var mapWin = '';
var monitorWin = '';
var qtWin = '';
var searchWin = '';
var newwin = '';
var newwinatts = '';
var newwinname = '';
var newwintype = '';
var newwinurl = '';
var alertwinatts = "height=150,width=300,top=200,left=200,screenX=200,screenY=200,toolbar=no,location=no,directories=no,personalbar=no,status=no,menubar=no,scrollbars=yes,resizable=no";
var flashwinatts = "height=270,width=480,top=280,left=185,screenX=280,screenY=185,toolbar=no,location=no,directories=no,personalbar=no,status=no,menubar=no,scrollbars=no,resizable=no";
var imwinatts = "height=260,width=460,top=30,left=30,screenX=30,screenY=30,toolbar=no,location=no,directories=no,personalbar=no,status=no,menubar=no,scrollbars=yes,resizable=no";
var infowinatts = "height=250,width=450,top=30,left=30,screenX=30,screenY=30,toolbar=no,location=no,directories=no,personalbar=no,status=no,menubar=no,scrollbars=yes,resizable=no";
var linkwinatts = "height=600,width=800,top=30,left=100,screenX=30,screenY=100,toolbar=yes,location=yes,directories=yes,personalbar=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes";
var lookupwinatts = "height=300,width=500,top=30,left=30,screenX=30,screenY=30,toolbar=no,location=no,directories=no,personalbar=no,status=no,menubar=no,scrollbars=yes,resizable=no";
var mapwinatts = "height=300,width=450,top=30,left=30,screenX=30,screenY=30,toolbar=no,location=no,directories=no,personalbar=no,status=no,menubar=no,scrollbars=yes,resizable=yes";
var monitorwinatts = "height=140,width=240,top=30,left=30,screenX=30,screenY=30,,toolbar=no,location=no,directories=no,personalbar=no,status=no,menubar=no,scrollbars=no,resizable=yes";
var qtwinatts = "height=290,width=480,top=200,left=190,screenX=200,screenY=190,toolbar=no,location=no,directories=no,personalbar=no,status=no,menubar=no,scrollbars=no,resizable=no";
var searchwinatts = "height=600,width=800,top=30,left=100,screenX=30,screenY=100,toolbar=yes,location=yes,directories=yes,personalbar=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes";

//
// FUNCTION TO OPEN NEW WINDOW
//
// opens winurl in pop-up window with attributes determined by wintype
//
function newWin(newwinurl,newwintype) {
// initialize local variables
var newwin = '';
var newwinname = newwintype + "Win";
// check value of newwinname to determine atts string
switch(newwinname) {
case 'alertWin':
newwinatts = alertwinatts;
break;
case 'flashWin':
newwinatts = flashwinatts;
break;
case 'imWin':
newwinatts = imwinatts;
break;
case 'linkWin':
newwinatts = linkwinatts;
break;
case 'lookupWin':
newwinatts = lookupwinatts;
break;
case 'infoWin':
newwinatts = infowinatts;
break;
case 'mapWin':
newwinatts = mapwinatts;
break;
case 'monitorWin':
newwinatts = monitorwinatts;
break;
case 'qtWin':
newwinatts = qtwinatts;
break;
case 'searchWin':
newwinatts = searchwinatts;
break;
default:
newwinatts = '';
}
/*
// if request is from core resources sidebar
if (newwintype == 'link') {
// open url in new window, and focus window
if (newwin = window.open(newwinurl,'',newwinatts)) {
newwin.focus();
} else {
alert("Could not open new window. Please disable your browser's pop-up blocker or add medical.lib.uci.edu as a trusted site in your browser preferences.");
}
// all other requests
} else {
	*/
// if window already open and not linkWin
if (!newwin.closed && newwin.location && !newwin.name == '') {
// load new url and focus window
newwin.location.href = newwinurl;
// DEBUG WRITE STATEMENT
// alert(window.name);
newwin.focus();
// if window not already open
} else {
// open url in new window and focus window
if (newwin = window.open(newwinurl,newwinname,newwinatts)) {
newwin.focus();
} else {
alert("Could not open new window. Please disable your browser's pop-up blocker or add medical.lib.uci.edu as a trusted site in your browser preferences.");
}
}
}
/* } */
//
// END