function embed_audio(audio, id, width) {
  embedextraAudio(audio, "", id, false, width);
}


function embedextraAudio(audio, audio_id, id, download, width) {
	var flashvars = false;
  var params = {
      wmode: "transparent",
      allowscriptaccess: "always",
      quality: "high",
      flashvars: "file=" + audio + "&autostart=false&popbutton=false&" +
          "popurl=/audio/xspf/" + id + "/&plugins=googlytics-1&" +
          "backcolor=111111&frontcolor=ffffff&lightcolor=99FF33&" +
          "screencolor=000000"};
	var attributes = {
      id: "audioplayer_" + id,
      name: "audioplayer_" + id};
	swfobject.embedSWF("/media/greeneplayer/player.swf", "audioplayer_" + id,
      width, "19", "9.0.0","", flashvars, params, attributes);
	if (download) {
    $('#' + audio_id).append('<a style="color: #7a7a7a; font-size: 9px;" ' +
        'class="mp3downembed" href="' + audio + '">Download MP3</a>');
  }
}


function embed_video(video, id, width, height, playlist, playlistsize, type,
    streamer) {
  var url_jpg=video.replace(/\.[a-z]+$/, ".png");
  var flashvars = false;

  if (!playlist) {
	  var playlist = 'none';
  }

  var fv = "file=" + video + "&fullscreen=true&stretching=exactfit&" +
      "plugins=googlytics-1&backcolor=111111&frontcolor=ffffff&" +
      "lightcolor=99FF33&screencolor=000000&playlistsize=" + playlistsize +
      "&playlist=" + playlist;
  if(type){
	  fv += "&type=" + type
  }
  if(streamer){
	  fv += "&streamer=" + streamer
	  url_jpg = "http://video.wnyc.org/thegreenespace/livewebcast.png";
  }

  fv += "&image=" + url_jpg;

  var params = {
      wmode: "transparent",
      allowscriptaccess: "always",
      allowfullscreen: "true",
      flashvars: fv};
  var attributes = {
      id: "videoplayer_" + id,
      name: "videoplayer_" + id};
  swfobject.embedSWF("/media/greeneplayer/player.swf", "videoplayer_" + id,
      width, height, "9.0.0","", flashvars, params, attributes);
};

$(document).ready(function() {
  $("input.clearonfocus").bind("focus", function() {
    if (this.defaultValue == this.value) this.value = '';
  });
  $('input.resetonblur').bind('blur', function() {
    if (this.value == '') this.value = this.defaultValue;
  });

  $("a.#aw0").click(function(){
    var s = s_gi('wnycdev');
    s.tl(this, 'e', 'Square Right Side Ad');
  });
})

$.fn.equalizeCols = function(){
  var height = 0, reset = $.browser.msie ? "1%" : "auto";

  return this.css("height", reset).each(function() {
    height = Math.max(height, this.offsetHeight);
  }).css("height", height).each(function() {
    var h = this.offsetHeight;
    if (h > height) {
      $(this).css("height", height - (h - height) - 10);
    };
  });
};

function loadEmailForm(ctype, pk) {
  var place = $('#emailthiswrapper');
  if (place.length) {
    place.load('/emailthis/' + ctype + '/' + pk + '/');
    var pos = $('#emailthislink').position();
    place.css({'top': pos.top - 400, 'left': pos.left + 25}).show('slow');
  }
  return false;
}

function cancelEmail() {
  $('#emailthiswrapper').slideUp(1000, function() {
     $(this).html('');
  });
}
