/**********************************************************************************/
function launchWindow(strURL, strName, intWidth, intHeight, strProperties) 
{
	var mywin;
	var intVersion;
	var dummyDate = new Date(); 
	
	intVersion = navigator.appVersion.substring(0,1);
	if (strURL != "") 
	{
		if (strURL.indexOf("?") != -1) { 
			strURL = strURL + "&rnd="
		} else {
			strURL = strURL + "?rnd="
		}
			
		strURL = strURL + dummyDate.getTime();
			
		strURL = Replace(strURL,"@","%40");
	}
	
	if (strProperties == "") {
		strProperties = "scrollbars=yes,resizable=yes,menubar=no,location=no,directories=no,toolbar=no";
	}
	
	strProperties = "status=yes,height=" + intHeight + ",width=" + intWidth + "," + strProperties;

	// replace all non-alphacharacters with X
	if(strName.replace)
		strName = strName.replace(/\W/g,"X");
	
	// lower case the string
	strName = strName.toLowerCase();
	
	mywin = window.open(strURL, strName, strProperties);
	mywin.name = strName
	if (mywin.opener == null) mywin.opener = self;
}


/**********************************************************************************/
function Split(str, strDelimiter) {
	var ary = new Array();
	var lngCurrentLoc;
	var i = 0;
	var strValue;
	var lngLength;
		
	lngCurrentLoc = str.indexOf(strDelimiter);
	while (lngCurrentLoc >= 0) 
	{
		strValue = str.substring(0, lngCurrentLoc);
		if (strValue.length > 0) 
		{
			ary[i++] = strValue
		}
		str = str.substring(lngCurrentLoc + 1, str.length);
		lngCurrentLoc = str.indexOf(strDelimiter);
	}
	if (str.length > 0) 
	{
		ary[i] = str;
	}
	return ary;
}


/**********************************************************************************/
function FriendsList(blnOnlineOnly)
{
	var strPath = '/friends/default.asp?Popup=1';
	var strProperties = "Resizable=yes,scrollbars=yes";
	if (blnOnlineOnly == true) {
		strPath = strPath + '&p=27004'
	}
	launchWindow(strPath,'MyPals',500,550,strProperties);
}


/**********************************************************************************/
function AddFriend(lngFriendID, strName) {
	var strURL;
	var strProperties = "Resizable=yes,scrollbars=yes";
	if (lngFriendID == null)
		lngFriendID = "";
	// change the "p" parameter to 27001 to Insert by MemberID
	strURL = '/friends/default.asp?Popup=1&p=27002&FriendUserName=' + escape(strName) + '&FriendMemberID=' + lngFriendID 
	launchWindow(strURL,'EditFriend',550,500,strProperties);
}


/**********************************************************************************/
function InitiateEMail(strRecipientName, strAdditionalParams)
{
	var strURL;
	var strName; 
	var strProperties;
	
	strURL = "/email/?to=" + escape(strRecipientName) + "&Popup=True&p=21112";
	if (strAdditionalParams != null) {
		strURL += '&' + strAdditionalParams;
	}
	strName = "Email" + escape(strRecipientName);
	strProperties = "Resizable=yes,scrollbars=yes";
	launchWindow(strURL, strName, 620, 600, strProperties);
}

/**********************************************************************************/
function InitiateEMailLink(strRecipientName, strScriptName, strQueryString, strTitle)
{
	var strURL;
	var strName; 
	var strProperties;
	
	strURL = "/r.asp?to=" + escape(strRecipientName) + "&Script=" + escape(strScriptName) + "&Query=" + escape(strQueryString) + "&Title=" + strTitle;

	strName = "Email" + escape(strRecipientName);
	strProperties = "Resizable=yes,scrollbars=yes";
	launchWindow(strURL, strName, 620, 520, strProperties);
}

/**********************************************************************************/
function LaunchIMByMOID(strRecipientMemberOnlineID, strRecipientUserName, strInitiatorIRCName, lngIMConversationTypeID)
{
	launchWindow("/im/default.asp?RecipientMemberOnlineID=" + strRecipientMemberOnlineID + "&RecipientUserName=" + escape(strRecipientUserName) + "&InitiatorIRCName=" + escape(strInitiatorIRCName) +  "&IMConversationTypeID=" + lngIMConversationTypeID + "&p=25001", "IM" + strRecipientUserName, 480, 290, "resizable=no,scrollbars=no");
}

/**********************************************************************************/
function LaunchIMByUserName(lngPage, strRecipientUserName, lngRecipientDomainID, lngIMConversationTypeID)
{
	launchWindow("/im/default.asp?RecipientUserName=" + escape(strRecipientUserName) + "&RecipientDomainID=" +  lngRecipientDomainID + "&IMConversationTypeID=" + lngIMConversationTypeID + "&p=" + lngPage, "IM" + strRecipientUserName, 480, 290, "resizable=no,scrollbars=no");
}

/**********************************************************************************/
function LaunchChat(strRoom) {
	var strURL, strName, strProperties;
	strRoom = strRoom.replace(/\ /g,"+");
	//strRoom = escape(strRoom);
	strURL = "/chat/default.asp?p=1001&ChatRoom=" + strRoom;
	strName = "Chat" + strRoom;
	//strProperties = "Resizable=no,scrollbars=no";
	launchWindow(strURL, strName, 600, 430, strProperties);
}

/**********************************************************************************/
function LaunchSpellChecker(strWindowName) {
	var strURL, strProperties;
	
	strURL = "/spellcheck/default.asp?Start=true";
	strProperties = "Resizable=yes,scrollbars=yes";
	launchWindow(strURL, strWindowName, 450, 350, strProperties);
}


/**********************************************************************************/
function Replace(str, substring, newstring) {
	if (str.length <= 0)
		return "";

	temp = "" + str; 

	while (temp.indexOf(substring)>-1) {
	pos = temp.indexOf(substring);
	temp = "" + (temp.substring(0, pos) + newstring + temp.substring((pos + substring.length), temp.length));
	}
	return temp;
}

/**********************************************************************************/
function ConfirmDelete(strMessage, strLocation) 
{
	if (confirm(strMessage)) {
		document.location.href = strLocation;
	}
}

/**********************************************************************************/
function CheckAll(frm)
{
	for (var i=0;i<frm.elements.length;i++)
	{
		var e = frm.elements[i];
		if (e.name != 'allbox')
			e.checked = frm.allbox.checked;
	}
}

/**********************************************************************************/
function UnCheckAllExceptOne(form_object, lngItem) {
	if (lngItem == null) {lngItem = 0};
	if (form_object[lngItem].checked == true) {
		var len = form_object.length;
		for (var i = 0; i < len; i++) {
			if (i != lngItem) {
				form_object[i].checked = false;
			}
		}
	}
}

/**********************************************************************************/
function UnCheckTop(form_object) 
{
	form_object[0].checked = false;
}


