/*
<b>RedirectOpenerWindow(url,shouldCloseSelf) </b>
written by Matt Pressnall 05/16/05

<b>What does it do?</b>
Changes the URL of the opener / parent window and has the ability of closing the child / pop-off window if desired.

<b>How do I use it?</b>
(call to JS file needs to be on a page only once)
&lt;script type="text/javascript" src="/js/standardFunctionality/RedirectOpenerWindow.js"&gt;&lt;/script&gt; 
&lt;a href="javascript:RedirectOpenerWindow('http://www.pressnall.com','closeSelf')"&gt;Will close pop-off window&lt;/a&gt;
&lt;a href="javascript:RedirectOpenerWindow('http://www.pressnall.com',)"&gt;Will not close anything&lt;/a&gt;

<i>Parameters:</i>
url - the URL you want the opener to go to
shouldCloseSelf	(optional) - if you specify a second parameter, the pop off window will close
*/


function RedirectOpenerWindow(url,shouldCloseSelf){
	var isOpenerOpen;
	
	// test if opener window is open
	if(self.opener){
		if(! self.opener.closed){
			isOpenerOpen = 1;
		}
	} 
	
	// the opener is open...refresh the data in that window
	if(isOpenerOpen){
		self.opener.location.href = url;
		if(shouldCloseSelf){
			self.close();
		}
		self.opener.focus();
	// there is no opener window, open a new window
	} else {
		var myWindow = window.open(url,"something");
		if(shouldCloseSelf){
			if(this){
				self.opener = this;
				self.close();
			}
			if(self.parent){
				self.close();
			}
		}
		myWindow.focus();
	}
}