if (!Function.prototype.bindAsEventListener) {
	Function.prototype.bindAsEventListener = function() {
		var __method=this,args=arguments,object=args[0];
		return function(event) {var a = args;a[0]=(event || window.event);return __method.apply(object,a);}
	}
}
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(IDTVVWP) == "undefined") {
	IDTVVWP = function () {this.initialize.apply(this, arguments);};
	IDTVVWP.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_6519f1ae66')[0];
				} catch(e) {}
			if (!this.element) { alert ('The iDesktop.tv video wall is not not embedded properly!'); return;}
			this.element.innerHTML = '<div class="idtv_' + this.ds.id + '"><div class="idtv_inres"></div><div class="idtv_bb">' +
				'<div class="idtv_btn_prev"></div><div class="idtv_btn_next"></div><div class="idtv_bb_pages"></div></div></div>';
			var divs = this.element.getElementsByTagName('div');
			this.elementout = divs[0];
			this.elementin = divs[1];
			this.btn_prev = divs[3];
			this.btn_next = divs[4];
			this.pagers_area = divs[5];
			if (this.ds.data.error) {
				this.elementin.innerHTML = '<div style="text-align:center">' + this.ds.data.error + '</div>';
			} else {
				this.btn_prev.onclick = this.prevP.bindAsEventListener(this);
				this.btn_next.onclick = this.nextP.bindAsEventListener(this);
				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;
				}
				this.results = new Array();
				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 ++) {
					if (this.ds.only_public && jsonArr[i].isprivate) continue;
					var nr = document.createElement('div');
					nr.className = 'idtv_res';
					if ((i % this.ds.cols + Math.floor(i / this.ds.cols)) % 2) nr.className += ' alt';
					jsonArr[i].title_esc = jsonArr[i].title.replace(/"/g, "&quot;");// ";
					var title = jsonArr[i].title_esc + (this.ds.thumb_show_length?' (' + 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 + "</span>";
						if (this.ds.thumb_show_author) {
							at += '<span class="ah">' + (this.ds.thumb_show_labels?'<span class="lb">Author: </span>':'') + 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;
							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>':'') + 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>':'') + Math.customRound(jsonArr[i].rating_avg, 1) + "</span>";
						if (this.ds.thumb_show_description) {
							at += '<span class="d">' + jsonArr[i].description + "</span>";
						}
						t = t + '<div class="out" title="' + title + '"><div class="in">' + at + '</div></div>';
					}
					if (this.ds.mark_private && jsonArr[i].isprivate)
						nr.innerHTML += '<div class="private_mark">PRIVATE</div>';
					nr.innerHTML += t;
					this.elementin.appendChild(nr);
					nr.style.display = 'none';
					this.results.push(nr);
					nr.onclick = this.onresclick.bindAsEventListener(this, i);
				}
				this.showRes();
			}
			var f = document.createElement('iframe');
			f.src = "http://www.idesktop.tv/embed/6519f1ae66/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);
				}
				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.frameholder.appendChild(this.frame);
			}
		},
		closeplr: function (event) { this.frameholder.style.display='none'; this.frameholder.removeChild(this.frame); },
		showRes: function () {
			if (this.results.length == 0)
				this.pagers_area.innerHTML = 'no results';
			else {
				var s = this.page * this.ds.pp, e = Math.min (s + this.ds.pp, this.results.length) - 1;
				for (var i = 0, n = this.results.length; i < n; i ++)
					this.results[i].style.display =  (i < s || i > e ? 'none' : 'block');
				this.pagers_area.innerHTML = (s+1) + ' - ' + (e+1) + ' (' + this.results.length + ')';
			}
		},
		nextP: function () { if (this.page < this.maxpage - 1) { this.page ++; this.showRes(); } },
		prevP: function () { if (this.page > 0) { this.page --; this.showRes(); } },
		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 IDTVLBDataSource6519f1ae66 = {
	id: '6519f1ae66', chost:'www.idesktop.tv',clbtnsrc:'http://www.idesktop.tv/images/player_icons/close.gif',
	width: 660, height: 122, pp: 5,
	rows: 1, cols: 5,
	plw: 500, plh: 420,
	createP: function () {this.p = new IDTVVWP(this); },
	plpl: 'center',
	only_public:true,mark_private:true,
	thumb_show_title : true, thumb_show_author : false,
	thumb_show_rating : false, thumb_show_views: false,
	thumb_show_length : true, thumb_show_description : false,
	thumb_show_labels : true,
	thumbnail_text: 'N',
	pldelta: 0,
		data: {results: [{id:'ICPDialJW28',title:'Oran, quartier de la marine',author:'aldjazairmultimedia',real_length:'108',length_seconds:'01:48',rating_avg:'5',rating_count:'2',view_count:'110',description:'Oran, quartier de la marine. Reportage: Sophia Choubane/Bendadda/Soudani. Montage: Mohamed Noureddine Lagha pour Canal Alg&Atilde;&copy;rie le 23 Avril 2010',tags:'oran, quartier, marine, pêche',thumbnail_url:'http://img.youtube.com/vi/ICPDialJW28/default.jpg',upload_time:'1272114192',comment_count:'0',url:'http://gdata.youtube.com/feeds/api/videos/ICPDialJW28/responses?v=2',ord:'0',isprivate:'',t:'v'},{id:'pZHROu0lb44',title:'Les Portes de la Ville d\'Oran',author:'aldjazairmultimedia',length_seconds:'01:32',rating_avg:'0',rating_count:'',view_count:'6',description:'Vestige de la pr&amp;amp;amp;amp;amp;amp;Atilde;&amp;amp;amp;amp;amp;amp;copy;sence espagnole dans la ville d\'Oran; la porte du santon, la porte de canastel... Commentaire: Nedjma Harche, pour Canal Alg&amp;amp;amp;amp;amp;amp;Atilde;&amp;amp;amp;amp;amp;amp;copy;rie le 19 Mars 2010',tags:'el, bahia, oran, porte, santon, canastel, bed, oued, tlemcen, bastionles',thumbnail_url:'http://img.youtube.com/vi/pZHROu0lb44/default.jpg',upload_time:'1269096157',comment_count:'0',url:'http://gdata.youtube.com/feeds/api/videos/pZHROu0lb44/responses?v=2',ord:'0',t:'v',mid:'275933'},{id:'KTbixt4Lox4',title:'M&eacute;tro d\'Alger',author:'aldjazairmultimedia',real_length:'92',length_seconds:'01:32',rating_avg:'5',rating_count:'2',view_count:'498',description:'M&amp;Atilde;&amp;copy;tro qui desservira la ville d\'Alger; www.metroalger.com - http Avec le m&amp;Atilde;&amp;copy;tro du Caire, Il constitue le seul m&amp;Atilde;&amp;copy;tro lourd du continent africain. Commentaire: Khaled Drareni pour Canal Alg&amp;Atilde;&amp;copy;rie le 06 Avril 2010',tags:'m&eacute;tro, tramway, alger, Alg&eacute;rie',thumbnail_url:'http://img.youtube.com/vi/KTbixt4Lox4/default.jpg',upload_time:'1270593482',comment_count:'0',url:'http://gdata.youtube.com/feeds/api/videos/KTbixt4Lox4/responses?v=2',ord:'5',t:'v',mid:'275934'},{id:'-TJFAOlGeKI',title:'Ruines Romaines - Madore, Souk Ahras',author:'aldjazairmultimedia',real_length:'106',length_seconds:'01:46',rating_avg:'5',rating_count:'1',view_count:'40',description:'Cit&Atilde;&copy; antique, ville de Madore; ruines romaines &Atilde;&nbsp; 50 Km de Souk Ahras. Commentaire: Nedjma Harche pour Canal Alg&Atilde;&copy;rie le 26 Avril 2010',tags:'ruines, romaines, madore, souk, ahras',thumbnail_url:'http://img.youtube.com/vi/-TJFAOlGeKI/default.jpg',upload_time:'1272329714',comment_count:'0',url:'http://gdata.youtube.com/feeds/api/videos/-TJFAOlGeKI/responses?v=2',ord:'0',isprivate:'',t:'v'},{id:'c-g-OcAToEo',title:'Ville de Khmissa - Souk Ahras',author:'aldjazairmultimedia',real_length:'95',length_seconds:'01:35',rating_avg:'0',rating_count:'',view_count:'4',description:'Vestiges antiques et ruines romaines situ&Atilde;&copy;s dans la ville de Khmissa, wilaya de Souk Ahkrass. Commentaire: Nabil Kitouni pour Canal Alg&Atilde;&copy;rie le 29 Avril 2010',tags:'vestiges, antiques, ruines, romaines, amphithéâtre',thumbnail_url:'http://img.youtube.com/vi/c-g-OcAToEo/default.jpg',upload_time:'1272670067',comment_count:'0',url:'http://gdata.youtube.com/feeds/api/videos/c-g-OcAToEo/responses?v=2',ord:'0',isprivate:'',t:'v'}]},
		initialize: function () {this.createP()}

};
var IDTVLBDataSource6519f1ae66IF = function () {IDTVLBDataSource6519f1ae66.initialize.apply(IDTVLBDataSource6519f1ae66, []);};
if (document.getElementById('IDTVP_6519f1ae66'))
	IDTVLBDataSource6519f1ae66IF ();
else if (window.addEventListener)
	window.addEventListener("load", IDTVLBDataSource6519f1ae66IF, true);
else
	window.attachEvent("onload", IDTVLBDataSource6519f1ae66IF);