// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
function playSound(soundfile) {
  var sEmbed = document.createElement("embed");
  sEmbed.setAttribute("src", soundfile);
  sEmbed.setAttribute("hidden", "true");
  sEmbed.setAttribute("autostart", "true");
  sEmbed.setAttribute("loop", "false");
  var target = document.getElementById("dummy");
  target.appendChild(sEmbed);  
}
function rateDrink(id, rating) {
  new Ajax.Updater('upd', '/drink/rate/' + id + '?rating=' + rating, {evalScripts:true, parameters:Form.serialize('authenticity')});
  }
  document.onkeydown = keydown;
function keydown(evt){
  if (!evt) evt = event;
  if (evt.shiftKey && evt.keyCode == 9){ //Shif+TAB
    Modalbox.show("/admin/login", {title:"Login to Sips Administration", width:400});
  }
}
function deleteComment(id) {
  new Effect.DropOut('comment_' + id);
  new Ajax.Updater('upd', '/comment/delete/' + id + '?rsn=user', {evalScripts:true, parameters:Form.serialize('authenticity')});
}
function loadJS(src) {
  myJS = document.createElement("script");
  myJS.setAttribute("type", "text/javascript");
  src = "/javascripts/" + src;
  myJS.setAttribute("src", src);
  $('head').appendChild(myJS);
}
