// +-------------------------------------------------------------+
// | Zaplife.com popup javascript file
// | All rights reserved. Copyright 2005-2008 Zaplife.com
// |
// +-------------------------------------------------------------+



var offsetFromMouse = [10,10]; //image x,y offsets from cursor position in pixels.

if (document.getElementById || document.all){
	document.write('<div id="popupid" style="position:absolute; display:none; z-index:1000;"></div>');
}

function getPopupObj(){
	if (document.getElementById)
		return document.getElementById("popupid").style
	else if (document.all)
		return document.all.popupid.style
}

function getPopupObjNostyle(){
	if (document.getElementById)
		return document.getElementById("popupid")
	else if (document.all)
		return document.all.popupid
}

function showPopup(userid){

	document.onmousemove=followMouse;

	//popupHTML = '<div style="padding: 0px; background-image: url(images/popup_background.gif); background-repeat: repeat-x; background-position: bottom center; border: 1px solid #CCCCCC;">';
	popupHTML = '<iframe src="' + webPath + 'popup.php?id='+userid+'" width="202" height="70" scrolling="no" frameborder="0" marginheight="0" marginwidth="0"></iframe>';
	//popupHTML = popupHTML + '</div>';

	getPopupObjNostyle().innerHTML = popupHTML;
	getPopupObj().display="";

}


function hidePopup(){
	getPopupObj().display="none";
	document.onmousemove="";
	//getPopupObj().left="-500px"
}

function followMouse(e){

	var xcoord=offsetFromMouse[0];
	var ycoord=offsetFromMouse[1];
	
	// Get inner dimensions of the window and how much the page has scrolled
	
	if (self.innerWidth) {
		// all except Explorer
		frameWidth = self.innerWidth;
		frameHeight = self.innerHeight;
		
		scrollY = self.pageYOffset;
		scrollX = self.pageXOffset;
		
	} else if (document.documentElement && document.documentElement.clientWidth) {
		// Explorer 6 Strict
		frameWidth = document.documentElement.clientWidth;
		frameHeight = document.documentElement.clientHeight;
		
		scrollY = document.documentElement.scrollTop;
		scrollX = document.documentElement.scrollLeft;
		
	} else if (document.body) {
		// other Explorers
		frameWidth = document.body.clientWidth;
		frameHeight = document.body.clientHeight;
		
		scrollY = document.body.scrollTop;
		scrollX = document.body.scrollLeft;
		
	}
	
	if (!e) var e = window.event;
	
	if (e.pageX || e.pageY) {
		// all except Explorer, relative to the document
	
		if (frameWidth - e.pageX + scrollX < 225) {
			xcoord = e.pageX - xcoord - 200; // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
		if (frameHeight - e.pageY + scrollY < 80) {
			ycoord = e.pageY - ycoord - 70; // Move to the top side of the cursor
		} else {
			ycoord += e.pageY;
		}
		
	} else if (e.clientX || e.clientY) {
		// all except Netscape 4, Safari gives relative to the document and not window
	
		if (frameWidth - e.clientX < 225) {
			xcoord = e.clientX - xcoord - 200 + scrollX; // Move to the left side of the cursor
		} else {
			xcoord += e.clientX + scrollX;
		}
		if (frameHeight - e.clientY < 80) {
			ycoord = e.clientY - ycoord - 70 + scrollY; // Move to the top side of the cursor
		} else {
			ycoord += e.clientY + scrollY;
		}
	}

	getPopupObj().left=xcoord+"px";
	getPopupObj().top=ycoord+"px";

}

