if (typeof(whispercast) == 'undefined') {
  whispercast  = {};
}
whispercast.css = whispercast.css ? whispercast.css : {};

/**
 * Adds a new stylesheet to the current page.
 *
 * @access public
 *
 * @parameter source:string
 *            The location of the style sheet or undefined
 *            for an empty stylesheet.
 *
 * @return object The created sylesheet.
 **/
whispercast.css.addSheet = function(source) {
  var sheet;
  if (source != undefined)
  {
    sheet = document.createElement('link');
    sheet.href = source;
    sheet.rel = 'stylesheet';
  } else {
    sheet = document.createElement('style');
  }
  sheet.type = 'text/css';
  document.getElementsByTagName('head')[0].appendChild(sheet);
  return sheet;
},
/**
 * Adds a new rule to the given stylesheet.
 *
 * @access public
 *
 * @parameter sheet:object
 *            The stylesheet to add the rule to.
 * @parameter selector:string
 *            The selector for the rule.
 * @parameter rule:string
 *            The actual rule.
 *
 * @return void
 **/
whispercast.css.addRule = function(sheet, selector, rule) {
  if (sheet.styleSheet) {
  if (sheet.styleSheet.cssText == '') {
    sheet.styleSheet.cssText = '';
  }
  sheet.styleSheet.cssText += selector + ' { '+rule+' }';
  } else {
    sheet.appendChild(document.createTextNode(selector + ' { '+rule+' }'));
  }
}
