/*
	popup code used to launch window holding Flash 
	for use as follows:
		<a href="file.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) {
	 
	 //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-8;
		//strScreenHeight = screen.availHeight-40;
		strScreenWidth = screen.availWidth;
		strScreenHeight = screen.availHeight;
	 } else {
		// if one of the passed parameters is blank, use the screen info instead
		strScreenWidth = (strWidth=="")? screen.availWidth-8 : strWidth;
		strScreenHeight = (strHeight=="")? screen.availHeight-40 : strHeight;
	 }
	 
	 var tools="";
	 if (type == "standard" ) {
	  newTop = 0;
	  newLeft = (screen.availWidth-strWidth-10)/2;
	  tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strScreenWidth+",height="+strScreenHeight+",left="+newLeft+",top="+newTop;
	 }
	if (type == "fullScreen") {
	  tools = "resizable=yes,toolbar=no,location=no,scrollbars=no,menubar=no,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);
	   	}
 	}
}	