// onReady.js for AOPA Live itself

Ext.onReady(function() {
	// Tab Interface
	var tabs = new AopaLive.TabHost({
		cls: "tabs1"
	});
	var video = urlparam("watch");

	// Get server date
	srvDate = new Aopa.ServerClock();

	// Set up our video state object for video state changes
	AopaLive.WATCHER = new AopaLive.VideoWatcher({
		player: Ext.getDom("player1"),
		title: Ext.getDom("videopanetitle"),
		description: Ext.getDom("videopanedesc")
	});

	/*var now = new Date(),
	    open_sat = Date.parseDate("2010-01-30T08:30-05:00", "c"),
	    close_sat = Date.parseDate("2010-01-30T13:00-05:00", "c");
	if(now.between(open_sat, close_sat)) {
		var ssa = new AopaLive.EventList({
			source:"res/ssa.txt"
		});

		AopaLive.SSA_FEED = new AopaLive.LiveFeed({
			embedCode: AopaLive.SSA_EMBED,
			eventList: ssa,
			watcher: AopaLive.WATCHER
		});
		if(video === "ssa") {
			AopaLive.SSA_FEED.open(true);
		}
		Ext.fly("watchlivebtn").setVisibilityMode(Ext.Element.VISIBILITY).setVisible(true, true);
	}*/

	var category = urlparam("category") || "latestcontainer";
	var cat_el = bottomSwitch(category, true);

	/*if(video) {
		// Load the requested video into the player when we're finished
		// parsing
		cat_el.result.on("load", function(events) {
			for(var i = 0; i < events.length; i ++) {
				var e = events[i];
				if(e.embedCode == video) {
					setVideo(e);
					break;
				}
			}
		}, this, { single: true });
	}*/

	if(window.name === "aopalive") {
		Ext.fly("aopaback").on("click", function() {
			window.close();
		}, this, {stopEvent: true});
	}
});
