function myOpenWindow(mylink, windowname, winFeatures, winObj)
{
  var theWin; // this will hold our opened window 

  // first check to see if the window already exists
  if (winObj != null)
  {
    // the window has already been created, but did the user close it?
    // if so, then reopen it. Otherwise make it the active window.
    if (!winObj.closed) {
	      //winObj.focus();
		  winobj.close();	//force close
		  var href;
		 if (typeof(mylink) == 'string')
		 href=mylink;
		 else
		 href=mylink.href; 
		 theWin= window.open(href, windowname, winFeatures);		
		 return theWin;			   
     	// return winObj;
    } 
    // otherwise fall through to the code below to re-open the window
  }

  // if we get here, then the window hasn't been created yet, or it
  // was closed by the user.
 var href;
 if (typeof(mylink) == 'string')
 href=mylink;
 else
 href=mylink.href; 
// theWin= window.open(href, windowname, 'width=318,height=' + height + ',left=150,top=200');
  theWin= window.open(href, windowname, winFeatures);
 
 // theWin.document.alert(height);
  //theWin = window.open(winURL, winName, winFeatures); 
  return theWin;
} 

/*
function popUp(url, myname, w, h, scroll) 
{ 
	var winl = (screen.width - w) / 2;
	var wint = ((screen.height - h) / 2)-20;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',toolbar=0, status=0, resizable=0,menubar=0'
	eval(myname+" = window.open(url, myname, winprops)");
	if (parseInt(navigator.appVersion) >= 4) { eval(myname+".window.focus()"); }
}

function checkWindow(namez) 
{
	try{
		if(eval("window."+namez+".document"))
		{
			alert("Window \""+namez+"\" open");
		}
		else
		{
			alert("Window \""+namez+"\" not found");
		}
	}
	catch(e) 
	{
		alert("Window \""+namez+"\" not found");
	}
}
*/

/***** SIMPLE POPUP WINDOW ****
function popitup1(url)
{
	newwindow=window.open(url,'mini','height=200,width=150');
	if (window.focus) {newwindow.focus()}
	return false;
}
/*****************************/


/***** STEP 2 POPUP WINDOW ***
var newwindow = '';
function popitup(url)
{
	/*When the window has never yet been opened, newwindow.closed is undefined (so !newwindow.closed is true, 
	just as if the window were open). Therefore we also check whether newwindow has a location property. 
	If the popup doesn't exist or has been closed, we open the new window as usual.
	*

	if (!newwindow.closed && newwindow.location)
	{
		newwindow.location.href = url;
	}
	else
	{
		newwindow=window.open(url,'name','height=200,width=150');
		if (!newwindow.opener) newwindow.opener = self;
	}
	if (window.focus) {newwindow.focus()}
	return false;
}


/***** STEP 3 My POPUP test specify height & width WORKS FINE ****
var newwindow = '';
function popitup(url,winfeatures)
{
	/*When the window has never yet been opened, newwindow.closed is undefined (so !newwindow.closed is true, 
	just as if the window were open). Therefore we also check whether newwindow has a location property. 
	If the popup doesn't exist or has been closed, we open the new window as usual.
	*

	if (!newwindow.closed && newwindow.location)
	{
		newwindow.location.href = url;
	}
	else
	{
		newwindow=window.open(url,'name',winfeatures);
		if (!newwindow.opener) newwindow.opener = self;
	}
	if (window.focus) {newwindow.focus()}
	return false;
}


/***** STEP 4 My POPUP test close  	WORKS FINE :) ****
var newwindow = '';
function popitup(url,winfeatures)
{
	/*When the window has never yet been opened, newwindow.closed is undefined (so !newwindow.closed is true, 
	just as if the window were open). Therefore we also check whether newwindow has a location property. 
	If the popup doesn't exist or has been closed, we open the new window as usual.
	*

	if (!newwindow.closed && newwindow.location)
	{
		//newwindow.location.href = url;
		//close window
		newwindow.close();
	}
	else
	{
		newwindow=window.open(url,'name',winfeatures);
		if (!newwindow.opener) newwindow.opener = self;
	}
	if (window.focus) {newwindow.focus()}
	return false;
}
*/


/***** STEP 5 My POPUP test close and reopen FINALLY WORKED !!!!! :) ****/
var newwindow = '';
function popitup(url,winfeatures)
{
	/*When the window has never yet been opened, newwindow.closed is undefined (so !newwindow.closed is true, 
	just as if the window were open). Therefore we also check whether newwindow has a location property. 
	If the popup doesn't exist or has been closed, we open the new window as usual.
	*/

	if (!newwindow.closed && newwindow.location)
	{
		//newwindow.location.href = url;
		//close window
		newwindow.close();
		newwindow=window.open(url,'name',winfeatures);
		if (!newwindow.opener) newwindow.opener = self;
	}
	else
	{
		newwindow=window.open(url,'name',winfeatures);
		if (!newwindow.opener) newwindow.opener = self;
	}
	if (window.focus) {newwindow.focus()}
	return false;
}



