/*
 * OTip
 * By Oliver Astrologo based on Cody Lindley JTIP
 * Under an Attribution, Share Alike License
 * OTip is built on top of the very light weight jquery library.
 */
 
function OT_show(linkId,title){
	var text = jQuery('.' + linkId).html();	
	if(title == false)title="&nbsp;";
	var de = document.documentElement;
	var params = [];
	params['width'] = getElementWidth(linkId)+50;	
    jQuery("body").append("<div id='OT' style='width:"+params['width']*1+"px'><div id='OT_close_left'>"+title+"</div><div id='OT_copy'></div>");//right side
	jQuery('#OT_copy').html(text);
	var clickElementy = getAbsoluteTop(linkId) - getElementHeight('OT'); //set y position
	var clickElementx = getAbsoluteLeft(linkId)-25 ;
	jQuery('#OT').css({left: clickElementx+"px", top: clickElementy+"px"});
	jQuery('#OT').fadeIn("fast");
}

function getElementWidth(objectId) {
	x = document.getElementById(objectId);
	return x.offsetWidth;
}

function getElementHeight(objectId) {
	y = document.getElementById(objectId);
	return y.offsetHeight;
}

function getAbsoluteLeft(objectId) {
	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) {	
	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
}
