﻿
function embedTest(file)
{
	document.write("[embedTest]");
}

function embedWBPlayerSide(userid)
{
	embedWBPlayerSettings(userid, 200, 400, 'settings_side.xml', 'side');
}

function embedWBPlayerSmall(userid)
{
	embedWBPlayerSettings(userid, 460, 226, 'settings_small.xml', '0');
}

function embedWBPlayerNormal(userid)
{
	embedWBPlayerSettings(userid, 460, 230, 'settings_standard.xml', 'user');
}

function embedWBPlayerNormalFaves(userid)
{
	embedWBPlayerSettings(userid, 460, 230, 'settings_standard.xml', 'faves');
}

function embedWBPlayerNormalRated(userid)
{
	embedWBPlayerSettings(userid, 460, 230, 'settings_standard.xml', 'rated');
}


function embedWBPlayerWide(userid)
{
	embedWBPlayerSettings(userid, 700, 500, 'settings_wide.xml', 'user');
}

function embedWBPlayerWideFaves(userid)
{
	embedWBPlayerSettings(userid, 700, 500, 'settings_wide.xml', 'faves');
}

function embedWBPlayerWideRated(userid)
{
	embedWBPlayerSettings(userid, 700, 500, 'settings_wide.xml', 'rated');
}

function embedWBPlayerSettings(userid, width, height, settingsfile, feedtype)
{
	var rnd = Math.floor(Math.random()*10000) + 1000;

	document.write('<div style="z-index:-1;"> ');
	document.write('<embed id="WB_Player'+rnd + '_' + userid +'" ');
	document.write('src="http://warbeats.com/wbplayer/wbplayer.swf?t='+rnd+'" ');
	document.write('bgColor = "#000000" ');
	document.write('width="'+width+'" ');
	document.write('height="'+height+'" ');
	document.write('wmode="transparent" ');
	document.write('allowfullscreen="true" ');
	document.write('allowScriptAccess="always" ');
	document.write('flashVars="pathToFiles=http://warbeats.com/wbplayer/warbeats/');
	document.write('&componentWidth='+width+'&componentHeight=' + height);
	document.write('&xmlPath=xml/'+settingsfile+'?t='+rnd);
	
	var feed = "http://warbeats.com/feeds/tracks/user/"+userid+"/ver/1/playlist.xml";
	
	if(feedtype == "charts")
		feed = "http://warbeats.com/feeds/tracks/charts/"+userid+"/ver/1/playlist.xml"

	if(feedtype == "faves")
		feed = "http://warbeats.com/feeds/tracks/faves/"+userid+"/playlist.xml"

	if(feedtype == "rated")
		feed = "http://warbeats.com/feeds/tracks/rated/"+userid+"/playlist.xml"

	document.write('&contentXMLPath=' + feed + '"></embed> ');
//	document.write('&contentXMLPath=xml/trackfeed/type/'+feedtype+'/uid/'+userid+'/playlist.xml?type='+feedtype+'"></embed> ');
	
	// feed = http://warbeats.com/feeds/tracks/user/3/playlist.xml
	
	document.write('</div> ');
	
}

function embedWBPlayer(userid)
{
	var rnd = Math.floor(Math.random()*10000) + 1000;

	document.write('<div style="z-index:0;"> ');
	document.write('<embed id="WB_Player'+rnd + '_' + userid +'" ');
	document.write('src="http://warbeats.com/js/player_1/deploy/player.swf?t=1306546033000" ');
	document.write('bgColor = "#000000" ');
	document.write('width="460" ');
	document.write('height="226" ');
	document.write('wmode="opaque" ');
	document.write('allowfullscreen="true" ');
	document.write('allowScriptAccess="always" ');
	document.write('flashVars="pathToFiles=http://warbeats.com/js/player_1/deploy/warbeats/&componentWidth=460&componentHeight=226&xmlPath=xml/settings_standard.xml?t=1306546033000&contentXMLPath=xml/trackfeed/uid/'+userid+'/playlist.xml"></embed> ');
	document.write('</div"> ');

}

function embedmp3(mp3file)
{
    var rnd = Math.floor(Math.random()*10000) + 1000;
    id = "AP" + rnd;
    document.write("<div id='"+id+"'><a href='http://www.adobe.com/go/getflashplayer'><img src='http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif' alt='Get Adobe Flash player'></a></div>");
	document.write("<script type='text/javascript'>AudioPlayer.embed('"+id+"', {soundFile: '"+mp3file+"'});</script>");
}

function playmp3(mp3file)
{
    var rnd = Math.floor(Math.random()*10000) + 1000;
    id = "AP" + rnd;
    document.write("<div id='"+id+"'><a href='http://www.adobe.com/go/getflashplayer'><img src='http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif' alt='Get Adobe Flash player'></a></div>");
	document.write("<script type='text/javascript'>AudioPlayer.embed('"+id+"', {autostart: 'yes', soundFile: '"+mp3file+"'});</script>");
}

function embedpic(picurl, width)
{
	embedpic2(picurl, width, '');
}

function embedpic2(picurl, width, text)
{
    var rnd = Math.floor(Math.random()*10000) + 1000;
    id = "PIC" + rnd;
	
	document.write("<div style='margin:4px; background-color:#343434; width:"+(width+8)+"px;'><span style='text-align:center; font-size:9px; color:#FFF; width:100%;'> "+text+"</span><img title='click for full size' src='"+picurl+"' rel='#"+id+"' style='margin:4px; width:"+width+"px; cursor:pointer' class='overlayimg' /></div>");
	
	document.write("<div class='big_overlay' id='"+id+"'>");
		
	document.write("<img src='" + picurl +"' />");
	document.write("</div>");
	
}

function embedmp3w(mp3file, width, animate)
{
    var rnd = Math.floor(Math.random()*10000) + 1000;
    id = "AP" + rnd;
	
	mp3files = mp3file;
	
	if(mp3file.indexOf("\|") > -1)
	{
		mp3files = mp3file.replace("\|",", ");
	}
	
	if(mp3file.indexOf(" ") > -1)
	{
		mp3files = mp3file.replace(" ","+");
	}
	
    document.write("<div id='"+id+"'><a href='http://www.adobe.com/go/getflashplayer'><img src='http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif' alt='Get Adobe Flash player'></a></div>");
	document.write("<script type='text/javascript'>AudioPlayer.embed('"+id+"', {soundFile: '"+mp3files+"', animation: '"+animate+"', width:'"+width+"', checkpolicy: 'yes'});</script>");
}

function embedpicmp3(picurl, mp3file, width, animate)
{
	embedpic(picurl, width);
	document.write("</br>");
	embedmp3w(mp3file, width, animate);
}

function picr(picurl, width)
{
	floatpicmp3(picurl, "right", "false", width, "false");
}

function picl(picurl, width)
{
	floatpicmp3(picurl, "left", "false", width, "false");
}

function floatpicmp3(picurl, floatstr, mp3file, width, animate)
{
	document.write("<div style='float:" + floatstr + "; width: "+width+"px; margin:6px; text-align:center; background-color:#444;' >");
	
	if (picurl != "false")
	{
		embedpic(picurl, width-8);
	}

	if (mp3file != "false")
	{
		document.write("<div style='height:28px;'>");
		embedmp3w(mp3file, width-8, animate);
		document.write("</div>");
	}
	
	document.write("</div>");
}

function articlepicmp3(picurl, mp3file)
{
	floatpicmp3(picurl, "left", mp3file, 225, "no");
}

function embedTS(mp3file, code)
{
    var rnd = Math.floor(Math.random()*10000) + 1000;
    id = "AP" + rnd;
	
	document.write("<div style='background-color: rgb(52, 52, 52); color: Orange; width: 420px; height: 32px; border: 1px solid orange; padding: 6px;'>");
	
		document.write("<a href='http://warbeats.com' target='_blank'><img src='http://images.warbeats.com.s3.amazonaws.com/WB_AV_32.png' title='Go to Warbeats'></a>");
	
		document.write("<div style='display: inline; vertical-align: 3px;'>");
	
			document.write("<span id='"+id+"'><a href='http://www.adobe.com/go/getflashplayer'><img src='http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif' alt='Get Adobe Flash player'></a></span>");
	
			document.write("<script type='text/javascript'>AudioPlayer.embed('"+id+"', {soundFile: '"+mp3file+"', animation: 'no', checkpolicy: 'yes'});</script>");

		document.write("</div>");
	
		document.write("<a href='http://warbeats.com/s/"+code+"' target='_blank'><img src='http://images.warbeats.com.s3.amazonaws.com/dl-orange.png' Title='View Share Page'></a> <a href='http://warbeats.com/share/upload' target='_blank'><img src='http://images.warbeats.com.s3.amazonaws.com/ul-orange.png' title='Upload to Warbeats Track Share'></a>");

	document.write("</div>");

}

function embedmp4(mp4file)
{
    var rnd = Math.floor(Math.random()*10000) + 1000;
    id = "VP" + rnd;
    playerid = "MP4" + rnd;
    document.write("<script type='text/javascript'>");
    document.write("var flashvars = {src: '"+mp4file+"',autostart: 'false',themeColor: 'ff9900',mode: 'sidebyside',scaleMode: 'fit',frameColor: '333333',fontColor: 'cccccc',link: '',embed: ''};");
    document.write("var params = {allowFullScreen: 'true'};");
    document.write("var attributes = {id: '"+playerid+"',name: '"+playerid+"'};");
    document.write("swfobject.embedSWF('/js/AkamaiFlashPlayer.swf', '"+id+"', '570', '480', '9.0.0', 'expressInstall.swf', flashvars, params, attributes);");
    document.write("</script>");
    document.write("<div id='"+id+"'><a href='http://www.adobe.com/go/getflashplayer'><img src='http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif' alt='Get Adobe Flash player'></a></div>");
}

function embedyoutubeplaylist(id)
{
	document.write('<object width="580" height="360"><param name="movie" value="http://www.youtube.com/p/' + id + '"></param>');
	document.write('<embed src="http://www.youtube.com/p/' + id + '" type="application/x-shockwave-flash" width="580" height="440"></embed></object>');
}

function embedyoutube(id)
{

	id = id + '&';
	
	//alert(id);
	
	var ytid = id; 
	
	var m = id.match("(?:youtu\.be\/(.{11}))|(?:youtube\.com\/.*v.*?[\=|\/](.{11})[\&|\s|\}])");
	
	if(m != null)
	{
		if(m[1] != null)
			ytid = m[1];

		if(m[2] != null)
			ytid = m[2];
	}
	
	//alert(ytid);
	
	if( ytid.length != 11 )
	{
		document.write("<a class='embedly' target='_blank' href='"+id+"'>"+id+"</a>");
	}
	else
	{
		document.write('<iframe width="580" height="360" src="http://www.youtube.com/embed/' + ytid );
		document.write('?wmode=transparent&rel=0" wmode="Opaque"');
		document.write(' frameborder="0" allowfullscreen></iframe>');
	}
	
	var refurl = ""; //document.URL;
	//var n = refurl.match("(?:aft\/(\d+))");
	
	//if(n != null)
	{
		document.write("<div class='nfxSubHeader' style='margin-top:0px; width:580px; text-align:right;'>" +
                "<a onclick='return ReportBrokenVideo(" + refurl + ");" +
                "return false;' href='#report' " +
                "title='Report this video as missing or broken.'> " +
                //"<img alt='' class='nfxImg16' src='http://images.warbeats.com.s3.amazonaws.com/dl_alert.png' /> " +
                "Report this video as missing or broken</a></div>");
	}
}

function embed(url)
{
	var m = url.match("youtu[\.|b]");
	
	if (m != null)
		embedyoutube(url)
	else
		document.write("<a class='embedly' target='_blank' href='"+url+"'>"+url+"</a>");
}

