
/* This script was based on a script
   from The JavaScript Source :: http://javascript.internet.com 
   Created by: JTricks.com :: http://www.jtricks.com/
   Arnold Kochman                */

function move_box(an, box, x0, y0)
{
    var cleft = x0;
    var ctop = y0;
    var obj = an;
    while (obj.offsetParent) 
	{
	    cleft += obj.offsetLeft;
	    ctop += obj.offsetTop;
	    obj = obj.offsetParent;
	}
    box.style.left = cleft + 'px';
    ctop += an.offsetHeight + 8;
    if (document.body.currentStyle && document.body.currentStyle['marginTop']) 
	{
	    ctop += parseInt(document.body.currentStyle['marginTop']);
	}
    box.style.top = ctop + 'px';
}


/* Prepares to alternately display or hide the URL */
function show_hide_box(an, width, height, borderStyle, x0, y0, bg) 
{
    var href = an.href;
    var boxdiv = document.getElementById(href);
    
    if (boxdiv != null) 
	{
	    if (boxdiv.style.display=='none')
		{
		    move_box(an, boxdiv, x0, y0);
		    boxdiv.style.display='inline';
		} 
	    else
		{
		boxdiv.style.display='none';
		}
	    return false;
	}
    
    boxdiv = document.createElement('div');
    boxdiv.setAttribute('id', href);
    boxdiv.style.display = 'inline';
    boxdiv.style.position = 'absolute';
    boxdiv.style.width = width + 'px';
    boxdiv.style.height = height + 'px';
    boxdiv.style.border = borderStyle;
    boxdiv.style.backgroundColor = bg;
    boxdiv.style.allowTransparency='allowTransparency';


    var contents = document.createElement('iframe');
    contents.scrolling = 'no';
    contents.frameBorder = '0';
    contents.style.width = width + 'px';
    contents.style.height = height + 'px';
    contents.src = href;
    
    boxdiv.appendChild(contents);
    document.body.appendChild(boxdiv);
    move_box(an, boxdiv, x0, y0);
    
    return false;
}



/* A global variable to keep the URL name for interoperaion of the 
   show_box_nolink and hide_box_nolink routines  */
var saved_link;



/* Prepares to display the URL - This routine overwrites the URL 
   name in the anchor object (with '#') so that clicking on the 
   link will not open the new page. However, it is saved to facilitate
   the removal of the display by hid_box_nolink */
function show_box_nolink(an, width, height, borderStyle, x0, y0, bg) 
{
    var href = an.href;
    var boxdiv = document.getElementById(href);
 
    saved_link = an.href;
    an.href = '#';

    if (boxdiv != null) 
	{
	    if (boxdiv.style.display=='none')
		{
		    move_box(an, boxdiv, x0, y0);
		    boxdiv.style.display='inline';
		} 
	    else
		{
		    boxdiv.style.display='none';
		}
	    return false;
	}
 
    boxdiv = document.createElement('div');
    boxdiv.setAttribute('id', href);
    boxdiv.style.display = 'inline';
    boxdiv.style.position = 'absolute';
    boxdiv.style.width = width + 'px';
    boxdiv.style.height = height + 'px';
    boxdiv.style.border = borderStyle;
    boxdiv.style.backgroundColor = bg;
    
    var contents = document.createElement('iframe');
    contents.scrolling = 'no';
    contents.frameBorder = '0';
    contents.style.width = width + 'px';
    contents.style.height = height + 'px';
    contents.src = href;
    
    boxdiv.appendChild(contents);
    document.body.appendChild(boxdiv);
    move_box(an, boxdiv, x0, y0);
  
    an.href = '#';
    return false;
}



/* Prepares to hide the URL */
function hide_box_nolink(an, width, height, borderStyle, x0, y0, bg) 
{
    an.href = saved_link;
    var href = an.href;
    var boxdiv = document.getElementById(href);

    if (boxdiv != null) 
	{
	    if (boxdiv.style.display=='none')
		{
		    move_box(an, boxdiv, x0, y0);
		    boxdiv.style.display='inline';
		} 
	    else
		{
		    boxdiv.style.display='none';
		}
	    return false;
	}
    
    boxdiv = document.createElement('div');
    boxdiv.setAttribute('id', href);
    boxdiv.style.display = 'inline';
    boxdiv.style.position = 'absolute';
    boxdiv.style.width = width + 'px';
    boxdiv.style.height = height + 'px';
    boxdiv.style.border = borderStyle;
    boxdiv.style.backgroundColor = bg;
    
    var contents = document.createElement('iframe');
    contents.scrolling = 'no';
    contents.frameBorder = '0';
    contents.style.width = width + 'px';
    contents.style.height = height + 'px';
    contents.src = href;
    
    boxdiv.appendChild(contents);
    document.body.appendChild(boxdiv);
    move_box(an, boxdiv, x0, y0);
    
    return false;
}


