/*
	popup code used to launch window holding Flash version of Horizons site
	for use as follows:
		<a href="horizons.html" 
			onClick="popTypedWin(this.href,'newWin','console',756,520);return false;" 
			onKeyPress="this.onClick();" 
			target="newWin" 
			title="This site requires Flash 6.">Flash site</a>
*/
var newWindow = this;
if(self.opener){
	var theOpener = self.opener.name;
}
var theText = "";

function closeWin(){
	if (newWindow != null){
		if(!newWindow.closed){
			//alert('newwindow.name='+newwindow.name);
			newWindow.close();
		}
	}
}

function popTypedWin(url, windowname, type, strWidth, strHeight) {
	/*if(self.name == windowname){
		self.name="blech"
	};*/
	//closeWin();//close any open window
	//alert("called popwin"+self.name);
	if (type == "fullScreen" || type == "console") {//if this is a fullscreen popup, get the screen properties to center the window
		strScreenWidth = screen.availWidth - 10;
		strScreenHeight = screen.availHeight - 160;
	}
	
	var tools="";
	if (type == "standard" || type == "fullScreen") {
		tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strScreenWidth+",height="+strScreenHeight+",top=0,left=0";
	}
	if (type == "console") {
		newTop = 10;//(strScreenHeight-strHeight)/2
		newLeft = (strScreenWidth-strWidth-10)/2;
		tools = "resizable=no,toolbar=no,location=no,scrollbars=no,width="+strWidth+",height="+strHeight+",left="+newLeft+",top="+newTop+"";
	}
	//alert("newLeft "+newLeft + " "+newTop + " " +strWidth);
	newWindow = window.open(url, windowname, tools);
	newWindow.name=windowname;
	newWindow.focus();
	newWindow.opener = self;
}

function setFlashWindow(url){
	popTypedWin(url,'VMCAux','console',756,520);
	//self.close();
}

function openFlashWindow(url) {
   if (!self.opener) {
       // Opener has not yet been defined, get the center point for a new window
	   // alert("opener not defined");
	   setFlashWindow(url);
	   
    } else {//check to see if the window.opener is still open

	  	if (!self.opener.closed&&(theOpener=="newWin"||theOpener=="VMCAux"||self.opener.name=="newWin"||self.opener.name=="VMCAux")) {
	        // alert("opener is still open")
			self.opener.focus();
			//give a little time for the app window to focus, then close this window
			setTimeout("closeWin()",500);
		   		
	 	} else {
		   	// Opener has been defined, but is now closed
		    // alert("opener has been defined, but is now closed");
			setFlashWindow(url);
	   	}
 	}
}	