var lastPmId=0;

function togglePM(id, uid, uname) {
	if (id==-1) id=lastPmId;
	var p=document.getElementById("pma_"+id);
	var d=document.getElementById("ice_pm");
	if (d.style.visibility=="visible" && id == lastPmId) {
		d.style.visibility="hidden";
		document.getElementById('pm-frame').src="about:blank";
	} else {
		fixBanners();
		var y=getY(p);
		var x=getX(p);
		y=y-d.offsetHeight;
		document.getElementById('pm-frame').src="http://blogs.yupi.gr/pm-form?to="+uid;
		d.style.position="absolute";
		d.style.left=(x-10)+"px";
		d.style.top=(y-10)+"px";
		d.style.visibility="visible";
	}
	lastPmId=id;
}

function getY(e) {
	var r=0;
	while(e!=null) {
		r+=e.offsetTop;
		e=e.offsetParent;
	}
	return r;
}

function getX(e) {
	var r=0;
	while(e!=null) {
		r+=e.offsetLeft;
		e=e.offsetParent;
	}
	return r;
}

function fixBanners() {
	return;
	var o=document.getElementsByTagName("OBJECT");
	for (var i=0; i<o.length; i++) {
		var child = null;
		var param = document.createElement('param');
		param.name = 'wmode';
		param.value = 'transparent';
		o[i].appendChild(param);
		for (var j=0, end=o[i].childNodes.length; j<end; j++) {
			child = o[i].childNodes[j];
			if (child.nodeName === 'EMBED') {
				child.wmode = 'transparent';
			}
		}
	}
}
