// get form buttons on page (excluding action bar) & generate html for left & right caps	
function formButtonBg(customSelector) {	
	var formButtons;
	if(customSelector) {
		formButtons = customSelector;
	} else {
		formButtons = $('page-content').select('input.lw-form-button','input.lw-form-button-delete');
	}
    var btnLeft = "<img src=\"/images/svc-button-left.gif\" class=\"svc-btn-left\" \/>";
    var btnRight = "<img src=\"/images/svc-button-right.gif\" class=\"svc-btn-right\" \/>";

    formButtons.each(function(fb) {
	    fb.insert({before:btnLeft});
	    fb.insert({after:btnRight});	
	});	
}
	
/*
  addButtonPipes() draws the pipes between <li> buttons
*/
function addButtonPipes() {
    // look for message buttons <li class="button">
    var msgButtons = jQuery('.lw-content-col li.button');
    if (msgButtons) {
    	msgButtons.each(function(){
        drawPipes(this);
      });
    }
    // add pipes to page buttons in site-header as well
    var pageButtons = jQuery('.lw-page-buttons li.button');
    if (pageButtons) { 
    	pageButtons.each(function(){
        drawPipes(this);
      });
    }
     // add pipes to page buttons in site-header as well
     
    pageButtons = jQuery('.lw-portlet-col li.button');
    if (pageButtons) {
    	pageButtons.each(function(){
        drawPipes(this);
      });
    }
}
	
var drawPipes = function(theButton) {

    // clean leading/trailing spaces & text nodes from <li>
    theButton.innerHTML.strip();
  $(theButton).cleanWhitespace();
    // add pipe to all <li>'s except the first <li>
    if($(theButton).previous()) {
    if (navigator.userAgent.indexOf('MSIE') !=-1  ) {
   			theButton.innerHTML = '<span class="lw-pipe">&nbsp;&#124;&nbsp;</span>' + theButton.innerHTML;
   		} else {
			theButton.innerHTML = "&nbsp;|&nbsp;" + theButton.innerHTML;
   		}
    } else {
	// if this is the first <li> in the <ul>, get the parent ul & strip text nodes
	$(theButton).up().cleanWhitespace();
    }
}
