var $_, $hxClasses = $hxClasses || {}, $estr = function() { return js.Boot.__string_rec(this,''); }
function $extend(from, fields) {
	function inherit() {}; inherit.prototype = from; var proto = new inherit();
	for (var name in fields) proto[name] = fields[name];
	return proto;
}
var data = data || {}
data.IMinClip = $hxClasses["data.IMinClip"] = function() { }
data.IMinClip.__name__ = ["data","IMinClip"];
data.IMinClip.prototype = {
	id: null
	,title: null
	,slug: null
	,description: null
	,language: null
	,thumbnail: null
	,pub_date: null
	,aspect_ratio: null
	,duration: null
	,__class__: data.IMinClip
}
data.IRelatedClips = $hxClasses["data.IRelatedClips"] = function() { }
data.IRelatedClips.__name__ = ["data","IRelatedClips"];
data.IRelatedClips.__interfaces__ = [data.IMinClip];
data.IRelatedClips.prototype = {
	related: null
	,__class__: data.IRelatedClips
}
data.IRssExtras = $hxClasses["data.IRssExtras"] = function() { }
data.IRssExtras.__name__ = ["data","IRssExtras"];
data.IRssExtras.prototype = {
	category: null
	,__class__: data.IRssExtras
}
data.IPageClip = $hxClasses["data.IPageClip"] = function() { }
data.IPageClip.__name__ = ["data","IPageClip"];
data.IPageClip.__interfaces__ = [data.IRssExtras,data.IRelatedClips];
data.IPageClip.prototype = {
	category: null
	,__class__: data.IPageClip
}
data.IClip = $hxClasses["data.IClip"] = function() { }
data.IClip.__name__ = ["data","IClip"];
data.IClip.__interfaces__ = [data.IMinClip];
data.IClip.prototype = {
	category: null
	,rating: null
	,mp4_270p: null
	,mp4_360p: null
	,mp4_480p: null
	,mp4_720p: null
	,subtitles: null
	,end_action: null
	,__class__: data.IClip
}
data.IFlashClip = $hxClasses["data.IFlashClip"] = function() { }
data.IFlashClip.__name__ = ["data","IFlashClip"];
data.IFlashClip.__interfaces__ = [data.IRelatedClips,data.IClip];
data.IFlashClip.prototype = {
	thumb_uri: null
	,video_uri: null
	,subtitle_uri: null
	,embed_url: null
	,share_url_short: null
	,share_url: null
	,share_links: null
	,__class__: data.IFlashClip
}
data.MinClip = $hxClasses["data.MinClip"] = function(obj,skip) {
	var me = this;
	if(obj != null) {
		var ifields = Type.getInstanceFields(Type.getClass(this));
		Lambda.iter(Reflect.fields(obj),function(fld) {
			if(Lambda.has(ifields,fld) && (skip == null || !Lambda.has(skip,fld))) me[fld] = Reflect.field(obj,fld);
		});
	}
}
data.MinClip.__name__ = ["data","MinClip"];
data.MinClip.__interfaces__ = [data.IMinClip];
data.MinClip.prototype = {
	id: null
	,title: null
	,slug: null
	,description: null
	,language: null
	,thumbnail: null
	,pub_date: null
	,aspect_ratio: null
	,duration: null
	,__class__: data.MinClip
}
data.FlashClip = $hxClasses["data.FlashClip"] = function(obj) {
	data.MinClip.call(this,obj);
}
data.FlashClip.__name__ = ["data","FlashClip"];
data.FlashClip.__interfaces__ = [data.IFlashClip];
data.FlashClip.__super__ = data.MinClip;
data.FlashClip.prototype = $extend(data.MinClip.prototype,{
	category: null
	,rating: null
	,mp4_270p: null
	,mp4_360p: null
	,mp4_480p: null
	,mp4_720p: null
	,subtitles: null
	,thumb_uri: null
	,video_uri: null
	,subtitle_uri: null
	,embed_url: null
	,share_url_short: null
	,share_url: null
	,share_links: null
	,end_action: null
	,related: null
	,__class__: data.FlashClip
});
var StringTools = $hxClasses["StringTools"] = function() { }
StringTools.__name__ = ["StringTools"];
StringTools.startsWith = function(s,start) {
	return s.length >= start.length && s.substr(0,start.length) == start;
}
StringTools.prototype = {
	__class__: StringTools
}
var J = $hxClasses["J"] = function() { }
J.__name__ = ["J"];
J.__properties__ = {get_qwin:"get_qwin",get_qthis:"get_qthis"}
J.qthis = null;
J.get_qthis = function() {
	return jQuery(this);
}
J.qwin = null;
J.get_qwin = function() {
	return jQuery(window);
}
J.q = function(html) {
	return jQuery(html);
}
J.runWhenReady = function(func) {
	return jQuery(document).ready(func);
}
J.runWhenLoaded = function(func) {
	return jQuery(window).load(func);
}
J.toQueryString = function(obj) {
	return jQuery.param(obj);
}
J.ajaxPost = function(url,dat,success) {
	jQuery.post(url,dat,success);
}
J.getJson = function(url,dat,success) {
	jQuery.getJSON(url,dat,success);
}
J.runWhenFxDone = function(j,func) {
	jQuery(j).promise().done(func);
}
J.prototype = {
	__class__: J
}
var Reflect = $hxClasses["Reflect"] = function() { }
Reflect.__name__ = ["Reflect"];
Reflect.hasField = function(o,field) {
	if(o.hasOwnProperty != null) return o.hasOwnProperty(field);
	var arr = Reflect.fields(o);
	var $it0 = arr.iterator();
	while( $it0.hasNext() ) {
		var t = $it0.next();
		if(t == field) return true;
	}
	return false;
}
Reflect.field = function(o,field) {
	var v = null;
	try {
		v = o[field];
	} catch( e ) {
	}
	return v;
}
Reflect.setField = function(o,field,value) {
	o[field] = value;
}
Reflect.getProperty = function(o,field) {
	var tmp;
	return o == null?null:o.__properties__ && (tmp = o.__properties__["get_" + field])?o[tmp]():o[field];
}
Reflect.setProperty = function(o,field,value) {
	var tmp;
	if(o.__properties__ && (tmp = o.__properties__["set_" + field])) o[tmp](value); else o[field] = value;
}
Reflect.callMethod = function(o,func,args) {
	return func.apply(o,args);
}
Reflect.fields = function(o) {
	if(o == null) return new Array();
	var a = new Array();
	if(o.hasOwnProperty) {
		for(var i in o) if( o.hasOwnProperty(i) ) a.push(i);
	} else {
		var t;
		try {
			t = o.__proto__;
		} catch( e ) {
			t = null;
		}
		if(t != null) o.__proto__ = null;
		for(var i in o) if( i != "__proto__" ) a.push(i);
		if(t != null) o.__proto__ = t;
	}
	return a;
}
Reflect.isFunction = function(f) {
	return typeof(f) == "function" && f.__name__ == null;
}
Reflect.compare = function(a,b) {
	return a == b?0:a > b?1:-1;
}
Reflect.compareMethods = function(f1,f2) {
	if(f1 == f2) return true;
	if(!Reflect.isFunction(f1) || !Reflect.isFunction(f2)) return false;
	return f1.scope == f2.scope && f1.method == f2.method && f1.method != null;
}
Reflect.isObject = function(v) {
	if(v == null) return false;
	var t = typeof(v);
	return t == "string" || t == "object" && !v.__enum__ || t == "function" && v.__name__ != null;
}
Reflect.deleteField = function(o,f) {
	if(!Reflect.hasField(o,f)) return false;
	delete(o[f]);
	return true;
}
Reflect.copy = function(o) {
	var o2 = { };
	var _g = 0, _g1 = Reflect.fields(o);
	while(_g < _g1.length) {
		var f = _g1[_g];
		++_g;
		o2[f] = Reflect.field(o,f);
	}
	return o2;
}
Reflect.makeVarArgs = function(f) {
	return function() {
		var a = new Array();
		var _g1 = 0, _g = arguments.length;
		while(_g1 < _g) {
			var i = _g1++;
			a.push(arguments[i]);
		}
		return f(a);
	};
}
Reflect.prototype = {
	__class__: Reflect
}
var StringBuf = $hxClasses["StringBuf"] = function() {
	this.b = new Array();
}
StringBuf.__name__ = ["StringBuf"];
StringBuf.prototype = {
	add: function(x) {
		this.b[this.b.length] = x == null?"null":x;
	}
	,toString: function() {
		return this.b.join("");
	}
	,b: null
	,__class__: StringBuf
}
var saptv = saptv || {}
saptv.Topics = $hxClasses["saptv.Topics"] = function() {
	var me = this;
	this.thumbDir = saptv.config.baseDir + "images/thumbnails/";
	this.topicIds = [];
	this.topicList = new IntHash();
	this.videoSection = new saptv.VideoSection();
	this.commentForm = new saptv.CommentForm(null,this.stopTimer.$bind(this),function() {
		if(!me.videoPlaying) me.startTimer();
	});
	this.fadeItems = jQuery("#video-section .text > *, #video-section #video img, #video-section #video .play-button");
	this.clickItems = jQuery("#video-section #video img, #video-section #video .play-button");
	jQuery("#topics-nav").hide().fadeIn(1000);
	jQuery("#topics-nav a").each(function() {
		me.topicIds.push(me.getTopicId(jQuery(this)));
	}).click();
	jQuery("#video-section .video-close").click(this.closeVideo.$bind(this));
	jQuery(window).bind("hashchange",this.routeByHash.$bind(this));
	this.routeByHash();
}
saptv.Topics.__name__ = ["saptv","Topics"];
saptv.Topics.prototype = {
	thumbDir: null
	,videoSection: null
	,commentForm: null
	,topicIds: null
	,topicList: null
	,clipList: null
	,clip: null
	,fadeItems: null
	,clickItems: null
	,selBtn: null
	,timer: null
	,timerPaused: null
	,videoPlaying: null
	,getTopicId: function(jq) {
		return Std.parseInt(jq.attr("href").split("/").pop());
	}
	,routeByHash: function(evt) {
		var me = this;
		var hash = js.Lib.window.location.hash;
		var rgx = new EReg("^#/topic/([1-9]([0-9]+)?)$","");
		var tid = rgx.match(hash)?(function(id) {
			return Lambda.has(me.topicIds,id)?id:me.topicIds[0];
		})(Std.parseInt(rgx.matched(1))):this.topicIds[0];
		this.getTopic(tid);
	}
	,getTopic: function(id) {
		var me = this;
		this.stopTimer();
		this.closeVideo();
		this.fadeItems.fadeOut(500);
		jQuery("#topics-nav .sel").removeClass("sel");
		jQuery(jQuery("#topics-nav a").get(Lambda.indexOf(this.topicIds,id))).addClass("sel");
		if(this.topicList.exists(id)) {
			this.clipList = this.topicList.get(id);
			this.setBtns();
			this.showClipInfo(0);
		} else jQuery.getJSON(saptv.config.baseDir + "topic/" + id + "/json",function(dat) {
			me.clipList = dat;
			me.topicList.set(id,me.clipList);
			me.setBtns();
			jQuery("#video-section .text ul, #video-section #video .play-button").css("visibility","visible");
			me.showClipInfo(0);
		},null);
	}
	,setBtns: function() {
		var me = this;
		jQuery("#topic-btns").empty();
		var _g = 0, _g1 = this.clipList;
		while(_g < _g1.length) {
			var clp = _g1[_g];
			++_g;
			var btn = jQuery("<a href=\"" + saptv.config.baseDir + "video/" + clp.id + "\"/>").appendTo("#topic-btns");
			btn.click(function() {
				return me.btnOnClick(jQuery(this).index(),jQuery(this).hasClass("sel"));
			});
		}
	}
	,btnOnClick: function(num,sel) {
		this.stopTimer();
		if(sel && this.getBtnBgPos() > -20) {
			if(this.timerPaused) {
				this.selBtn.empty();
				jQuery("#topic-btns a:not(.sel)").fadeTo(500,1.0);
				this.timerPaused = false;
				this.startTimer();
			} else {
				this.selBtn.text("| |");
				jQuery("#topic-btns a:not(.sel)").fadeTo(500,0.5);
				this.timerPaused = true;
			}
		} else {
			if(this.timerPaused) {
				this.selBtn.empty();
				jQuery("#topic-btns a").css("opacity","1.0");
				this.timerPaused = false;
			}
			this.changeClip(num);
		}
		return false;
	}
	,showClipInfo: function(num) {
		var me = this;
		if(this.selBtn != null) this.selBtn.removeClass("sel").css("background-position","0 -20px");
		this.selBtn = jQuery(jQuery("#topic-btns a").get(num)).addClass("sel").css("background-position","0 0");
		this.clip = this.clipList[num];
		jQuery("#video-section .text h1").html(this.clip.title + "&nbsp;<span>[" + this.clip.duration.minutes + "]</span>");
		jQuery("#video-section .text p").text(this.clip.description);
		if(this.clip.thumbnail == "") this.clip.thumbnail = "../spacing.gif";
		jQuery("#video-section #video img").unbind("load").attr("src",this.thumbDir + this.clip.thumbnail).load(function(evt) {
			me.fadeIn();
		});
		this.clickItems.unbind("click").click(function() {
			me.showVideo(me.clip);
		});
		this.videoSection.addRating(this.clip,function(rate) {
			me.clip.rating = rate;
		});
		this.commentForm.clipID = this.clip.id;
		jQuery("#video-section .ui-rater-rating").text(this.clip.rating == 0?"no ratings yet":"average: " + this.clip.rating);
	}
	,fadeIn: function() {
		this.fadeItems.fadeIn(1500);
		jQuery(this.fadeItems).promise().done(this.startTimer.$bind(this));
	}
	,changeClip: function(num) {
		var me = this;
		this.fadeItems.fadeOut(500);
		jQuery(this.fadeItems).promise().done(function() {
			me.showClipInfo(num);
		});
	}
	,startTimer: function() {
		var me = this;
		if(this.timer != null || this.timerPaused) return;
		var pos = this.getBtnBgPos();
		this.timer = new haxe.Timer(500);
		this.timer.run = function() {
			if(me.selBtn != null) me.selBtn.css("background-position","0 " + (pos = pos - 2) + "px");
			if(pos == -20) {
				me.stopTimer();
				var num = me.selBtn.index() + 1;
				if(num < me.clipList.length) me.changeClip(num); else {
					var idx = jQuery("#topics-nav .sel").parent().index() + 1;
					if(idx < me.topicIds.length) me.setHash(me.topicIds[idx]); else me.setHash(me.topicIds[0]);
				}
			}
		};
	}
	,getBtnBgPos: function() {
		return this.selBtn.css("background-position") != null?Std.parseInt(this.selBtn.css("background-position").split(" ").pop()):0;
	}
	,stopTimer: function() {
		if(this.timer != null) this.timer.stop();
		this.timer = null;
	}
	,setHash: function(id) {
		js.Lib.window.location.hash = "#/topic/" + id;
	}
	,showVideo: function(clp) {
		if(this.videoPlaying || this.timer == null) return;
		this.stopTimer();
		jQuery("#video-section .video-close").fadeIn();
		this.videoSection.insertVideoPlayer(clp,true);
		this.videoPlaying = true;
		this.videoSection.insertAddThisBar();
		this.videoSection.initAddThisBar(clp);
	}
	,closeVideo: function() {
		if(this.videoPlaying) {
			jQuery("#video-section .video-close").fadeOut(500);
			ext.SWFObject.removeSWF("vplayer");
			jQuery("#vplayer").remove();
			this.videoPlaying = false;
			jQuery(".addthis_toolbox").empty();
			this.startTimer();
		}
		return this.videoPlaying;
	}
	,__class__: saptv.Topics
}
var haxe = haxe || {}
haxe.Timer = $hxClasses["haxe.Timer"] = function(time_ms) {
	var arr = haxe_timers;
	this.id = arr.length;
	arr[this.id] = this;
	this.timerId = window.setInterval("haxe_timers[" + this.id + "].run();",time_ms);
}
haxe.Timer.__name__ = ["haxe","Timer"];
haxe.Timer.delay = function(f,time_ms) {
	var t = new haxe.Timer(time_ms);
	t.run = function() {
		t.stop();
		f();
	};
	return t;
}
haxe.Timer.prototype = {
	id: null
	,timerId: null
	,stop: function() {
		if(this.id == null) return;
		window.clearInterval(this.timerId);
		var arr = haxe_timers;
		arr[this.id] = null;
		if(this.id > 100 && this.id == arr.length - 1) {
			var p = this.id - 1;
			while(p >= 0 && arr[p] == null) p--;
			arr = arr.slice(0,p + 1);
		}
		this.id = null;
	}
	,run: function() {
	}
	,__class__: haxe.Timer
}
saptv.SearchResults = $hxClasses["saptv.SearchResults"] = function(hasResults) {
	var me = this;
	jQuery("#video-search :radio").change(function(evt) {
		jQuery("#video-search select[name=\"categ\"]:enabled").attr("disabled","disabled");
		jQuery(this).nextAll("select").removeAttr("disabled");
	});
	if(hasResults) {
		this.videoSection = new saptv.VideoSection();
		if(jQuery("#search-results .list li").length > 0) jQuery("#search-results .list li").find("h2, a.more").click(function() {
			var li = jQuery(this).parent();
			var expanded = li.hasClass("exp");
			me.contractResult();
			if(!expanded) me.expandResult(li);
			return false;
		}); else if(jQuery("#search-results .thumbnails li").length > 0) jQuery("#search-results .thumbnails li a").click(function() {
			me.showVideoFromThumbnail(jQuery(this));
			return false;
		});
	}
}
saptv.SearchResults.__name__ = ["saptv","SearchResults"];
saptv.SearchResults.prototype = {
	videoSection: null
	,showVideoFromThumbnail: function(a) {
		var list = jQuery("#search-results .thumbnails"), li = a.parents("li"), pos = li.position(), vid = list.find("#video"), overl = list.find(".overlay");
		if(vid.length == 0) {
			overl = jQuery("<div class=\"overlay\"/>").appendTo(list);
			vid = jQuery("<div id=\"video\"/>").append("<button class=\"video-close\"/>").appendTo(list);
			vid.find(".video-close").click(function() {
				ext.SWFObject.removeSWF("vplayer");
				vid.fadeOut(500,function() {
					overl.hide();
				});
			});
		}
		if(pos.left == 0) vid.css("left","0"); else if(pos.left == list.width() - li.width()) vid.css("left","").css("right","3px"); else vid.css("left",(list.width() - vid.width()) / 2 + "px");
		if(pos.top == 0) vid.css("top","0"); else if(pos.top == list.height() - li.height() - 3) vid.css("top","").css("bottom","3px"); else vid.css("top",pos.top - (vid.height() - li.height()) / 2 + "px");
		overl.show();
		vid.fadeIn(1000);
		var clip = this.getClipData(a,li);
		this.videoSection.insertVideoPlayer(clip,true);
	}
	,getClipData: function(a,li) {
		var clipid = Std.parseInt(a.attr("href").split("/").pop());
		var clipdata = js.JQuery.parseJSON(li.find(".clipdata").text());
		return new data.FlashClip({ id : clipid, thumb_uri : saptv.config.thumbUri, thumbnail : clipdata.thumbnail, video_uri : saptv.config.videoUri, mp4_360p : { file : clipdata.mp4_360p.file, rate : 0}});
	}
	,expandResult: function(li) {
		li.addClass("exp").find("span").not(".clipdata").css("display","inline");
		var a = li.find("a.more").text("Less");
		li.append("<div id=\"video\"/>");
		var clip = this.getClipData(a,li);
		this.videoSection.insertVideoPlayer(clip);
	}
	,contractResult: function() {
		var exp = jQuery("#search-results li.exp");
		if(exp.length == 0) return;
		ext.SWFObject.removeSWF("vplayer");
		jQuery("#video").remove();
		exp.removeClass("exp").find("span").css("display","none");
		exp.find("a.more").text("More");
	}
	,__class__: saptv.SearchResults
}
var Std = $hxClasses["Std"] = function() { }
Std.__name__ = ["Std"];
Std["is"] = function(v,t) {
	return js.Boot.__instanceof(v,t);
}
Std.string = function(s) {
	return js.Boot.__string_rec(s,"");
}
Std["int"] = function(x) {
	if(x < 0) return Math.ceil(x);
	return Math.floor(x);
}
Std.parseInt = function(x) {
	var v = parseInt(x,10);
	if(v == 0 && x.charCodeAt(1) == 120) v = parseInt(x);
	if(isNaN(v)) return null;
	return v;
}
Std.parseFloat = function(x) {
	return parseFloat(x);
}
Std.random = function(x) {
	return Math.floor(Math.random() * x);
}
Std.prototype = {
	__class__: Std
}
saptv.Client = $hxClasses["saptv.Client"] = function() {
	this.clearLabelOnFocus();
	var uri = js.Lib.window.location.pathname;
	if(StringTools.startsWith(uri,saptv.config.baseDir)) uri = uri.substr(saptv.config.baseDir.length);
	var pg = uri.split("/").shift();
	switch(pg) {
	case "":
		new saptv.Topics();
		break;
	case "video":
		new saptv.VideoSection().addVideoItems();
		break;
	case "archive":case "search":
		new saptv.SearchResults(pg == "search");
		break;
	}
}
saptv.Client.__name__ = ["saptv","Client"];
saptv.Client.main = function() {
	jQuery(document).ready(function() {
		new saptv.Client();
	});
}
saptv.Client.prototype = {
	clearLabelOnFocus: function() {
		jQuery(".clear-label").each(function() {
			if(jQuery(this).val() != "") jQuery(this).prev("label").hide();
		}).focus(function(evt) {
			jQuery(this).prev("label").hide();
		}).blur(function(evt) {
			if(jQuery(this).val() == "") jQuery(this).prev("label").show();
		});
	}
	,__class__: saptv.Client
}
saptv.CommentForm = $hxClasses["saptv.CommentForm"] = function(id,onOpen,onClose) {
	var me = this;
	this.clipID = id;
	var dlg = new ext.jquery.ui.Dialog("#comment-form").dialog({ autoOpen : false, width : 380, height : 150, modal : true, show : "fade", hide : "fade", open : onOpen, close : function() {
		jQuery("#comment-text" + "," + "#email-address").val("");
		if(onClose != null) onClose();
	}});
	jQuery("#comment-add").click(function() {
		var pos = jQuery(this).offset();
		dlg.dialog({ position : [pos.left - jQuery(window).scrollLeft(),pos.top - jQuery(window).scrollTop() + 20]}).dialog("open");
		return false;
	});
	jQuery("#comment-form" + " .cancel").click(function() {
		dlg.dialog("close");
		return false;
	});
	jQuery("#comment-form" + " .submit").click(function() {
		var cmt = jQuery("#comment-text").val();
		var email = jQuery("#email-address").val();
		if(cmt == "") {
			jQuery("#comment-text").blur();
			return false;
		}
		if(cmt.length > 400) cmt = cmt.substr(0,400);
		jQuery.post(saptv.config.baseDir + "clip/" + me.clipID + "/comment",{ comment : cmt, email : email},function(ret) {
			dlg.dialog("close");
		});
		jQuery(".ui-dialog").fadeOut();
		return false;
	});
}
saptv.CommentForm.__name__ = ["saptv","CommentForm"];
saptv.CommentForm.prototype = {
	clipID: null
	,__class__: saptv.CommentForm
}
var Lambda = $hxClasses["Lambda"] = function() { }
Lambda.__name__ = ["Lambda"];
Lambda.has = function(it,elt,cmp) {
	if(cmp == null) {
		var $it0 = it.iterator();
		while( $it0.hasNext() ) {
			var x = $it0.next();
			if(x == elt) return true;
		}
	} else {
		var $it1 = it.iterator();
		while( $it1.hasNext() ) {
			var x = $it1.next();
			if(cmp(x,elt)) return true;
		}
	}
	return false;
}
Lambda.iter = function(it,f) {
	var $it0 = it.iterator();
	while( $it0.hasNext() ) {
		var x = $it0.next();
		f(x);
	}
}
Lambda.indexOf = function(it,v) {
	var i = 0;
	var $it0 = it.iterator();
	while( $it0.hasNext() ) {
		var v2 = $it0.next();
		if(v == v2) return i;
		i++;
	}
	return -1;
}
Lambda.prototype = {
	__class__: Lambda
}
var List = $hxClasses["List"] = function() { }
List.__name__ = ["List"];
List.prototype = {
	length: null
	,__class__: List
}
var ValueType = $hxClasses["ValueType"] = { __ename__ : ["ValueType"], __constructs__ : ["TNull","TInt","TFloat","TBool","TObject","TFunction","TClass","TEnum","TUnknown"] }
ValueType.TNull = ["TNull",0];
ValueType.TNull.toString = $estr;
ValueType.TNull.__enum__ = ValueType;
ValueType.TInt = ["TInt",1];
ValueType.TInt.toString = $estr;
ValueType.TInt.__enum__ = ValueType;
ValueType.TFloat = ["TFloat",2];
ValueType.TFloat.toString = $estr;
ValueType.TFloat.__enum__ = ValueType;
ValueType.TBool = ["TBool",3];
ValueType.TBool.toString = $estr;
ValueType.TBool.__enum__ = ValueType;
ValueType.TObject = ["TObject",4];
ValueType.TObject.toString = $estr;
ValueType.TObject.__enum__ = ValueType;
ValueType.TFunction = ["TFunction",5];
ValueType.TFunction.toString = $estr;
ValueType.TFunction.__enum__ = ValueType;
ValueType.TClass = function(c) { var $x = ["TClass",6,c]; $x.__enum__ = ValueType; $x.toString = $estr; return $x; }
ValueType.TEnum = function(e) { var $x = ["TEnum",7,e]; $x.__enum__ = ValueType; $x.toString = $estr; return $x; }
ValueType.TUnknown = ["TUnknown",8];
ValueType.TUnknown.toString = $estr;
ValueType.TUnknown.__enum__ = ValueType;
var Type = $hxClasses["Type"] = function() { }
Type.__name__ = ["Type"];
Type.getClass = function(o) {
	if(o == null) return null;
	if(o.__enum__ != null) return null;
	return o.__class__;
}
Type.getEnum = function(o) {
	if(o == null) return null;
	return o.__enum__;
}
Type.getSuperClass = function(c) {
	return c.__super__;
}
Type.getClassName = function(c) {
	var a = c.__name__;
	return a.join(".");
}
Type.getEnumName = function(e) {
	var a = e.__ename__;
	return a.join(".");
}
Type.resolveClass = function(name) {
	var cl = $hxClasses[name];
	if(cl == null || cl.__name__ == null) return null;
	return cl;
}
Type.resolveEnum = function(name) {
	var e = $hxClasses[name];
	if(e == null || e.__ename__ == null) return null;
	return e;
}
Type.createInstance = function(cl,args) {
	if(args.length <= 3) return new cl(args[0],args[1],args[2]);
	if(args.length > 8) throw "Too many arguments";
	return new cl(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7]);
}
Type.createEmptyInstance = function(cl) {
	function empty() {}; empty.prototype = cl.prototype;
	return new empty();
}
Type.createEnum = function(e,constr,params) {
	var f = Reflect.field(e,constr);
	if(f == null) throw "No such constructor " + constr;
	if(Reflect.isFunction(f)) {
		if(params == null) throw "Constructor " + constr + " need parameters";
		return f.apply(e,params);
	}
	if(params != null && params.length != 0) throw "Constructor " + constr + " does not need parameters";
	return f;
}
Type.createEnumIndex = function(e,index,params) {
	var c = e.__constructs__[index];
	if(c == null) throw index + " is not a valid enum constructor index";
	return Type.createEnum(e,c,params);
}
Type.getInstanceFields = function(c) {
	var a = [];
	for(var i in c.prototype) a.push(i);
	a.remove("__class__");
	a.remove("__properties__");
	return a;
}
Type.getClassFields = function(c) {
	var a = Reflect.fields(c);
	a.remove("__name__");
	a.remove("__interfaces__");
	a.remove("__properties__");
	a.remove("__super__");
	a.remove("prototype");
	return a;
}
Type.getEnumConstructs = function(e) {
	var a = e.__constructs__;
	return a.copy();
}
Type["typeof"] = function(v) {
	switch(typeof(v)) {
	case "boolean":
		return ValueType.TBool;
	case "string":
		return ValueType.TClass(String);
	case "number":
		if(Math.ceil(v) == v % 2147483648.0) return ValueType.TInt;
		return ValueType.TFloat;
	case "object":
		if(v == null) return ValueType.TNull;
		var e = v.__enum__;
		if(e != null) return ValueType.TEnum(e);
		var c = v.__class__;
		if(c != null) return ValueType.TClass(c);
		return ValueType.TObject;
	case "function":
		if(v.__name__ != null) return ValueType.TObject;
		return ValueType.TFunction;
	case "undefined":
		return ValueType.TNull;
	default:
		return ValueType.TUnknown;
	}
}
Type.enumEq = function(a,b) {
	if(a == b) return true;
	try {
		if(a[0] != b[0]) return false;
		var _g1 = 2, _g = a.length;
		while(_g1 < _g) {
			var i = _g1++;
			if(!Type.enumEq(a[i],b[i])) return false;
		}
		var e = a.__enum__;
		if(e != b.__enum__ || e == null) return false;
	} catch( e ) {
		return false;
	}
	return true;
}
Type.enumConstructor = function(e) {
	return e[0];
}
Type.enumParameters = function(e) {
	return e.slice(2);
}
Type.enumIndex = function(e) {
	return e[1];
}
Type.allEnums = function(e) {
	var all = [];
	var cst = e.__constructs__;
	var _g = 0;
	while(_g < cst.length) {
		var c = cst[_g];
		++_g;
		var v = Reflect.field(e,c);
		if(!Reflect.isFunction(v)) all.push(v);
	}
	return all;
}
Type.prototype = {
	__class__: Type
}
var js = js || {}
js.Lib = $hxClasses["js.Lib"] = function() { }
js.Lib.__name__ = ["js","Lib"];
js.Lib.isIE = null;
js.Lib.isOpera = null;
js.Lib.document = null;
js.Lib.window = null;
js.Lib.prototype = {
	__class__: js.Lib
}
js.Boot = $hxClasses["js.Boot"] = function() { }
js.Boot.__name__ = ["js","Boot"];
js.Boot.__unhtml = function(s) {
	return s.split("&").join("&amp;").split("<").join("&lt;").split(">").join("&gt;");
}
js.Boot.__trace = function(v,i) {
	var msg = i != null?i.fileName + ":" + i.lineNumber + ": ":"";
	msg += js.Boot.__string_rec(v,"");
	var d = document.getElementById("haxe:trace");
	if(d != null) d.innerHTML += js.Boot.__unhtml(msg) + "<br/>"; else if(typeof(console) != "undefined" && console.log != null) console.log(msg);
}
js.Boot.__clear_trace = function() {
	var d = document.getElementById("haxe:trace");
	if(d != null) d.innerHTML = "";
}
js.Boot.__string_rec = function(o,s) {
	if(o == null) return "null";
	if(s.length >= 5) return "<...>";
	var t = typeof(o);
	if(t == "function" && (o.__name__ != null || o.__ename__ != null)) t = "object";
	switch(t) {
	case "object":
		if(o instanceof Array) {
			if(o.__enum__ != null) {
				if(o.length == 2) return o[0];
				var str = o[0] + "(";
				s += "\t";
				var _g1 = 2, _g = o.length;
				while(_g1 < _g) {
					var i = _g1++;
					if(i != 2) str += "," + js.Boot.__string_rec(o[i],s); else str += js.Boot.__string_rec(o[i],s);
				}
				return str + ")";
			}
			var l = o.length;
			var i;
			var str = "[";
			s += "\t";
			var _g = 0;
			while(_g < l) {
				var i1 = _g++;
				str += (i1 > 0?",":"") + js.Boot.__string_rec(o[i1],s);
			}
			str += "]";
			return str;
		}
		var tostr;
		try {
			tostr = o.toString;
		} catch( e ) {
			return "???";
		}
		if(tostr != null && tostr != Object.toString) {
			var s2 = o.toString();
			if(s2 != "[object Object]") return s2;
		}
		var k = null;
		var str = "{\n";
		s += "\t";
		var hasp = o.hasOwnProperty != null;
		for( var k in o ) { ;
		if(hasp && !o.hasOwnProperty(k)) {
			continue;
		}
		if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
			continue;
		}
		if(str.length != 2) str += ", \n";
		str += s + k + " : " + js.Boot.__string_rec(o[k],s);
		}
		s = s.substring(1);
		str += "\n" + s + "}";
		return str;
	case "function":
		return "<function>";
	case "string":
		return o;
	default:
		return String(o);
	}
}
js.Boot.__interfLoop = function(cc,cl) {
	if(cc == null) return false;
	if(cc == cl) return true;
	var intf = cc.__interfaces__;
	if(intf != null) {
		var _g1 = 0, _g = intf.length;
		while(_g1 < _g) {
			var i = _g1++;
			var i1 = intf[i];
			if(i1 == cl || js.Boot.__interfLoop(i1,cl)) return true;
		}
	}
	return js.Boot.__interfLoop(cc.__super__,cl);
}
js.Boot.__instanceof = function(o,cl) {
	try {
		if(o instanceof cl) {
			if(cl == Array) return o.__enum__ == null;
			return true;
		}
		if(js.Boot.__interfLoop(o.__class__,cl)) return true;
	} catch( e ) {
		if(cl == null) return false;
	}
	switch(cl) {
	case Int:
		return Math.ceil(o%2147483648.0) === o;
	case Float:
		return typeof(o) == "number";
	case Bool:
		return o === true || o === false;
	case String:
		return typeof(o) == "string";
	case Dynamic:
		return true;
	default:
		if(o == null) return false;
		return o.__enum__ == cl || cl == Class && o.__name__ != null || cl == Enum && o.__ename__ != null;
	}
}
js.Boot.__init = function() {
	js.Lib.isIE = typeof document!='undefined' && document.all != null && typeof window!='undefined' && window.opera == null;
	js.Lib.isOpera = typeof window!='undefined' && window.opera != null;
	Array.prototype.copy = Array.prototype.slice;
	Array.prototype.insert = function(i,x) {
		this.splice(i,0,x);
	};
	Array.prototype.remove = Array.prototype.indexOf?function(obj) {
		var idx = this.indexOf(obj);
		if(idx == -1) return false;
		this.splice(idx,1);
		return true;
	}:function(obj) {
		var i = 0;
		var l = this.length;
		while(i < l) {
			if(this[i] == obj) {
				this.splice(i,1);
				return true;
			}
			i++;
		}
		return false;
	};
	Array.prototype.iterator = function() {
		return { cur : 0, arr : this, hasNext : function() {
			return this.cur < this.arr.length;
		}, next : function() {
			return this.arr[this.cur++];
		}};
	};
	if(String.prototype.cca == null) String.prototype.cca = String.prototype.charCodeAt;
	String.prototype.charCodeAt = function(i) {
		var x = this.cca(i);
		if(x != x) return undefined;
		return x;
	};
	var oldsub = String.prototype.substr;
	String.prototype.substr = function(pos,len) {
		if(pos != null && pos != 0 && len != null && len < 0) return "";
		if(len == null) len = this.length;
		if(pos < 0) {
			pos = this.length + pos;
			if(pos < 0) pos = 0;
		} else if(len < 0) len = this.length + len - pos;
		return oldsub.apply(this,[pos,len]);
	};
	Function.prototype["$bind"] = function(o) {
		var f = function() {
			return f.method.apply(f.scope,arguments);
		};
		f.scope = o;
		f.method = this;
		return f;
	};
}
js.Boot.prototype = {
	__class__: js.Boot
}
var IntHash = $hxClasses["IntHash"] = function() {
	this.h = {}
	if(this.h.__proto__ != null) {
		this.h.__proto__ = null;
		delete(this.h.__proto__);
	}
}
IntHash.__name__ = ["IntHash"];
IntHash.prototype = {
	h: null
	,set: function(key,value) {
		this.h[key] = value;
	}
	,get: function(key) {
		return this.h[key];
	}
	,exists: function(key) {
		return this.h[key] != null;
	}
	,remove: function(key) {
		if(this.h[key] == null) return false;
		delete(this.h[key]);
		return true;
	}
	,keys: function() {
		var a = new Array();
		for( x in this.h ) a.push(x);
		return a.iterator();
	}
	,iterator: function() {
		return { ref : this.h, it : this.keys(), hasNext : function() {
			return this.it.hasNext();
		}, next : function() {
			var i = this.it.next();
			return this.ref[i];
		}};
	}
	,toString: function() {
		var s = new StringBuf();
		s.b[s.b.length] = "{";
		var it = this.keys();
		while( it.hasNext() ) {
			var i = it.next();
			s.b[s.b.length] = i == null?"null":i;
			s.b[s.b.length] = " => ";
			s.add(Std.string(this.get(i)));
			if(it.hasNext()) s.b[s.b.length] = ", ";
		}
		s.b[s.b.length] = "}";
		return s.b.join("");
	}
	,__class__: IntHash
}
saptv.VideoSection = $hxClasses["saptv.VideoSection"] = function() {
}
saptv.VideoSection.__name__ = ["saptv","VideoSection"];
saptv.VideoSection.prototype = {
	clip: null
	,addVideoItems: function() {
		var me = this;
		this.clip = new data.FlashClip(saptv.clip);
		this.insertVideoPlayer(this.clip);
		this.addRating(this.clip);
		new saptv.CommentForm(this.clip.id);
		this.insertAddThisBar();
		jQuery(window).load(function() {
			jQuery("#video-section .text ul").hide().css("visibility","visible").fadeIn();
			me.initAddThisBar(me.clip);
		});
	}
	,insertVideoPlayer: function(clp,autoStart) {
		if(autoStart == null) autoStart = false;
		jQuery("#video").append("<div id=\"vplayer\"/>");
		if(saptv.config.useHtml5Video) {
			var vid = "<video id=\"vplayer\" src=\"" + clp.video_uri + clp.mp4_360p.file + "\" \n\t\t\t\ttype=\"video/mp4\" width=\"100%\" height=\"100%\" controls=\"controls\" \n\t\t\t\tposter=\"" + clp.thumb_uri + clp.thumbnail + "\"/>";
			jQuery("#vplayer").replaceWith(vid);
			if(autoStart) {
				var vplayer = jQuery("#vplayer").get(0);
				vplayer.load();
				vplayer.play();
			}
		} else if(ext.SWFObject.hasFlashPlayerVersion("10.3.0")) ext.SWFObject.createSWF({ data : saptv.config.baseDir + "flash/" + saptv.config.vplayer, width : "100%", height : "100%"},{ menu : true, allowFullScreen : true, allowScriptAccess : "always", wmode : "opaque", bgcolor : "#000000", flashvars : jQuery.param({ vidID : clp.id, myServer : saptv.config.baseDir + "clip/", autoStart : autoStart, stageVideo : true, showTitle : true, showRelated : true, showSharing : true, vidres : "360p", colors : "sap", lang : "en"})},"vplayer"); else {
			var btn = "<div id=\"flash-button\">\n\t\t\t\t\t<p>For watching the videos you need the newest version of the Adobe Flash Player.</p>\n\t\t\t\t\t<a href=\"http://www.adobe.com/go/getflashplayer\" target=\"_blank\">\n\t\t\t\t\t<img src=\"" + saptv.config.baseDir + "images/buttons/160x41_Get_Flash_Player.jpg\" width=\"160\" height=\"41\" />\n\t\t\t\t\t</a></div>";
			jQuery("#vplayer").append(btn);
		}
	}
	,addRating: function(clp,func) {
		new ext.jquery.Rater("#rating").rater({ postHref : saptv.config.baseDir + "clip/" + clp.id + "/rate", rating : clp.rating, id : clp.id, callbackFunc : func});
	}
	,insertAddThisBar: function() {
		var btns = "<a class=\"addthis_button_facebook_like\" fb:like:layout=\"button_count\" fb:like:action=\"recommend\"></a>\n\t\t\t<a class=\"addthis_button_tweet\" tw:via=\"saptv\"></a>\n\t\t\t<a class=\"addthis_button_google_plusone\" g:plusone:size=\"medium\"></a>";
		jQuery(".addthis_toolbox").append(btns);
	}
	,initAddThisBar: function(clp) {
		addthis.toolbox(".addthis_toolbox",null,{ url : "http://www.sap-tv.com/video/" + clp.id + "/" + clp.slug, title : clp.title});
		haxe.Timer.delay(function() {
			jQuery(".addthis_button_facebook_like iframe").css("width","125px");
			jQuery(".addthis_button_tweet").css("width","100px");
			jQuery(".addthis_button_google_plusone").css("width","70px");
			jQuery(".addthis_toolbox > a").fadeIn();
		},1000);
	}
	,__class__: saptv.VideoSection
}
var EReg = $hxClasses["EReg"] = function(r,opt) {
	opt = opt.split("u").join("");
	this.r = new RegExp(r,opt);
}
EReg.__name__ = ["EReg"];
EReg.prototype = {
	r: null
	,match: function(s) {
		this.r.m = this.r.exec(s);
		this.r.s = s;
		return this.r.m != null;
	}
	,matched: function(n) {
		return this.r.m != null && n >= 0 && n < this.r.m.length?this.r.m[n]:(function($this) {
			var $r;
			throw "EReg::matched";
			return $r;
		}(this));
	}
	,matchedLeft: function() {
		if(this.r.m == null) throw "No string matched";
		return this.r.s.substr(0,this.r.m.index);
	}
	,matchedRight: function() {
		if(this.r.m == null) throw "No string matched";
		var sz = this.r.m.index + this.r.m[0].length;
		return this.r.s.substr(sz,this.r.s.length - sz);
	}
	,matchedPos: function() {
		if(this.r.m == null) throw "No string matched";
		return { pos : this.r.m.index, len : this.r.m[0].length};
	}
	,split: function(s) {
		var d = "#__delim__#";
		return s.replace(this.r,d).split(d);
	}
	,replace: function(s,by) {
		return s.replace(this.r,by);
	}
	,customReplace: function(s,f) {
		var buf = new StringBuf();
		while(true) {
			if(!this.match(s)) break;
			buf.add(this.matchedLeft());
			buf.add(f(this));
			s = this.matchedRight();
		}
		buf.b[buf.b.length] = s == null?"null":s;
		return buf.b.join("");
	}
	,__class__: EReg
}
js.Boot.__res = {}
js.Boot.__init();
{
	var q = window.jQuery;
	js.JQuery = q;
	q.fn.iterator = function() {
		return { pos : 0, j : this, hasNext : function() {
			return this.pos < this.j.length;
		}, next : function() {
			return $(this.j[this.pos++]);
		}};
	};
}
{
	var ext = ext || {};
	ext.jquery = ext.jquery || {};;
	ext.jquery.Rater = window.jQuery;
}
{
	var ext = ext || {}
	ext.SWFObject = window.swfobject;
}
{
	var ext = ext || {};
	ext.jquery = ext.jquery || {};
	ext.jquery.ui = ext.jquery.ui || {};;
	ext.jquery.ui.Dialog = window.jQuery;
}
if(typeof(haxe_timers) == "undefined") haxe_timers = [];
{
	String.prototype.__class__ = $hxClasses["String"] = String;
	String.__name__ = ["String"];
	Array.prototype.__class__ = $hxClasses["Array"] = Array;
	Array.__name__ = ["Array"];
	Int = $hxClasses["Int"] = { __name__ : ["Int"]};
	Dynamic = $hxClasses["Dynamic"] = { __name__ : ["Dynamic"]};
	Float = $hxClasses["Float"] = Number;
	Float.__name__ = ["Float"];
	Bool = $hxClasses["Bool"] = { __ename__ : ["Bool"]};
	Class = $hxClasses["Class"] = { __name__ : ["Class"]};
	Enum = { };
	Void = $hxClasses["Void"] = { __ename__ : ["Void"]};
}
{
	Math.__name__ = ["Math"];
	Math.NaN = Number["NaN"];
	Math.NEGATIVE_INFINITY = Number["NEGATIVE_INFINITY"];
	Math.POSITIVE_INFINITY = Number["POSITIVE_INFINITY"];
	$hxClasses["Math"] = Math;
	Math.isFinite = function(i) {
		return isFinite(i);
	};
	Math.isNaN = function(i) {
		return isNaN(i);
	};
}
{
	js.Lib.document = document;
	js.Lib.window = window;
	onerror = function(msg,url,line) {
		var f = js.Lib.onerror;
		if( f == null )
			return false;
		return f(msg,[url+":"+line]);
	}
}
J.swf = ext.SWFObject;
saptv.Topics.baseDir = saptv.config.baseDir;
saptv.SearchResults.thumbUri = saptv.config.thumbUri;
saptv.SearchResults.videoUri = saptv.config.videoUri;
saptv.Client.baseDir = saptv.config.baseDir;
saptv.CommentForm.form = "#comment-form";
saptv.CommentForm.textArea = "#comment-text";
saptv.CommentForm.emailInput = "#email-address";
saptv.CommentForm.openLink = "#comment-add";
saptv.CommentForm.MAX_LENGTH = 400;
saptv.VideoSection.baseDir = saptv.config.baseDir;
saptv.VideoSection.useHtml5Video = saptv.config.useHtml5Video;
saptv.VideoSection.vplayer = saptv.config.vplayer;
saptv.Client.main()
