/** Toggle Functions
  * Helper functions to toggle visibility and/or images.  
  * Toggling is fun!
  * @author verysimple, inc. <www.verysimple.com>
  */

/** Toggles the visibility of the given tag
  * @param tagid the id of the dom item to toggle
  * @return void
  */
function toggle(tagid)
{
	var divtag = getDiv(tagid);
	
	divtag.style.display = (divtag.style.display == 'none') ? '' : 'none';

}

/** Toggles an image between two graphics
  * @param tagid the id of the dom item to toggle
  * @param url1 first of the two image rls being toggled
  * @param url2 second of the two image rls being toggled
  * @return void
  */
function toggleImage(tagid,url1,url2)
{
	var img = getDiv(tagid);

	// the skin path is often something like './skins/etc...'
	// if so we need to strip it off because the image src proprty will remove
	// that from it's path & we won't find a match when toggling

	if (url1.substr(0,2) == './') url1 = url1.substr(2)
	if (url2.substr(0,2) == './') url2 = url2.substr(2)
	
	// we have to get the end of the scr string because the browser may
	// report back to us the full url & we won't get a match
	if (img.src.substr(img.src.length-url1.length,url1.length) == url1)
	{
	    img.src = url2;
	}
	else
	{
	    img.src = url1
	}
	
}

/** Sets an objects visibility to visible
  * @param tagid the id of the dom item to toggle
  * @return void
  */
function show(tagid)
{
	var divtag = getDiv(tagid);
	
	divtag.style.display = '';

}

/** Sets an objects visibility to hidden
  * @param tagid the id of the dom item to toggle
  * @return void
  */
function hide(tagid)
{
	var divtag = getDiv(tagid);
	
	divtag.style.display = 'none';

}


/** Returns the dom object given the id string
  * @param tagid the id of the dom item to toggle
  * @return object
  */
function getDiv(tagid)
{

	if (document.getElementById)
	{
		return document.getElementById(tagid);
	}

	return document.all(tagid);

}