function findPos(obj) {
	var curleft = curtop = 0;

	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}	
		
	return [curleft,curtop];
}


function preview() {
	var startArticle = this.href.lastIndexOf("_")+1;
	var stopArticle = this.href.lastIndexOf("/");
	thisArticle = this.href.substring(startArticle, stopArticle);
	
	
	var theBrowser = navigator.appName;
	var theVerNum = navigator.appVersion;
	//var testLoc = findPos(this);
	
	if ((theBrowser.indexOf("Explorer")>-1)&&(theVerNum<7)) {
	
		if(this.childNodes[0].nodeType == 1) {
			var previewX =  findPos(this)[0]-38;
			var previewY = findPos(this)[1] + 5;
		} else {
			var previewX =  findPos(this)[0] - 54;
			var previewY = findPos(this)[1] + 6;
		}
	
	} else {
		
		if(this.childNodes[0].nodeType == 1) {
			var previewX =  findPos(this)[0]-34;
			var previewY = findPos(this)[1] + 11;
		} else {
			var previewX =  findPos(this)[0] - 50;
			var previewY = findPos(this)[1] + 14;
		}		
	}
	document.getElementById("preview").style.display = "block";
	document.getElementById("preview").style.left = previewX + "px";
	document.getElementById("preview").style.top = previewY + "px";
	
	document.getElementById("preview").onmouseover = keepPreview;
	document.getElementById("preview").onmouseout = losePreview;
	
	var theHeadline = articles[thisArticle][0];
	var theArticle = articles[thisArticle][1];
	var theGraphic = articles[thisArticle][2];
	
	//alert(theGraphic);
	
	prev_html = "<img src=\"" + theGraphic + "\" /><h3>" + theHeadline + "</h3><p>" + theArticle + "</p>";
	
	document.getElementById("prev_body").innerHTML = prev_html;
	document.getElementById("preview").onclick = gotoArticle;
	
}

function gotoArticle () {
	var goto = "gracenews.php?article=" + thisArticle;
	window.location = goto;
}

function keepPreview() {

	document.getElementById("preview").style.display = "block";
	
}

function losePreview() {

		document.getElementById("preview").style.display = "none";

}
	
	
	
	
//		if(browser.isNS){
//			var mouseX=e.pageX; var mouseY=e.pageY;
//		} else {
//			var mouseX=event.x; var mouseY=event.y;
//	alert("x= "+mouseX+", y= "+mouseY);
	
	//document.getElementById(thisMenuName).style.display = "block";
	//document.getElementById(thisMenuName).style.position = "relative";
	//document.getElementById(thisMenuName).style.zIndex = 1;
	
	//this.parentNode.className = thisMenuName;
	//this.parentNode.onmouseout = toggleDivOff;
	//this.parentNode.onmouseover = toggleDivOn;
	//if(thisMenuName != menuHistory) {
	//	menuHistory = thisMenuName;
	//	closeSubMenu();
	//}
//}
