//solo.js for channel 3007 / widget 766173 / WxH: 280x243 / skin: clean / vid: 0 / autoplay: N / matrix: Y 
// Widget standard js for yubby
// NOT based on prototype or jquery - cause it must be lightweight and cant interfere with host

/**
 *	htmlspecialchars - like its php counterpart
 *	@author rvw
 *	@since 08-03-2010 12:19
 */
function htmlspecialchars(string) {
	string = string.toString();
	string = string.replace(/&/g, '&amp;');    
	string = string.replace(/</g, '&lt;').replace(/>/g, '&gt;');
	string = string.replace(/"/g, '&quot;');
	// single quote.. string = string.replace(/'/g, '&#039;');
	return string;
}
// pgstats - poor mans page statistics.. 
// NOT based on prototype or jquery - cause it must be lightweight

// // get our script src, to know our baseurl so we can call home
// var pgstatsScriptSource = (function(scripts) {
//     var scripts = document.getElementsByTagName('script'),
//         script = scripts[scripts.length - 1];	// at ths very moment, we are the last script guaranteed
// 
//     if (script.getAttribute.length !== undefined) {
//         return script.src
//     }
// 
//     return script.getAttribute('src', -1)
// }());

var pgstats= {
	browser: navigator.userAgent,
	uid: '',
	scr: screen.width.toString()+'x'+screen.height.toString(),
	url: document.URL,
	referrer: document.referrer,
	ecollect: {},
	baseurl: 'http://www.yubby.com/',	// pgstatsScriptSource.substr(0,pgstatsScriptSource.lastIndexOf('/pgstats/')),
	init: function() {
		if (!(this.uid=this.readCookie('pgstats'))) {
			this.uid= Math.round(Math.random() * 2147483647).toString();
			this.uid+= Math.round(Math.random() * 2147483647).toString();
			this.createCookie('pgstats',this.uid,365*2);
		}
	}, 
	xPageHit: function () {
		var xhReq=this.createXMLHttpRequest();
		if (!xhReq)
			return 'ERR:xhReq';	// forget it..
		if (!this.baseurl)
			return 'ERR:baseurl';	// forget it..
		xhReq.open('get',this.baseurl+'pgstats/tick?'+this.collectInfo(),true);
		// xhReq.onreadystatechange = function() {
		//     if (xhReq.readyState != 4)  { return; }
		//     var serverResponse = xhReq.responseText;
		//     alert(serverResponse);
		// };
		xhReq.send();
		return 'OK';
	},
	collectInfo: function() {
		var rv;
		rv='ts=' + new Date().getTime();
		//rv+='&br='+this.encURI(this.browser);
		rv+='&uid='+this.uid;
		rv+='&url='+this.encURI(this.url);
		rv+='&refer='+this.encURI(this.referrer);
		//rv+='&ssrc='+this.encURI(this.baseurl);
		rv+='&scr='+this.scr;
		for (i in this.ecollect) {
			rv+='&'+i+'='+this.encURI(this.ecollect[i]);
		}

		return rv;
	},
	addcollect: function(key,val) {
		this.ecollect[key]=val;
	},
	//------- helper functions ----------
	createCookie: function (name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	},
	readCookie: function(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	},
	eraseCookie: function(name) {
		createCookie(name,"",-1);
	},
	encURI: function(url) {
		//return encodeURIComponent(url);	// forgets to encode a lot of chars. Useless
		var s = escape(url);	// this is the most complete one, however forgets to encode star, slash, @ and +
		s = s.replace(/\*/g,"%2A");
		s = s.replace(/\//g,"%2F");
		s = s.replace(/\@/g,"%40");
		s = s.replace(/\+/g,"%2B");
		return s;
	},
	createXMLHttpRequest: function() {
  		try { return new XMLHttpRequest(); } catch(e) {}
		try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
		try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch (e) {}
		return null;
	}
}
pgstats.init();
//pgstats.addcollect('vid','234234');
//pgstats.xPageHit();
var isIE = /MSIE ((5\.5)|[6])/.test(navigator.userAgent) && navigator.platform == "Win32";

var cvids_766173= new Array();	// channelvideo's
var curvid_766173=0;			// first video
var cpvideo_766173=false;		// false=thumb, true=video

// in IE, you need to declare these before the vp_createwg is called, otherwise they do not exist in the onclick context
var matrix_curpg=1;
var matrix_npages=1;


var butnext_mousein=false;
var butprev_mousein=false;
var butplay_mousein=false;
var butstop_mousein=false;
var butmatrix_mousein=false;

var imgNext_ov = new Image;
var imgNext_ou = new Image;
var imgNext_d  = new Image;
imgNext_ov.src="http://www.yubby.com//img/widget/solo/iconnext24ov.png";
imgNext_ou.src="http://www.yubby.com//img/widget/solo/iconnext24.png";
imgNext_d.src ="http://www.yubby.com//img/widget/solo/iconnext24d.png";

var imgPrev_ov = new Image;
var imgPrev_ou = new Image;
var imgPrev_d  = new Image;
imgPrev_ov.src="http://www.yubby.com//img/widget/solo/iconprev24ov.png";
imgPrev_ou.src="http://www.yubby.com//img/widget/solo/iconprev24.png";
imgPrev_d.src ="http://www.yubby.com//img/widget/solo/iconprev24d.png";

var imgPlay_ov = new Image;
var imgPlay_ou = new Image;
var imgPlay_d  = new Image;
imgPlay_ov.src="http://www.yubby.com//img/widget/solo/iconplay24ov.png";
imgPlay_ou.src="http://www.yubby.com//img/widget/solo/iconplay24.png";
imgPlay_d.src ="http://www.yubby.com//img/widget/solo/iconplay24d.png";

var imgStop_ov = new Image;
var imgStop_ou = new Image;
var imgStop_d  = new Image;
imgStop_ov.src="http://www.yubby.com//img/widget/solo/iconstop24ov.png";
imgStop_ou.src="http://www.yubby.com//img/widget/solo/iconstop24.png";
imgStop_d.src ="http://www.yubby.com//img/widget/solo/iconstop24d.png";

var imgMatrix_ov = new Image;
var imgMatrix_ou = new Image;
var imgMatrix_d  = new Image;
imgMatrix_ov.src="http://www.yubby.com//img/widget/solo/iconmatrix24ov.png";
imgMatrix_ou.src="http://www.yubby.com//img/widget/solo/iconmatrix24.png";
imgMatrix_d.src ="http://www.yubby.com//img/widget/solo/iconmatrix24d.png";

var wgElm_766173 = document.getElementById('viidoo_solo_766173');
if (wgElm_766173) {
	vp_createwg();
}

pgstats.addcollect('chid','3007');
pgstats.addcollect('hit','embed');
pgstats.addcollect('widget','solo');
pgstats.xPageHit();

function vp_createwg() {
	// silly IE needs BR
	var html='<br style="display:none;"/><style type="text/css">	\
				.v69resetstyle	{ -moz-box-sizing: content-box !important; } \
				</style>';
	html+='<div id="widget_flash_766173" class="widget_flash v69resetstyle" style="width: 280px;height:243px;overflow:hidden; border: 1px solid #DDDDDD;font-family:Trebuchet MS,Lucida Sans Unicode,Lucida Grande,Lucida Sans,Tahoma,Geneva,Arial,helvetica,sans-serif">';

	cvids_766173.push({vid:86522, thumb: 'http://i.ytimg.com/vi/6ILQrUrEWe8/0.jpg', title: 'Did You Know 4.0', desc: 'This is another official update to the original \"Shift Happens\" video. This completely new Fall 2009 version includes facts and stats focusing on the changing media landscape, including convergence and technology, and was developed in partnership with The Economist. For more information, or to join the conversation, please visit mediaconvergence.economist.com and http Content by XPLANE, The Economist, Karl Fisch, Scott McLeod and Laura Bestler. Music by DoKashiteru, \"Home Tonight.\" Design ...'});
	cvids_766173.push({vid:86521, thumb: 'http://i.ytimg.com/vi/vNDEwsIGJKI/0.jpg', title: 'apple Think different seinfeld ad', desc: 'apple Think different seinfeld ad '});
	cvids_766173.push({vid:40029, thumb: 'http://i.ytimg.com/vi/ntY01qoIdus/1.jpg', title: 'Transcendent Man Film Trailer', desc: 'Transcendent Man introduces the life and ideas of Ray Kurzweil, the renowned futurist who journeys the world offering his vision of a future in which we will merge with our machines, can live forever, and are billions of times more intelligent...all within the next thirty years. ... \"Transcendent Man\" Kurzweil \"Ray Kurzweil\" nanotechnology exponential Transhumanism Singularity Futurist Biotech nanotech AI Robotics \"Artificial Intelligence\" Genetics \"Colin Powell\" \"William Shatner\" \"Tony ...'});
	cvids_766173.push({vid:41887, thumb: 'http://i.ytimg.com/vi/IfbOyw3CT6A/1.jpg', title: 'Ray Kurzweil: How technology\'s accelerating power will transform us', desc: 'www.ted.com Inventor, entrepreneur and visionary Ray Kurzweil explains in abundant, grounded detail why, by the 2020s, we will have reverse-engineered the human brain and nanobots will be operating your consciousness.TEDTalks is a daily video podcast of the best talks and performances from the TED Conference, where the world\'s leading thinkers and doers are invited to give the talk of their lives in 18 minutes -- including speakers such as Jill Bolte Taylor, Sir Ken Robinson, Hans Rosling ...'});
	cvids_766173.push({vid:37897, thumb: 'http://i.ytimg.com/vi/cL9Wu2kWwSY/1.jpg', title: 'Did You Know?', desc: 'Fantastic video on the progression of information technology, researched by Karl Fisch, Scott McLeod, and Jeff Brenman, remixed By the way, I did not create this video! Search on the names above if you want more info - they are responsible.'});
	cvids_766173.push({vid:49063, thumb: 'http://i.ytimg.com/vi/-Bn6Gel7yEs/1.jpg', title: 'Bill Stone: Journey to the center of the Earth ... and beyond!', desc: 'www.ted.com Bill Stone, a maverick cave explorer who has plumbed Earths deepest abysses, discusses his efforts to mine lunar ice for space fuel and to build an autonomous robot for studying Jupiters moon Europa.TEDTalks is a daily video podcast of the best talks and performances from the TED Conference, where the world\'s leading thinkers and doers are invited to give the talk of their lives in 18 minutes -- including speakers such as Jill Bolte Taylor, Sir Ken Robinson, Hans Rosling, Al Gore ...'});
	cvids_766173.push({vid:41244, thumb: 'http://i.ytimg.com/vi/qY4msj5Q05Q/1.jpg', title: 'Project P.U.M.A. (HD)', desc: 'What about a two passengers Segway PT? Segway has developed a working prototype dubbed Personal Urban Mobility \&amp; Accessibility (PUMA) that demonstrates a dramatically different approach to urban mobility.'});
	cvids_766173.push({vid:41103, thumb: 'http://i.ytimg.com/vi/uQGYr9bnktw/1.jpg', title: 'Seth Godin on the tribes we lead', desc: 'www.ted.com Seth Godin argues the Internet has ended mass marketing and revived a human social unit from the distant past tribes. Founded on shared ideas and values, tribes give ordinary people the power to lead and make big change. He urges us to do so.TEDTalks is a daily video podcast of the best talks and performances from the TED Conference, where the world\'s leading thinkers and doers give the talk of their lives in 18 minutes. Featured speakers have included Al Gore on climate change ...'});
	cvids_766173.push({vid:39386, thumb: 'http://ak2.static.dailymotion.com/static/video/297/922/15229792:jpeg_preview_large.jpg?20090423035806', title: 'Dean Kamen on \'Innovation and Taking Risks\'', desc: 'X PRIZE Thinkers segment in the INNOVATION in ACTION podcast series, Dean Kamen, of DEKA Research \&amp; Development Corp. talks to Peter Diamandis, of X PRIZE about why innovators need to know when and how to take risks to enable breakthroughs.'});
	cvids_766173.push({vid:84199, thumb: 'http://i.ytimg.com/vi/KyqHGdIMcas/0.jpg', title: 'Creating a Culture of Innovation', desc: 'An interview with David Kester, Chief Executive, Design Council. To foster a culture of innovation, managers must look outward to identify consumers\' problems and spark ideas for solving those problems. They must also ease employees\' fear of change.'});
	cvids_766173.push({vid:39387, thumb: 'http://i.ytimg.com/vi/8-JY8I_QswM/1.jpg', title: 'Patients Test an Advanced Prosthetic Arm', desc: 'surgical technique, developed by scientists at the Rehabilitation Institute of Chicago, allows patients who have lost arms to use residual nerve signals to control a prosthetic limb. This video shows three patients testing a prototype limb being developed by DARPA. The patients can perform complex tasks, including picking up a cup, grasping a cracker without breaking it, and putting a spoon in a cup. Video by DEKA Research and Development, and The Rehabilitation Institute of Chicago ...'});
	cvids_766173.push({vid:39379, thumb: 'http://i.ytimg.com/vi/qTnnJR-hS7k/1.jpg', title: 'Virtusphere - Full Body Immersion Virtual Reality', desc: 'This looks like the closest thing yet to a real-life holodeck! The Virtusphere is (as the name suggests) a large hollow sphere which sits on a set of computer monitored wheels. This allows the sphere to rotate a complete 360\u00ba whilst still allowing the computer to track the movments. For more information please visit www.hack247.co.uk'});
	cvids_766173.push({vid:41879, thumb: 'http://i.ytimg.com/vi/SlAaUK6jsTE/1.jpg', title: 'The Designful Company -- a video ditty', desc: 'Consider THE DESIGNFUL COMPANY from Marty Neumeier as a manifesto on building a company based upon the pillars of vision, culture, and innovation. To give you a flavor for THE DESIGNFUL COMPANY, I designed a three-minute video ditty sharing smart tid-bits. Enjoy. Google THE DESIGNFUL COMPANY for more info.'});
	cvids_766173.push({vid:51433, thumb: 'http://i.ytimg.com/vi/sIFYPQjYhv8/1.jpg', title: 'Social Media Revolution', desc: 'Is social media a fad? Or is it the biggest shift since the Industrial Revolution? Welcome to the World of Socialnomics ... Erik Qualman Socialnomics Facebook MySpace Youtube Vimeo social media Wiley Publishing '});
	cvids_766173.push({vid:39382, thumb: 'http://i.ytimg.com/vi/bpC2TXhJGkE/1.jpg', title: 'Xbox 360 Project Natal - Lionhead Milo Demo HD!', desc: 'Click the HD button. Project Natal Official Trailer in HD! www.youtube.com This is Lionhead\'s application for Project Natal that they put together while experimenting with Project Natal for a few months. I must say this is amazing. I could see this being heavily incorporated into Black \& White 3, if they ever develop it (Remember, you got that idea from me first Lionhead) =P Imagine the fun! You come back from a stressful day at work, turn on Black \& White 3 and beat the virtual crap out of ...'});
	cvids_766173.push({vid:41102, thumb: 'http://i.ytimg.com/vi/T6MhAwQ64c0/1.jpg', title: 'Entrepreneurs can change the world', desc: 'Join the entrepreneur movement. Stimulate the economy. Spread the word. grasshopper.com - Original music by Carly Comando. Written \& Produced by Sonja Jacob. Designed by Ben White.'});
	cvids_766173.push({vid:41242, thumb: 'http://images.vimeo.com/10/86/23/108623785/108623785_200x150.jpg', title: 'Innergy', desc: 'Gazelle\'s Paddle Assisted Bicycle - bike between 50 \u2013 75 km (~40 miles) without exhausting yourself. The bike won the Bike of the Year 2009 award.'});
	cvids_766173.push({vid:39384, thumb: 'http://i.ytimg.com/vi/oACt9R9z37U/1.jpg', title: 'Project Natal for XBOX 360', desc: 'Xbox introduces controller-free gaming and entertainment. Get off the couch and get in the game - no controller required!'});
	cvids_766173.push({vid:40028, thumb: 'http://a.images.blip.tv/Vincente-CESunvieledDeEersteDagVanCes2009218-456.jpg', title: 'CES-unvieled, de eerste dag van ces2009', desc: '\n\nCes unveilled\u2022 Doven video telefoon www.viable.net\u2022 Internet radio 299 blaupunkt\u2022 Powermat draadloze electriciteit www.pwrmat.com\u2022 www.Asus.com 1 kg gps tv tuner, net pc\u2022 Logitech.com met gaming add ons\u2022 Wifi/hsdpa novatel router\u2022 Draadloos usb display kabel\u2022 Wii jogger\u2022 3D webcamera www.minoru3D.com\u2022 Massage stoel voor luie amerikanen\u2022 Eco batterije zonder slechte stoffen.\n\n'});
	cvids_766173.push({vid:49142, thumb: 'http://i.ytimg.com/vi/rcfNC_x0VvE/1.jpg', title: 'Cisco Telepresence Magic', desc: 'Cisco Telepresence Magic. Btw, if you want to take a look at a more formal video on the same event, feel free to check out: www.musion.co.uk'});
html+='<div class="v69resetstyle" id="thumb_766173" style="width:280px;height:217px;background-color:#FFFFFF;position:relative;">';
html+=vidthumbhtml_766173(curvid_766173);
html+='</div>';
	html +='<div class="v69resetstyle" style="height:26px;width:280px;position:relative;background-color:#FFFFFF;">';
	html +='<div class="v69resetstyle" style="position:absolute;left:35px;top:3px;color:#444;font-size:11px;line-height:10px;cursor:pointer;width:185px;height:20px;overflow:hidden;" onclick="location.href=vidplayurl_766173();"><span style="color:#888;"></div>';
	html +='<img style="position:absolute;left:136px;top:0px;height:25px;z-index:5;cursor:pointer;margin:0;padding:0;" src="http://www.yubby.com/img/project/yubby/logo.png" onclick="location.href=vidplayurl_766173();">';
		html +='<img onclick="showmatrix_766173(0);" style="position:absolute;left:5px;top:1px;cursor:pointer;margin:0;padding:0;" src="http://www.yubby.com//img/widget/solo/iconmatrix24.png" title="popup an overview with all videos"  	id="pgmatrix_766173" 	onmouseover="oMouEv(this,true);" onmouseout="oMouEv(this,false);"/>';
		html +='<img onclick="playprev_766173();" style="position:absolute;left:204px;top:1px;cursor:pointer;margin:0;padding:0;" src="http://www.yubby.com//img/widget/solo/iconprev24.png" title="go to the previous video in the channel"  		id="pgprev_766173" 	onmouseover="oMouEv(this,true);" onmouseout="oMouEv(this,false);" />';
	//html +='<img onclick="playstop_766173();" style="position:absolute;left:204px;top:1px;cursor:pointer;margin:0;padding:0;" src="http://www.yubby.com//img/widget/solo/iconstop24.png" title="stop"  													id="pgstop_766173"	onmouseover="oMouEv(this,true);" onmouseout="oMouEv(this,false);" />';
	//html +='<img onclick="playstart_766173();" style="position:absolute;left:228px;top:1px;cursor:pointer;margin:0;padding:0;" src="http://www.yubby.com//img/widget/solo/iconplay24.png" title="play"  									id="pgplay_766173"	onmouseover="oMouEv(this,true);" onmouseout="oMouEv(this,false);" />';
	// start is now a toggle
	html +='<img onclick="playstartstop_766173();" style="position:absolute;left:228px;top:1px;cursor:pointer;margin:0;padding:0;" src="http://www.yubby.com//img/widget/solo/iconplay24.png" title="play"  									id="pgplay_766173"	onmouseover="oMouEv(this,true);" onmouseout="oMouEv(this,false);" />';
	html +='<img onclick="playnext_766173();" style="position:absolute;left:252px;top:1px;cursor:pointer;margin:0;padding:0;" src="http://www.yubby.com//img/widget/solo/iconnext24.png" title="go to the next video in the channel"  	id="pgnext_766173"	onmouseover="oMouEv(this,true);" onmouseout="oMouEv(this,false);" />';
	html +='</div>';
	html+='</div>';
	wgElm_766173.innerHTML=html;
	wgElm_766173.style.display = 'block';
		updAllButState(); 
}

function playnext_766173() {
	if (curvid_766173 < cvids_766173.length -1 ) {
		curvid_766173++;
		if (cpvideo_766173)
			playstart_766173();	// we are playing video
		else {
			var thumbdiv=document.getElementById('thumb_766173');
			thumbdiv.innerHTML=vidthumbhtml_766173(curvid_766173);
		}
	}
	updAllButState();
}
function playprev_766173() {
	if (curvid_766173 >0 ) {
		curvid_766173--;
		if (cpvideo_766173)
			playstart_766173();	// we are playing video
		else {
			var thumbdiv=document.getElementById('thumb_766173');
			thumbdiv.innerHTML=vidthumbhtml_766173(curvid_766173);
		}
	}
	updAllButState();
}

function playstart_766173(vnr) {
	closepopup_766173();	// close popup (if open)
	if (vnr==null)
		vnr=curvid_766173;
	else
		curvid_766173=vnr;	// set the current
	var thumbdiv=document.getElementById('thumb_766173');
	thumbdiv.style.background='#FFF url(http://www.yubby.com/img/spinner32.gif) no-repeat 110px 78.5px';
	thumbdiv.innerHTML='<iframe name="playerframe" class="playerframe" src="http://www.yubby.com/widget/playvideo/'+cvids_766173[vnr].vid+'/280/217/L/W" width="280" height="217" frameborder="0" scrolling="no" allowtransparency="true"></iframe>';
	cpvideo_766173=true;
	updAllButState();
}

function playstop_766173() {
	cpvideo_766173=false;
	var thumbdiv=document.getElementById('thumb_766173');
	thumbdiv.style.background='#FFF';
	thumbdiv.innerHTML=vidthumbhtml_766173(curvid_766173);
	updAllButState();
}

function playstartstop_766173() {
	if (cpvideo_766173) 
		playstop_766173();
	else
		playstart_766173();
}

function vidthumbhtml_766173(vnr) {
	var html='';
	html+='<div class="v69resetstyle" style="width:270px;height:169px; overflow:hidden; position:absolute;left:5px;top:5px;">';
html+='<img src="'+cvids_766173[vnr].thumb+'" style="width:270px;height:203px;top:-17px;position:relative;">';
html+='</div>';
html+='<div class="v69resetstyle" style="width:260px;height:33px;position:absolute;left:5px;top:174px;background-color:#AAA;padding:5px;"><div class="v69resetstyle" style="overflow:hidden;height:38px;width:260px;"><div class="v69resetstyle" style="margin: 1px 3px; white-space: nowrap; font-size:12px;line-height:12px;color:#555555;">'+htmlspecialchars(cvids_766173[vnr].title)+'</div><div class="v69resetstyle" style="margin: 1px 5px; font-size:11px;line-height:11px;color:#ffffff;overflow:hidden;height:40px;"  title="'+htmlspecialchars(cvids_766173[vnr].desc)+'">'+htmlspecialchars(cvids_766173[vnr].desc)+'</div><div class="v69resetstyle" style="padding: 3px 5px; letter-spacing:1px; background-color: #aaa; color: white; position: absolute; right: 0px; top: -14px; font-size: 10px;">'+(vnr+1)+'/'+(cvids_766173.length)+'</div></div></div>';
html+='<div class="v69resetstyle" style="position: absolute; width:72px;height:72px;top:72.5px;left:104px;z-index:200;cursor:pointer;cursor:hand;background:url(http://www.yubby.com/img/media_play72.png) no-repeat;" onClick="playstart_766173();"></div>';
	return html;
}

function vidthumbhtmlSmall_766173(vnr) {
	var html='';
	html='';
	html+='<div class="v69resetstyle" style="margin: 5px; float: left; position: relative; width: 162px; height: 90px;">';
		html+='<div  class="v69resetstyle" style="width:160px;max-height:122px;background:#f6f6f6;margin:0 auto 6px auto;overflow:hidden;position:relative;">';
			html+='<div  class="v69resetstyle" style="width:156px;height:86px;background:#cccccc;border:2px solid #dedede;overflow:hidden;position:relative;">';
				html+='<img style="position:absolute;width:160px;height:119px;top:-20px;left:0;cursor: pointer;" onclick="playstart_766173('+vnr+')" title="'+htmlspecialchars(cvids_766173[vnr].desc)+'" src="'+cvids_766173[vnr].thumb+'" />';
				html+='<div class="v69resetstyle" style="position: absolute; width:24px;height:24px;top:28px;left:68px;z-index:200;cursor:pointer;cursor:hand;background:url(http://www.yubby.com/img/media_play24.png) no-repeat;" onclick="playstart_766173('+vnr+')"></div>';
				html+='<div class="v69resetstyle" style="position: absolute; bottom: 0px; left: 0px;width:156px;height:15px;z-index:200;background-color:#dedede;color:#000000;font-size:11px;overflow:hidden;white-space: nowrap;padding:2px 5px 2px 3px;filter: alpha(opacity=80);filter: progid:DXImageTransform.Microsoft.Alpha(opacity=80);-moz-opacity: 0.80; opacity: 0.80;cursor: pointer;" onclick="playVideo_773417(15893)" >'+htmlspecialchars(cvids_766173[vnr].title)+'</div>';
			html+='</div>';
		html+='</div>';
	html+='</div>';
	return html;
}

// cp 1..npages
function paginationhtml_766173(cp,npages) {
	if (npages<=1)
		return '';	// empty if no pagination..
	var html='';
	html+='<div class="pages v69resetstyle">';
	if (cp>1) {
		// we CAN prev!
		html+= '<span class="pageblock" onclick="gotopage_766173('+(cp-1)+');">&#171; Previous</span>';
	}
	else {
		html+= '<span class="pageblock_disabled">&#171; Previous</span>';
	}
	// Available pages - Link
	var lpage = 1;
	var cpageSur = 2;
	var dotted = false;
	for (var lpage=1;lpage<=npages;lpage++) {
		// 1-2...8-9-[10]-11-12....58-59 
		if ( lpage<=2 || (lpage>=cp-4 && lpage<=cp+4) || lpage>=npages-1) {
			dotted = false;	// we need to dot afterwards
			if (lpage == cp )
				html+='<span class="pageblock_curpage"><b>'+lpage+'</b></span>';
			else
				html+='<span class="pageblock" onclick="gotopage_766173('+lpage+');">'+lpage+'</span>';
		}
		else {
			// no printing.. buttt maybe we need to dot
			if ( !dotted ) {
				html+='<span class="pageblock_dots">&nbsp;...&nbsp;</span>';
				dotted = true;
			}
		}
	}
		
	// Next page - Link
	if ( cp<npages )
		html+='<span class="pageblock" onclick="gotopage_766173('+(cp+1)+');">Next &#187;</span>';
	else
		html+='<span class="pageblock_disabled">Next &#187;</span>';
	html+='</div>';
	return html;
}

function vidplayurl_766173(vnr) {
	if (vnr==null)
		vnr=curvid_766173;
	return 'http://www.yubby.com/channel/player/3007/'+cvids_766173[vnr].vid;
}

//------------------------------------ button handlers --------------------------------------
function stButImg(oBut) {
	if (oBut.id == 'pgnext_766173') { 
		if (curvid_766173 >= cvids_766173.length -1 ) 
			oBut.src = imgNext_d.src;
		else
			oBut.src= butnext_mousein ? imgNext_ov.src : imgNext_ou.src;
	}
	if (oBut.id == 'pgprev_766173') { 
		if (curvid_766173==0 ) 
			oBut.src = imgPrev_d.src;
		else
			oBut.src= butprev_mousein ? imgPrev_ov.src : imgPrev_ou.src;
	}
	if (oBut.id == 'pgplay_766173') { 
		if (cpvideo_766173) 	// we are currently playing
			oBut.src = butplay_mousein ? imgStop_ov.src : imgStop_ou.src;
		else
			oBut.src= butplay_mousein ? imgPlay_ov.src : imgPlay_ou.src;
	}
	// if (oBut.id == 'pgstop_766173') { 
	// 	if (!cpvideo_766173 ) 	// currently NOT playing
	// 		oBut.src = imgStop_ov.src;
	// 	else
	// 		oBut.src= butstop_mousein ? imgStop_ov.src : imgStop_ou.src;
	// }
	if (oBut.id == 'pgmatrix_766173') { 
		oBut.src= butmatrix_mousein ? imgMatrix_ov.src : imgMatrix_ou.src;
	}
}

function oMouEv(oBut,mouseIn) {
	
	if (oBut.id == 'pgnext_766173') 
		butnext_mousein=mouseIn;
	if (oBut.id == 'pgprev_766173') 
		butprev_mousein=mouseIn;
	if (oBut.id == 'pgplay_766173') 
		butplay_mousein=mouseIn;
	// if (oBut.id == 'pgstop_766173') 
	// 	butstop_mousein=mouseIn;
	if (oBut.id == 'pgmatrix_766173') 
		butmatrix_mousein=mouseIn;
	stButImg(oBut);
}

function updAllButState() {
	el = document.getElementById('pgnext_766173');
	if (el) 
		stButImg(el); // update nextbutton state

	el = document.getElementById('pgprev_766173');
	if (el) 
		stButImg(el); // update prevbutton state
		
	el = document.getElementById('pgplay_766173');
	if (el) 
		stButImg(el); // update prevbutton state
		
	// el = document.getElementById('pgstop_766173');
	// if (el) 
	// 	stButImg(el); // update prevbutton state

	el = document.getElementById('pgmatrix_766173');
	if (el) 
		stButImg(el); // update prevbutton state
}

//------------------------------------ other stuff -------------
// find absolute top loc of object

function vp_offsetTop(obj) {
    curtop = 0;
    if (obj.offsetParent) {
    curtop = obj.offsetTop
    while (obj = obj.offsetParent) {
      curtop += obj.offsetTop
    }
  }
  return curtop;
}

function vp_offsetLeft(obj) {
  curtop = 0;
  if (obj.offsetParent) {
    curtop = obj.offsetLeft;
    while (obj = obj.offsetParent) {
      curtop += obj.offsetLeft;
    }
  }
  return curtop;
}


function closepopup_766173() {
  el = document.getElementById('ipopup_766173');
  if (el) {
    el.parentNode.removeChild(el);
  } 
}

//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}



//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function gotopage_766173(pg) {
	if (pg<1)
		pg=1;
	if (matrix_npages<1)
		matrix_npages=1;
	if (pg>matrix_npages) 
		pg=matrix_npages;
		
	matrix_curpg=pg;
	var mxs=document.getElementById('mxs_766173');
	var html='';
	for (var i=(matrix_curpg-1)*16,cv=0;i<cvids_766173.length && cv<16;i++) {
		html+=  vidthumbhtmlSmall_766173(i);
		cv++;
	}
	html+=  '<div class="v69resetstyle" style="clear:both;"></div>';
	if (matrix_npages>1) {
		html+=  '<div  class="v69resetstyle" style="margin:10px 0px">'+paginationhtml_766173(matrix_curpg, matrix_npages)+'</div>';
	}

	mxs.innerHTML=html;
}

function showmatrix_766173() {
	// close old one
	closepopup_766173();

	matrix_npages= Math.ceil(cvids_766173.length / 16);
	
	// open new
	var popup_div = document.createElement('div');
	var title='matrix';
	popup_div.id = "ipopup_766173";
	popup_div.style.position = 'absolute';
	popup_div.style.border = 'none';
	popup_div.className = "v69resetstyle";

	var base_width=172*4+25;

	var base_height=100*4+30+10+4;
	if (matrix_npages>1) 
		base_height+=30;
	popup_div.style.width = base_width+'px';
	popup_div.style.height = base_height+'px';
	popup_div.style.fontFamily='Trebuchet MS,Lucida Sans Unicode,Lucida Grande,Lucida Sans,Tahoma,Geneva,Arial,helvetica,sans-serif';
	popup_div.style.zIndex = '10000';

	// CENTER SCREEN
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	var popup_top = arrayPageScroll[1] + ((arrayPageSize[3] -base_height) / 2);
	var popup_left = arrayPageScroll[0] +((arrayPageSize[0] - base_width) / 2);
	if (popup_top<0)
		popup_top=0;
	if (popup_left<0)
		popup_left=0;
	popup_div.style.position = 'absolute';
	popup_div.style.top = popup_top + 'px';
	popup_div.style.left = popup_left + 'px';


	
	var vid_html='';
	vid_html+='<div class="v69resetstyle" style="padding:0px;position:relative;border:2px #CCC solid;background-color:white;width:'+(base_width-4)+'px;height:'+(base_height-4)+'px;">';
	vid_html+='<br style="display:none;"/><style type="text/css">	\
		.pages {padding:2px 0 2px 8px; margin:0; clear:both;font-size:12px;} \
			.pages span.pageblock {border: 1px solid #888; color:#000; height: 12px; padding: 3px 6px;margin: 0px 4px 0px 0px;cursor: pointer;cursor:hand;}\
			.pages span.pageblock:hover {color:#D10101;text-decoration:underline;}	\
			.pages span.pageblock_disabled {border: 1px solid #888; color: #aaa; height: 12px; padding: 3px 6px;margin: 0px 4px 0px 0px;}\
			.pages span.pageblock_dots {border: 0px solid #888; color: #000; height: 12px; padding: 3px 6px;margin: 0px 4px 0px 0px;}\
			.pages span.pageblock_curpage {border: 1px solid #888; color: #aaa; height: 12px; padding: 3px 6px;margin: 0px 4px 0px 0px;}\
		</style>';
	vid_html+=	'<div class="v69resetstyle" onclick="closepopup_766173();" style="position:absolute;top:7px;right:8px;cursor:pointer;cursor:hand;background:url(http://www.yubby.com/img/icon_bw_close22.png) no-repeat;width:24px;height:24px;z-index:10000;"></div>';
	vid_html+=	'<div class="v69resetstyle" style="position:absolute;top:8px;left:15px;color:#888;font-size:15px;overflow:hidden;width:'+(base_width-50)+'px;">Innovation Conversations</div>';
	vid_html+=	'<div class="v69resetstyle" style="margin:30px 10px 10px 10px;" id="mxs_766173">';
	// for (var i=0,cv=0;i<cvids_766173.length && cv<16;i++) { 
	// 		vid_html+=  vidthumbhtmlSmall_766173(i);
	// 		cv++;
	// 	}
	// 	vid_html+=  '<div style="clear:both;"></div>';
	// 
	// 	if (matrix_npages>1) {
	// 		vid_html+=  '<div style="margin:10px 0px">'+paginationhtml_766173(matrix_curpg, matrix_npages)+'</div>';
	// 	}
	vid_html+=	'</div>';
	vid_html+=  '<div class="v69resetstyle" style="clear:both;"></div>';
	vid_html+='</div>';
					
	popup_div.innerHTML=vid_html;
	document.body.appendChild(popup_div);
	gotopage_766173(matrix_curpg);
}

// utf8 to string conversions
var escapable = /[\\\"\x00-\x1f\x7f-\uffff]/g,
    meta = {    // table of character substitutions
        '\b': '\\b',
        '\t': '\\t',
        '\n': '\\n',
        '\f': '\\f',
        '\r': '\\r',
        '"' : '\\"',
        '\\': '\\\\'
    };

function utf8quote(string) {
	// If the string contains no control characters, no quote characters, and no
	// backslash characters, then we can safely slap some quotes around it.
	// Otherwise we must also replace the offending characters with safe escape
	// sequences.

    escapable.lastIndex = 0;
    return escapable.test(string) ?
        '"' + string.replace(escapable, function (a) {
            var c = meta[a];
            return typeof c === 'string' ? c :
                '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
        }) + '"' :
        '"' + string + '"';
}



