
/*************************************************************************
  This code is from Dynamic Web Coding at http://www.dyn-web.com/
  Copyright 2003 by Sharon Paine 
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/
//    var shdw = document.getElementById? document.getElementById('shdw'): null;
    var shdw = document.getElementById('shdw');
    var hostName = location.host;
   // var mnu = document.getElementById? document.getElementById('tooltip_l'): null;

var menuLayers = {
  timer: null,
  activeMenuID: null,
  show: function(id, e, span_over, hdr) {
  //alert(span_over.id);
    if ( document.getElementById('shdw').nextSibling!=null && document.body.lastChild.id.substring(0,8)=="tooltip_l") var  RemovedItem = document.body.removeChild(document.body.lastChild);
    //if ( document.getElementById('shdw').nextSibling!=null ) var RemovedItem = document.body.removeChild(document.getElementById('shdw').nextSibling);
    var mnu = document.getElementById? document.getElementById("tooltip_l"+span_over.id): null;
	var id_over = document.getElementById? document.getElementById(span_over): null;
	if (!mnu) {mnu = document.createElement("span");
	mnu.className="tooltip_pr";
	mnu.setAttribute("id","tooltip_l"+span_over.id);
	mnu.setAttribute("z-index","1000");}
	
	mnu.innerHTML='<b style="background-color: transparent;" class="rtop"><b style="background-color: rgb(29, 29, 29);" class="r1"></b><b style="background-color: rgb(250, 250, 250);" class="r2"></b><b style="background-color: rgb(250, 250, 250);" class="r3"></b><b style="background-color: rgb(250, 250, 250);" class="r4"></b><b style="background-color: rgb(250, 250, 250);" class="r5"></b></b><span class="tip_content" id="tip_content'+span_over.id+'"><span style="float: right; font-weight: bold; margin-right: 10px;"><a href="javascript:;" onclick="OnMouseLeaveSpan_span(this)" style="text-decoration: none; font: 11px Verdana!important bold; color:#a5a5a5;">x</a></span><img src="http://'+hostName+'/images/balloon/logo.gif" style="margin-bottom: 10px;"><br><span class="tt_hdr">' + hdr + '</span>' + document.getElementById(id).innerHTML + '</span><b style="background-color: transparent;" class="rbottom"><b style="background-color: rgb(250, 250, 250);" class="r5"></b><b style="background-color: rgb(250, 250, 250);" class="r4"></b><b style="background-color: rgb(250, 250, 250);" class="r3"></b><b style="background-color: rgb(250, 250, 250);" class="r2"></b><b style="background-color: rgb(29, 29, 29);" class="r1"></b></b>';
	
	document.body.appendChild(mnu);  
	
	//r_span="span#"+id;
	span_over.style.background="bisque";
	overElm = span_over.id;
	this.activeMenuID = "tooltip_l"+span_over.id;
	if ( mnu.onmouseout == null ) mnu.onmouseout = this.mouseoutCheck;
    if ( mnu.onmouseover == null ) mnu.onmouseover = this.clearTimer;
	//if (mnu.firstChild.className!="rtop") {RoundedTop(r_span,"transparent","#efefef"); RoundedBottom(r_span,"transparent","#efefef");}
	//if (!shdw){
	//shdw = document.createElement("span");
	//shdw.className="tip_shdw";
	//shdw.id="shdw";
	//shdw.style.width="320px";
	
	//shdw.style.height=span_over.offsetHeight+5+"px";
	//RoundedTop(shdw,"transparent","#000"); RoundedBottom(shdw,"transparent","#000");
	//document.body.appendChild(shdw);
	//}
    viewport.getAll();
	
        this.position(mnu,e,span_over);
        //var cmndString = "createShadow('"+span_over.id+"');";
        
        this.timer = setTimeout("createShadow('"+span_over.id+"');",200);
    
  },
  
  hide: function(idp) {
    this.clearTimer();
	//alert(idp);
	
    if (this.activeMenuID && document.getElementById) {
	  var id=menuLayers.activeMenuID;
	  
	  var cmndString;
      cmndString = "if (document.getElementById('"+id+"')!= null) document.getElementById('"+id+"').style.visibility = 'hidden';"
      this.timer = setTimeout(cmndString, 200);
    }
   //   this.timer = setTimeout("hideShadow();", 200);
   hideShadow();
//  document.getElementById(idp).style.background="";
  },
  
//   position_old: function(mnu, e, so) {
//    var x = e.pageX? e.pageX: e.clientX + viewport.scrollX;
//    var y = e.pageY? e.pageY: e.clientY + viewport.scrollY;
//	
//	if ( (so.offsetWidth - mnu.offsetWidth)/2+ so.offsetLeft < viewport.scrollX ) 
//		x = viewport.scrollX+8;
//	else
//	{
//	if ( so.offsetWidth/2 + so.offsetLeft + mnu.offsetWidth/2  > viewport.width + viewport.scrollX )
//      	{x = viewport.width + viewport.scrollX - mnu.offsetWidth-8;}
//    else { x = (so.offsetWidth- mnu.offsetWidth)/2+ so.offsetLeft + viewport.scrollX+8;}
//	}
//	if ( so.offsetTop - mnu.offsetHeight + 5 < viewport.scrollY  )
//	{ y = so.offsetTop + so.offsetHeight+5;
//	}
//    else{ y = so.offsetTop - mnu.offsetHeight+5; 
//	}
//	
//	mnu.style.left = x + "px"; mnu.style.top = y + "px";
//    this.timer = setTimeout("document.getElementById('" + menuLayers.activeMenuID + "').style.visibility = 'visible'", 300);
//  },
  
  
  position: function(mnu, e, so) {
	   
    d = window.event ? window.event.srcElement : e.currentTarget;
	currentElement = d;
	
	position = getBounds(d);
	
	var	x = position.left + position.width/2-155;
	var	y = position.top - mnu.offsetHeight-15;	
    var arrX = e.pageX? e.pageX-x: e.clientX + viewport.scrollX-x;
    //alert(mouseX);

    //alert("position overElm="+ overElm);
	if (x<7) x=5;
	else if (x + mnu.offsetWidth> viewport.width + viewport.scrollX) x=viewport.width + viewport.scrollX-mnu.offsetWidth-5;
	
	var arrX = e.pageX? e.pageX-x: e.clientX + viewport.scrollX-x;
	if(arrX > 310) arrX=280;
	else if (arrX < 10) arrX=10;
	
	var v = document.createElement("span");
	v.className="tip_v";
	v.innerHTML="";

	
	if (y+5< viewport.scrollY) {y=position.top+so.offsetHeight+18; v.style.marginTop="-23px"; v.style.position="relative"; v.style.background="url(http://"+hostName+"/images/balloon/v_tp.gif) " + arrX + "px 0px no-repeat";mnu.insertBefore(v,mnu.childNodes[1]);}
	else {v.style.marginTop="-1px";v.style.background="url(http://"+hostName+"/images/balloon/v_bttm.gif) " + arrX + "px 0px no-repeat"; mnu.appendChild(v);}
	
	mnu.style.left = x + "px"; mnu.style.top = y + "px";
	var cmndString = "if (document.getElementById('"+ menuLayers.activeMenuID + "')!= null) document.getElementById('" + menuLayers.activeMenuID + "').style.visibility = 'visible';"
    this.timer = setTimeout(cmndString, 200);
    //var cmndString = "createShadow('"+span_over.id+"');";
    //this.timer = setTimeout(cmndString,200);
  }, 
  
  
  mouseoutCheck: function(e) {
    e = e? e: window.event;
    // is element moused into contained by menu? or is it menu (ul or li or a to menu div)?
    var mnu = document.getElementById(menuLayers.activeMenuID);
	var id_s=mnu.id;
    var toEl = e.relatedTarget? e.relatedTarget: e.toElement;
    //alert("mouseCheck overElm="+ overElm);
	//mnu.style.background="bisque";
	if ( mnu != toEl && !menuLayers.contained(toEl, mnu) )
	{
	  menuLayers.hide();
	}
  },
  
  // returns true of oNode is contained by oCont (container)
  contained: function(oNode, oCont) {
    if (!oNode) return; // in case alt-tab away while hovering (prevent error)
    while ( oNode = oNode.parentNode ) 
      if ( oNode == oCont ) return true;
    return false;
  },

  clearTimer: function() {
    if (menuLayers.timer) clearTimeout(menuLayers.timer);
  }
  
}

/*function OnMouseOverSpanTran(obj,evnt)
{
	id = obj.id;
	if (id.search("tgt_") >= 0)
		{id = id.replace("tgt_", "src_");}
	else 
		{id = id.replace("src_", "tgt_");}
	hdr=;
	menuLayers.show(id, evnt, obj,hdr);
}

function OnMouseOverSpanOrig(obj,evnt)
{
	id = obj.id;
	if (id.search("tgt_") >= 0)
		{id = id.replace("tgt_", "src_");}
	else 
		{id = id.replace("src_", "tgt_");}
	hdr=;
	menuLayers.show(id, evnt, obj,hdr);
}*/

function OnMouseLeaveSpan(obj)
{	
id = obj.id;
	if (id.search("tgt_") >= 0)
		{id = id.replace("tgt_", "src_");}
	else 
		{id = id.replace("src_", "tgt_");}
        menuLayers.hide(id);
        //menuLayers.mouseoutCheck(event);
	   document.getElementById(obj.id).style.background="";
	   
	
}

function OnMouseLeaveSpan_span(obj)
{	

id = obj.id;
	obj.style.background="";
	menuLayers.hide(id);
	
	
}



/*function ilinks(){
    var span_tips, k;
    span_tips=document.getElementsByTagName('span');
    for(k=0; k<span_tips.length; k++) 
    {
        id=span_tips[k].id
        if (id.search("src_") >= 0) {
		span_tips[k].className="tooltip";
		span_tips[k].removeEventListener("onmouseover",null , false);
        }
    }
    
}

*/
function ilinks(){
    var linkss,i;
    linkss=document.getElementsByTagName('a');
    for (i=0; i<linkss.length; i++) {linkss[i].target="_parent";}
//    if (!mnu) {mnu = document.createElement("span");
//	mnu.className="tooltip";
//	mnu.setAttribute("id","tooltip_l");
//	mnu.setAttribute("z-index","1000");}
//	document.body.appendChild(mnu);

	//if (!shdw){
	//shdw = document.createElement("div");
	//shdw.className="tip_shdw";
   // shdw.id="shdw";
//shdw.innerHTML='<b style="background-color: transparent;" class="rtop_s"><b style="background-color: rgb(0, 0, 0);" class="r1_s"></b><b style="background-color: rgb(0, 0, 0);" class="r2_s"></b><b style="background-color: rgb(0, 0, 0);" class="r3_s"></b><b style="background-color: rgb(0, 0, 0);" class="r4_s"></b><b style="background-color: rgb(0, 0, 0);" class="r5_s"></b></b><span  id="shdw_block" class="shdw_block"></span><b style="background-color: transparent;" class="rbottom_s"><b style="background-color: rgb(0, 0, 0);" class="r5_s"></b><b style="background-color: rgb(0, 0, 0);" class="r4_s"></b><b style="background-color: rgb(0, 0, 0);" class="r3_s"></b><b style="background-color: rgb(0, 0, 0);" class="r2_s"></b><b style="background-color: rgb(0, 0, 0);" class="r1_s"></b></b>';}

//	shdwL1 = document.createElement("div");
//	shdwL1.className="tip_shdw";
//	shdwL1.id="shdw1";
//	shdwL1.innerHTML='<b style="background-color: transparent;" class="rtop_s"><b style="background-color: rgb(0, 0, 0);" class="r1_s"></b><b style="background-color: rgb(0, 0, 0);" class="r2_s"></b><b style="background-color: rgb(0, 0, 0);" class="r3_s"></b><b style="background-color: rgb(0, 0, 0);" class="r4_s"></b><b style="background-color: rgb(0, 0, 0);" class="r5_s"></b></b><span  id="shdw_block" class="shdw_block"></span><b style="background-color: transparent;" class="rbottom_s"><b style="background-color: rgb(0, 0, 0);" class="r5_s"></b><b style="background-color: rgb(0, 0, 0);" class="r4_s"></b><b style="background-color: rgb(0, 0, 0);" class="r3_s"></b><b style="background-color: rgb(0, 0, 0);" class="r2_s"></b><b style="background-color: rgb(0, 0, 0);" class="r1_s"></b></b>'
//	shdwL2 = document.createElement("div");
//	shdwL2.className="tip_shdw";
//	shdwL2.id="shdw2";
//	shdwL2.innerHTML='<b style="background-color: transparent;" class="rtop_s"><b style="background-color: rgb(0, 0, 0);" class="r1_s"></b><b style="background-color: rgb(0, 0, 0);" class="r2_s"></b><b style="background-color: rgb(0, 0, 0);" class="r3_s"></b><b style="background-color: rgb(0, 0, 0);" class="r4_s"></b><b style="background-color: rgb(0, 0, 0);" class="r5_s"></b></b><span  id="shdw_block" class="shdw_block"></span><b style="background-color: transparent;" class="rbottom_s"><b style="background-color: rgb(0, 0, 0);" class="r5_s"></b><b style="background-color: rgb(0, 0, 0);" class="r4_s"></b><b style="background-color: rgb(0, 0, 0);" class="r3_s"></b><b style="background-color: rgb(0, 0, 0);" class="r2_s"></b><b style="background-color: rgb(0, 0, 0);" class="r1_s"></b></b>'
//	shdw.appendChild(shdwL1);
//	shdw.appendChild(shdwL2)

  //  document.body.appendChild(shdw);
		
}

function ShadowCreate(){
if (!shdw){
	shdw = document.createElement("div");
	shdw.className="tip_shdw";
    shdw.id="shdw";
shdw.innerHTML='<b style="background-color: transparent;" class="rtop_s"><b style="background-color: rgb(0, 0, 0);" class="r1_s"></b><b style="background-color: rgb(0, 0, 0);" class="r2_s"></b><b style="background-color: rgb(0, 0, 0);" class="r3_s"></b><b style="background-color: rgb(0, 0, 0);" class="r4_s"></b><b style="background-color: rgb(0, 0, 0);" class="r5_s"></b></b><span  id="shdw_block" class="shdw_block"></span><b style="background-color: transparent;" class="rbottom_s"><b style="background-color: rgb(0, 0, 0);" class="r5_s"></b><b style="background-color: rgb(0, 0, 0);" class="r4_s"></b><b style="background-color: rgb(0, 0, 0);" class="r3_s"></b><b style="background-color: rgb(0, 0, 0);" class="r2_s"></b><b style="background-color: rgb(0, 0, 0);" class="r1_s"></b></b>';}

document.body.appendChild(shdw);
}


function createShadow_old()
{   
    //document.getElementById('shdw_block').style.height=document.getElementById('tooltip_l').getElementsByTagName("span")[0].offsetHeight+"px";
	document.getElementById('shdw_block').style.height=document.getElementById("tip_content").offsetHeight+"px";
	shdw.style.left = parseInt(document.getElementById('tooltip_l').style.left)+4+"px";
	shdw.style.top = parseInt(document.getElementById('tooltip_l').style.top)+4+"px";
	
	shdw.style.display="block";
	shdw.style.visibility = 'visible';

	
}

function createShadow(ce)
{   
    
    document.getElementById('shdw_block').style.height=document.getElementById("tip_content"+ce).offsetHeight+"px";
	shdw.style.left = parseInt(document.getElementById('tooltip_l'+ce).style.left)+4+"px";
	shdw.style.top = parseInt(document.getElementById('tooltip_l'+ce).style.top)+4+"px";
	
	shdw.style.display="block";
	shdw.style.visibility = 'visible';

	
}


 
 function hideShadow()
{   
	
	shdw.style.display="none";
	shdw.style.visibility = 'hidden';
	
}