﻿var searchBoxID = '';
var decFriendshipText = '';
var applicantLinkID = '';
var count = 0;
var selectedMediaType = 0;
function search() {
	location.href = '/section/tagsystem/search.aspx?type=' + selectedMediaType + '&search=' + escape($F(searchBoxID));
}
function searchGames() {
	location.href = '/section/games/search.aspx?search=' + escape($F(searchBoxID));
}
var friendData;
function toggleFriends() {
	if (friendData == null || friendData == '') {
		new Ajax.Request('/section/user/profile/FriendsAjax.ashx?m=getfriendlist', { onSuccess: handleFriends });
	}
	else {
		friendsPopup();
	}
}
var applicantData;
function toggleApplicants() {
	if (applicantData == null || applicantData == '') {
		new Ajax.Request('/section/user/profile/FriendsAjax.ashx?m=getapplicants', { onSuccess: handleApplicants });
	}
	else {
		applicantPopup();
	}
}
function handleFriends(data) {
	friendData = data.responseText;
	friendsPopup()
}
function handleApplicants(data) {
	applicantData = data.responseText;
	applicantPopup();
}
function friendsPopup() {
	return overlib(friendData, STICKY, CENTER, NOCLOSE, WRAP, CELLPAD, 4, BGCLASS, 'friendBoxBG', FGCLASS, 'friendBoxFG', TEXTSIZE, '11px');
}
function applicantPopup() {
	return overlib(applicantData, STICKY, CENTER, NOCLOSE, WRAP, CELLPAD, 4, BGCLASS, 'friendBoxBG', FGCLASS, 'friendBoxFG', TEXTSIZE, '11px');
}
function approveFriendship(fid) {
	new Ajax.Request('/section/user/profile/FriendsAjax.ashx?m=approvefriendship&fid=' + fid);
	applicantData = null;
	friendData = null;
	updateFriendshipCount();
	getE('overDiv').style.visibility = 'hidden';
}
function declineFriendship(fid, name) {
	if (confirm(decFriendshipText + name + '?') == true) {
		new Ajax.Request('/section/user/profile/FriendsAjax.ashx?m=declinefriendship&fid=' + fid);
		applicantData = null;
		friendData = null;
		updateFriendshipCount();
		$('overDiv').style.visibility = 'hidden';
	}
}
function setNewCount() {
	if (count == 0) {
		$(applicantLinkID).innerHTML = '(0)';
	}
	else {
		$('friendshipCountSpan').update(count);
	}
}
function toggleLoginBox() {
	$('topbarLoginBox').toggle();
}