﻿/// <reference path="~/App_Themes/Global/js/jquery-vsdoc.js" />
function embedVideo(id, url, width, height, proxy) {
    var container = $j(id);
	var auto = true;
	var options = {
		embedMethod: 'fill',
		allowedProviders: ['vimeo'],
		customProviders: [ new $j.fn.oembed.OEmbedProvider('youtubecustom', 'video', ['youtube\\.com/watch.+v=[\\w-]+&?'], proxy) ],
		youtubecustom: { iframe: 1 }
	};

    if (!isNaN(width) && width > 0) {
		auto = false;
		options.maxWidth = width;
	}
    if (!isNaN(height) && height > 0) {
		auto = false;
		options.maxHeight = height;
	}
	if (auto) {
		width = container.width();
		if (width > 0) {
			options.maxWidth = width;
		}
	}
    container.oembed(url, options);
}

