/**
 * noneBlock
 *
 * Description:
 *   Changes the class name of the passed elements. Multiple elements, with
 *   their styles, can be updated.
 *
 * Functional Overview:
 *   1) loop over all arguments passed to this function
 *   2) split each argument into element name and class name
 *   3) get reference to element
 *   4) set class name
 *
 * Parameters:
 *   x number of parameters specifying element!style pairs
 *   styles are as follows:
 *     0 = none
 *     1 = block
 *     2 = inline
 *     3 = table-row (block for IE)
 *
 * Examples:
 *   noneBlock( "myDiv!2" );
 *   noneBlock( 'myDiv!1', 'yourDiv!0' );
 */

function noneBlock()
{
  var s_navigator = navigator.userAgent.toLowerCase();
  var isIE = (s_navigator.indexOf("msie")>-1&&s_navigator.indexOf("opera")==-1);
  var a_arguments = noneBlock.arguments;
  for(var i=0;i < a_arguments.length;i++)
  {
    a_nB = a_arguments[i].split("!");
    s_nBit = a_nB[0];
    i_nBdisplay = a_nB[1];
    o_showHide = document.getElementById(s_nBit)
	  if(o_showHide != null)
      o_showHide.style.display = (i_nBdisplay==0) ? "none" : (i_nBdisplay==1) ? "block" : (i_nBdisplay==2) ? "inline" : (i_nBdisplay==3) ? (isIE) ? "block" : "table-row" : (i_nBdisplay==4) ? (isIE) ? "block" : "table-cell" : "block";
  }
}

/**
 * switchCss
 *
 * Description:
 *   Changes the display style of the passed elements. The available display
 *   styles are: none, block and inline. Multiple elements, with their styles,
 *   can be updated.
 *
 * Functional Overview:
 *   1) loop over all arguments passed to this function
 *   2) split each argument into element name and display style
 *   3) get reference to element
 *   4) set display style
 *
 * Parameters:
 *   x number of parameters specifying element!className pairs
 *
 * Examples:
 *   cssSwitch( "myDiv!myStyle" );
 *   cssSwitch( 'myDiv!myStyle', 'yourDiv!yourStyle' );
 */

function cssSwitch()
{
  var a_arguments = cssSwitch.arguments;
  for(var i=0;i < a_arguments.length;i++)
  {
    a_nB = a_arguments[i].split("&");
    s_nBit = a_nB[0];
    i_nBdisplay = a_nB[1];
    o_showHide = document.getElementById(s_nBit)
    o_showHide.className = i_nBdisplay;
  }
}


/**
 * fltrObj
 *
 * Description:
 *   Changes the content of the passed element.
 *
 * Functional Overview:
 *   1) split argument into element name and content
 *   2) get reference to element
 *   3) set element's content
 *
 * Parameters:
 *   parameter specifying element!content pair
 *
 * Examples:
 *   fltrObj( "myDiv!myContent" );
 */

function fltrObj(s_fOValue)
{
  a_fO = s_fOValue.split("|");
  document.getElementById(a_fO[0]).innerHTML = a_fO[1];
}


/**
 * funSort
 *
 * Description:
 *   Sorts out which functions to call base one the parameters given.
 *   That is, name/value pairs separated by ! will be passed to noneBlock,
 *   name/value pairs separated by | will be passed to fltrObj, and
 *   all other name/value pairs will be passed to cssSwitch which assumes
 *   the pair is separated by &.
 *
 * Functional Overview:
 *   1) loop over all arguments passed to this function
 *   2) if name/value pair is separated by !, then pass pair to noneBlock
 *   3) if name/value pair is separated by |, then pass pair to fltrObj
 *   4) else pass name/value pair to cssSwitch
 *
 * Parameters:
 *   parameter specifying element!content pair
 *
 * Examples:
 *   funSort( "myDiv!0", "yourDiv!2", "myDiv|myContent", "yourDiv&yourCssStyle" );
 */

function funSort()
{
  a_fSarg = funSort.arguments;
  for (var i=0;i < a_fSarg.length;i++)
  {
    (a_fSarg[i].indexOf("!") > 0) ? noneBlock(a_fSarg[i]) : (a_fSarg[i].indexOf("|") > 0) ? fltrObj(a_fSarg[i]) : cssSwitch(a_fSarg[i]);
  }
}
/**
*  Function open the time keeper popup window
*
*/

function timeKeeperPopUp()
{
  win=window.open('TimekeeperPopUpAction.do','tkpop','width=500,height=400,resizable=no,scrollbars=no,toolbar=no,location=no,status=no,top=175,left=300');
  statusWindow='open';
  win.focus();
}

/**
 * setVisibility
 *
 * Description:
 *   Changes the visibility style of the passed elements.
 *   Multiple elements can be updated.
 *
 * Patterned after noneBlock()
 *
 * Functional Overview:
 *   1) loop over all arguments passed to this function
 *   2) split each argument into element name and visibility indicator
 *   3) get reference to element
 *   4) set style.visibility
 *
 * Parameters:
 *   x number of parameters specifying element!indicator pairs
 *   styles are as follows:
 *     0 = set to hidden
 *     1 = set to visible
 *     2 = set to collapse
 *
 * Examples:
 *   noneBlock( "myDiv!1" );
 *   noneBlock( 'myDiv!0', 'yourDiv!0' );
 */

function setVisibility()
{
  var a_arguments = setVisibility.arguments;

  for(var i=0;i < a_arguments.length;i++)
  {
    a_nB = a_arguments[i].split("!");
    s_nBit = a_nB[0];
    i_nBdisplay = a_nB[1];
    o_showHide = document.getElementById(s_nBit)

    if ( o_showHide != null )
    {
      o_showHide.style.visibility = (i_nBdisplay==0) ? "hidden" : (i_nBdisplay==1) ? "visible" : "collapse";
    }
  }
}



/*
 * compare two strings, without regard to case
 *
 */
function equalsIgnoreCase( string1, string2 )
{
  var upperString1 = string1.toUpperCase();
  var upperString2 = string2.toUpperCase();

  if ( upperString1 == upperString2 )
  {
    return true;
  }

  return false;
}

