function loadMemProfile(mid){
	var dest = {w:200,h:100};
	var info = $('#dpop');	
	$("#bcont").hide();
	$("#bcont").html("");
	$.post("/popprofile.php",{memid:mid},function(data){
		$("#bloading").hide();
		//$("#bcont").stop();
		//$("#bcont").html(data).css({width:30,height:30}).animate({width:dest.w,height:dest.h},{queue:false,duration:500});
		//info.animate({left: '-='+((dest.w/2)-15)+'px',top:'-='+(dest.h)+'px'},{queue:false,duration:500});
		$("#bcont").html(data).show().css({width:dest.w,height:dest.h});
		info.stop();
		pos = info.position();
		add_log(pos.left+","+pos.top+" == ");		
		info.css({left:(pos.left-(dest.w/2)-15+30)+'px',top:(pos.top-dest.h+30)+'px'});
	});
}
$(function () {
	if($("#ie6").size()>0) return(false);
	
	
	var distance = 5;
	var time = 100;
	var hideDelay = 500;
	
	var hideDelayTimer = null;
	
	var beingShown = false;
	var shown = false;
	//var trigger = $('.trigger', this);
	var curr_balloon = null;
	var hold_balloon = false;
	//var info = $('.popup', this).css('opacity', 0);	
	
	$("#body").append('<table class="popup" id="dpop">'+
					 '<tr><td class="corner" id="topleft"></td><td class="top"></td><td class="corner" id="topright"></td></tr>'+
					 '<tr><td class="lft"></td><td class="bcont"><div id="bcont"></div><div id="bloading"></div></td><td class="right"></td></tr>'+
					 '<tr><td id="bottomleft" class="corner"></td><td class="bottom"><div class="barrow"></div></td><td class="corner" id="bottomright"></td></tr>'+
					 '</table>');
	var info = $('#dpop').css('opacity', 0);
	
	info.mouseover(function(){
		hold_balloon = true;
	}).mouseout(function(){
		hold_balloon = false;
		if (hideDelayTimer) clearTimeout(hideDelayTimer);
		hideDelayTimer = setTimeout(function () {
			hideDelayTimer = null;
			if(!hold_balloon){
				shown = false;
				info.css('display', 'none');
				curr_balloon = null;
			}

		}, hideDelay);
	});
	
	$('.avt1, .avt2').not(".noball").each(function () {		
		$(this).mouseover(function () {
			$this = $(this);
			linkTop = posY = $this.offset().top;
			linkLeft = $this.offset().left;
			//mouseX = event.pageX;
			//mouseY = event.pageY;
			if ($this[0].tagName.toLowerCase() != 'area') {
			  sTop = $(document).scrollTop();
			  winWidth = $(window).width();
			}
			
			if (hideDelayTimer) clearTimeout(hideDelayTimer);
			//if($this.attr("rel")!=curr_balloon){
			if($this.attr("bid")!=curr_balloon){
				//add_log("Not Same");
			}else{
				//add_log("Same");
				return;
			}
			
			
			/*if (beingShown || shown) {
				// don't trigger the animation again
				return;
			}else*/
			{
				// reset position of info box
				//beingShown = true;
				beingShown = false;
				shown = true;
				info.stop();
				$("#bcont").html("").hide();	
				$("#bloading").show().css({width:30,height:30});
				//info.css('display', 'none');
				info.css({
					top: linkTop-60,
					left: linkLeft-15,
					display: 'block'
				}).animate({
					top: '-=' + distance + 'px',
					opacity: 1
				}, time, 'swing', function() {					
					
					curr_balloon = $this.attr("bid");
					loadMemProfile(curr_balloon);
				});
			}
			
			
			
			return false;
		}).mouseout(function () {
			if (hideDelayTimer) clearTimeout(hideDelayTimer);
			hideDelayTimer = setTimeout(function () {
				hideDelayTimer = null;
				/*info.animate({
					top: '-=' + distance + 'px',
					opacity: 0
				}, time, 'swing', function () {
					shown = false;
					info.css('display', 'none');
				});*/
				if(!hold_balloon){
					shown = false;
					info.css('display', 'none');
					curr_balloon = null;
				}

			}, hideDelay);
			/*shown = false;
			info.css('display', 'none');*/

			return false;
		});
	});
	
});
