//gw.js for group 87 / widget 188112 / WxH: 520x500 / RxC: 0x1 / skin: simple 
// 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 chs_188112= new Array();	// channels
var curch_188112=0;			// first channel

var wgElm_188112 = document.getElementById('viidoo_gw_188112');
if (wgElm_188112) {
	vp_createwg();
}

pgstats.addcollect('gid','87');
pgstats.addcollect('hit','embed');
pgstats.addcollect('widget','groupwidget');
pgstats.xPageHit();

function vp_createwg() {
	var html='<div id="widget_flash_188112" style="width: 520px;height:500px;overflow:hidden; border: 1px solid #dddddd;background-color:#ffffff;font-family:Trebuchet MS,Lucida Sans Unicode,Lucida Grande,Lucida Sans,Tahoma,Geneva,Arial,helvetica,sans-serif">';

	chs_188112.push({chid:31122, thumb: 'http://www.yubby.com/img/channels/000012850u.jpg',twidth: '553.66666666667',theight: '110',tleft: '-31.333333333333',tright: '190.5',ttop: '0',tbottom: '0',title: 'Sony hoofdtelefoons, oortelefoons en headsets', desc: 'Ontdek het uitgebreide assortiment hoofdtelefoons, oortelefoons en headsets van Sony: alle modellen produceren geluid van topklasse. Is uw oortelefoon aan vervanging toe of wilt u gewoon wat meer comfort? Of u nu op reis of aan het sporten bent, thuis of op het werk, we hebben de beste hoofdtelefoon voor u.'});
	chs_188112.push({chid:22431, thumb: 'http://www.yubby.com/img/channels/000012854u.jpg',twidth: '553.66666666667',theight: '110',tleft: '-31.333333333333',tright: '190.5',ttop: '0',tbottom: '0',title: 'Sony in-car', desc: 'Bedien uw MP3-speler of iPod\u00ae via uw autoradio en zoek eenvoudig uw favoriete muziek. Bel handsfree met Bluetooth\u00ae op uw mobiele telefoon. En geniet onderweg van video met breedbeeld DVD-weergave. Ons assortiment autoradio\'s biedt u de beste muziek- en entertainmentervaring voor onderweg met een indrukwekkende geluidskwaliteit.'});
	chs_188112.push({chid:26804, thumb: 'http://www.yubby.com/img/channels/000012853u.jpg',twidth: '553.66666666667',theight: '110',tleft: '-31.333333333333',tright: '190.5',ttop: '0',tbottom: '0',title: 'Sony PlayStation', desc: 'PlayStation\u00ae3: Alle entertainment die u ooit nodig hebt in \u00e9\u00e9n slank en stijlvol apparaat; adembenemende gameplay, een Blu-ray Disc\u2122-speler en internettoegang in \u00e9\u00e9n. Speel de populairste games of speel met meerdere gamers tegelijk op het PlayStation\u00aeNetwork.<br/><br/>PSP (PlayStation\u00aePortable): Geweldig entertainment voor onderweg, inclusief supergave games, de grootste bioscoophits, uw favoriete muziek, internettoegang en onlinechatten. U kunt zelfs video\'s van uw PS3\u2122 thuis streamen of uw TV aansluiten om de video\'s op een groot scherm te bewonderen.<br/><br/>PlayStation\u00aeNetwork: Treed binnen in de onlinewereld van PlayStation\u00ae. Doe mee aan games voor meerdere spelers, chat met vrienden en familie over de gehele wereld en surf op internet, en dat allemaal gratis.'});
	chs_188112.push({chid:26807, thumb: 'http://www.yubby.com/img/channels/000012852u.jpg',twidth: '553.66666666667',theight: '110',tleft: '-31.333333333333',tright: '190.5',ttop: '0',tbottom: '0',title: 'Sony VAIO', desc: 'Elke VAIO bevat een ongelooflijke hoeveelheid technologie. Dat is gewoon een feit. We weten dat u de nieuwste functies wilt hebben, dus daar zorgen wij voor.<br/><br/>VAIO heeft altijd al een benijdenswaardige reputatie gehad op het gebied van toonaangevende vormgeving en creativiteit met een esthetisch en toch functioneel ontwerp, waardoor een erg eigentijds uiterlijk en gevoel ontstaat.<br/><br/>VAIO brengt mensen en techniek dichter bij elkaar. VAIO voorziet in lichtgewicht apparaten met een langere levensduur van de batterij en dus een ongekende draagbaarheid voor mensen die altijd onderweg zijn.<br/><br/>VAIO heeft de ultieme technologie voor uw ultieme entertainment. Zoekt u een bron van muzikale inspiratie, een schijf voor opslag of een schermresolutie waar u altijd van hebt gedroomd?<br/><br/>VAIO is het perfecte, professionele apparaat: veilig, robuust en betrouwbaar. De geavanceerde beveiliging garandeert de veiligheid van uw gegevens terwijl een superieure bouwkwaliteit en stijl een hoge betrouwbaarheid koppelen aan een geweldig mooie laptop.'});
	chs_188112.push({chid:30002, thumb: 'http://www.yubby.com/img/channels/000012851u.jpg',twidth: '553.66666666667',theight: '110',tleft: '-31.333333333333',tright: '190.5',ttop: '0',tbottom: '0',title: 'Sony bloggie', desc: 'When fun happens, the all-new pocket-sized bloggie\u2122 camera lets you capture, upload and share the action in high definition. It plays nicely with sites like YouTube\u2122, so it\'s easy to upload your photos and videos to the web.'});
	chs_188112.push({chid:22422, thumb: 'http://www.yubby.com/img/channels/000012863u.jpg',twidth: '553.66666666667',theight: '110',tleft: '-31.333333333333',tright: '190.5',ttop: '0',tbottom: '0',title: 'Sony DSLR- en SLT-camera\'s', desc: 'Het is tijd om uw foto\'s naar een hoger niveau te tillen. Maak gebruik van spannende nieuwe creatieve mogelijkheden met de digitale spiegelreflexcamera\'s, lenzen en accessoires van Sony. De Sony \u03b1 (spreek uit als: alfa) DSLR-camerareeks omvat de full-frame A900, de gevoelige A550 en de compacte, gebruiksvriendelijke A380.'});
	chs_188112.push({chid:22423, thumb: 'http://www.yubby.com/img/channels/000012862u.jpg',twidth: '553.66666666667',theight: '110',tleft: '-31.333333333333',tright: '190.5',ttop: '0',tbottom: '0',title: 'Sony televisies', desc: 'BRAVIA\u00ae Full HD LCD-televisies van Sony: ga op in de Full High Definition-TV breedbeeldervaring of kijk naar vloeiende actiesc\u00e8nes op een Motionflow HD-TV. Maak een keuze uit TV-ontwerpen, innovatieve LCD TV-beeldtechnologie, superslanke televisies of de nieuwste digitale Full HD- en HD ready-TV\'s.'});
	chs_188112.push({chid:22425, thumb: 'http://www.yubby.com/img/channels/000012861u.jpg',twidth: '553.66666666667',theight: '110',tleft: '-31.333333333333',tright: '190.5',ttop: '0',tbottom: '0',title: 'Sony Handycam-camcorders', desc: 'Deel dierbare herinneringen met een Handycam-camcorder. De nieuwste digitale camcorders hebben innovatieve videocameratechnologie van Sony zodat u in ongelooflijke details kunt filmen. U kunt de stijlvolle Handycam-camcorder overal mee naartoe nemen om met vrienden en familie dat grote evenement of die dierbare vakantieherinneringen in Full HD terug te zien.'});
	chs_188112.push({chid:22426, thumb: 'http://www.yubby.com/img/channels/000012860u.jpg',twidth: '553.66666666667',theight: '110',tleft: '-31.333333333333',tright: '190.5',ttop: '0',tbottom: '0',title: 'Sony Cyber-shot-camera\'s', desc: 'Met de nieuwe serie Cyber-shot-camera\'s kunt u met een druk op de knop inspirerende foto\'s maken. Met de nieuwste Cyber-shot compacte digitale camera\'s is het dankzij functies als Intelligent draaipanorama, Exmor R\u2122 CMOS-sensor en het opnemen van High Definition-films gemakkelijker dan ooit om schitterende foto\'s en video\'s te maken.'});
	chs_188112.push({chid:22427, thumb: 'http://www.yubby.com/img/channels/000012859u.jpg',twidth: '553.66666666667',theight: '110',tleft: '-31.333333333333',tright: '190.5',ttop: '0',tbottom: '0',title: 'Sony thuisbioscoop', desc: 'Met zorg gemaakt en voorzien van de laatste audiotechnologie: een thuisbioscoopsysteem van Sony laat een volle, rijke HD Surround Sound in uw huis klinken. Dim de verlichting en kijk naar Blu-ray Disc\u2122-films met Full HD-geluid of geniet van de overweldigende game-ervaring - en dat alles in de sfeer van een thuisbisocoop.'});
	chs_188112.push({chid:22429, thumb: 'http://www.yubby.com/img/channels/000012858u.jpg',twidth: '553.66666666667',theight: '110',tleft: '-31.333333333333',tright: '190.5',ttop: '0',tbottom: '0',title: 'Sony Reader eBook', desc: 'Een Reader biedt ruimte aan honderden of zelfs duizenden elektronische boeken. De ultradunne, vederlichte boeklezer past gemakkelijk in uw jaszak of handtas, zodat u deze overal kunt meenemen en gebruiken.'});
	chs_188112.push({chid:22430, thumb: 'http://www.yubby.com/img/channels/000012857u.jpg',twidth: '553.66666666667',theight: '110',tleft: '-31.333333333333',tright: '190.5',ttop: '0',tbottom: '0',title: 'Sony draagbare audio', desc: 'Iedere WALKMAN\u00ae mp3-speler en mp4-speler beschikt over unieke speciale functies. Van draadloos en draagbaar tot digitale ruisonderdrukking en video\'s van topkwaliteit. Neem al uw muziek en video\'s mee voor onderweg met de draagbare WALKMAN\u00ae mp3/mp4-spelers. Er is een model met uitzonderlijke geluids-, video- en beeldkwaliteit voor elk budget.'});
html+='<div id="thumb_188112" style="width:518px;height:498px;position:relative;padding:5px 0px 0 5px;">';
html+=chMatrixHtml_188112(508,488);
html +='<img style="position:absolute;right:20px;bottom:10px;height:25px;z-index:5;cursor:pointer;" src="http://incdn.s3.amazonaws.com/yubbyp_v1/img/project/yubby/logo_stroke.png" onclick="location.href=\'http://www.yubby.com/\';">';
html+='</div>';
	/******
	html +='<div style="height:26px;width:520px;position:relative;">';
	html +='<div 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_188112();"><span style="color:#888;">You are watching channel</span><br/>sony producten</div>';
	html +='<img style="position:absolute;left:356px;top:0px;height:25px;z-index:5;cursor:pointer;" src="http://incdn.s3.amazonaws.com/yubbyp_v1/img/project/yubby/logo.png" onclick="location.href=vidplayurl_188112();">';
	html +='<img onclick="showmatrix_188112(0);" style="position:absolute;left:5px;top:1px;cursor:pointer;" src="http://www.yubby.com//img/widget/solo/skins/simple/iconmatrix24.png" title="Click here for related videos"/>';
	html +='<img onclick="playprev_188112();" style="position:absolute;left:420px;top:1px;cursor:pointer;" src="http://www.yubby.com//img/widget/solo/skins/simple/iconprev24.png" title="go to the previous video in the channel"/>';
	html +='<img onclick="playstop_188112();" style="position:absolute;left:444px;top:1px;cursor:pointer;" src="http://www.yubby.com//img/widget/solo/skins/simple/iconstop24.png" title="stop"/>';
	html +='<img onclick="playstart_188112();" style="position:absolute;left:468px;top:1px;cursor:pointer;" src="http://www.yubby.com//img/widget/solo/skins/simple/iconplay24.png" title="play"/>';
	html +='<img onclick="playnext_188112();" style="position:absolute;left:492px;top:1px;cursor:pointer;" src="http://www.yubby.com//img/widget/solo/skins/simple/iconnext24.png" title="go to the next video in the channel"/>';
	html +='</div>';
	html+='</div>';
	*/

	wgElm_188112.innerHTML=html;
	gotopage_188112(1);
	wgElm_188112.style.display = 'block';
}

function playnext_188112() {
	if (curvid_188112 < chs_188112.length -1 ) {
		curvid_188112++;
		if (cpvideo_188112)
			playstart_188112();	// we are playing video
		else {
			var thumbdiv=document.getElementById('thumb_188112');
			thumbdiv.innerHTML=vidthumbhtml_188112(curvid_188112);
		}
	}
}
function playprev_188112() {
	if (curvid_188112 >0 ) {
		curvid_188112--;
		if (cpvideo_188112)
			playstart_188112();	// we are playing video
		else {
			var thumbdiv=document.getElementById('thumb_188112');
			thumbdiv.innerHTML=vidthumbhtml_188112(curvid_188112);
		}
	}
}
function playstart_188112(vnr) {
	closepopup_188112();	// close popup (if open)
	if (vnr==null)
		vnr=curvid_188112;
	else
		curvid_188112=vnr;	// set the current
	var thumbdiv=document.getElementById('thumb_188112');
	thumbdiv.innerHTML='<iframe name="playerframe" class="playerframe" src="http://www.yubby.com/widget/playvideo/'+chs_188112[vnr].vid+'/520/474/L/W" width="520" height="474" frameborder="0" scrolling="no" allowtransparency="true"></iframe>';
	cpvideo_188112=true;
}

function playstop_188112() {
	cpvideo_188112=false;
	var thumbdiv=document.getElementById('thumb_188112');
	thumbdiv.innerHTML=vidthumbhtml_188112(curvid_188112);
}

function chthumbhtml_188112(vnr) {
	var html='';
	html+='<div style="width:510px;height:319px; overflow:hidden; position:absolute;left:5px;top:5px;">';
html+='<img src="'+chs_188112[vnr].thumb+'" style="width:510px;height:383px;top:-32px;position:relative;">';
html+='</div>';
html+='<div style="width:500px;height:140px;position:absolute;left:5px;top:324px;background-color:#AAA;padding:5px;"><div style="overflow:hidden;height:140px;"><div style="margin: 2px 3px; font-size:16px;color:#555555;">'+chs_188112[vnr].title+'</div><div style="margin: 2px 5px; font-size:13px;line-height:13px;color:#ffffff;overflow:hidden;height:40px;"  title="'+chs_188112[vnr].desc+'">'+chs_188112[vnr].desc+'</div><div style="padding: 3px 5px; letter-spacing:1px; background-color: #aaa; color: white; position: absolute; right: 0px; top: -14px; font-size: 10px;">'+(vnr+1)+'/'+(chs_188112.length)+'</div></div></div>';
html+='<div style="position: absolute; width:72px;height:72px;top:201px;left:224px;z-index:200;cursor:pointer;cursor:hand;background:url(http://www.yubby.com/img/media_play72.png) no-repeat;" onClick="playstart_188112();"></div>';
	return html;
}

function chthumbhtmlSmall_188112(vnr,twidth,theight) {
	var html='';
	// 162 // 
	// 90 // max-height:122px;
	var twidth=491;		// width 500 3 cols = 480/3-10 = 150 
	var theight=136;
	var titleh=22;
	var dwidth=twidth;
	var iwidth=dwidth;
	var iheight=theight-4-titleh;
	var oimg=chs_188112[vnr];
	var ptop=(iheight-48)/2;
	var imgtooltip=chs_188112[vnr].desc;
	imgtooltip=imgtooltip.replace(/\<br\/\>/g," ");
	//alert(imgtooltip);
	
	html+='<div style="margin: 5px; float: left; position: relative; width: '+twidth+'px; height: '+theight+'px;border:2px solid #dedede;background-color:#ffffff">';
		//html+='<div style="width:'+dwidth+'px;background:#f6f6f6;margin:0 auto 6px auto;overflow:hidden;position:relative;">';
			html+='<div style="width:'+iwidth+'px;height:'+iheight+'px;background:#cccccc;overflow:hidden;position:relative;">';
				html+='<img style="position:absolute;border:0 solid #ffffff;padding:0;margin:0;left:'+oimg.tleft+'px;top:'+oimg.ttop+'px;width:'+oimg.twidth+'px;height:'+oimg.theight+'px;cursor: pointer;" onclick="playChannel_188112('+vnr+')" title="'+imgtooltip+'" src="'+chs_188112[vnr].thumb+'" />';
										html+='<div style="position: absolute; width:48px;height:48px;top:'+ptop+'px;right:10px;z-index:200;cursor:pointer;cursor:hand;background:url(http://www.yubby.com/img/media_play48.png) no-repeat;" onclick="playChannel_188112('+vnr+')"></div>';
							html+='</div>';
			html+='<div style="position: absolute; bottom: 0px; left: 0px;width:'+(twidth)+'px;height:'+titleh+'px;z-index:200;background-color:#ffffff;color:#888888;font-size:14px;line-height:normal;overflow:hidden;white-space: nowrap;padding:0px 0px 0px 0px;cursor: pointer;" onclick="playChannel_188112('+vnr+')">'+chs_188112[vnr].title+'</div>';

		//html+='</div>';

	html+='</div>';
	return html;
}

// cp 1..npages
function paginationhtml_188112(cp,npages) {
	if (npages<=1)
		return '';	// empty if no pagination..
	var html='';
	html+='<div class="pages">';
	if (cp>1) {
		// we CAN prev!
		html+= '<span class="pageblock" onclick="gotopage_188112('+(cp-1)+');">&#x25C0;</span>';
	}
	else {
		html+= '<span class="pageblock_disabled">&#x25C0;</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_188112('+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_188112('+(cp+1)+');">&#x25B6;</span>';
	else
		html+='<span class="pageblock_disabled">&#x25B6;</span>';
	html+='</div>';
	return html;
}

var curr_channel=0;
function chplayurl_188112(vnr) {
	if (vnr==null)
		vnr=curr_channel;
	return 'http://www.yubby.com/channel/player/'+chs_188112[vnr].chid+'/first';
}



function closepopup_188112() {
  el = document.getElementById('ipopup_188112');
  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;
}



var matrix_curpg=1;
var matrix_npages=1;

function gotopage_188112(pg) {
	matrix_curpg=pg;
	var ippage=3;	// ncols*nrows;	// items per page
	matrix_npages= Math.ceil(chs_188112.length / ippage);	// global
	
	var mxs=document.getElementById('mxs_188112');
	var html='';
	for (var i=(matrix_curpg-1)*ippage,cv=0;i<chs_188112.length && cv<ippage;i++) {
		html+=  chthumbhtmlSmall_188112(i);
		cv++;
	}
	html+=  '<div style="clear:both;"></div>';
				if (matrix_npages>1) {
				html+=  '<div style="margin:0px 0px;position: absolute; bottom:4px;">'+paginationhtml_188112(matrix_curpg, matrix_npages)+'</div>';
			}
			mxs.innerHTML=html;
}

function chMatrixHtml_188112(base_width,base_height) {	// w500-12 = 488 
	// determine size and cols/rows and pages
	var ncols=1;	// Math.floor(base_width/300)+1;
	var nrows=3;	// Math.floor(base_height/200)+1;
	var ippage=3;	// ncols*nrows;	// items per page
	
	var twidth=491;	//Math.floor(base_width/ncols)-10;
	var theight=136;
	
	matrix_npages= Math.ceil(chs_188112.length / ippage);	// global
	
	var ch_html='';
	ch_html+='<div style="padding:0px;position:relative;background-color:#ffffff;width:'+(base_width)+'px;height:'+(base_height)+'px;">';
	ch_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;background-color:#fff; 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; background-color:#fff;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; background-color:#fff; color: #aaa; height: 12px; padding: 3px 6px;margin: 0px 4px 0px 0px;}\
		</style>';
	ch_html+=	'<div style="margin:0px 0px 0px 0px;" id="mxs_188112">';
	// for (var i=0,cv=0;i<chs_188112.length && cv<ippage;i++) {
	// 	ch_html+=  chthumbhtmlSmall_188112(i);
	// 	cv++;
	// }
	// ch_html+=  '<div style="clear:both;"></div>';
	// 
	// if (matrix_npages>1) {
	// 	ch_html+=  '<div style="margin:10px 0px;position:abolute;bottom:0px;">'+paginationhtml_188112(matrix_curpg, matrix_npages)+'</div>';
	// }

	ch_html+=	'</div>';
	ch_html+=  '<div style="clear:both;"></div>';
	ch_html+='</div>';
	return ch_html;
}

//--------------------------------------------- POPUP -----------------------------------------------------

// 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 closech_188112() {
  el = document.getElementById('chplayer_188112');
  if (el) {
    el.parentNode.removeChild(el);
  } 
}
// obsolete
function closeVideoPlayer_188112() {
	// close screen
	closevid_188112();
	// call to flash object
	getFlashObject("videostrip_188112").videoDeselect(0);
}

function playChannel_188112(vnr) {

	// close old one
	closech_188112();
	curr_channel=vnr;
	// open new
	var ch_div = document.createElement('div');
	var title='hello';
	ch_div.id = "chplayer_188112";
	ch_div.style.position = 'absolute';
	ch_div.style.border = 'none';
	var base_width=500;
	var base_height=500;
	
	ch_div.style.width = (base_width+14)+'px';
	ch_div.style.height = (base_height+16+2*22)+'px';
	ch_div.style.zIndex = '10000';
	//ch_div.style.border = "5px solid #cccccc";
	
	if (true) {
		// 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;
		ch_div.style.position = 'absolute';
		ch_div.style.top = popup_top + 'px';
		ch_div.style.left = popup_left + 'px';
	}
	else {
		// left or right of widget
		var top = vp_offsetTop(wgElm_188112);
		var left = vp_offsetLeft(wgElm_188112);

		// left or right
	    if (left < document.body.clientWidth/2) {
			ch_left = left +520; // - 8;
			alert('hij zit links, left='+left);
	    } else {

			ch_left = left - (base_width+2*17+10) ; // 402 plus borders 2x17 
			alert ('left='+left+' basew='+base_width);
	    }
		top=top; // - 3;
	
		//alert('video_left='+video_left+' top='+top);
		ch_div.style.top = top + 'px';
		ch_div.style.left = ch_left + 'px';
	}
	//	$skins['simple']=array('wskin'=>'simple','wbgcol'=>'#ffffff','wborder'=>'0px solid #fff');
	var ch_html = '<div style="padding:3px 3px 3px 3px;position:relative;border:0px solid #ffffff;background-color:#ffffff;">';
	ch_html +='<iframe name="playerframe" class="playerframe"	src = "http://www.yubby.com/widget/embed/square/'+chs_188112[vnr].chid+'/selected_item:first/autoplay:Y/lang:en/500/skin:simple" width="500" height="500" frameborder=0 scrolling="no" allowtransparency="true"></iframe>';
	ch_html +=	   '<div onclick="closech_188112();" style="position:absolute;top:13px;right:13px;cursor:pointer;cursor:hand;background:url(http://www.yubby.com/img/icon_bwht_close22.png) no-repeat;width:24px;height:24px;z-index:10000;"></div>\
					</div>';
					
	ch_div.innerHTML=ch_html;
	document.body.appendChild(ch_div);
}






