embtv = (typeof embtv != "undefined" ? embtv : {'$':jQuery});
/** 
 * flashembed 0.31. Adobe Flash embedding script
 * 
 * http://flowplayer.org/tools/flash-embed.html
 *
 * Copyright (c) 2008 Tero Piirainen (tipiirai@gmail.com)
 *
 * Released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 * 
 * >> Basically you can do anything you want but leave this header as is <<
 *
 * version 0.01 - 03/11/2008 
 * version 0.31 - Tue Jul 22 2008 06:30:31 GMT+0200 (GMT+02:00)
 */
function flashembed(root,userParams,flashvars){function getHTML(){var html="";if(typeof flashvars=='function'){flashvars=flashvars();}if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){html='<embed type="application/x-shockwave-flash" ';if(params.id){extend(params,{name:params.id});}for(var key in params){if(params[key]!==null){html+=[key]+'="'+params[key]+'"\n\t';}}if(flashvars){html+='flashvars=\''+concatVars(flashvars)+'\'';}html+='/>';}else{html='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';html+='width="'+params.width+'" height="'+params.height+'"';if(!params.id&&document.all){params.id="_"+(""+Math.random()).substring(5);}if(params.id){html+=' id="'+params.id+'"';}html+='>';html+='\n\t<param name="movie" value="'+params.src+'" />';params.id=params.src=params.width=params.height=null;for(var k in params){if(params[k]!==null){html+='\n\t<param name="'+k+'" value="'+params[k]+'" />';}}if(flashvars){html+='\n\t<param name="flashvars" value=\''+concatVars(flashvars)+'\' />';}html+="</object>";if(debug){alert(html);}}return html;}function init(name){var timer=setInterval(function(){var doc=document;var el=doc.getElementById(name);if(el){flashembed(el,userParams,flashvars);clearInterval(timer);}else if(doc&&doc.getElementsByTagName&&doc.getElementById&&doc.body){clearInterval(timer);}},13);return true;}function extend(to,from){if(from){for(key in from){if(from.hasOwnProperty(key)){to[key]=from[key];}}}}var params={src:'#',width:'100%',height:'100%',version:null,onFail:null,expressInstall:null,debug:false,bgcolor:'#ffffff',allowfullscreen:true,allowscriptaccess:'always',quality:'high',type:'application/x-shockwave-flash',pluginspage:'http://www.adobe.com/go/getflashplayer'};if(typeof userParams=='string'){userParams={src:userParams};}extend(params,userParams);var version=flashembed.getVersion();var required=params.version;var express=params.expressInstall;var debug=params.debug;if(typeof root=='string'){var el=document.getElementById(root);if(el){root=el;}else{return init(root);}}if(!root){return;}if(!required||flashembed.isSupported(required)){params.onFail=params.version=params.expressInstall=params.debug=null;root.innerHTML=getHTML();return root.firstChild;}else if(params.onFail){var ret=params.onFail.call(params,flashembed.getVersion(),flashvars);if(ret){root.innerHTML=ret;}}else if(required&&express&&flashembed.isSupported([6,65])){extend(params,{src:express});flashvars={MMredirectURL:location.href,MMplayerType:'PlugIn',MMdoctitle:document.title};root.innerHTML=getHTML();}else{if(root.innerHTML.replace(/\s/g,'')!==''){}else{root.innerHTML="<h2>Flash version "+required+" or greater is required</h2>"+"<h3>"+(version[0]>0?"Your version is "+version:"You have no flash plugin installed")+"</h3>"+"<p>Download latest version from <a href='"+params.pluginspage+"'>here</a></p>";}}function concatVars(vars){var out="";for(var key in vars){if(vars[key]){out+=[key]+'='+asString(vars[key])+'&';}}return out.substring(0,out.length-1);}function asString(obj){switch(typeOf(obj)){case'string':return'"'+obj.replace(new RegExp('(["\\\\])','g'),'\\$1')+'"';case'array':return'['+map(obj,function(el){return asString(el);}).join(',')+']';case'function':return'"function()"';case'object':var str=[];for(var prop in obj){if(obj.hasOwnProperty(prop)){str.push('"'+prop+'":'+asString(obj[prop]));}}return'{'+str.join(',')+'}';}return String(obj).replace(/\s/g," ").replace(/\'/g,"\"");}function typeOf(obj){if(obj===null||obj===undefined){return false;}var type=typeof obj;return(type=='object'&&obj.push)?'array':type;}if(window.attachEvent){window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};});}function map(arr,func){var newArr=[];for(var i in arr){if(arr.hasOwnProperty(i)){newArr[i]=func(arr[i]);}}return newArr;}return root;}if(typeof jQuery=='function'){(function($){$.fn.extend({flashembed:function(params,flashvars){return this.each(function(){flashembed(this,params,flashvars);});}});})(jQuery);}flashembed=flashembed||{};flashembed.getVersion=function(){var version=[0,0];if(navigator.plugins&&typeof navigator.plugins["Shockwave Flash"]=="object"){var _d=navigator.plugins["Shockwave Flash"].description;if(typeof _d!="undefined"){_d=_d.replace(/^.*\s+(\S+\s+\S+$)/,"$1");var _m=parseInt(_d.replace(/^(.*)\..*$/,"$1"),10);var _r=/r/.test(_d)?parseInt(_d.replace(/^.*r(.*)$/,"$1"),10):0;version=[_m,_r];}}else if(window.ActiveXObject){try{var _a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{_a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");version=[6,0];_a.AllowScriptAccess="always";}catch(ee){if(version[0]==6){return;}}try{_a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(eee){}}if(typeof _a=="object"){_d=_a.GetVariable("$version");if(typeof _d!="undefined"){_d=_d.replace(/^\S+\s+(.*)$/,"$1").split(",");version=[parseInt(_d[0],10),parseInt(_d[2],10)];}}}return version;};flashembed.isSupported=function(version){var now=flashembed.getVersion();var ret=(now[0]>version[0])||(now[0]==version[0]&&now[1]>=version[1]);return ret;};/*
 * Metadata - jQuery plugin for parsing metadata from elements
 *
 * Copyright (c) 2006 John Resig, Yehuda Katz, J�örn Zaefferer, Paul McLanahan
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id: jquery.metadata.js 3620 2007-10-10 20:55:38Z pmclanahan $
 *
 */
(function($){$.extend({metadata:{defaults:{type:'class',name:'metadata',cre:/({.*})/,single:'metadata'},setType:function(type,name){this.defaults.type=type;this.defaults.name=name;},get:function(elem,opts){var settings=$.extend({},this.defaults,opts);if(!settings.single.length)settings.single='metadata';var data=$.data(elem,settings.single);if(data)return data;data="{}";if(settings.type=="class"){var m=settings.cre.exec(elem.className);if(m)data=m[1];}else if(settings.type=="elem"){if(!elem.getElementsByTagName)return;var e=elem.getElementsByTagName(settings.name);if(e.length)data=$.trim(e[0].innerHTML);}else if(elem.getAttribute!=undefined){var attr=elem.getAttribute(settings.name);if(attr)data=attr;}if(data.indexOf('{')<0)data="{"+data+"}";data=eval("("+data+")");$.data(elem,settings.single,data);return data;}}});$.fn.metadata=function(opts){return $.metadata.get(this[0],opts);};})(jQuery);var embtvStatUrl =  "http://video.kxly.com/inline/async_scripts/stat.php";
var embtvVideoTracker = null;

jQuery(function() {
	jQuery.getScript("http://www.google-analytics.com/ga.js", function() {
		embtvVideoTracker = _gat._getTracker("UA-1618154-23");
	});
});

function onPlay(clip){
	//cschams : 2008-12-19 : manual tracking using G/A and our internal database
	if (clip.type != "flv") return;
	jQuery.getJSON(embtvStatUrl+"?jsoncallback=?&mgid="+clip.id);
	if (! clip.controlEnabled ) {
		var ads = 'ads/';
	}else {
		var ads = '';
	}
	embtvVideoTracker._trackPageview('/video_stats/'+ads+'start/'+clip.id+'/'+clip.name);
}

	
function onPause(clip){
	//cschams : 2008-12-19 : manual tracking using G/A and our internal database
	if (clip.type != "flv") return;
	if (! clip.controlEnabled ) {
		var ads = 'ads/';
	}else {
		var ads = '';
	}
	embtvVideoTracker._trackPageview('/video_stats/'+ads+'pause/'+clip.id+'/'+clip.name);
}

function onResume(clip){
	//cschams : 2008-12-19 : manual tracking using G/A and our internal database
	if (clip.type != "flv") return;
        if (! clip.controlEnabled ) {
		var ads = 'ads/';
	}else {
		var ads = '';
	}
		embtvVideoTracker._trackPageview('/video_stats/'+ads+'resume/'+clip.id+'/'+clip.name);
}

function onClipDone(clip){
	//cschams : 2008-12-19 : manual tracking using G/A and our internal database
	if (clip.type != "flv") return;
	if (! clip.controlEnabled ) {
		var ads = 'ads/';
	}else {
		var ads = '';
	}
	embtvVideoTracker._trackPageview('/video_stats/'+ads+'finish/'+clip.id+'/'+clip.name);
}
(function($) {

	// Avoid re-declaring embtvVideo
	if ( $.fn.embtvVideo != undefined) return;

	$.fn.embtvVideo = function(options) {
		//Provides the embtvVideo object api if called for a single object.
		if (this.length == 1 && this.data('embtvVideo') != undefined) {
			return this.data('embtvVideo');
		}
		return this.each(function() {
			if ($(this).data('embtvVideo') == undefined) {
				new $.embtvVideo(this, options);
			}
		});
	};
	
	$.log = function (message) {
		if (window.console && console.log ) {
			console.log(message);
		}
	}
	
	//constructor
	$.embtvVideo = function(el, options) {
	
		this.canvas = $(el);
		
		// Prevent re-initializiation by checking for, then setting the embtvVideo property on the canvas. 
		if (this.canvas.data('embtvVideo') != undefined) return;
		this.canvas.data('embtvVideo', this);
		
		$.embtvVideo.instances.push(this);
		
		this.opts = $.extend({}, 
			$.embtvVideo.defaults,
			{playlist: $.embtvVideo.playlist.id, canvas: $.embtvVideo.canvas.id, info: $.embtvVideo.info.id, live: $.embtvVideo.live.id},
			$.embtvVideo.canvas, 
			{width: this.canvas.attr("width"), height: this.canvas.attr("height")},
			$.embtvVideo.info,
			$.embtvVideo.playlist,
			$.embtvVideo.live,
			options
		);

		this.opts = $.metadata ? $.extend({}, this.opts, this.canvas.metadata()) : this.opts;

		this.adCounter = 0;
		this.currentVideo = this.opts.mgid;
		this.currentCategory = this.opts.category;
		
		//if MGID is present, play video immediately. 
		if (this.opts.mgid && ! this.opts.autoLive) {
			if (typeof this.opts.mgid == "object") {
				this.playlistPage({data:{'mgid[]': this.opts.mgid}});
				this.playVideo(this.opts.mgid[0]);
			}else {
				this.playVideo(this.opts.mgid);
			}
		}		

		this.info = $(this.opts.info);
		this.list = $(this.opts.playlist);
		this.categories = $(this.opts.categoryListId);
		this.live = $(this.opts.live);
		
		
		if (this.opts.categoryList != null) {
			this.initCategoryList();
			if (! this.opts.category) this.opts.category = this.opts.categoryList[0];
		}
		if (this.opts.category) {
			this.playlistPage({data:{section: this.opts.category}});
		}
		if (this.opts.showSearch) {
			var self = this;
			if (this.opts.searchBarHtml) this.list.before($(this.opts.searchBarHtml));
			$(this.opts.searchFieldId).bind('focus', function() {
				if ($(this).attr('value') == self.opts.searchDefault) $(this).attr('value', '');
			}).bind('blur', function() {
				if ($(this).attr('value') == '') $(this).attr('value', self.opts.searchDefault);
			}).bind('keypress', function(event) {
				if (event.which != 13) return;
				$(this).trigger('submit_search');
			}).bind('submit_search', {"do": "search"}, function(event) {
				if ($(this).attr('value') == '' || $(this).attr('value') ==  self.opts.searchDefault) {
					if (typeof $.fn.dialog == "function") {
					    $('<div title="Search Failed">Please enter a search term.</div>').dialog({modal:true});
					}else {
					    alert("Please enter a search term.");
					}
					return;
				}
				event.data.search_text = $(this).attr('value');
				self.playlistPage(event);
			});
			$(this.opts.searchButtonId).bind('click', function(event) {
				$(self.opts.searchFieldId).trigger('submit_search');
			});
		}
		if (this.opts.live) {
			this.getLive();
		}

	};
	
	$.embtvVideo.instances = [];
	
	$.embtvVideo.defaults = {
		player_url: 'http://video.kxly.com/inline/',
		flash_url: 'http://s3.data.spokanetogo.com/miniplayer/FlowPlayerLight.swf',
		config_file: 'async_scripts/config_cache.php',
		info_file: 'async_scripts/video_info_cache.php',
		playlist_file: 'async_scripts/video_list_new.php',
		categorylist_file: 'async_scripts/category_list_cache.php',
		live_file: 'async_scripts/live.php',
		live_iframe: 'async_scripts/live_iframe.php',
		store_url: 'http://video.kxly.com/store/cart.php?add=true&id=',
		playlist: null, //DOM ojbect\string selector
		video_list: null,
		info: null, //DOM object\string selector
		live: null, //DOM object\string selector
		canvas: null, //DOM object\string selector 
		title: null, //DOM object\string selector
		category_callback: null, //function
		list_callback: null, //function
		info_callback: null, //function
		live_callback: null, //function
		live_click_callback: null //function
	};
	
	$.embtvVideo.canvas = {
		mgid: null, //integer
		width: 298, //integer
		height: 250, //integer
		liveWidth: 650,
		liveHeight: 440,
		hideControls: false, //bool
		showScrubber: true, //integer
		showStopButton: false, //integer
		showPlayButton: true, //integer
		showVolumeSlider: true, //integer
		noAuto: true, //integer
		adCount: 1, //integer - Number of clips between ads, 0 to disable ads. 
		controlBarGloss: 'none', //string 'none', 'high'
		controlBarBackgroundColor: '0x3A5B7E'
	};
	
	$.embtvVideo.playlist = {
		id: null, //jQuery selector
		categoryListId: null,
		category: null, //integer
		categoryList: null, //array of integers
		categoryListItemHtml: '<li />',
		thumbnailHtml: '<img style="float:left" />', //HTML markup
		thumbnailHeight: 54, //integer
		thumbnailWidth: 94, //integer
		teaserHtml: '<p class="summary" />', //HTML markup
		itemHtml: '<div class="video" />', //HTML markup
		itemPostHtml: '<div style="clear:both" />', //HTML markup
		itemsPerPage: 5, //integer
		itemTitleHtml: '<b/>', //HTML markup
		playlistTitleHtml: '<p class="title" />', //HTML markup
		navHtml: '<div class="nav">', //HTML markup
		navControlHtml: '<span style="color:#0000FF;cursor:pointer;font-weight:800" />',
		navPrevHtml: '&laquo; Prev ',
		navNextHtml: ' Next &raquo;',
		searchBarHtml: '<div><input type="text" id="embtvVideoSearch" Value="Search Videos..." /><button type="button" id="embtvVideoSearchButton" />Search</div>',
		searchDefault: 'Search Videos...',
		showSearch: false, //bool		
		searchFieldId: "#embtvVideoSearch",
		searchButtonId: "#embtvVideoSearchButton"
	};
	
	$.embtvVideo.live = {
		id: null, //jQuery selector
		liveItemHtml: '<div class="video" />',
		liveItemTitleHtml: '<b/>',
		liveItemTeaserHtml: '<p class="summary" />', 
		autoLive: false
	};		

	$.embtvVideo.info = {
		id: null, //jQuery selector
		titleHtml: '<p class="title" />', //HTML markup
		summaryHtml: '<p class="summary" />', //HTML markup
		dateHtml: '<p class="date" />', //HTML markup
		storeHtml: '<a target="blank"></a>', //HTML markup
		storeMessage: 'Purchase this video for 99&cent;' //String
	};
		
	// Create shortcut for internal use
	var $embtv = $.embtvVideo;
	
	$embtv.fn = $embtv.prototype = {
		embtvVideo: '0.9.10'
	};

	$embtv.fn.extend = $embtv.extend = $.extend;

	$embtv.fn.extend({
	
		playVideo: function(mgid, o) {
                    if (o == undefined) o = {};		
		    var opts = $.extend({}, this.opts, o);
		    var ad = '&noad=true';
		    if (opts.adCount) {
			if (this.adCounter == 0) {
			    ad='';
			}
			this.adCounter++;
			if (this.adCounter == opts.adCount) this.adCounter = 0;
		    }
		    var config_uri = encodeURIComponent(opts.player_url
							+opts.config_file
							+'?noauto='+(opts.noAuto ? "true" : "")
							+'&id='+mgid
							+'&cat_id='+this.currentCategory
							+ad
							+'&nocache='+Math.ceil(Math.random()*1000));
	            this.api = flashembed(this.canvas[0], {
                        src: /* opts.player_url+ */opts.flash_url,
                        width:opts.width,
                        height:opts.height,
			wmode: 'transparent'
                    },
                    {config:{
                        configFileName: config_uri,
                        initialScale: "fit",
			hideControls: opts.hideControls,
			showScrubber: opts.showScrubber,
			showStopButton: opts.showStopButton,
			showPlayButton: opts.showPlayButton,
			showVolumeSlider: opts.showVolumeSlider,
			controlBarGloss: opts.controlBarGloss,
			controlBarBackgroundColor: opts.controlBarBackgroundColor,
			menuItems: [0, 1, 1, 0, 1, 1, 0]
                    }});
		    if (this.opts.info) this.videoInfo(mgid);
		    this.currentVideo = mgid;
		},
		
		playWMV: function(clip) {
			var url = clip.baseUrl + '/' + clip.fileName;
			var s = this.opts.player_url + this.opts.live_iframe + '?media=' + url + "&w=" + this.opts.width + "&h=" + this.opts.height;
			var player = $('<iframe src="'+s+'" frameborder="0" width="'+this.opts.width+'" height="'+this.opts.height+'" scrolling="no"></iframe>');
			this.api = null;
			this.canvas.empty();
			this.canvas.append(player);
		},
		
		videoInfo: function(mgid) {
		    var self = this;
		    $.getJSON(this.opts.player_url + this.opts.info_file + '?jsoncallback=?',{"id": mgid}, function(data){
		        self.info.empty()
			if (self.opts.titleHtml) self.info.append($(self.opts.titleHtml).html(data.title));
			if (self.opts.dateHtml) self.info.append($(self.opts.dateHtml).html(data.date));
			if (self.opts.imgHtml && info.thumb) self.info.append($(self.info.imgHtml).atr("src", info.thumb));
			if (self.opts.summaryHtml) self.info.append($(self.opts.summaryHtml).html(data.description));
			if (data.sell == 'y' && self.opts.storeHtml && self.opts.storeMessage) {
			     self.info.append(
				$(self.opts.storeHtml)
				    .attr('href',self.opts.store_url+String(mgid))
				    .html(self.opts.storeMessage)
			    );
			}
			if (self.opts.info_callback != null) {
				self.opts.info_callback(self);
			}
		    });
		},
		
		initCategoryList: function() {
			var self = this;
			var data = {"cat_id[]": this.opts.categoryList}
			$.getJSON(this.opts.player_url+this.opts.categorylist_file+'?jsoncallback=?', data, function(data) {
				$.each(data, function(i) {
					self.categories.append(
					    $(self.opts.categoryListItemHtml)
						.html(data[i].title)
						.bind("click", {section: data[i].cat_id, page: 1}, function(event){ self.playlistPage(event);})
					)
				});
				if (self.opts.category_callback != null) {
					self.opts.category_callback(self);
				}
			});
		},
		
		getLive: function() {
			var self = this;
			$.getJSON(this.opts.player_url+this.opts.live_file+'?jsoncallback=?', function(data) {
				if (data && data.length) {
					self.liveVideoList = data;
					$.each(data, function(l) {
						var i = $(self.opts.liveItemHtml);
						i.attr('live', data[l].link).attr('title', data[l].title).attr('description', data[l].description);
						if (self.opts.liveItemTitleHtml && data[l].title) i.append($(self.opts.liveItemTitleHtml).text(data[l].title));
						if (self.opts.liveItemTeaserHtml && data[l].description) i.append($(self.opts.liveItemTeaserHtml).text(data[l].description));
						i.bind('click', function() { self.playLive($(this).attr('live'), $(this).attr('title'), $(this).attr('description')); });
						i.css("cursor", "pointer");
						i.appendTo(self.live);
					});
					if ( self.opts.autoLive ) self.playLive(data[0].link, data[0].title, data[0].description);
				} else {
					if (self.opts.mgid && self.opts.autoLive) self.playVideo(self.opts.mgid);
				}
				if (self.opts.live_callback != null) {
					self.opts.live_callback(self);
				}
			});
		},

		playLive: function(link, title, description) {
		
		    opts = this.opts;
		
		    if (typeof(link) == "string" && link.substr(0,7) == "http://") {
			window.location.href= link;
			return;
		    }		
		
	            this.api = flashembed(this.canvas[0], {
                        src: /* opts.player_url+ */opts.flash_url,
                        width:opts.width,
                        height:opts.height,
			wmode: 'transparent'
                    },
                    {config:{
                        
			streamingServerURL: "rtmp://atl.fla.abacast.com/kxlytv",
			videoFile: link,
			streamingServer: "fms",
			live: true,
			name: 'live',
            initialScale: "fit",
			hideControls: opts.hideControls,
			showScrubber: opts.showScrubber,
			showStopButton: opts.showStopButton,
			showPlayButton: opts.showPlayButton,
			showVolumeSlider: opts.showVolumeSlider,
			controlBarGloss: opts.controlBarGloss,
			controlBarBackgroundColor: opts.controlBarBackgroundColor,
			menuItems: [0, 1, 1, 0, 1, 1, 0]
                    }});
		    
		    this.info.empty();
		    if (this.opts.titleHtml) this.info.append($(this.opts.titleHtml).html(title));
		    if (this.opts.summaryHtml) this.info.append($(this.opts.summaryHtml).html(description));
		    if (this.opts.live_click_callback != null) {
			this.opts.live_click_callback(this);
		    }
		},
		
		playlistPage: function(event) {
		    var self = this;
		    var data = $.extend({page: 1, per_page: this.opts.itemsPerPage}, event.data);
		    if (event.data.section) {
			this.currentCategory = event.data.section;
		    }else {
			this.currentCategory = null;
		    }
		    $.getJSON(this.opts.player_url+this.opts.playlist_file+'?jsoncallback=?', data, function(data) { self.loadPlaylist(data); } );
		},

		loadPlaylist: function(data) {
		    var self = this;
		    if ( ! this.opts.playlist )  return;
		    if (data.count > 0) {
			if (! this.opts.mgid) {
				this.opts.mgid=data.playlist[0].vfile;
				if (! this.opts.autoLive) this.playVideo(this.opts.mgid);
			}
			this.list.empty();
			if (this.opts.playlistTitleHtml) this.list.append($(this.opts.playlistTitleHtml).html(data.title));
			if (this.opts.navHtml && data.num_pages > 1) {
			    var nav = $(this.opts.navHtml).append('<span style="float:left">Page '+data.page+' of '+data.num_pages+'</span>');
			    var navRight = $('<span style="float:right" />');
			    if (data.prev) navRight.append(
				$(self.opts.navControlHtml)
				    .html(self.opts.navPrevHtml)
				    .bind('click', data.prev, function(event) { self.playlistPage(event) } )
			    );
			    if (data.next) navRight.append(
				$(self.opts.navControlHtml)
				    .html(self.opts.navNextHtml)
				    .bind('click', data.next, function(event) { self.playlistPage(event) } )
			    );
			    nav.append(navRight).append('<div style="clear:both"/>').appendTo(this.list);
			}
			$.each(data.playlist, function(index, item) { 
			    var i = $(self.opts.itemHtml).css("cursor", "pointer").attr("id", "embtv-video-"+item.vfile);
			    if (self.opts.itemTitleHtml) i.append($(self.opts.itemTitleHtml).html(item.title));
			    if (self.opts.thumbnailHtml) {
				thumb = $(self.opts.thumbnailHtml).attr("src", item.thumb_url).attr("title", item.title);
				if (self.opts.thumbnailWidth) thumb.attr("width", self.opts.thumbnailWidth);
				if (self.opts.thumbnailHeight) thumb.attr("height", self.opts.thumbnailHeight);
				i.append(thumb);
			    }
			    if (self.opts.teaserHtml) i.append($(self.opts.teaserHtml).html(item.teaser));
			    if (self.opts.itemPostHtml) i.append($(self.opts.itemPostHtml));
			    i.bind("click", function(event) {
				    event.preventDefault(); 
				    self.playVideo(item.vfile, {noAuto:""});
				}).appendTo(self.list);
			});
		    } else if ( data.title ){
			this.list.empty();
			if (typeof $.fn.dialog == "function") {
				$('<div title="No Videos Found">'+data.title+'</div>').dialog({modal: true});
			}else {
				alert(data.title);
			}
		    }	
		    if (self.opts.list_callback != null) {
			self.opts.list_callback(self);
		    }
		}
	});
	var oldOnPlay = window.onPlay;
	window.onPlay = function(clip) {
		if (typeof oldOnPlay == "function") {
			oldOnPlay(clip);
		}
		clip_pieces = clip.fileName.split('.');
		type = clip_pieces[clip_pieces.length -1];
		if (type != "wmv") return;
		var inst = embtv.$.embtvVideo.instances;
		for (var i=0; i < inst.length; i++) {
			if (inst[i].currentVideo == clip.id) {
				inst[i].playWMV(clip);
			}
		}
	}
	
	
})(embtv.$); 
