/**
 * This method extracts a the value for a key from a delimited list of key-value pairs. It assumes
 * the format for a pair is key=value.
 * @param key whose value you want
 * @param string The string where the key-value pair exists
 * @param delimiter The delimiter that separates key-value pairs.
 * @return The value or an empty string if the key wasn't found
 */
function getVariable(item, string, delim)
{
  var value = '';
  if (string.indexOf(item) != -1)
  {
    var start = string.indexOf('=', string.indexOf(item)) + 1;
    if (start != 0)
    {
      var end = (string.indexOf(delim, start) == -1) ? string.length : string.indexOf(delim, start);
      value = string.substring(start, end);
    }
  }
  return value;
}

/**
 * This creates an array of WpniAdProperties based on the content of a meta tag.
 * It only works in IE.
 * @param key for the properties (all properties are created with the same key)
 * @param name of the meta tag
 * @return An array of WpniAdProperties
 */
function getMetaTag(key, name)
{
  var value = new Array();
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var temp = eval('document.all.' + name);
    if (temp != null)
    {
      temp = temp.content;
      value = parseStringIntoAdProperties(key, temp, ' ');
    }
  }
  return value;
}

/**
 * This creates an array of WpniAdProperties based on a generic string.
 * @param key for the properties (all properties are created with the same key)
 * @param string that should be parsed into properties
 * @param delimiter for the string
 * @return An array of WpniAdProperties
 */
function parseStringIntoAdProperties(key, str, delim)
{
  var start = 0; var end = 0;
  var value = new Array();
  var arCount = 0;
  if (parseStringIntoAdProperties.arguments.length == 4){
    start = str.indexOf(delim, str.indexOf(parseStringIntoAdProperties.arguments[3]));
    if (start == -1) return value;
  }
  while (start < str.length)
  {
    end = str.indexOf(delim, start);
    if (end == -1) end = str.length;
    value[arCount++] = new WpniAdProperty(key, str.substring(start, end));
    start = end + 1;
  }
  return value;
}

function doesntMeetCriteria()
{
  return false;
}

function doesMeetCriteria()
{
  return true;
}
