// ==============================================================================
//
// Javascript utility library
//
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// LTrim removing leading spaces
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
    function ltrim()
    { var i;
      var s=this;
      for (i=0; i<s.length; i++)
      { if (s.substr(i,1) != " ")
          break;
      }
      if (i < s.length)
        s=s.substr(i);
      else
        s="";
      return s;
    }
//
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// RTrim removing trailing spaces
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
    function rtrim()
    { var i;
      var s=this;
      for (i=s.length-1; i>=0; i--)
      { if (s.substr(i,1) != " ")
          break;
      }
      if (i >=0)
        s=s.substr(0, i+1);
      else
        s="";
      return s;
    }
//
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Trim a string, removing leading and trailing spaces
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
    function trim()
    { var i;
      var s=this;
      // Ltrim
      for (i=0; i<s.length; i++)
      { if (s.substr(i,1) != " ")
          break;
      }
      if (i < s.length)
        s=s.substr(i);
      else
        s="";
      // RTrim
      for (i=s.length-1; i>=0; i--)
      { if (s.substr(i,1) != " ")
          break;
      }
      if (i >=0)
        s=s.substr(0, i+1);
      else
        s="";
      return s;
    }
//
//  Add to 'String' function
//
    String.prototype.ltrim=ltrim;
    String.prototype.rtrim=rtrim;
    String.prototype.trim=trim;
//
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//    Mouse Over Function for LeftBar
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//   
//
  function MouseOn()
  { if (window.event)
      if (window.event.srcElement)
      { if (window.event.srcElement.className=="LeftBarLink")
          window.event.srcElement.className="LeftBarHighlight";
        
        if (window.event.srcElement.className=="MainLink")
          window.event.srcElement.className="MainLinkHighlight";
      }
  }
  
  function MouseOff()
  { if (window.event)
      if (window.event.srcElement)
      { if (window.event.srcElement.className=="LeftBarHighlight")
          window.event.srcElement.className="LeftBarLink";
        
        if (window.event.srcElement.className=="MainLinkHighlight")
          window.event.srcElement.className="MainLink";
      }
  }
  
  document.onmouseover = MouseOn;
  document.onmouseout  = MouseOff;
//

// ==============================================================================
// Proper case Function (deals with Mc and Mac)
// ==============================================================================

function PCase(STRING){
	var strReturn_Value = "";
	var iTemp = STRING.length;
	if(iTemp==0){
	return"";
	}
	var UcaseNext = false;
	strReturn_Value += STRING.charAt(0).toUpperCase();
	for(var iCounter=1;iCounter < iTemp;iCounter++){
	if(UcaseNext == true){
		strReturn_Value += STRING.charAt(iCounter).toUpperCase();
	}
	else{
	strReturn_Value += STRING.charAt(iCounter).toLowerCase();
	}
	var iChar = STRING.charCodeAt(iCounter);
	if(iChar == 32 || iChar == 45 || iChar == 46){
		UcaseNext = true;
	}
	else{
	UcaseNext = false
	}
	if(iChar == 99 || iChar == 67){
	if(STRING.charCodeAt(iCounter-1)==77 || STRING.charCodeAt(iCounter-1)==109){
	UcaseNext = true;
	}
	}
	
	
	} //End For
	
	return strReturn_Value;
}
//End Function


// ==============================================================================
// Open Window Function
// ==============================================================================

function openWin(url, windowName, width, height, scrollbars) {
var win;
var params;
var windowName;
params = "toolbar=0,";
params += "location=0,";
params += "directories=0,";
params += "status=0,";
params += "menubar=0,";
params += "scrollbars="+scrollbars+",";
params += "resizable=1,";
params += "top=20,";
params += "left=20,";
params += "width="+width+",";
params += "height="+height;
win = window.open(url, windowName, params);
}
//End Function


