$(document).ready(function() {	
	/*
	Tooltip
	*/
	var currentlyShowing = false;
	$(".highlight").hover(
		function() {
			if(currentlyShowing == false) {
				currentlyShowing = true;
				//alert($(this).text());
				thistmpid = $(this).attr("id");
				//alert(thistmpid);
				//e.preventDefault();
				toolTipShow(thistmpid, currentlyShowing);
			}
		},
		function() {
			$("#" + thistmpid + " div").hide();
			$("#" + thistmpid + " span").hide();
			currentlyShowing = false;
		}
	);
	
});
function rPosition(elementID, mouseX, mouseY) {
  var offset = $('#'+elementID).offset();
  var x = mouseX - offset.left;
  var y = mouseY - offset.top;

  return {'x': x, 'y': y};
}
var mouseX = 0;
var mouseY = 0;
$().mousemove( function(e) {
   mouseX = e.pageX; 
   mouseY = e.pageY;
 });
function toolTipShow(elementid, tmpShow) {
	//$("#" + elementid).attr("title", data);
	//alert($("#" + elementid).attr("title"));
	//$("#" + elementid).title = "AGTESTING";
	var thistext = "";
	thistext = $("#" + elementid).text();
	//alert(thistext);
	var pos = $("#copy").offset();  
  	var width = $("#copy").width();

	$("#" + elementid).simpletip({
		content: "<img src='images/loading.gif' alt='Loading' />",
		//fixed: false,
		position: [0, 0],
		onBeforeShow: function(){
			// Note this refers to the API in the callback function
			if(tmpShow) {
				this.load('ajax_tooltip.php?tooltip=' + escape(thistext) + "&x=" + (mouseX - pos.left) + "&y=" + (mouseY - pos.top));
			}
		}
	});
}

function viewcalculator(thisurl) {
	var thiswindow;
	thiswindow = window.open(thisurl, 'viewpage', 'width=650,height=500,scrollbars,resizable');
	thiswindow.focus();
}
