
function swap(img,isrc) {
   if (!document.images) return;
   document.images[img].src = isrc;
}

// get the height of an image, by it's id="" value
function docjslib_getImageHeight(imgID) {
  return eval(imgID).height;
}

// get the left (x) coord of an image, by it's id="" value
function docjslib_getRealLeft(imgElem) {
	xPos = eval(imgElem).offsetLeft;
	tempEl = eval(imgElem).offsetParent;
  	while (tempEl != null) {
  		xPos += tempEl.offsetLeft;
  		tempEl = tempEl.offsetParent;
  	}
	return xPos;
}

// get the top (y) coord of an image, by it's id="" value
function docjslib_getRealTop(imgElem) {
	yPos = eval(imgElem).offsetTop;
	tempEl = eval(imgElem).offsetParent;
	while (tempEl != null) {
  		yPos += tempEl.offsetTop;
  		tempEl = tempEl.offsetParent;
  	}
	return yPos;
}

function find_left( imgName  )
{
    var imgID = document.images[imgName];
    var left;

    left = docjslib_getRealLeft( imgID ) + 2;

    return left;
}

function find_top( imgName  )
{
    var imgID = document.images[imgName];
    var top;

    top = docjslib_getRealTop( imgID );

    return top;
}

function find_bottom( imgName  )
{
    var imgID = document.images[imgName];
    var bottom, height;

    height = docjslib_getImageHeight( imgID );
    bottom = docjslib_getRealTop( imgID ) + height - 1;

    return bottom;
}

// this function shows/hides the text hints in form fields
function textHint( $frm, $element, $event, $text, $hint )
{
    $obj = document.forms[$frm].elements[$element];

    if( $obj )
    {
	if( $event == 'focus' )
	{
	    if( $obj.value == $text )
	    {
		$obj.value = '';
	    }
	    
	    if( $hint )
	    {
		window.status = $hint;
	    }
	}
	else if( $event == 'blur' )
	{
	    if( $obj.value == '' )
	    {
	    	$obj.value = $text;
	    }

	    if( $hint )
	    {
		window.status = '';
	    }
	}
    }
}

function pageOffset()
{
    if( document.layers && document.layers['flash_menu'] != null ) // then, Netscape (?)
    {
	document.layers['flash_menu'].pageX = find_left( 'flash_menu_spacer' ) - 2;
	document.layers['flash_menu'].pageY = find_top( 'flash_menu_spacer' ) - 1;
    }
    else if( document.all && document.all['flash_menu'] != null ) // then, MSIE
    {
	document.all['flash_menu'].style.left = find_left( 'flash_menu_spacer' ) - 2;
	document.all['flash_menu'].style.top = find_top( 'flash_menu_spacer' ) - 1;
    }
}

function popWindow( uri, width, height )
{
    var wnd = window.open( uri,
			   '_blank', 
			   'height=' + height + ',width=' + width + ',location=no,menubar=no,scrollbars=no,resizable=no,toolbar=no'
			   );
    wnd.focus();
} // popWindow

function popOnLoad( url, width, height )
{
        var x = (screen.width - width)/2;
        var y = (screen.height - height)/2;
	var wnd = window.open( url,
			       '_blank', 
			       'height=' + height + ',width=' + width + ',left=' + x + ',top=' + y + ',location=no,menubar=no,scrollbars=no,resizable=no,toolbar=no'
			       );
	wnd.focus();	
} // popOnLoad


