﻿


function Video(container)
{
	this.Id = 0;
	this.Container = container;
	this.Name = "";
	this.AssociatedEvent = null;
	this.Description = "";
	this.Resolution = null;
	this.Duration = null;

	var properties = container.getElementsByTagName("p");
	var html = "";
	for (var i = 0; i < properties.length; i++)
	{
		var value = properties[i].innerHTML;

		switch (properties[i].className)
		{
			case "MediaId":
				this.Id = parseInt(value);
				break;
			case "MediaName":
				this.Name = value;
				break;
			case "MediaDuration":
				break;
			case "MediaAssociatedEvent":
				this.AssociatedEvent = Site.FindId(value);
				break;
			case "MediaDescription":
				this.Description = value;
				break;
			case "MediaSize":
				this.Resolution = new Size(value.split(",")[0], value.split(",")[1]);
				break;
			case "MediaLength":
				this.Duration = value;
				break;
			default:
				break;
		}
	}

	html = "<table class=\"VideoTable\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr style=\"display: none\"><td>" + this.Id + "</td></tr><tr><td class=\"MediaSource\" colspan=\"2\">";
	html += "<img src=\"Resources/Videos/" + this.Id + ".png\" />";
	html += "</td></tr>";
	if (this.Name != null)
	{
		html += "<tr><td class=\"MediaName\" colspan=\"2\" >";
		html += this.Name;
		html += "</td></tr>";
	}

	html += "</table>";
	container.innerHTML = html;
}
