//New pop-up function added for 13517
//Following new function is an uber-popup function to replace all others previously used.

//THE FUNCTION

function PopUp(theURL,winName,features){
	remote=window.open(theURL,winName,features);
	if (remote.opener == null) remote.opener = window; 
	remote.opener.name = "opener";
	remote.focus();
}

//See "How to Create Links" on Eng Web Site for Documentation on function

//============================================================================================

//The function handles all links inside popup. It targets the window "opener".
//If the "opener" window is closed, it creates it in the open call.
//If the "opener" window is open, it simply outputs the code there.
function gotoHref(szLink)
{
	if (window.opener.closed)
	{
		//each new window gets a unique name so the new page isn't
		//loaded in a window not with focus, which confuses the user.
		var szDate = new Date();
		win = window.open(szLink,"opener"+szDate.getTime());
	}
	else
	{
		window.opener.location.href = szLink;
	}
	window.close();
}


//these two functions are added for 24652
//they will open a popup window with the full member photo
var win
function memberphotoPopup(height, width, pid, nServiceID, nGroupID, nPmode, nDisplayPrice, strFLParams, strReturnURL)
{
	var strHeight = (height + 125);
	var strWidth = 130;
	var LeftPosition, TopPosition, settings
	var strUrl = '/memberpub/member_photo.asp?pid=' + pid + '&sid=' + nServiceID + '&gid=' + nGroupID + '&pmode=' + nPmode + '&dpr=' + nDisplayPrice + strFLParams + '&URL=' + strReturnURL
	var name
	if (width > strWidth)
	{
		strWidth = (width + 30);
	}
	
	name = pid
	
	if(!win || win.closed)
	{
		//setting the cookies (bug 36383)
		if (strFLParams != "")
		{
			document.cookie = "MPhV=1;path=/";
		}

		LeftPosition = (screen.width) ? (screen.width-strWidth)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-strHeight)/2 : 0;
		//settings ='height='+ strHeight +',width='+strWidth+',top='+TopPosition+',left='+LeftPosition+',notitlebar,nomenubar,scrollbars=no,resizable=no'
		settings ='height='+ strHeight +',width='+strWidth+',notitlebar,nomenubar,scrollbars=no,resizable=no'

		win = window.open(strUrl,pid,settings);
		win.focus()	
	}	
}


function wincloseRemote()
{
	//if (window.WinImage) WinImage.close();
	if (window.win && window.win.open && !window.win.closed) win.close();
}

//============================================================================================

//this function resizes a window based on the passed in dimensions.
//if the browser window is larger than these dimensions, no resize happens
function resizeWin(newWidth, newHeight)
{

	var frameWidth;
	var frameHeight;
	
	//determine window size for different browser types
	if (self.innerWidth)
	{
		frameWidth = self.innerWidth;
		frameHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientWidth)
	{
		frameWidth = document.documentElement.clientWidth;
		frameHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		frameWidth = document.body.clientWidth;
		frameHeight = document.body.clientHeight;
	}
	
	//only resize window if new dimensions are larger than current.		
	if ((frameWidth < newWidth)||(frameHeight < newHeight))
	{ 
		//in netscape 4, window height is counted differently
		//from other browsers, so window height is artificially low 
		//and an extra 100 pixels need to be added
		newHeight += 100;
		
		//only resize up to the size of the screen resolution.
		if (newHeight > self.screen.height)
		{
			newHeight = self.screen.height
		}
		
		if (newWidth > self.screen.width)
		{
			newWidth = self.screen.width
		}

		//if netscape 4, must add in button and border layer sizes
		//so window is resized properly
		if (document.layers)
		{
			var tmp1 = parent.outerWidth - parent.innerWidth;
			var tmp2 = parent.outerHeight - parent.innerHeight;
			newWidth -= tmp1;
			newHeight -= tmp2;
		}
		
		//resize window
		window.resizeTo(newWidth, newHeight);	
		window.moveTo(0,0);		
	}
}

//============================================================================================
