/**
*	Utility.js - what do you think it does?
*/

/**
*	straight stolen from prototype
*/
function $(id)
{
	return document.getElementById(id);
}

/**
*	This one is all mine - does not seem to work unless call things after window.onload()
*/
function trace(msg, target)
{
	var target = target || 'tracebox';
	var style = '';
	msg += '<br/>';
	
	
	if(!$(target))
	{
		if(target == 'tracebox')
		{
			style = "position:absolute;";
			style += "top:0px; right:0px;"
			style += "width:170px;"
			style += "border:1px solid #AAAAAA;";
			style += "background:#EEEEEE;";
			style += "padding:5px;";
		}
		
		$('wrapper').innerHTML += '<div id="' + target + '" style="' + style +'"></div>';
		$(target).innerHTML = '';
	}
	
	$(target).innerHTML += msg;
}

/**
*	EZ remapping (I think that is the term for it ...
*/
function dw(msg)
{
	document.write(msg + '<br/>');
}

/**
*   HTML tag writing function
*   Aaron Lile 2008
*
*   @param element -    string, the element type. ie: 'p'
*   @param content -    the text node value.  ie: 'this is some sample content'
*                           note: other elements can be sent in the content, such as <em> tags
*   @param attributes - object containing any attributes desired in the element.  ie: {class:'leftNav'}
*   @return tag -       a string with the assembled parameters
*/
function enTag(element, content, attributes)
{
    // check params
    var element = element || 'span';
    var content = content || '';
    var attributes = attributes || false;
    // open the tag
    var tag = "<" + element;
    // set element attributes, if any are given
    if(attributes)
    {
        for(var i in attributes)
        {
            tag += " " + i + "=\"" + attributes[i] + "\"";
        }
    }
    // close the tag
    if(element == 'img' || element == 'input')// then it self closes
    {
        tag += "/>";
    }
    else
    {
        tag += ">" + content + "</" + element + ">";
    }
    // return the string
    return tag;
}