/**
 * The sound cloud embed code generates some IE script errors and can cause the browser to hang.
 * It is also a IE/Flash issue Adobe have yet to fix, so its time for some JQuery hacks
 */

/**
 * Acording to sound cloud this also will help
 */
window["__flash__removeCallback"] = function (instance, name) {
	try {
		if (instance) {
			instance[name] = null;
		}
	} catch (flashEx) {}
};

/**
 * Also make all emebed flash wmod transparent
 */
$(document).ready(function() {
    //FLASH FIX DESTROYS IE7 AND IE8. BRILLIANT, SOMEBODY GIVE ME MY HOUR OF LIFE BACK

    // $("object").append('<param name="wmode" value="opaque">');
    // $('object').find('param[name="allowscriptaccess"]').attr('value', 'sameDomain')
    // $('embed').attr('allowscriptaccess', 'sameDomain');
	
  var embedTag;

  $("embed").each(function(i) {
      embedTag = $(this).attr("outerHTML");
      if ((embedTag != null) && (embedTag.length > 0)) {
          embedTag = embedTag.replace(/embed /gi, "embed wmode=\"opaque\" ");
          $(this).attr("outerHTML", embedTag);
      } else {
          $(this).wrap("<div></div>");
      }
  });
        // alert('inflashfix3');    
});
