packageAd = Class.create();
packageAd.prototype = {

	sizes: {
		small: { width:320, height:240 },
		medium: { width:480, height:360 },
		large: { width:574, height:322 },
		hd: { width:574, height:322 }
	},

	initialize: function(size, url, container, controller) {
		// get the container node
		this.container = $(container);
		if (!controller) var controller = 'moviecontroller';

		if (!AC.Detector.isQTInstalled()) {
			// if we don't have QT, display the download stuff
			this.container.getElementsByClassName('noqt')[0].style.display = 'block';

		} else {
			// if we're not opera use the custom controller
			if (!AC.Detector.isOpera()) {
				var controllerstatus = false;
				var height = this.sizes[size].height;
				var movieController = new AC.QuicktimeController();
				movieController.render(controller);
			} else {
				var controllerstatus = true;
				var height = this.sizes[size].height+16;
			}

			// package the movie
			var movie = AC.Quicktime.packageMovie('vid-'+size, url, {
				width: this.sizes[size].width,
				height: height,
				autoplay: true,
				controller: controllerstatus,
				cache: true,
				showlogo: false
			});
			this.container.appendChild(movie);
			
			// if we're doing the controller, let's attach it
			if (movieController) {
				movieController.attachToMovie(movie);
				movieController.monitorMovie();
			}
		}

	}
}

Event.observe(window, 'load', function() {
	if ($('adsthumbs')) {
		// redirect the page to size we're on, instead of just the index...
		var match = window.location.pathname.match(/([^\/]+\.html)$/);
		var vidPage = (match == null || match[0] == "index.html" ? "" : match[0]);
		$A($('adsthumbs').getElementsByTagName("a")).each(function(anchor) {
				anchor.href = anchor.href + vidPage;
		});
	}
});
