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

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 trimAll(sString)
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	
	return sString;
}

function mypopup_video(url, widthX, heightY, mediaId)
{
  //Update the video view count to DB
  new Ajax.Request('/mymedia/increase_media_count/?media_id=' + mediaId, {asynchronous:true, method:'get'});
  
  mywindow = window.open (url, "mywindow","location=0,status=0,scrollbars=1, resizable=0,menubar =0,toolbar=0, width=" + widthX + ",height=" + heightY);
  mywindow.moveTo(0,0);
  mywindow.focus();
} 

function deleteMedia(mediaId)
{
  if(confirm("Are you sure you want to delete this media?"))
  {
    alert("Media deleted");
  }
}
