var MP_WIDTH=640;
var MP_HEIGHT=480;

function MP_show(title, director, brand, agency, url, width, height, slug)
{
	MP_WIDTH=parseInt(width)+200;
	MP_HEIGHT=parseInt(height);
	
	if (agency!='') agency='<br><b>Agency:</b> '+ agency;
	if ((brand!='')&&(title!='')) title=' '+title;
	
	/* $(document.body).append("<div id='MP_overlay'></div><div id='MP_window' style='width:"+MP_WIDTH+"px'><div style='display:block; float:left;'><video controls autoplay autobuffer width='"+ width +"' height='"+ height +"' style='background:#000000 url(/images/logo.gif) center center no-repeat'><source src='http://static.edcommercials.com.s3.amazonaws.com/"+ url +".mp4' type='video/mp4' /><source src='http://static.edcommercials.com.s3.amazonaws.com/"+ url +".ogv' type='video/ogg' /><object style='display:block; width:"+ width +"px; height:"+ height +"px; background:#000;' id='_player' name='_player' data='/flowplayer/flowplayer-3.2.2.swf' type='application/x-shockwave-flash'><param name='movie' value='flowplayer/flowplayer-3.2.2.swf' /><param name='allowfullscreen' value='true' /><param name='allowscriptaccess' value='always' /><param name='flashvars' value=\"config={'clip':{'url':'http://static.edcommercials.com.s3.amazonaws.com/"+url+".mp4','scaling':'orig'},'player':{'':''}}\" /></object></video></div><div style='display:block; width:200px; float:left;'><a href='javascript:MP_hide()'><img src='/images/close_player.gif'></a><br><br><span class='label'><b>Dir. "+ director +"</b><br><b>"+ brand +"</b> "+ title +"<br><b>Agency:</b> "+ agency +"<br><br><b>Download:</b> <a href='http://static.edcommercials.com.s3.amazonaws.com/"+ url +".mp4'>MP4</a> / <a href='http://static.edcommercials.com.s3.amazonaws.com/"+ url +".ogv'>OGG</a><br><br><b>Share:</b></span>&nbsp;<a href='#' class='ico facebook'><img src='/images/pixel_trans.gif'></a>&nbsp;<a href='#' class='ico twitter'><img src='/images/pixel_trans.gif'></a>&nbsp;<a href='#' class='ico digg'><img src='/images/pixel_trans.gif'></a></div></div>"); */
	/* $(document.body).append("<div id='MP_overlay'></div><div id='MP_window' style='width:"+MP_WIDTH+"px'><div style='display:block; float:left;'><video controls autoplay autobuffer width='"+ width +"' height='"+ height +"' style='background:#000000 url(/images/logo.gif) center center no-repeat'><source src='http://static.edcommercials.com.s3.amazonaws.com/"+ url +".mp4' type='video/mp4' /><source src='http://static.edcommercials.com.s3.amazonaws.com/"+ url +".ogv' type='video/ogg' /><object style='display:block; width:"+ width +"px; height:"+ height +"px; background:#000;' id='_player' name='_player' data='/flowplayer/flowplayer-3.2.2.swf' type='application/x-shockwave-flash'><param name='movie' value='flowplayer/flowplayer-3.2.2.swf' /><param name='allowfullscreen' value='true' /><param name='allowscriptaccess' value='always' /><param name='flashvars' value=\"config={'clip':{'url':'http://static.edcommercials.com.s3.amazonaws.com/"+url+".mp4','scaling':'orig'},'player':{'':''}}\" /></object></video></div><div style='display:block; width:200px; float:left;'><a href='javascript:MP_hide()'><img src='/images/close_player.gif'></a><br><br><span class='label'><b>Dir. "+ director +"</b><br><b>"+ brand +"</b> "+ title +"<br><b>Agency:</b> "+ agency +"<br><br><b>Download:</b> <a href='http://static.edcommercials.com.s3.amazonaws.com/"+ url +".mp4'>MP4</a> / <a href='http://static.edcommercials.com.s3.amazonaws.com/"+ url +".ogv'>OGG</a></div></div>"); */
	/* $(document.body).append("<div id='MP_overlay'></div><div id='MP_window' style='width:"+MP_WIDTH+"px'><div style='display:block; float:left;'><video controls autoplay autobuffer width='"+ width +"' height='"+ height +"' style='background:#000000 url(/images/logo.gif) center center no-repeat'><source src='http://static.edcommercials.com.s3.amazonaws.com/"+ url +".mp4' type='video/mp4' /><source src='http://static.edcommercials.com.s3.amazonaws.com/"+ url +".ogv' type='video/ogg' /><object style='display:block; width:"+ width +"px; height:"+ height +"px; background:#000;' id='_player' name='_player' data='/flowplayer/flowplayer-3.2.2.swf' type='application/x-shockwave-flash'><param name='movie' value='flowplayer/flowplayer-3.2.2.swf' /><param name='allowfullscreen' value='true' /><param name='allowscriptaccess' value='always' /><param name='flashvars' value=\"config={'clip':{'url':'http://static.edcommercials.com.s3.amazonaws.com/"+url+".mp4','scaling':'orig'},'player':{'':''}}\" /></object></video></div><div style='display:block; width:200px; float:left;'><a href='javascript:MP_hide()'><img src='/images/close_player.gif'></a><br><br><span class='label'><b>Dir. "+ director +"</b><br><b>"+ brand +"</b> "+ title + agency +"<br><br><b>Download:</b> <a href='http://static.edcommercials.com.s3.amazonaws.com/"+ url +".mp4'>MP4</a> / <a href='http://static.edcommercials.com.s3.amazonaws.com/"+ url +".ogv'>OGG</a></div></div>"); */

	$(document.body).append("<div id='MP_overlay'></div><div id='MP_window' style='width:"+MP_WIDTH+"px'><div style='display:block; float:left;'><video controls autoplay autobuffer width='"+ width +"' height='"+ height +"' style='background:#000000 url(/images/logo.gif) center center no-repeat'><source src='http://dwp9kj0nnxout.cloudfront.net/"+ url +".mp4' type='video/mp4' /><source src='http://dwp9kj0nnxout.cloudfront.net/"+ url +".ogv' type='video/ogg' /><object style='display:block; width:"+ width +"px; height:"+ height +"px; background:#000;' id='_player' name='_player' data='/flowplayer/flowplayer-3.2.2.swf' type='application/x-shockwave-flash'><param name='movie' value='/flowplayer/flowplayer-3.2.2.swf' /><param name='allowfullscreen' value='true' /><param name='allowscriptaccess' value='always' /><param name='flashvars' value=\"config={'clip':{'url':'http://dwp9kj0nnxout.cloudfront.net/"+url+".mp4','scaling':'orig'},'player':{'':''}}\" /></object></video></div><div style='display:block; width:200px; float:left;'><a href='javascript:MP_hide()'><img src='/images/close_player.gif'></a><br><br><span class='label'><b>Dir. "+ director +"</b><br><b>"+ brand +"</b> "+ title + agency +"<br><br><b>Download:</b> <a href='http://dwp9kj0nnxout.cloudfront.net/"+ url +".mp4'>MP4</a> / <a href='http://dwp9kj0nnxout.cloudfront.net/"+ url +".ogv'>OGG</a><br><br><b>Share:</b></span>&nbsp;<a href='http://www.facebook.com/sharer.php?u=http://edcommercials.com/movies/"+ slug +"&t=EDCommercials - "+brand+title+"' class='ico facebook'><img src='/images/pixel_trans.gif'></a>&nbsp;<a href='http://digg.com/submit?phase=2&url=http://edcommercials.com/movies/"+ slug +"' class='ico digg'><img src='/images/pixel_trans.gif'></a></div></div>");
	
	$("#MP_overlay").click(MP_hide);
	
	$("#MP_overlay").show();
	MP_position();
	$("#MP_window").show();
}

function MP_hide()
{
	$("#MP_window,#MP_overlay").remove();
}

function MP_position()
{
	var de = document.documentElement;
	var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var h = self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
	
	left=(w - MP_WIDTH)/2;
	window_top=(h - MP_HEIGHT)/2;
	
	$("#MP_window").css({left: left+"px", top: window_top+"px" });
}
