// JavaScript Utility Library v1.1
// Copyright 2002 Andrew Hibner, the HiBeck Company
//
// This script may be freely distributed provided this header 
// is always present at the top of the library, unaltered.
//
// Editing/modifying this header in anyway voids any usage
// and distribution license.
//
// visit http://www.thenamelesspage.com/hibeck/
// email: contact@thenamelesspage.com
//
// Please email if you find a bug / compatibility issue or
// wish to make a suggestion.
//


/////////////////////
// call this routine from a JavaScript code block just after the <body>
// tag but before any other HTML
//
// init_the_div() will make the DIV object available under DOM

function init_the_div()
{
	if( !isDOM ) return;

	var newDiv = document.createElement('div');
	document.getElementsByTagName('body').item(0).appendChild(newDiv);

}

function init_the_span()
{
	if( !isDOM ) return;
	
	var newSpan = document.createElement('span');
	document.getElementsByTagName('body').item(0).appendChild(newSpan);

}

/////////////////////////
// will return an HTML element regaurdless of browser
//
function get_at_object(id)
{
	if( isDOM ) return document.getElementById(id);
	if( isIE4 ) return document.all[id];
	if( isNS ) return eval("document."+id);

}

//////////////////////
// returns the "style" of an object
// use this routine to access all objects
//
function get_style(id)
{
	return (isNS ? get_at_object(id) : get_at_object(id).style);

}

function get_image(id)
{
	var dud = isNS ? "document."+id : "document.images[\'"+id+"\']";
	var dudin = eval(dud);
	return dudin;

}

function show_object(id, bShow)
{
	var dud = get_style(id);
	dud.visibility = bShow ? VISIBLE : HIDDEN;

}

function show_objectEx(object, bShow)
{
	object.visibility = bShow ? VISIBLE : HIDDEN;
}

function move_object(id, x, y)
{
	var dud = get_style(id);
	dud.left = x;
	dud.top = y;

}

//////////
// move_window() functions similiar to win32 routine MoveWindow(),
// it can change the position and size of an object
function move_window(id, x, y, w, h)
{
	var dud = get_style(id);
	dud.left=x;
	dud.top=y;
	dud.width=w;
	dud.height=h;

}

function get_width(id)
{
	var dud = get_style(id);
	return dud.width;
}
function get_height(id)
{
	var dud = get_style(id);
	return dud.height;
}

function change_color(id, color)
{
	var dud = get_at_object(id);
	dud.color = color;

}

// image param is a URL to new image
function flip_image(id, image)
{
	var dud = get_image(id);
	dud.src = image;

}

////////////////////////////////////////////////
// 24bit color values are typically stored as 0x00BBGGRR
//
// the following routines are modeled after their corresponding
// win32 macros and yeild the same output
//

// this routine will generate a 32bit RGB color value
function RGB(red, green, blue)
{
	var dud = ((blue) | (green << 8) | (red << 16) | (0x00 << 24));
	return dud;

}

// extract individual color components
function GetRValue(color)
{
	return (color << 24)>>24;
}
function GetGValue(color)
{
	return (color << 16)>>24;
}
function GetBValue(color)
{
	return (color >> 16);
}


// globals

var isDOM = document.getElementById ? true : false;
var isIE4 = document.style ? true : false;
var isNS = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) == 4);	// backwards


var VISIBLE = (isNS) ? 'show' : 'visible';
var HIDDEN = (isNS) ? 'hide' : 'hidden';

var screenx = screen.width;
var screeny = screen.height;
var browser_name = navigator.appName;
var browserv = navigator.appVersion;
var scrollTop = (isNS) ? 'window.pageYOffset' : 'document.body.scrollTop';
var scrollLeft = (isNS) ? 'window.pageXOffset' : 'document.body.scrollLeft';