//jspopupwindow.js
//purpose: to be used with evergreenhiker.net...especially webres2001css.asp file.
//created by John J. Maher IV

//***********************************************************************************
//beginning of function

	//function popupwindow
	//purpose: to create code links page popup and associatted specific code pages. 
	//only one popup will be opened at all times

//need to make these vars global so can use value from prior function call
var win,gotourl,winflag,winflagstatus,oldwinflag,winname,filename,scroll,windowwidth,windowheight

function popupwindow(filename,winname,scroll,winwidth,winheight,winflag)
	{
		var screenWcenter,screenHcenter,leftOffset,heightOffset,windowfeatures;
		
		//getting screen center data
		screenWcenter	= parseInt(top.window.screen.width/2);		
		screenHcenter	= parseInt(top.window.screen.height/2);
		
		scrollstatus=scroll;
		windowwidth=winwidth;
		windowheight=winheight;
						
		//setting variables for centering popupwindow
		leftOffset		= parseInt(screenWcenter-(windowwidth/2));	
		heightOffset	= parseInt(screenHcenter-(windowheight/2));
		
		gotourl 			= filename;
		windowname		= winname;
		
		windowfeatures	="'" + 
					   		"toolbar=no," +
					   		
					   		//first refers to bottom scroll
					   		//second refers to right scroll 
					   		"scrollbars="+scrollstatus+",scrollbars="+scrollstatus+"," +
					   		"resizable=yes," +
					   		"width=" + windowwidth  + "," + 
					   		"height=" + windowheight + "," +
					   		"left=" +leftOffset + "," +
					   		"top=" + heightOffset + 
					  		"'";
		//setting value of winflagstatus based on passed winflag
		winflagstatus=winflag;
		//I need to use gotourl in condition so else clause works if filename is uncorrect or missing
		//If I don't do this, you'll get a popup with 404 'file not found' error message...not pretty! 
		if(gotourl=='xmlcode.asp' && winflagstatus=='tobeopened' && oldwinflag==null)
		{
			//testing code
			//alert("First function call");
			
			//this is an important var as it will let code know that 
			//popup is already opened
			oldwinflag='opened';
			
			win=window.open(gotourl,windowname,windowfeatures);
			win.focus();	
		}
		//going to specific code page
		//will for now, list all possible files to faciliate error trapping
		//error trap for file name misspellings...else clause will catch the error
		else if(gotourl=='resumexsd.asp'||gotourl=='resumexml.asp'||gotourl=='resumedtd.asp'||gotourl=='resumexslt.asp')
		{
			//testing code
			//alert("Going from xmlcode.asp to a specific code page!");
			//close current popup window...only want one popup at all times
			this.close();
			win=window.open(gotourl,windowname,windowfeatures);
			this.focus();
		}
		//going to xmlcode.asp from a specific code page
		else if(gotourl=='xmlcode.asp' && winflagstatus=='opened')
		{
			//testing code
			//alert("Going from a specific code page to xmlcode.asp and value of winflagstatus is "+winflagstatus+"!");
			//close current popup window...only want one popup at all times
			this.close();
			win=window.open(gotourl,windowname,windowfeatures);
			this.focus();
		}
		//we don't need to open another popup window unless it's been manually closed
		//oldwinflag will have a value so that indicates popup has been created.
		else if(winflagstatus=='tobeopened' && oldwinflag!=null)
		{
			//testing code
			//alert("Popup has been opened and oldwinflag is "+oldwinflag+"!!!!");		
			alert("Popup window is already opened and has been minimized.\r\r(if closed, please use Refresh or Reload button)");
		}
		//want to alert coder that he/she may need to change parameters such as gotourl and other vars
		else
		{
			alert("You may need to change parameter values for gotourl and other vars.");
		}
	}
		
		
//**********************************************************************************
// end of function 

function closewindow()
{
	this.close();
}


