var Video = {
	player:function(id){
		$.getJSON(_base+'videos.php?action=loadclip&vid='+id,
			function(d){
				loc = d.file.replace(/^s+|s+$/g,"");
				iloc = d.graphic.replace(/^s+|s+$/g,"");
				var flashvars = {
					'autostart':'false',
					'file':loc,
					'image':iloc,
					'stretching':'fill',
					'screencolor':'ffffff',
					'lightcolor':'000000',
					'frontcolor':'000000',
					'provider':d.type,
					'type':d.type,
					'viral.functions':'link'
				};
				
				var params = {};
				params.play = "true";
				params.menu = "false";
				params.quality = "best";
				params.wmode = "transparent";
				params.bgcolor = "#FFFFFF";
				params.allowfullscreen = "true";
				params.allowscriptaccess = "always";
					
				var attributes = {};
				attributes.id = "player"+d.id;
				attributes.name = "player"+d.id;
				attributes.align = "";
				swfobject.embedSWF(_base+"media/video-player.swf", "vidplayer"+d.id, d.w, d.h, "9.0.0", "expressInstall.swf", flashvars, params, attributes);
		});
	},
	external:function(id){
		$.getScript(_base+'js/swfobject',
			function(){
				Video.player(id);
			});
	},
	win:function(id){
		if(!$("#modal").length){
			$('body').prepend('<link rel="stylesheet" type="text/css" href="http://www.vonfalconer.com/css/modal.css" id="modal" />');
		}
		$('body').append('<div id="vp" style="display: none;"><div id="vidplayer'+id+'"></div></div>');
		Video.external(id);
		$.getScript(_base+'js/jquery.simplemodal.js',
			function(){
				$("#vp").modal({
					opacity:50,
					autoResize : true,
					overlayClose : true,
					containerCss:{
						width: 427,
						height: 320,
						padding: 0
					},
					onOpen: function (dialog) {
						dialog.overlay.fadeIn('slow', function () {
							dialog.data.hide();
							dialog.container.fadeIn('slow', function () {
								dialog.data.fadeIn('slow',
									function(){
										//	
									});
							});
						});
					},
					onClose: function (dialog) {
						dialog.data.fadeOut('slow', function () {
							dialog.container.fadeOut('slow', function () {
								dialog.overlay.fadeOut('slow', function () {
									$.modal.close();
									$("#vp").remove();
								});
							});
						});
					}
				});
			});
	}
}
