function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
    if(document.layers)	   //NN4+
    {
       document.layers[szDivID].visibility = iState ? "show" : "hide";
    }
    else if(document.getElementById)	  //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        obj.style.visibility = iState ? "visible" : "hidden";
        /*obj.style.marginLeft="0px";*/
        if(navigator.appName=="Microsoft Internet Explorer" && parseInt(navigator.appVersion)>=4){obj.style.marginLeft="70px"}
    }
    else if(document.all)	// IE 4
    {
        document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
    }
}


function debug(text){

//    document.getElementById('debug').innerHTML += '<BR>' + text;

}



function enableTooltips(id){
    help_images = getElementsByClassName(document, '*','help_img');
   
   

   for(i=0;i<help_images.length;i++){
       Prepare(help_images[i]);
    }
}



function Prepare(el){
    var help = el.id.replace('img_','bubble_');

	
	
   el.onmouseover = function(e){
        showTooltip(e, help);
    }
    el.onmouseout = function(e){
        hideTooltip(e, help);
    }
    el.onmousemove = function(e){
        showTooltip(e, help);
    }
}


function showTooltip(e, fieldname){

    var posx=0,posy=0;
    if(e==null) e=window.event;
    if(e.pageX || e.pageY){
        posx=e.pageX; posy=e.pageY;
        }
    else if(e.clientX || e.clientY){
        if(document.documentElement.scrollTop){
            posx=e.clientX+document.documentElement.scrollLeft;
            posy=e.clientY+document.documentElement.scrollTop;
            }
        else{
            posx=e.clientX+document.body.scrollLeft;
            posy=e.clientY+document.body.scrollTop;
            }
    }
   	
	var TIP = document.getElementById(fieldname); 
    
	//alert(TIP.Value);
	TIP.style.display = 'block';
    TIP.style.zIndex = "1000";
    height_visible_screen = (window.innerHeight || document.documentElement.clientHeight);
    heigh_TIP_div      = TIP.offsetHeight;
    heigh_cursor_position = posy;
        //allow these values to be altered from within the HTML
        fieldname_alter_top = 20;
         if ( document.getElementById(fieldname).getAttribute("fieldname_alter_top") ){
           fieldname_alter_top = parseInt(TIP.getAttribute("fieldname_alter_top") );
        }
        fieldname_alter_left = 5;
        if ( document.getElementById(fieldname).getAttribute("fieldname_alter_left") ){
           fieldname_alter_left = parseInt( TIP.getAttribute("fieldname_alter_left") );
        } 
        // end left,top setup
    TIP_style_top  = posy + fieldname_alter_top;
    TIP_style_left = posx+fieldname_alter_left;
    //if there is no space to display to TIP under the cursor, show it on top 
    if( (heigh_cursor_position + heigh_TIP_div + 20) > height_visible_screen ){
        TIP_style_top = (heigh_cursor_position - heigh_TIP_div - 5);
    }
    //Finally set the top/left
    TIP.style.top = TIP_style_top+'px';
    TIP.style.left = TIP_style_left+'px';    
}

function hideTooltip(e, fieldname){
	document.getElementById(fieldname).style.display = 'none';

}