function getParent(myWin)
{
	return (myWin.parent || myWin)
}

function getFirstOpener()
{
	theWin = getParent(window);
	theOpener = '';
	if (theWin.opener)
	{
		while (theOpener=theWin.opener)
		{
			//If the opener is still on Matchdragon.. new ride!
			if (theOpener.location.href.indexOf('matchdragon') || theOpener.location.href.indexOf('1haojob')) {theWin=getParent(theOpener);}
			//Else, return the current window.
			else {return theParent(theWin);}
		}
	}
	return theWin;
}

// If there is an opener, launch the link in the opener!
function linkFromPopup(myLink)
{
	if (!myLink.converted)
	{
		destination = myLink.href;
		myOpener = getFirstOpener();
		
		myLink.href = "javascript:void(null)";
		addEvent(myLink,"click",function(){myOpener.location.href=destination; myOpener.focus();});
		myLink.converted = true;
	}
}
