function RTrim(value)
{
     var whitespace = new String(" \t\n\r");
     var s = new String(value);

     if (whitespace.indexOf(s.charAt(s.length-1)) != -1)
     {
          var i = s.length - 1;       // Get length of string
          while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
               i--;
               s = s.substring(0, i+1);
     }
     return s;
}

function LTrim(value)
{
     var whitespace = new String(" \t\n\r");
     var s = new String(value);

     if (whitespace.indexOf(s.charAt(0)) != -1)
     {
          var j=0, i = s.length;
          
          while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
               j++;
               s = s.substring(j, i);
     }
     return s;
}

function Trim(value)
{
     // return a boolean
     return RTrim(LTrim(value));
}

function closeMe()
{
     // close the current window
     self.close();
}

/********************************************************
* Button Functions                                               *
*********************************************************/
function HighlightButton(a){
     if (a.style)
     {
          if (a.className == 'pcButton')
          {
               // MouseOver
               a.className = 'pcButtonHighLight';
          }
          else
          {
               // MouseOut
               a.className = 'pcButton';
          }
     }
}

function HighlightButtonSubmenu(a){
     if (a.style)
     {
          if (a.className == 'pcButtonSubmenu')
          {
               // MouseOver
               a.className = 'pcButtonHighLightSubmenu';
          }
          else
          {
               // MouseOut
               a.className = 'pcButtonSubmenu';
          }
     }
}

function HighlightButtonSmall(a){
     if (a.style)
     {
          if (a.className == 'pcButtonSmall')
          {
               // MouseOver
               a.className = 'pcButtonSmallHighLight';
          }
          else
          {
               // MouseOut
               a.className = 'pcButtonSmall';
          }
     }
}

function HighlightButtonSmallWhite(a){
     if (a.style)
     {
          if (a.className == 'pcButtonSmallWhite')
          {
               // MouseOver
               a.className = 'pcButtonSmallHighLight';
          }
          else
          {
               // MouseOut
               a.className = 'pcButtonSmallWhite';
          }
     }
}
function HighlightButton2(obj,name){
   if (obj)  
	 obj.src = "/LBNLCareers/client/lbl/images/buttons/" + name; 
}

/********************************************************
* Popup Functions                                                *
*********************************************************/

function openCart()
{
     var h = 250;
     var w = 525;
     var t = ((screen.height / 2) - (h / 2)) - 100;
     var l = ((screen.width / 2) - (w / 2));
     var Config;
     var Page = '/LBNLCareers/popup/cart.asp';
     
     /* Set the configuration options */
     Config    =  ''
     Config += 'channelmode=no, ';
     Config += 'copyhistory=no, ';
     Config    += 'directories=no, ';
     Config += 'fullscreen=no, ';
     Config    += 'height=' + h + ', ';
     Config    += 'left=' + l + ', ';
     Config    += 'location=no, ';
     Config    += 'menubar=no, ';
     Config    += 'resizable=no, ';
     Config    += 'scrollbars=yes, ';
     Config    += 'status=no, ';
     Config    += 'titlebar=no, ';
     Config    += 'toolbar=no, ';
     Config    += 'top=' + t + ', ';
     Config    += 'width=' + w;
     
     /* Open the window */
     popup = window.open(Page, 'cart', Config);

     if(popup.opener == null) popup.opener = window;
     popup.opener.name = 'opener';
     
     /* Set the focus to the new window */
     if (popup)
     {
          popup.focus();
     }
}

function openSplash()
{
     var h = 150;
     var w = 325;
     var t = ((screen.height / 2) - (h / 2)) - 100;
     var l = ((screen.width / 2) - (w / 2));
     var Config;
     var Page = '/LBNLCareers/popup/splash.asp';
     
     /* Set the configuration options */
     Config    =  ''
     Config += 'channelmode=no, ';
     Config += 'copyhistory=no, ';
     Config    += 'directories=no, ';
     Config += 'fullscreen=no, ';
     Config    += 'height=' + h + ', ';
     Config    += 'left=' + l + ', ';
     Config    += 'location=no, ';
     Config    += 'menubar=no, ';
     Config    += 'resizable=no, ';
     Config    += 'scrollbars=no, ';
     Config    += 'status=no, ';
     Config    += 'titlebar=no, ';
     Config    += 'toolbar=no, ';
     Config    += 'top=' + t + ', ';
     Config    += 'width=' + w;
     
     /* Open the window */
     popup = window.open(Page, 'Uploading', Config);

     /*if(popup.opener == null) popup.opener = window;
     popup.opener.name = 'opener';
     
      Set the focus to the new window 
     if (popup)
     {
          popup.focus();
     }*/
}

function openEmail(jid)
{
     var h = 250;
     var w = 525;
     var t = ((screen.height / 2) - (h / 2)) - 100;
     var l = ((screen.width / 2) - (w / 2));
     var Config;
     var Page = 'popup/email.asp?jid=' + jid;

     // Set the configuration options
     Config    =  ''
     Config += 'channelmode=no, ';
     Config += 'copyhistory=no, ';
     Config    += 'directories=no, ';
     Config += 'fullscreen=no, ';
     Config    += 'height=' + h + ', ';
     Config    += 'left=' + l + ', ';
     Config    += 'location=no, ';
     Config    += 'menubar=no, ';
     Config    += 'resizable=no, ';
     Config    += 'scrollbars=yes, ';
     Config    += 'status=no, ';
     Config    += 'titlebar=no, ';
     Config    += 'toolbar=no, ';
     Config    += 'top=' + t + ', ';
     Config    += 'width=' + w;
     
     // Open the window
     popup = window.open(Page, 'email', Config);

     if(popup.opener == null) popup.opener = window;
     popup.opener.name = 'opener';
     
     // Set the focus to the new window
     if (popup)
     {
          popup.focus();
     }
}

function openResume(type)
{
     var h = 170;
     var w = 400;
     var t = ((screen.height / 2) - (h / 2)) - 100;
     var l = ((screen.width / 2) - (w / 2));
     var Config;
     var Page = '/LBNLCareers/popup/upload.asp?type='+type;
   
     /* Set the configuration options */
     Config    =  ''
     Config += 'channelmode=no, ';
     Config += 'copyhistory=no, ';
     Config    += 'directories=no, ';
     Config += 'fullscreen=no, ';
     Config    += 'height=' + h + ', ';
     Config    += 'left=' + l + ', ';
     Config    += 'location=no, ';
     Config    += 'menubar=no, ';
     Config    += 'resizable=no, ';
     Config    += 'scrollbars=no, ';
     Config    += 'status=no, ';
     Config    += 'titlebar=no, ';
     Config    += 'toolbar=no, ';
     Config    += 'top=' + t + ', ';
     Config    += 'width=' + w;

     /* Open the window */
     popup = window.open(Page, 'upload', Config);

     if(popup.opener == null) popup.opener = window;
     popup.opener.name = 'opener';
     
     /* Set the focus to the new window */
     if (popup)
     {
          popup.focus();
     }
}    

function OpenDatePopup(sDate, sDateField)
{
	OpenDatePopupWithFormNumber(0, sDate, sDateField);
}



function OpenDatePopupMulti(oField, sDateField)
{
	var oForm;
	
	oForm = getForm(oField);

	if( oForm )	
		OpenDatePopupWithFormName(oForm.name, oForm.item(sDateField).value, sDateField)
		
}

// currently, only Active Reports require the form name
function OpenDatePopupWithFormName(sFormName, sDate, sDateField)
{
	var theleft;
	var thetop;
	var width;
	var height;

	width	= 250;
	height	= 196;
	theleft	= (window.screen.availWidth / 2) - (width / 2);
	thetop	= (window.screen.availHeight / 4);

	var windowconfig = 'status=0,scrollbars=0,resizable=1,width=' + width + ',height=' + height + ',top=' + thetop + ',left=' + theleft + ',toolbar=0,location=0,directories=0,menubar=0';
	var windowvar = window.open('/LBNLCareers/popup/calendar.asp?date=' + sDate + '&datefield=' + sDateField + '&formname=' + sFormName, 'DatePicker', windowconfig);
	windowvar.focus();
}

// Currently only requisition/search.asp needs the form number.
function OpenDatePopupWithFormNumber(sFormNumber, sDate, sDateField)
{
	var theleft;
	var thetop;
	var width;
	var height;

	width	= 280;
	height	= 196;
	theleft	= (window.screen.availWidth / 2) - (width / 2);
	thetop	= (window.screen.availHeight / 4);

	var windowconfig = 'status=0,scrollbars=0,resizable=1,width=' + width + ',height=' + height + ',top=' + thetop + ',left=' + theleft + ',toolbar=0,location=0,directories=0,menubar=0';
	var windowvar = window.open('/LBNLCareers/popup/calendar.asp?date=' + sDate + '&datefield=' + sDateField + '&formnumber=' + sFormNumber, 'DatePicker', windowconfig);
	windowvar.focus();
}
