﻿// Set the horizontal and vertical position for the popup

PositionX = 100;
PositionY = 100;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = 500;
defaultHeight = 500;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
writeln('width=250-(document.body.clientWidth-document.images[0].width);');
writeln('height=100-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
close();		
}}

// Launches Heck Yes! SWFs in a popup window.
//
// File name is analyzed and popup window sized accordingly
// 
// The script determines if the file to 'popup' is named something like this:
// 
//     *_500390pm.html
//     *_375570pmz.html
//     *_650425pmzi.html
// 
//     etc.
// 
// 
// If the file matches, the Width and Height of the popup window is set automatically.
// 
// If the filename does not match, the popup uses the width and height sent as arguments to the popup script.
// 
// If the filename does not match and arguments were not sent to the script, default values of 650x650 are used as the popup dimensions.
// 
// 
// Usage for text link:
//		
//		Minimum requirement - sending URL to the function.  The script will correctly determine the window should be 500x425.
//		<a href="http://heckyesproductions.com/acme/ACM_001/rocketSkates/rocketSkates_500300pmz.swf" onclick="NewWindowII(this.href);return false">launch</a>
//		
//		or use the script to launch some other file on the web.  Set the width to 276 and height to 110
//		<a href="http://www.google.com/intl/en_ALL/images/logo.gif" onclick="NewWindowII(this.href,'myPopupName','276','110');return false">launch</a>
//		
//		
//		or use the script to launch some other file on the web and don't set the width.  The popup will be dafault of 650 wide and 650 high
//		<a href="http://www.google.com/intl/en_ALL/images/logo.gif" onclick="NewWindowII(this.href,'myPopupName');return false">launch</a>	
//		
		
function NewWindowII(mypage,myname,w,h){

	var win = null;
	
	// Assign default if arguments not passed in
	myname = typeof(myname) != 'undefined' ? myname : "someName";
	w = typeof(w) != 'undefined' ? w : 650;
	h = typeof(h) != 'undefined' ? h : 650;
	
	
	// Match file suffixes: _500390pm.html, _375570pmz.html, _650425pmzi.html, etc.
	regex = new RegExp("_([0-9]{3})([0-9]{3})([a-zA-Z]{3,4})\.([a-zA-Z]{3,4})");
	
	// Create array from backrefs (e.g. "_500425pmz.html", "500", "425", "pmz", "html")
	fileSuffix = regex.exec(mypage);
	
	// Set width, height from backrefs.  Defaults determined above: w, h
	x = fileSuffix ? (fileSuffix[1]) : w;
	y = fileSuffix ? (fileSuffix[2]) : h;
	
	LeftPosition = screen.width ? (screen.width-x)/2 : 0;
	TopPosition = screen.height ? (screen.height-y)/3 : 0;
	
	settings = 'height='+y+',width='+x+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no,resizable=yes';
	myname = x.toString() + y.toString();
	
	//alert("\n\n mypage: "+mypage+"\n\n regex: "+regex+"\n\n fileSuffix (null if not matched): "+fileSuffix+"\n\n x: "+x+"\n\n y: "+y+"\n\n TopPosition: "+TopPosition+"\n\n LeftPosition: "+LeftPosition+"\n\n settings: "+settings+"\n\n myname: "+myname);
	
	win = window.open(mypage,myname,settings);
	win.focus();
	
}
