if (!String.prototype.trim) {
	String.prototype.trim = function() {
		var str = this.replace(/^\s*/, '');
		return str.replace(/\s*$/, '');
	};
}

function popupAlert(title, content, className) {
  if (alertWindow) {
    className = (className ? className : "info");
    var alert_title_div = $('alert_title_div');
    if (alert_title_div) {
      alert_title_div.className = "message message-" + className;
    }
    var alert_title = $('alert_title');
    if (alert_title) {
      alert_title.innerHTML = title;
      alert_title.className = "title " + className;
    }
    var alert_content = $('alert_content');
    if (alert_content) {
      alert_content.innerHTML = content;
    }
    var alert_button = $('alert_button');
    if (alert_button) {
      alert_button.className = className + '_button';
    }
    alertWindow.show();
  } else {
    alert(content);
  }
}

function getTagValue(xml, tag) {
  var elements = xml.getElementsByTagName(tag);
  if (elements) {
    var element = elements[0];
    if (element && element.hasChildNodes) {
      return element.childNodes[0].nodeValue;
    }
  }
  return "";
}

function getCDataValue(xml, tag) {
  var elements = xml.getElementsByTagName(tag);
  if (elements) {
    var element = elements[0];
    if (element && element.hasChildNodes) {
      return (Prototype.Browser.IE) ?
        element.childNodes[0].nodeValue : element.childNodes[0].textContent;
    }
  }
  return "";
}

var uid = (function() {
  var id = 0;
  return function() {
    if(arguments[0] === 0) {
      id = 0;
    }
    return id++;
  };
})();

function cloneElement(id) {
  var new_div = Element.clone($(id), true);
  var new_id = uid();
  new_div.id = 'div_' + new_id;
  var children = new_div.select('*[id]');
  for (var i = 0; i < children.length; i++) {
    var old_id = children[i].getAttribute('id');
    if (old_id.length > 0) {
      children[i].setAttribute('id', old_id + new_id);
    }
  }
  document.body.appendChild(new_div);
  return new_id;
}


