// JavaScript Document

function prefillEmbed(filename,width,height,scale,sound,loop){
	
	$('flv').value = filename;
	$('width').value = width;
	$('height').value = height;
	//$('scale').value = scale;
	$('loop').value = loop;
	$('sound').value = sound;
	
	embedCode();
}

function embedCode(){ // filename, width, height, scale, loop, sound

	var filename = $F('flv');
	var width = $F('width');
	var height = $F('height');
	//var scale = $F('scale');
	var loop = $F('loop');
	var sound = $F('sound');

	//if(scale == 'noscale'){
		var swf_width = width;
		var swf_height = height;
	//} else {
	//	var swf_width = '100%';
	//	var swf_height = '100%';
	//}
	var scale = 'noscale';

	var returnCode = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="' + swf_width + '" height="' + swf_height + '">';
		returnCode += '<param name="movie" value="http://www.ngmoco.com/Media/vplayer_embed.swf" />';
		returnCode += '<param name="loop" value="false" />';
		returnCode += '<param name="menu" value="false" />';
		returnCode += '<param name="quality" value="best" />';
		returnCode += '<param name="wmode" value="transparent" />';
		//if(scale != "showall"){
			returnCode += '<param name="scale" value="' + scale + '" />';	
		//}
		returnCode += '<param name="FlashVars" value="flv=' + filename + '&w=' + width + '&h=' + height;
		if(loop == "true"){
			returnCode += '&loop=' + loop;
		}
		if(sound == "true"){
			returnCode += '&sound=' + sound;
		}
		returnCode += '&scale=' + scale + '" />';
		returnCode += '<embed src="http://www.ngmoco.com/Media/vplayer_embed.swf" loop="false" menu="false" quality="best" ';
		//if(scale != "showall"){
			returnCode += 'scale="' + scale + '"';
		//}
		returnCode += ' wmode="transparent" width="' + swf_width + '" height="' + swf_height + '" type="application/x-shockwave-flash" FlashVars="flv=' + filename + '&w=' + width + '&h=' + height;
		if(loop == "true"){
			returnCode += '&loop=' + loop;
		}
		if(sound == "true"){
			returnCode += '&sound=' + sound;
		}
		returnCode += '&scale=' + scale + '" pluginspage="http://www.macromedia.com/go/getflashplayer"  />';
		returnCode += '</object>';
	
	//alert(returnCode);
	$('code_preview').value = returnCode;
	//if(scale == "noscale"){
		$('vid_preview').style.width = width + "px";
		$('vid_preview').style.height = height + "px";	
	//}
	$('vid_preview').innerHTML = returnCode;
}

