// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

var HtmlSelectOptions = {}

HtmlSelectOptions = {
  clear: function(dom_id) {
    $(dom_id).options.length = 0;
  },
  add: function(dom_id, text, value, selected) {
    var option = document.createElement('option');
    option.appendChild(document.createTextNode(text));
    option.setAttribute('value', value);
    if (selected) { option.selected = true }
    $(dom_id).appendChild(option);
  },
  load: function(dom_id, options, selected) {
    if (options == null) return;
    options.each(function(item, index) {
      HtmlSelectOptions.add(dom_id, item[0], item[1], item[1] == selected);
    });
  },
  selectOptionByValue: function(dom_id, option_value) {
    with($(dom_id)) {
      for(var i=0;i<length;i++) {
        if (options[i].value == option_value) {
          selectedIndex = i;
          break;
        }
      }
    }
  }
}

function bookmarksite(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}
