var getBounds=function(p){
    var left=p.offsetLeft,top=p.offsetTop,w=p.offsetWidth;h=p.offsetHeight;
    while(p=p.offsetParent){left+=p.offsetLeft;top+=p.offsetTop;}return{left:left,top:top,width:w,height:h};};

var getSize=function(){var x,y,sx,sy,px,py;if(self.innnerHeight){x=self.innerWidth;y=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){x=document.documentElement.clientWidth;y=document.documentElement.clientHeight;}else if(document.body){x=document.body.clientWidth;y=document.body.clientHeight;}if(self.pageYOffset){sx=self.pageXOffset;sy=self.pageYOffset;}else if(document.documentElement&&document.documentElement.scrollTop){sx=document.documentElement.scrollLeft;sy=document.documentElement.scrollTop;}else if(document.body){sx=document.body.scrollLeft;sy=document.body.scrollTop;}var test1=document.body.scrollHeight;var test2=document.body.offsetHeight;if(test1>test2){px=document.body.scrollWidth;py=document.body.scrollHeight;}else{px=document.body.offsetWidth;py=document.body.offsetHeight;}return {x:x,y:y,sx:sx,sy:sy,px:px,py:py};};

function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  window.alert( 'Width = ' + myWidth );
  window.alert( 'Height = ' + myHeight );
}

/*
var locateCenter = function(objPos,Xwidth,Yheight,divid){
    var viewportH = getViewPortHeight();
    
    screenNum = Math.floor(objPos/viewportH);
    leftOffset = getBounds(document.body).width;
    
    vertpos = (Math.round(viewportH/2)-Math.round(Yheight/2)) + screenNum*viewportH;
    leftOffset = (Math.round(leftOffset/2)-Math.round(Xwidth/2))
    
    var o=document.getElementById(divid); 
    var r=o.style; 
    r.position='absolute'; 
    r.top = vertpos-30 + 'px'; 
    r.left = leftOffset + 'px'; 
    
    alertSize()
    //alert(getScrollXY()[1])
}
*/
function getToolTip(e, obj, createShim,myShim){
   if (typeof arguments.callee.tooltip == 'undefined') {
   		var t = document.createElement('div');
   		var title  = t.appendChild(document.createElement('div'));
   		var content = t.appendChild(document.createElement('div'));
   		var closing = t.appendChild(document.createElement('div'));
   		t.id = 'myToolTip';
   		title.id = 'myToolTipTitle';
   		content.id = 'myToolTipContent';
   		closing.id = 'myToolTipCross';
   		closing.innerHTML = '&times;';
   		closing.onclick = function(e){myShim.hideShim(); this.parentNode.style.display = 'none'; var shim = document.getElementById('myShim'); /*document.getElementById('shadow').style.display = 'none';*/ if(shim) {shim.style.display='none';} if(window.event) window.event.cancelBubble = true; if (e) e.stopPropagation(); };
   		t.onclick = function(e){ this.style.display = 'block'; if (window.event) window.event.cancelBubble = true; if (e) e.stopPropagation(); };
   		
   		t.setTitle = function(ttl){ this.firstChild.innerHTML = ttl; };
   		t.setContent = function(cnt) { this.childNodes[1].innerHTML = cnt; };
   		t.style.position = 'absolute';
   		t.style.zIndex = '9999';
   		
   		arguments.callee.tooltip = document.body.appendChild(t);
   }

   var mc = getBounds(obj);
   with(arguments.callee.tooltip.style) {
     display = 'block';
   //  left = '90px';
     top = (mc.top + mc.height - 3 ) + 'px';
     left = obj.offsetLeft+17 + 'px';
     //top = (mc.top + mc.height - 3 ) + 'px';
   }
   
    myShim.setWidth(getBounds(document.body).width + 'px')
    myShim.setHeight(getBounds(document.body).height +6 + 'px')
    var pbpos = findPos(document.body);
    myShim.setTop(pbpos[1]-3);
    myShim.setLeft(pbpos[0]);
    myShim.setTransparency(.7);
    myShim.showShim();
                
   if (createShim) {
     if (typeof arguments.callee.shim == 'undefined') {
       var shim = document.createElement('iframe');
       shim.id = 'myShim';
       shim.src = "javascript:'<html></html>'";
       with (shim.style) {
         position = 'absolute';
         zIndex = '1';
         background = 'red';
       }
       arguments.callee.shim = document.body.appendChild(shim);
     }
     arguments.callee.shim.style.display = 'block';
   }
   
   return arguments.callee.tooltip;
}

function showTooltip(e, obj, msg,myShim){
	var createShim = false; 
	var tooltip = getToolTip(e, obj, createShim,myShim);
	
	tooltip.setTitle('Description');
	tooltip.setContent(msg);
	
	if(window.event) window.event.cancelBubble = true
	if(e)if(e.stopPropagation) e.stopPropagation();
	
	//var mc = getBounds(obj);
    //objPos = mc.top;
   
    //mc = getBounds(tooltip);
    //locateCenter(objPos,mc.width,mc.height,'myToolTip');
   
	return false;
}
