/********************************
ActiveBoard User Menu Script
Copyright ©2005 Sparklit Networks

Depends: forum_menu.js
*********************************/

var abumMnuDiv;
var abumABID;
var abumEnablePM = 1;
var abumSlideDelay = 20;
var abumEnableEffects = 1;
var abumJustClicked = 0;
var abumEnanbleEmail = 0;

function abumInit(aBID, enablePM) {
	abumABID = aBID;
	abumEnablePM = enablePM;
	abumMnuDiv = document.getElementById('abumMnuDiv');
	abumMnuDiv.style.position = 'absolute';
	abumMnuDiv.style.display = 'none';
}

function abumShowMenu(id, userName, homepage, e, enableEmail) {
	abumJustClicked=1;
	
	abumFillDiv(id, userName, homepage, enableEmail);
	
	abumMnuDiv.style.left = absoluteLeft(e)-5;
	abumMnuDiv.style.top = absoluteBottom(e)+2;
	
	if(abumEnableEffects) {
		abumMnuDiv.style.clip = "rect(auto, auto, 1px, 1px)";
		abumMnuDiv.style.display = 'block';
		abumGrowMenu(20, 5, abumMnuDiv.offsetWidth, abumMnuDiv.offsetHeight);
	}
	else {
		abumMnuDiv.style.display = 'block';
	}
}

function abumHideMenu(id, e) {
	if(abumJustClicked)
		abumJustClicked=0;
	else
		abumMnuDiv.style.display = 'none';
}

function abumGrowMenu(stepX, stepY, stopX, stopY) {
	
	if(stepX < stopX) {
		stopX -= stepX;
	} else {
		stopX = 0;
	}
	x = abumMnuDiv.offsetWidth - stopX;
	
	if(stepY < stopY) {
		stopY -= stepY;
	} else {
		stopY = 0;
	}
	y = abumMnuDiv.offsetHeight - stopY;
	
	abumMnuDiv.style.clip = "rect(auto, "+x+"px, "+y+"px, auto)";
	if(stopY || stopX)
		setTimeout('abumGrowMenu('+stepX+','+stepY+','+stopX+','+stopY+')', abumSlideDelay);
}

  //////////////
  /////////////
  /// WARNING: the AB page URL args (&p=???)) are hardcoded in here.  When changing the defs in ab_page_def.inc, make sure
  /// these are still correct.
  //////
  /////

function abumFillDiv(id, userName, homepage, enableEmail) {
	str = '<table width=200 cellSpacing=0 cellPadding=1 class="genmed borderline dhtmlline" style="cursor: hand">';
	/// formerly: &action=viewMember
	url = 'forum.spark?aBID='+abumABID+'&p=20&memberID='+id;
	str += '<tr><td class=row1 onClick="document.location=\''+url+'\'" onMouseover="this.className=\'highlight\'" onMouseout="this.className=\'row1\'" id="abum_td_0">';
	str += '&nbsp;<a href="'+url+'" id="abum_a_0" style="text-decoration: none" class=genmed>View User Profile</a></td></tr>';
	
	if(abumEnablePM) {
		// formerly: &action=newPM
		url = 'forum.spark?aBID='+abumABID+'&p=63&recipientID='+id;
		str += '<tr><td class=row1 onClick="document.location=\''+url+'\'" onMouseover="this.className=\'highlight\'" onMouseout="this.className=\'row1\'" id="abum_td_1">';
		str += '&nbsp;<a href="'+url+'" id="abum_a_1" style="text-decoration: none" class=genmed>Send Private Message</a></td></tr>'
	}
	
	if(homepage) {
		str += '<tr><td class=row1 onMouseover="this.className=\'highlight\'" onMouseout="this.className=\'row1\'" id="abum_td_2">';
		str += '&nbsp;<a href="'+homepage+'" target=_blank id="abum_a_2" style="text-decoration: none;" class=genmed>Visit Homepage</a></td></tr>'
	}
	
	if(enableEmail) {
		// there doesn't seem to be any ABP where the user can send email.  That functionality may not have been
		// implemented in the abframework.
		url = 'forum.spark?aBID='+abumABID+'&action=forumEmail&recipientID='+id;
		str += '<tr><td class=row1 onClick="document.location=\''+url+'\'" onMouseover="this.className=\'highlight\'" onMouseout="this.className=\'row1\'" id="abum_td_1">';
		str += '&nbsp;<a href="'+url+'" id="abum_a_1" style="text-decoration: none" class=genmed>Send an Email</a></td></tr>'		
		
	}
	
	str += '</table>';
	
	abumMnuDiv.innerHTML = str;
}
