﻿/*
 * JTip
 * By Cody Lindley (http://www.codylindley.com)
 * Under an Attribution, Share Alike License
 * JTip is built on top of the very light weight jquery library.
 */

//on page load (as soon as its ready) call JT_init
//$(document).ready(JT_init);
//function JT_init(){
//	       $("a.jTip").hover(function(){JT_show("/US/Processing/getModelInfo.aspx",this.id,this.name)},function(){$('#JT').remove()});	   
//}
function removeJT(){$('#JT').remove();}
function JT_show(linkId,ptitle){
	var url = '/Processing/getModelInfo.aspx';
	ptitle = ptitle.replace('And', '+').replace('Or', '/').replace(' ','');
	if(ptitle == false) ptitle="&nbsp;";
    if(ptitle == "&nbsp;") return false;
	var de = document.documentElement;
	var clickElementy = getAbsoluteTop(linkId) + 28; //set y position
	$("body").append("<div id='JT' style='width:350px'><div id='JT_close_left'>" + ptitle + "</div><div id='JT_copy'><div class='JT_loader'><div></div></div>"); //right side
	var arrowOffset = getElementWidth(linkId) + 11;
	var clickElementx = getAbsoluteLeft(linkId);// + arrowOffset; //set x position
	$('#JT').css({left: clickElementx+"px", top: clickElementy+"px"});
	$('#JT').show();
	$('#JT_copy').load(url+'?PN='+ptitle);
}

function Paps_show(linkId, ptitle) {
    var url = '/Processing/getPAPSInfo.aspx';
    ptitle = ptitle.replace('And', '+').replace('Or', '/');
    if (ptitle == false) ptitle = "&nbsp;";
    if (ptitle == "&nbsp;") return false;
    var de = document.documentElement;
    var clickElementy = getAbsoluteTop(linkId) + 28; //set y position
    $("body").append("<div id='JT' style='width:533px'><div id='JT_close_left'>" + ptitle + "</div><div id='JT_copy'><div class='JT_loader'><div></div></div>"); //right side
    var arrowOffset = getElementWidth(linkId) + 11;
    var clickElementx = getAbsoluteLeft(linkId); // + arrowOffset; //set x position
    $('#JT').css({ left: clickElementx + "px", top: clickElementy + "px" });
    $('#JT').show();
    $('#JT_copy').load(url + '?PN=' + ptitle);
}

function getElementWidth(objectId) {
	x = document.getElementById(objectId);
	return x.offsetWidth;
}
function getAbsoluteLeft(objectId) {
	// Get an object left position from the upper left viewport corner
	o = document.getElementById(objectId);
	oLeft = o.offsetLeft;            // Get left position from the parent object
	while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent;    // Get parent object reference
		oLeft += oParent.offsetLeft; // Add parent left position
		o = oParent;
	}
	return oLeft;
}
function getAbsoluteTop(objectId) {
	// Get an object top position from the upper left viewport corner
	o = document.getElementById(objectId);
	oTop = o.offsetTop;            // Get top position from the parent object
	while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent;  // Get parent object reference
		oTop += oParent.offsetTop; // Add parent top position
		o = oParent;
	}
	return oTop;
}