/*
 * $Id: shareutil.js,v 1.2 2008/01/08 21:23:17 chaitat Exp $
 *
 * Author: Chaitat Piriyasatit <chaitat@openface.ca>
 *
 * Date Created: 3 November 2007
 */

// Check to see if the web browser is IE or Firefox.
function shareutilIsIE() {
  return navigator.appName == "Microsoft Internet Explorer";
}
 
/*
 * Check if the specified text input (<input type=text ... />) is blank.
 */
function shareutilIsTextInputBlank(oTextInput) {
  return oTextInput.value.match('^[ ]*$') ? true : false;
}

function shareutilGetCookie(cookieName) {
  var cookieStart;
  var cookieEnd;
  
  if (document.cookie.length > 0) {
    cookieStart = document.cookie.indexOf(cookieName + '=');
    if (cookieStart != -1) { 
      cookieStart = cookieStart + cookieName.length + 1; 
      cookieEnd = document.cookie.indexOf(';', cookieStart);
      if (cookieEnd == -1)
        cookieEnd = document.cookie.length;
        return unescape(document.cookie.substring(cookieName, cookieEnd));
      } 
    }
    
  return '';
}

function shareutilSetCookie(cookieName, value, expiredays) {
  var exdate = new Date();
  exdate.setDate(exdate.getDate() + expiredays);
  document.cookie = cookieName+ '=' + escape(value) + ((expiredays == null) ? '' : ';expires=' + exdate.toGMTString());
}
