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

function playSound(url, id) {
  document.getElementById(id).innerHTML=
    "<embed src='"+url+"' hidden=true autostart=true loop=false>";
}

function closeAll() {
	Windows.closeAll();
}


function openAudioPicker(to_url) {
  	closeAll();
	var win = new Window({className: "mfc", title: "", 
                        top:900, left:300, width:500, height:525, zIndex: 100, 
                        url: to_url, showEffectOptions: {duration:0.5}, showProgress: true}); 
  win.show(); 			  
}

function wrapText(id, openTag, closeTag) {
	var el = document.getElementById(id);
	if (el.setSelectionRange) {
 		// W3C/Mozilla
 		el.value = el.value.substring(0,el.selectionStart) + openTag + el.value.substring(el.selectionStart,el.selectionEnd) + closeTag + el.value.substring(el.selectionEnd,el.value.length);
 	}
 	else if (document.selection && document.selection.createRange) {
 		// IE code goes here
		el.focus(); //or else text is added to the activating control
		var range = document.selection.createRange();
		range.text = openTag + range.text + closeTag;
 	}
}

Event.observe(window, 'load', function() {
	$$('.rounded').each(function(item) { new Effect.Corner(item, "0px"); });
	Event.observe('selectAll', 'click', checkAll);
  Event.observe('deSelectAll', 'click', deCheckAll);
});


function sayHi() {
  alert('hi');
}

Ajax.Responders.register({
  onCreate: function() {
    if($('busy') && Ajax.activeRequestCount>0)
      Effect.Appear('busy',{duration:0.5,queue:'end'});
  },
  onComplete: function() {
    if($('busy') && Ajax.activeRequestCount==0)
      Effect.Fade('busy',{duration:0.5,queue:'end'});
  }
});

function checkAll() {
  $$('input[type="checkbox"]').each(function(e) {
    e.checked = 1;
  });
}

function deCheckAll() {
  $$('input[type="checkbox"]').each(function(e) {
    e.checked = 0;
  });
}



function moreInfo() {  
  // Use date/time to assign a unique id  
  var day = new Date();  
  var id = day.getTime();  
  // Taking advice about resizable/scrollbars  
  // To ignore this, change to  
  // var windowAttr = 'width='+w+',height='+h;
  var url = "http://www.moviefancentral.com/fanboxinfo";
  var title = "Fanbox Info";
  var attr = "width=300,height=200";
  window.open(url,title, attr);  
  return false; 
} 

