// Takes n arguments which are either the IDs or object references of
// elements whose style display mode will be toggled.

function getObject(param) {
  
  if ( typeof(param) == "object" ) {
    
    return param;
    
  } else {
    
    return document.getElementById(param);
    
  }
  
}

function show(obj) {
  
  obj = getObject(obj);
  
  obj.style.display = getDefaultDisplay(obj);
  
  obj.style.visibility = "visible";
  
}


function hide(obj) {
  
  obj = getObject(obj);
  
  obj.style.display = "none";

  obj.style.visibility = "hidden";
  
}

// Determines the default display value for the object's HTML element type. For
// instance, a DIV would have a default display of "block". This method should
// ensure that we use the correct display value for each browser.

function getDefaultDisplay(obj) {
  
  var value = "";
  
  // Create a new element with a tag name that corresponds to the object.
  
  var objCopy = document.createElement(obj.tagName);
  
  // Unless we add the element to the document, we won't know the actual
  // display value. IE will return an empty string; Firefox, "block".
  
  // By setting the visibility to hidden, we ensure that the user will not
  // see any such changes.
  
  objCopy.visibility = "hidden";
  
  document.body.appendChild(objCopy);
  
  value = getActiveStyle(objCopy).display;
  
  document.body.removeChild(objCopy);
  
  return value;
  
}

function getActiveStyle(obj) {
  
  // Ensure that we have an object and not just the ID of an HTML element.
  
  obj = getObject(obj);
  
  if ( obj.currentStyle ) {
    
    // Internet Explorer
    
    return obj.currentStyle;
    
  } else if ( document.defaultView && document.defaultView.getComputedStyle ) {
    
    // Mozilla/FireFox
    
    return document.defaultView.getComputedStyle(obj, null);
    
  } else {
    
    // Fall back to non-computed style.
    
    return obj.style;
    
  }
  
}

// Adds a trim() method to the String class.

String.prototype.trim  = function(str) {
        
        str = this != window ? this : str;
        
        return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
        
};

/* These functions toggle editability of public and private content. */

function showPrivate() {
	
	// Content
	
	show('privateContent');
	hide('publicContent');
	
	// Selectors
	
	show('privateSelector');
	hide('publicSelector');
	
}

function showPublic() {
	
	// Content
	
	show('publicContent');
	
	hide('privateContent');
	
	// Selectors
	
	show('publicSelector');
	
	hide('privateSelector');
	
}