/*
Copyright (c) 2011 Church Media Group, Inc. (http://churchmedia.cc) All rights reserved.

This code is distributed under the following terms:

Redistribution and use of this software in source and binary forms, with or without modification,
are not permitted without prior written permission by the copyright holders.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/


/*****************************************************************************************
 *
 *                           General helper functions
 *
 *****************************************************************************************/

/**
 * Extend the String object so that we can use the trim() function like; sVar.trim();
 *
 *     var first_name = "Chris ";
 *     first_name = first_name.trim();
 *
 * @return string
 */
String.prototype.trim = function() {
  var a = this.replace(/^\s+/, '');
  return a.replace(/\s+$/, '');
};

/**
 * Write an email address to the screen. Helps so that bots can't parse email addresses from the site.
 *
 *     writeEmail("info", "info", "churchmedia.cc");
 *
 * @param string
 * @param string
 * @param string
 */
function writeEmail(contact, email, emailHost) {
  document.write("<a href=" + "&#109a&#105l" + "&#116&#111:" + email + "@" + emailHost+ ">" + contact + "@" + emailHost+"</a>");
}

/**
 * Pop up window in a certain size and no scrollbar.
 */
function pop(url, name, props) {
	window.open(url, name, props);
}
