function msEmbed(T,C,U,L)
{
  return 'http://www.myspace.com/index.cfm?fuseaction=postto&' +
         't=' + encodeURIComponent(T) +
		 '&c=' + encodeURIComponent(C) +
		 '&u=' + encodeURIComponent(U) +
		 '&l=' + L;
}



$(document).ready(function()
{
	$.getJSON(BASE_PATH + '/ajax/getRelatedSong/song_id=' + self.cs_content_id, function(response)
	{
		var brano_name = response.brano.name;
		var artista_name = response.artista.name;

		var brano_url = response.brano.url;
		var artista_url = response.artista.url;


		//carico l'embed
		$.getJSON(BASE_PATH + '/ajax/getEmbed/song_id=' + self.cs_content_id , function(response) {

			$("#embed textarea").text(response.html_code);

		});


		/* vecchio embed

		var style = '<style type="text/css">#titolo #titolo2 a {color:#000; text-decoration:none;}#titolo #titolo2 a:hover {color:#000; text-decoration: underline;}#artista #artista2 a {color:#999; text-decoration:none;}#artista #artista2 a:hover {color:#999; text-decoration: underline;}</style>';

		var embed = '<div id="boxembed" style="background: transparent url(' + STATIC_PATH_IMG + '/bgembed.gif) no-repeat; height: 220px; width:180px; padding: 6px 10px 10px 10px;"><a href="' + BASE_PATH + '"><img border="0" src="' + STATIC_PATH_IMG + '/minilogo.gif" alt="MP3.it"></a><object type="application/x-shockwave-flash" data="http://embed.dada.net/swf/vdet.swf" width="180" height="130" ><param name="quality" value="high" /> <param name="wmode" value="transparent" /> <param name="menu" value="false" /> <param name="allowscriptaccess" value="always" /> <param name="flashvars" value="cid=' + self.cs_content_id + '&domain=it&conf=M06OOO" /> <param name="movie" value="http://embed.dada.net/swf/vdet.swf" /> </object><div id="titolo" style="background:transparent url(' + STATIC_PATH_IMG + '/song_16.gif) no-repeat scroll 0 0; height: auto; height: 17px; min-height: 17px; margin-top: 13px;"><div id="titolo2" style="padding-left: 20px; padding-top: 1px; font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#000;"><a target="_blank" href="' + BASE_PATH + '/' + brano_url + '">' + brano_name + '</a></div></div><div id="artista" style="background:transparent url(' + STATIC_PATH_IMG + '/artist_16.gif) no-repeat scroll 0 0; height: auto; height: 17px; min-height: 17px; margin-top: 3px;"><div id="artista2" style="padding-left: 20px; padding-top: 1px; font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#999;"><a target="_blank" href="' + BASE_PATH + '/' + artista_url + '">' + artista_name + '</a></div></div></div>';

		$("#embed textarea").text(style + embed);
		*/

		$("#ms").attr('href', msEmbed(artista_name + ' - ' + brano_name, embed, 'http://www.myspace.com', 6));
	});


	// seleziona il box embed al click
	$("#embed textarea").click( function()
	{
		$(this).select();
	});

});
