// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
function MM_openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}

function toggleMediaRow(elm) {
  if (elm.tagName != 'tr') {
    elm = elm.up('tr');
  }
  elm.next('.media').toggle();
}

function showVideo(url, desc) {
  var so = new SWFObject('/player.swf','mpl','470','320','9');
  so.addParam('allowscriptaccess','always');
  so.addParam('allowfullscreen','true');
  so.addParam('flashvars','&file='+url+'&dock=false');
  so.write('player');
  $('video_desc').innerHTML = desc;
  $('video_download').innerHTML = "<a href='"+url+"'>Download this video</a>"
  $('video_overlay').show();
  $('video_container').show();
}

function hideVideo() {
  $('video_overlay').hide();
  $('video_container').hide();
  $('player').innerHTML = '&nbsp;'
}

var new_id = 1;

function addNewRow(item) {
  item_downcase = item.toLowerCase().gsub(' ', '_');
  var tr = "<tr><td class='label'><label>"+item+"</label></td><td class='text-to-translate'></td><td class='translation'><input id='new_"+item_downcase+"_"+new_id+"' type='text' value='' name='new_"+item_downcase+"["+new_id+"]' /></td></tr>"
  $('add_row').insert({'before' : tr});
  new_id += 1;
}