/* modified jTip */

$(document).ready(tooltip_init);

function tooltip_init(){
	$("a.tooltip")
	.hover(function() { tooltip_show(this.id,this.id,this.name,this.href) }, function(){ $('#tooltip').remove() })
	//.click(function(){return false});	   
}

function tooltip_show(url,linkId,title,linkhref){
	if(title == false)title="&nbsp;";
	var de = document.documentElement;
	var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var hasArea = w - getAbsoluteLeft(linkId);
	var clickElementy = getAbsoluteTop(linkId);
	var url = "/_scripts/_player.php?id="+url;
	var clickurl = linkhref;
	
	
	if(clickurl !== undefined){
	$('#' + linkId).bind('click',function(){window.location = clickurl});
	$('#' + linkId).css('cursor','pointer');
	}
	
	$("body").append("<div id='tooltip'></div>");
	var arrowOffset = getElementWidth(linkId) + 10;
	var clickElementx = getAbsoluteLeft(linkId) + arrowOffset;
	
	$('#tooltip').css({left: clickElementx+"px", top: clickElementy+"px"});
	$('#tooltip').show();
	$('#tooltip').load(url);

}

function getElementWidth(objectId) {
	x = document.getElementById(objectId);
	return x.offsetWidth;
}

function getAbsoluteLeft(objectId) {
	o = document.getElementById(objectId)
	oLeft = o.offsetLeft
	while(o.offsetParent!=null) {
		oParent = o.offsetParent
		oLeft += oParent.offsetLeft
		o = oParent
	}
	return oLeft
}

function getAbsoluteTop(objectId) {
	o = document.getElementById(objectId)
	oTop = o.offsetTop
	while(o.offsetParent!=null) {
		oParent = o.offsetParent
		oTop += oParent.offsetTop
		o = oParent
	}
	return oTop
}

function parseQuery(query) {
   var Params = new Object ();
   if ( ! query ) return Params;
   var Pairs = query.split(/[;&]/);
   for ( var i = 0; i < Pairs.length; i++ ) {
      var KeyVal = Pairs[i].split('=');
      if ( ! KeyVal || KeyVal.length != 2 ) continue;
      var key = unescape( KeyVal[0] );
      var val = unescape( KeyVal[1] );
      val = val.replace(/\+/g, ' ');
      Params[key] = val;
   }
   return Params;
}

function blockEvents(evt) {
	if(evt.target) {
		evt.preventDefault();
	}
	else {
		evt.returnValue = false;
	}
}