if (!Function.prototype.bindAsEventListener) {
	Function.prototype.bindAsEventListener = function() {
		var __method = this, args = $A(arguments), object = args.shift();
		return function(event) {
			return __method.apply(object, [event || window.event].concat(args));
		}
	}
}
var $A = Array.from = function(iterable) {
	if (!iterable) return [];
	if (iterable.toArray) {
		return iterable.toArray();
	} else {
		var results = [];
		for (var i = 0; i < iterable.length; i++)
			results.push(iterable[i]);
		return results;
	}
}
if (!Math.customRound) {
	Math.customRound = function (number, digits) {
		if (arguments.length == 1) var digits = 2;
		var d = Math.pow(10, digits);
		return parseInt(number * d) / d;
	}
}
if (typeof(IDTVHZP) == "undefined") {
	IDTVHZP = function () {this.initialize.apply(this, arguments);};
	IDTVHZP.prototype = {
		frame: null,
		initialize: function (ds) {
			this.ds = ds;
			this.element = document.getElementById('IDTVP_' + this.ds.id);
			if (!this.element && document.getElementsByClassName)
				try {
					this.element = document.getElementsByClassName ('idtv_ada05cca7b')[0];
				} catch(e) {}
			if (!this.element) { alert ('The iDesktop.tv horizontal box is not not embedded properly!'); return;}
			this.element.innerHTML = '<div class="idtv_' + this.ds.id + '"><div class="idtv_bp"></div><div class="idtv_outres"><div class="idtv_inres"></div></div><div class="idtv_bn"></div></div>';
			var es = this.element.getElementsByTagName('div');
			this.elementout = es[0];
			this.btnprev = es[1]; this.btnnext = es[4];
			this.elementout = es[2];
			this.elementin = es[3];
			if (this.ds.data.error) {
				this.elementin.innerHTML = '<div style="text-align:center">' + this.ds.data.error + '</div>';
			} else {
				this.results = new Array();
				if (this.ds.only_public) { // go trough ds.data.results and remove all private videos
					var newdata = new Array();
					for (var i = 0; i < this.ds.data.results.length; i ++)
						if (!this.ds.data.results[i].isprivate)
							newdata.push(this.ds.data.results[i]);
					this.ds.data.results = newdata;
				}
				var jsonArr = this.ds.data.results;
				this.page = 0; this.resc = jsonArr.length;
				this.maxpage = Math.ceil(this.resc/this.ds.pp);
				for (var i = 0, n = this.resc; i < n; i ++) {
					var nr = document.createElement('div');
					nr.className = 'idtv_res';
					//nr.style.left = i * (this.ds.width - 40) + "px";
					jsonArr[i].title_esc = (jsonArr[i].title ? jsonArr[i].title.replace(/"/g, "&quot;") : '');// ";
					var title = jsonArr[i].title_esc + (this.ds.thumb_show_length && jsonArr[i].length_seconds ?' (' + jsonArr[i].length_seconds + ')':'');
					var t = '<img src="' + jsonArr[i].thumbnail_url + '" alt="' + jsonArr[i].title_esc + '" title="' + title + '" />';
					if (this.ds.thumb_show_title || this.ds.thumb_show_author || this.ds.thumb_show_length || this.ds.thumb_show_rating || this.ds.thumb_show_description) {
						var at = '';
						if (this.ds.thumb_show_title)
							//at = '<a href="http://www.idesktop.tv/?watch=' + jsonArr[i].id + '" title="' + jsonArr[i].title + '" target="_blank">' + jsonArr[i].title + "</a>";
							at = '<span class="t">' + (jsonArr[i].title ? jsonArr[i].title : '') + "</span>";
						if (this.ds.thumb_show_author) {
							at += '<span class="ah">' + (this.ds.thumb_show_labels?'<span class="lb">Author: </span>':'') + (jsonArr[i].author ? jsonArr[i].author : '') + '</span>';
						}
						if (this.ds.thumb_show_length || this.ds.thumb_show_views) {
							at += '<span class="lv">';
							if (this.ds.thumb_show_length) at += (this.ds.thumb_show_labels?'<span class="lb">Length: </span>':'') +(jsonArr[i].length_seconds ? jsonArr[i].length_seconds : '');
							if (this.ds.thumb_show_length && this.ds.thumb_show_views) at += ' | ';
							if (this.ds.thumb_show_views) at += (this.ds.thumb_show_labels?'<span class="lb">Views: </span>':'') + (jsonArr[i].view_count ? this.formatCommasInt(jsonArr[i].view_count) : '');
							at += '</span>';
						}
						if (this.ds.thumb_show_rating)
							at += '<span class="r">' + (this.ds.thumb_show_labels?'<span class="lb">Rating: </span>':'') + (jsonArr[i].rating_avg ? Math.customRound(jsonArr[i].rating_avg, 1) : '') + "</span>";
						if (this.ds.thumb_show_description) {
							at += '<span class="d">' + (jsonArr[i].description ? jsonArr[i].description : '') + "</span>";
						}
						t = t + '<div class="out" title="' + title + '"><div class="in">' + at + '</div></div>';
					}
					nr.innerHTML += t;
					if (this.ds.mark_private && jsonArr[i].isprivate)
						nr.innerHTML += '<div class="private_mark">PRIVATE</div>';
					this.elementin.appendChild(nr);
					this.results.push(nr);
					nr.onclick = this.onresclick.bindAsEventListener(this, i);
					nr.style.display = 'none';
				}
				this.elementin.style.width = this.results.length * (this.ds.width - 40) + "px";
				this.btnprev.onclick = this.prevP.bindAsEventListener(this);
				this.btnnext.onclick = this.nextP.bindAsEventListener(this);
				if (this.results.length > 0)
					this.results[0].style.display = 'block';
			}
			var f = document.createElement('iframe');
			f.src = "http://www.idesktop.tv/embed/ada05cca7b/utr.html?r=" + document.location;
			f.style.cssText = 'width:0;height:0;border:none;';
			f.frameborder = f.frameBorder = f.border = "0";
			this.element.appendChild(f);

		},
		onresclick: function (event,i) {
			var elem = event.target || event.srcElement;
			if (elem.tagName == 'A') return;
			if (this.ds.plpl == "newwin") {
				var loaded = false;
				if (this.frw) {
					try {
						this.frw.Player.playlist.selectItem(i);
						this.frw.Player.playlist.playSelected();
						loaded = true;
					} catch(e) {
						loaded = false;
					}
				}
				if (!loaded)
					this.frw = window.open ('http://'+this.ds.chost+'/embed/'+this.ds.id+'/play.html?vid='+this.ds.data.results[i].id, 'idtvwin', 'width=' + this.ds.plw + ',height=' + this.ds.plh + 'toolbar=no,status=no,scrollbars=no,resize=no');
				return;
			}
			if (!this.frame) {
				this.plclbtn = document.createElement('img');
				this.plclbtn.src = this.ds.clbtnsrc;
				this.plclbtn.onclick = this.closeplr.bindAsEventListener(this);
				this.plclbtn.className = 'idtvp_clbtn';
				this.frameholder = document.createElement('div');
				this.frameholder.id = 'idtvpfh' + this.ds.id;
				this.frame = document.createElement('iframe');
				this.frame.id = 'idtvpf' + this.ds.id;
				this.frame.frameborder = this.frame.frameBorder = this.frame.border = "0";
				try {
					document.body.appendChild(this.frameholder);
					this.ba = true;
				} catch (e) {
					this.elementout.appendChild(this.frameholder);
					this.ba = false;
				}
				this.frameholder.appendChild(this.plclbtn);

			}
			/*this.frameholder.style.top = this.results[i].offsetTop + "px";
			this.frameholder.style.left = this.results[i].offsetLeft + this.results[i].offsetWidth + "px";*/
			var scrlX = (window.pageXOffset || document.body.scrollLeft || document.documentElement.scrollLeft);
		    var scrlY = (window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop);
		    var viewportW = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth ;
		    var viewportH = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
		    var element = this.elementout;
			var elFixedX = 0, elFixedY = 0;
		    do {
		    	elFixedY += element.offsetTop  || 0; elFixedX += element.offsetLeft || 0; element = element.offsetParent || element.parentNode;
		    } while (element);
		    var nx = 0, ny =0;
			switch (this.ds.plpl) {
				case "center":
					nx = scrlX + ((viewportW - this.ds.plw) / 2) - elFixedX;
					ny = scrlY + ((viewportH - this.ds.plh) / 2) - elFixedY;
					break;
				case "left":
					nx = this.results[i].offsetLeft - this.ds.plw;
					ny = this.results[i].offsetTop - this.ds.pldelta;
					break;
				case "right":
					nx = this.results[i].offsetLeft + this.results[i].offsetWidth;
					ny = this.results[i].offsetTop - this.ds.pldelta;
					break;
				case "top":
					nx = this.results[i].offsetLeft - this.ds.pldelta;
					ny = this.results[i].offsetTop - this.ds.plh;
					break;
				case "bottom":
					nx = this.results[i].offsetLeft - this.ds.pldelta;
					ny = this.results[i].offsetTop + this.results[i].offsetHeight;
					break;
				default: return;
			}
			if (this.ba) {
				nx += elFixedX; ny += elFixedY;
				if (nx < 0) nx = 0;
				if (ny < 0) ny = 0;
			} else {
				if (this.ds.plpl != "center") { // some checks if top/left it is out of the viewport
					var rx = nx + elFixedX, ry = ny + elFixedY;
					if (rx < 0) nx -= rx;
					if (ry < 0) ny -= ry;
				}
			}
			this.frameholder.style.left = nx + "px";
			this.frameholder.style.top = ny + "px";

			this.frameholder.style.display = 'block';
			var loaded = false;
			try {
				if (this.frame.contentWindow && this.frame.contentWindow.Player) { // detect if script access is allowed
					this.frame.contentWindow.Player.playlist.selectItem(i);
					this.frame.contentWindow.Player.playlist.playSelected();
					loaded = true;
				}
			} catch (e) {};
			if (!loaded) {
				if (this.frame.parentNode == this.frameholder) this.frameholder.removeChild(this.frame);
				this.frame.src = 'http://'+this.ds.chost+'/embed/'+this.ds.id+'/play.html?vid='+(this.ds.data.results[i].id?this.ds.data.results[i].id:i);
				this.frameholder.appendChild(this.frame);
			}
		},
		closeplr: function (event) { this.frameholder.style.display='none'; this.frameholder.removeChild(this.frame); },
		showRes: function () {
			/*var s = this.page * this.ds.pp, e = Math.min (s + this.ds.pp, this.results.length) - 1;
			s = Math.max (e - this.ds.pp, 0);
			this.elementout.scrollLeft = s * (this.ds.width - 40);*/

		},
		nextP: function () {/*this.elementout.scrollLeft = Math.min(this.elementout.scrollLeft + this.elementout.offsetWidth, this.elementout.scrollWidth - this.elementout.offsetWidth);*/
			if (this.page < this.maxpage - 1) {
				this.results[this.page].style.display='none';
				this.page ++;// this.showRes();
				this.results[this.page].style.display='';
			}
		},
		prevP: function () {/*this.elementout.scrollLeft = Math.max(this.elementout.scrollLeft - this.elementout.offsetWidth, 0);*/
			if (this.page > 0) {
				this.results[this.page].style.display='none';
				this.page --; //this.showRes();
				this.results[this.page].style.display='';
			}
		},
		formatCommasInt: function (val) {
			var s = new String(val);
			var rgx = /(\d+)(\d{3})/;
			while (rgx.test(s)) s = s.replace(rgx, '$1' + ',' + '$2');
			return s;
		}
	}
}

var IDTVLBDataSourceada05cca7b = {
	id: 'ada05cca7b', chost:'www.idesktop.tv',clbtnsrc:'http://www.idesktop.tv/images/player_icons/close.gif',
	width: 270, height: 102, pp: 1,
	rows: 1, cols: 1,
	plw: 500, plh: 420,
	createP: function () {
		if (this.reverse_playlist) this.data.results = this.data.results.reverse();
		this.p = new IDTVHZP(this);
	},
	plpl: 'newwin',
	only_public:true,mark_private:true,
	thumb_show_title : true, thumb_show_author : false,
	thumb_show_rating : false, thumb_show_views: true,
	thumb_show_length : true, thumb_show_description : false,
	thumb_show_labels : true,
	thumbnail_text: 'R',
	reverse_playlist: false,
	pldelta: 0,
		data: {results: [{id:'BGWE3hwJ21U',title:'Taylor Swift- You Belong with me official music video',author:'Kristi123123',real_length:'228',length_seconds:'03:48',rating_avg:'4.9',rating_count:'19533',view_count:'6193296',description:'All credit goes to Taylor Swift and Big machine Records!! watch a better quality video at www.cmt.com I love this video!!!!',tags:'You, Belong, with, me, official, music, video',thumbnail_url:'http://img.youtube.com/vi/BGWE3hwJ21U/default.jpg',upload_time:'1241505175',comment_count:'0',url:'http://gdata.youtube.com/feeds/api/videos/BGWE3hwJ21U/responses?v=2',ord:'0',isprivate:'',t:'v'},{id:'P4E4rqpC9ME',title:'Afterlife Music Video',author:'jake2matt',real_length:'515',length_seconds:'08:35',rating_avg:'4.9',rating_count:'1066',view_count:'104017',description:'Ghost Hunters investigates a haunted location in Huntington Beach, California. They set out to investigate hoping to catch evidence of paranormal activity, but they end up getting more than they bargained for. \u0022Afterlife\u0022 is a song by Avenged Sevenfold',tags:'jake2matt, afterlife, music, video, avenged, sevenfold, scott, matt, josh, lewandowski, croll, betts, ghost, hunters, taps',thumbnail_url:'http://img.youtube.com/vi/P4E4rqpC9ME/default.jpg',upload_time:'1205180597',comment_count:'0',url:'http://gdata.youtube.com/feeds/api/videos/P4E4rqpC9ME/responses?v=2',ord:'10',isprivate:'',t:'v'},{id:'-MHtgrEeHt4',title:'Cherish - Ai Otsuka [MUSIC VIDEO]',author:'nellie7444',real_length:'295',length_seconds:'04:55',rating_avg:'4.9',rating_count:'803',view_count:'63575',description:'DISCLAIMER: I DO NOT OWN THIS VIDEO. ALL RIGHTS AND CLAIMS AND THIS VIDEO BELONGS TO Avex Entertainment, Inc.! ONCE AGAIN, THIS IS A VIDEO UPLOADED BY A FAN, NOTHING MORE! I DO NOT OWN THIS!',tags:'cherish, ai, otsuka, pv, mv, music, video',thumbnail_url:'http://img.youtube.com/vi/-MHtgrEeHt4/default.jpg',upload_time:'1239222459',comment_count:'0',url:'http://gdata.youtube.com/feeds/api/videos/-MHtgrEeHt4/responses?v=2',ord:'31',isprivate:'',t:'v'},{id:'elTIpkZsM-E',title:'Linkin Park - New Divide (Official Music Video)   Lyrics',author:'libertycitystories',real_length:'279',length_seconds:'04:39',rating_avg:'4.9',rating_count:'2516',view_count:'336118',description:'The official music video for New Divide, filmed on the set of Transformers: Revenge of the Fallen, directed by Joe Hahn. Get the song at iTunes now. ax.itunes.apple.com The soundtrack from the film is in stores 6/23 New Divide by Linkin Park Linkin Park - linkinpark.com Lyrics are \'annotations\', so annotations need to be turned on (which also allows people to turn the lyrics off as well) I AM NOT PROFITING FROM UPLOADING THIS VIDEO TO YOUTUBE, THIS IS PROMOTING LINKIN PARK AND THE MOVIE ...',tags:'Linkin, Park, New, Divide, Transformers, Revenge, of, the, Fallen, Official, Music, Video, Lyrics, linkinpark, film, theme, song, directed, by, Joe, Hahn, itunes, megan, fox, Bumblebee, Optimus, Prime, Megatron, Autobots, Decepticons, robots',thumbnail_url:'http://img.youtube.com/vi/elTIpkZsM-E/default.jpg',upload_time:'1244792442',comment_count:'0',url:'http://gdata.youtube.com/feeds/api/videos/elTIpkZsM-E/responses?v=2',ord:'33',isprivate:'',t:'v'},{id:'CAME8GDRTfI',title:'Coldplay - \'Yellow\' music video',author:'parlophone',real_length:'278',length_seconds:'04:38',rating_avg:'4.9',rating_count:'1771',view_count:'988677',description:'Coldplay - \'Yellow\' music video',tags:'Coldplay, Yellow, music, video',thumbnail_url:'http://img.youtube.com/vi/CAME8GDRTfI/default.jpg',upload_time:'1193150280',comment_count:'0',url:'http://gdata.youtube.com/feeds/api/videos/CAME8GDRTfI/responses?v=2',ord:'8',isprivate:'',t:'v'},{id:'5aLpfHxEqj0',title:'Leona Lewis - Summertime',author:'LeonaRulez',real_length:'387',length_seconds:'06:27',rating_avg:'4.87',rating_count:'1026',view_count:'613452',description:'Intro included, Also trying to make the sound less compressed.  week 3. This was the week when Leona really did start to shine, before hand she was good..but with week 3 onwards, she became amazing..This performace changed everything. She stepped up her game when it came to singing and performance. She became the favorite to win and remained favorite for the rest of the competition, with great performance after great performance.',tags:'Leona, Lewis',thumbnail_url:'http://img.youtube.com/vi/5aLpfHxEqj0/2.jpg',upload_time:'1176238429',comment_count:'0',url:'http://gdata.youtube.com/feeds/api/videos/5aLpfHxEqj0/responses',ord:'18',mid:'30544'},{id:'G8ytM0rl_uU',title:'Britney Spears - Circus',author:'BritneyTV',real_length:'281',length_seconds:'04:41',rating_avg:'4.7',rating_count:'1479',view_count:'1016775',description:'Britney Spears Circus from the album Circus (C) 2008 Zomba Recording LLC',tags:'Britney, Spears, Circus',thumbnail_url:'http://img.youtube.com/vi/G8ytM0rl_uU/default.jpg',upload_time:'1243459920',comment_count:'0',url:'http://gdata.youtube.com/feeds/api/videos/G8ytM0rl_uU/responses?v=2',ord:'22',isprivate:'',t:'v'},{id:'l4-PDLz3tdI',title:'Sometimes - Britney Spears',author:'fsa369',real_length:'245',length_seconds:'04:05',rating_avg:'4.8',rating_count:'437',view_count:'309435',description:'Sometimes - Britney Spears',tags:'sometimes, britney, spears',thumbnail_url:'http://img.youtube.com/vi/l4-PDLz3tdI/default.jpg',upload_time:'1223649320',comment_count:'0',url:'http://gdata.youtube.com/feeds/api/videos/l4-PDLz3tdI/responses?v=2',ord:'12',isprivate:'',t:'v'}]},
		initialize: function () {this.createP()}

};
var IDTVLBDataSourceada05cca7bIF = function () {IDTVLBDataSourceada05cca7b.initialize.apply(IDTVLBDataSourceada05cca7b, []);};
if (document.getElementById('IDTVP_ada05cca7b'))
	IDTVLBDataSourceada05cca7bIF ();
else if (window.addEventListener)
	window.addEventListener("load", IDTVLBDataSourceada05cca7bIF, true);
else
	window.attachEvent("onload", IDTVLBDataSourceada05cca7bIF);
