var appletStarted = false;

/**********************************************************************************/
function isIEonMac()
{
	var agt=navigator.userAgent.toLowerCase();
	var ie  = (agt.indexOf("msie") != -1);
	var mac = (agt.indexOf("mac")!=-1);
	if ( ie && mac )
		return true;
}

/**********************************************************************************/
function isNSonMac()
{
	var agt=navigator.userAgent.toLowerCase();
	var ns  = (navigator.appName.indexOf("Netscape") != -1);
	var mac = (agt.indexOf("mac")!=-1);
	if ( ns && mac )
		return true;
}

/**********************************************************************************/
function isMac() // Is the browser running on a Mac?
{
	var agt=navigator.userAgent.toLowerCase();
	return (agt.indexOf("mac")!=-1);
}


/**********************************************************************************/
function isNS() // Is this browser Netscape?
{
	return (navigator.appName.indexOf("Netscape") != -1);
}


/**********************************************************************************/
function AddFriendByMemberID(lngFriendID) 
{
	var strURL;
	var strProperties = "Resizable=yes,scrollbars=yes";
	if (lngFriendID == null)
		lngFriendID = "";
	// change the "p" parameter to 27001 to Insert by MemberID
	//strURL = '/default.asp?PageType=4&a=26550&ListMemberID=' + lngFriendID + '&MemberID=' + lngFriendID;
	strURL = '/default.asp?PageType=4&a=26550&ToMemberID=' + lngFriendID + '&MemberID=' + lngFriendID;
	launchWindow(strURL,'EditFriend',750, 525,strProperties);
}

/**********************************************************************************/
function InitiateEMailByMemberID(lngMemberID)
{
	var strURL;
	var strName; 
	var strProperties;
	
	strURL = "/default.asp?p=10040&PageType=4&MemberID=" + lngMemberID;
	strName = "Email" + lngMemberID;
	strProperties = "Resizable=yes,scrollbars=yes";
	launchWindow(strURL, strName, 750, 525, strProperties);
}

/**********************************************************************************/
function LaunchIMByMemberID(lngRecipientMemberID)
{
	launchWindow("/default.asp?a=19540&PageType=4&MemberID=" + lngRecipientMemberID + "&RecipientMemberID=" + lngRecipientMemberID + "&IMConversationTypeID=1", "IM" + lngRecipientMemberID, 649, 450, "Resizable=yes,scrollbars=yes,status=yes ");
}

/**********************************************************************************/
function LaunchViewProfileByMemberID(lngMemberID) 
{
	launchWindow('/default.asp?p=7070&PageType=4&MemberID=' + lngMemberID, 'ViewProfile' + lngMemberID,750,525,'status=yes,height=525,width=750,scrollbars=yes,resizable=yes,menubar=no,location=no,directories=no,toolbar=no');
}


/**********************************************************************************/
function OpenIMPrintWindow(strContents, newWindow)
{
	newWindow = window.open("","imPrint","width=550,height=480,scrollbars=yes,resizable=yes,menubar=yes,location=no,status=no,directories=no,toolbar=no");
	newWindow.opener = self;
	newWindow.document.open();
	newWindow.document.write( strContents );
	newWindow.document.close();
}

/**********************************************************************************/
function isNSonWin()
{
	var agt=navigator.userAgent.toLowerCase();
	var ie  = (agt.indexOf("msie") != -1);
	var ns  = (navigator.appName.indexOf("Netscape") != -1);
	var win = ((agt.indexOf("win")!=-1) || (agt.indexOf("32bit")!=-1));
	var mac = (agt.indexOf("mac")!=-1);
	if ( ns && win )
		return true;
	return false;
}

/**********************************************************************************/
function isIEonWin()
{
	var agt=navigator.userAgent.toLowerCase();
	var ie  = (agt.indexOf("msie") != -1);
	var ns  = (navigator.appName.indexOf("Netscape") != -1);
	var win = ((agt.indexOf("win")!=-1) || (agt.indexOf("32bit")!=-1));
	var mac = (agt.indexOf("mac")!=-1);
	if ( ie && win )
		return true;
	
	return false;
}

/**********************************************************************************/
function onAppletStarted()
{
	if ( isNS() )
		return;
	
	appletStarted = true;
}

/**********************************************************************************/
function chatAppletResize() 
{
	AppletResize(0, 0, 0) 
}

function messengerAppletResize() 
{
	AppletResize(210, 0, 30) 
}
	
/**********************************************************************************/
function AppletResize(headerImgHeight, footerPadding, profilePaneWidth) 
{
	var newWidth,newHeight;
	var minWindowWidth = 629;
	var minWindowHeight = 420;
	var newWindowWidth = 0;
	var newWindowHight = 0;
	
	if ( isNS() )
		return;
	
	if ( isMac() )
		return;
		
	if (navigator.appName.indexOf("Microsoft") != -1)
	{
		newWindowWidth=document.body.clientWidth;
		newWindowHeight=document.body.clientHeight;
	}
	else
	{
		var netscapeScrollWidth=15;
		newWindowWidth=window.innerWidth-netscapeScrollWidth;
		newWindowHeight=window.innerHeight-netscapeScrollWidth;
	}
	
	if ( newWindowWidth < minWindowWidth )
	{
		window.resizeBy(minWindowWidth - newWindowWidth ,0);
		newWindowWidth = minWindowWidth;
	}
	
	if ( newWindowHeight < minWindowHeight )
	{
		window.resizeBy(0,minWindowHeight - newWindowHeight);
		newWindowHeight = minWindowHeight;
	}

	newWidth = newWindowWidth - profilePaneWidth;// - profilePaneWidth;
	newHeight = newWindowHeight - headerImgHeight;// - headerImageHeight-footerPadding;
	
	try
	{
		document.Messenger.width = newWidth;
		document.Messenger.height = newHeight;

		document.Messenger.setSize(newWidth,newHeight);
	}
	catch(e)
	{
	}
}

/**********************************************************************************/
function LaunchChat(strRoom) {
	var strURL, strName, strProperties;
	strRoom = strRoom.replace(/\ /g,"+");
	//strRoom = escape(strRoom);
	strURL = "/default.asp?p=12000&IsPopUp=true&PageType=2&ChatRoom=" + strRoom;
	strName = "Chat";
	
	if ( isMac() || isNS() )
	{
		strProperties = "Resizable=no,scrollbars=no,status=no,statusbar=false";
	}
	else
	{
		strProperties = "Resizable=yes,scrollbars=no,status=no,statusbar=false";
	}

	launchWindow(strURL, strName, 580, 430, strProperties);
}




