
if (typeof String.prototype.supplant == 'undefined') {
   String.prototype.supplant = function(o) {
     return this.replace(/{{([^{}]*)}}/g,
       function(a, b) {
         var r = o[b];
         return typeof r === 'string' ?
           r : a;
       }
     );  
   };
}


function topspinTimestamp() {
  return (new Date).getTime().toString().substr(0,10);
}



function updateEmailWidget(oldObject) {

  var timestamp = topspinTimestamp();

  var template = '';
    template += '  	<object type="application/x-shockwave-flash" ';
    template += '  			height="80" width="245" id="TSWidget17845" ';
    template += '  			data="http://cdn.topspin.net/widgets/email2/swf/TSEmailMediaWidget.swf?timestamp={{stamp}}" ';
    template += '  			bgColor="#000000">  ';
    template += '  		<param value="always" name="allowScriptAccess" />  ';
    template += '  		<param name="allowfullscreen" value="true" />  ';
    template += '  		<param name="quality" value="high" />  ';
    template += '  		<param name="movie" value="http://cdn.topspin.net/widgets/email2/swf/TSEmailMediaWidget.swf?timestamp={{stamp}}" />  ';
    template += '  		<param name="flashvars" value="widget_id=http://cdn.topspin.net/api/v1/artist/1918/email_for_media/17845?timestamp={{stamp}}&amp;theme=black&amp;highlightColor=0xB7DC21" />';
    template += '  	</object>';

  var newObject = $(template.supplant({stamp: timestamp}));
  oldObject.replaceWith(newObject);    
}


function updateSidebarPlayerWidget(oldObject) {

  var timestamp = topspinTimestamp();

  var template = '';
  template += '<object type="application/x-shockwave-flash" ';
  template += 'height="250" width="274" id="TSWidget17888" ';
  template += 'data="http://cdn.topspin.net/widgets/bundle/swf/TSBundleWidget.swf?timestamp={{stamp}}" ';
  template += 'bgColor="#000000">  ';
  template += '<param value="always" name="allowScriptAccess" /> ';
  template += '<param name="allowfullscreen" value="true" /> ';
  template += '<param name="quality" value="high" /> ';
  template += '<param name="movie" value="http://cdn.topspin.net/widgets/bundle/swf/TSBundleWidget.swf?timestamp={{stamp}}" /> ';
  template += '<param name="flashvars" value="widget_id=http://cdn.topspin.net/api/v1/artist/1918/bundle_widget/17888?timestamp={{stamp}}&amp;theme=black&amp;highlightColor=0xB7DC21" />';
  template += '<param name="wmode" value="transparent" /> ';
  template += '</object>';

  var newObject = $(template.supplant({stamp: timestamp}));
  oldObject.replaceWith(newObject);    
}


function updateHomepagePlayerWidget(oldObject) {

  var timestamp = topspinTimestamp();

  var template = '';
  template += '<object type="application/x-shockwave-flash" ';
  template += 'height="250" width="273" id="TSWidget17888" ';
  template += 'data="http://cdn.topspin.net/widgets/bundle/swf/TSBundleWidget.swf?timestamp={{stamp}}" ';
  template += 'bgColor="#000000">  ';
  template += '<param value="always" name="allowScriptAccess" /> ';
  template += '<param name="allowfullscreen" value="true" /> ';
  template += '<param name="quality" value="high" />  ';
  template += '<param name="movie" value="http://cdn.topspin.net/widgets/bundle/swf/TSBundleWidget.swf?timestamp={{stamp}}" /> ';
  template += '<param name="flashvars" value="widget_id=http://cdn.topspin.net/api/v1/artist/1918/bundle_widget/17888?timestamp={{stamp}}&amp;theme=black&amp;highlightColor=0xB7DC21" />';
  template += '<param name="wmode" value="transparent" />  ';
  template += '</object>';

  var newObject = $(template.supplant({stamp: timestamp}));
  oldObject.replaceWith(newObject);    
}


  		        
  		 





