//gw.js for group 21 / widget 931917 / WxH: 275x900 / 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_931917= new Array();	// channels
var curch_931917=0;			// first channel

var wgElm_931917 = document.getElementById('viidoo_gw_931917');
if (wgElm_931917) {
	vp_createwg();
}

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

function vp_createwg() {
	var html='<div id="widget_flash_931917" style="width: 275px;height:900px;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_931917.push({chid:7736, thumb: 'http://www.yubby.com/img/channels/000005480w884h120.jpg',twidth: '744.03333333333',theight: '101',tleft: '-249.01666666667',tright: '-45.333333333333',ttop: '0',tbottom: '0',title: 'CMN Travels: Hawaii', desc: 'Chef Mark visits Hawaii on the \&quot;So Much More Hawaii\&quot; tour, sponsored by the Hawaii Tourism Authority. Visiting Kauai, Maui, The Big Island and Oahu, Chef Mark meets some of the amazing people doing their best to produce quality food in the Aloha State.<br/><br/>A production of the Culinary Media Network.<br/>www.culinarymedianetwork.com<br/><br/>Travel \&amp; accommodations provided by Hawaii Tourism Authority'});
	chs_931917.push({chid:7735, thumb: 'http://www.yubby.com/img/channels/000005446w799h120.jpg',twidth: '672.49166666667',theight: '101',tleft: '-213.66666666667',tright: '-9.1416666666667',ttop: '0',tbottom: '0',title: 'CMN Travels: Indonesia', desc: 'Chef Mark travels to Indonesia for the Pesta Blogger conference, the national blogging festival. On the way, he stops in Bali, Jogjakarta, and Jakarta to learn about the foods and traditions of this incredibly diverse archipelago.<br/><br/>A production of the Culinary Media Network.<br/>www.culinarymedianetwork.com'});
	chs_931917.push({chid:7749, thumb: 'http://www.yubby.com/img/channels/000005420w647h120.jpg',twidth: '544.55833333333',theight: '101',tleft: '-149.7',tright: '54.825',ttop: '0',tbottom: '0',title: 'CMN Travels: Nova Scotia', desc: 'Jennifer and Chef Mark explore the great seafood, wine, and chefs of the maritime province of Nova Scotia in Canada. From shucking scallops to exploring the farmer\'s market and meeting many of the top chefs of Halifax, we leave no stone unturned to find the best of Nova Scotia.<br/><br/>A production of the Culinary Media Network.<br/>www.culinarymedianetwork.com'});
	chs_931917.push({chid:7751, thumb: 'http://www.yubby.com/img/channels/000005424w627h120.jpg',twidth: '527.725',theight: '101',tleft: '-141.28333333333',tright: '63.241666666667',ttop: '0',tbottom: '0',title: 'CMN Travels: Colonial Virginia', desc: 'Jennifer Iannolo and Chef Mark explore Colonial Williamsburg and Jamestown, learning about the Colonial foods of Virginia. They also discover that the contemporary foods of Virginia are pretty great too!<br/><br/>A production of the Culinary Media Network.<br/>www.culinarymedianetwork.com'});
	chs_931917.push({chid:7782, thumb: 'http://www.yubby.com/img/channels/000005477w749h120.jpg',twidth: '630.40833333333',theight: '101',tleft: '-192.625',tright: '11.9',ttop: '0',tbottom: '0',title: 'CMN Travels: Switzerland', desc: 'Chef Mark Tafoya \&amp; Jennifer Iannolo jet over to Zurich to learn what SWISS Airlines is doing to improve the image of airline food. While there, they explore the Christmas Market, taste seasonal delights, sample fondue \&amp; raclette, and pay a visit to Europe\'s oldest vegetarian restaurant. They also visit Luzern and Mount Pilatus.<br/><br/>A production of the Culinary Media Network.<br/>www.culinarymedianetwork.com<br/><br/>Travel \&amp; accommodations provided by SWISS Airlines \&amp; Switzerland Tourism.'});
	chs_931917.push({chid:7784, thumb: 'http://www.yubby.com/img/channels/000005479w768h120.jpg',twidth: '646.4',theight: '101',tleft: '-200.2',tright: '3.4833333333333',ttop: '0',tbottom: '0',title: 'CMN Travels: Sicily', desc: 'Chef Mark and Jennifer visit Sicily with the restaurateurs from GRI (Gruppo Ristoratori Italiani) on their annual Italian road trip, \&amp; learn about the ancient history of this Mediterranean island, as well as the traditional foods, from Olive Oil to Cassatas, tuna, blood oranges \&amp; Marsala wine.  Also included are quick \&quot;Fork in the Road\&quot; videos shot on the fly with a handheld camera.<br/><br/>A production of the Culinary Media Network.<br/>www.culinarymedianetwork.com<br/><br/>Travel \&amp; accomodations provided by GRI.'});
	chs_931917.push({chid:18058, thumb: 'http://www.yubby.com/img/channels/genbanner18058.jpg',twidth: '508.36666666667',theight: '101',tleft: '-131.18333333333',tright: '72.5',ttop: '0',tbottom: '0',title: 'CMN Travels: Wales', desc: 'Jennifer Iannolo and Chef Mark Tafoya experience Wales for the first time, from the bustling town of Cardiff to the Gower Food Festival. Let\'s not forget the Penderyn Whiskey, either!<br/><br/>Travel and Accommodations provided by Visit Britain.<br/><br/>A production of the Culinary Media Network.<br/>www.culinarymedianetwwork.com'});
	chs_931917.push({chid:18060, thumb: 'http://www.yubby.com/img/channels/000008754u.jpg',twidth: '508.36666666667',theight: '118.675',tleft: '-131.18333333333',tright: '72.5',ttop: '-9.2583333333333',tbottom: '-8.4166666666667',title: 'CMN Travels: Scotland', desc: 'Jennifer Iannolo and Chef Mark Tafoya travel with Jennifer\'s Mother to Scotland during \&quot;Homecoming 2009\&quot;, and discover alot about the local food and drink of Mum\'s homeland!<br/><br/>Travel and accommodations provided by Visit Britain.<br/><br/>A production of the Culinary Media Network.<br/>www.culinarymedianetwork.com'});
	chs_931917.push({chid:18064, thumb: 'http://www.yubby.com/img/channels/genbanner18064.jpg',twidth: '508.36666666667',theight: '101',tleft: '-131.18333333333',tright: '72.5',ttop: '0',tbottom: '0',title: 'CMN Travels: Alto Adige', desc: 'Chef Mark Tafoya and Jennifer Iannolo discover two great DOP products: Speck Alto Adige and Asiago Cheese. <br/><br/>A production of the Culinary Media Network.<br/>www.culinarymedianetwork.com'});
html+='<div id="thumb_931917" style="width:273px;height:898px;position:relative;padding:5px 0px 0 5px;">';
html+=chMatrixHtml_931917(263,888);
html +='<img style="position:absolute;right:20px;bottom:10px;height:25px;z-index:5;cursor:pointer;" src="http://www.yubby.com/img/project/yubby/logo_stroke.png" onclick="location.href=\'http://www.yubby.com/\';">';
html+='</div>';
	/******
	html +='<div style="height:26px;width:275px;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_931917();"><span style="color:#888;"></div>';
	html +='<img style="position:absolute;left:111px;top:0px;height:25px;z-index:5;cursor:pointer;" src="http://www.yubby.com/img/project/yubby/logo.png" onclick="location.href=vidplayurl_931917();">';
	html +='<img onclick="showmatrix_931917(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_931917();" style="position:absolute;left:175px;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_931917();" style="position:absolute;left:199px;top:1px;cursor:pointer;" src="http://www.yubby.com//img/widget/solo/skins/simple/iconstop24.png" title="stop"/>';
	html +='<img onclick="playstart_931917();" style="position:absolute;left:223px;top:1px;cursor:pointer;" src="http://www.yubby.com//img/widget/solo/skins/simple/iconplay24.png" title="play"/>';
	html +='<img onclick="playnext_931917();" style="position:absolute;left:247px;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_931917.innerHTML=html;
	gotopage_931917(1);
	wgElm_931917.style.display = 'block';
}

function playnext_931917() {
	if (curvid_931917 < chs_931917.length -1 ) {
		curvid_931917++;
		if (cpvideo_931917)
			playstart_931917();	// we are playing video
		else {
			var thumbdiv=document.getElementById('thumb_931917');
			thumbdiv.innerHTML=vidthumbhtml_931917(curvid_931917);
		}
	}
}
function playprev_931917() {
	if (curvid_931917 >0 ) {
		curvid_931917--;
		if (cpvideo_931917)
			playstart_931917();	// we are playing video
		else {
			var thumbdiv=document.getElementById('thumb_931917');
			thumbdiv.innerHTML=vidthumbhtml_931917(curvid_931917);
		}
	}
}
function playstart_931917(vnr) {
	closepopup_931917();	// close popup (if open)
	if (vnr==null)
		vnr=curvid_931917;
	else
		curvid_931917=vnr;	// set the current
	var thumbdiv=document.getElementById('thumb_931917');
	thumbdiv.innerHTML='<iframe name="playerframe" class="playerframe" src="http://www.yubby.com/widget/playvideo/'+chs_931917[vnr].vid+'/275/874/L/W" width="275" height="874" frameborder="0" scrolling="no" allowtransparency="true"></iframe>';
	cpvideo_931917=true;
}

function playstop_931917() {
	cpvideo_931917=false;
	var thumbdiv=document.getElementById('thumb_931917');
	thumbdiv.innerHTML=vidthumbhtml_931917(curvid_931917);
}

function chthumbhtml_931917(vnr) {
	var html='';
	html+='<div style="width:265px;height:166px; overflow:hidden; position:absolute;left:5px;top:5px;">';
html+='<img src="'+chs_931917[vnr].thumb+'" style="width:265px;height:199px;top:-16px;position:relative;">';
html+='</div>';
html+='<div style="width:255px;height:693px;position:absolute;left:5px;top:171px;background-color:#AAA;padding:5px;"><div style="overflow:hidden;height:693px;"><div style="margin: 2px 3px; font-size:16px;color:#555555;">'+chs_931917[vnr].title+'</div><div style="margin: 2px 5px; font-size:13px;line-height:13px;color:#ffffff;overflow:hidden;height:40px;"  title="'+chs_931917[vnr].desc+'">'+chs_931917[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_931917.length)+'</div></div></div>';
html+='<div style="position: absolute; width:72px;height:72px;top:401px;left:101.5px;z-index:200;cursor:pointer;cursor:hand;background:url(http://www.yubby.com/img/media_play72.png) no-repeat;" onClick="playstart_931917();"></div>';
	return html;
}

function chthumbhtmlSmall_931917(vnr,twidth,theight) {
	var html='';
	// 162 // 
	// 90 // max-height:122px;
	var twidth=246;		// width 500 3 cols = 480/3-10 = 150 
	var theight=127;
	var titleh=22;
	var dwidth=twidth;
	var iwidth=dwidth;
	var iheight=theight-4-titleh;
	var oimg=chs_931917[vnr];
	var ptop=(iheight-48)/2;
	var imgtooltip=chs_931917[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_931917('+vnr+')" title="'+imgtooltip+'" src="'+chs_931917[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_931917('+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_931917('+vnr+')">'+chs_931917[vnr].title+'</div>';

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

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

// cp 1..npages
function paginationhtml_931917(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_931917('+(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_931917('+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_931917('+(cp+1)+');">&#x25B6;</span>';
	else
		html+='<span class="pageblock_disabled">&#x25B6;</span>';
	html+='</div>';
	return html;
}

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



function closepopup_931917() {
  el = document.getElementById('ipopup_931917');
  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_931917(pg) {
	matrix_curpg=pg;
	var ippage=6;	// ncols*nrows;	// items per page
	matrix_npages= Math.ceil(chs_931917.length / ippage);	// global
	
	var mxs=document.getElementById('mxs_931917');
	var html='';
	for (var i=(matrix_curpg-1)*ippage,cv=0;i<chs_931917.length && cv<ippage;i++) {
		html+=  chthumbhtmlSmall_931917(i);
		cv++;
	}
	html+=  '<div style="clear:both;"></div>';
				if (matrix_npages>1) {
				html+=  '<div style="margin:0px 0px;position: absolute; bottom:4px;">'+paginationhtml_931917(matrix_curpg, matrix_npages)+'</div>';
			}
			mxs.innerHTML=html;
}

function chMatrixHtml_931917(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=6;	// Math.floor(base_height/200)+1;
	var ippage=6;	// ncols*nrows;	// items per page
	
	var twidth=246;	//Math.floor(base_width/ncols)-10;
	var theight=127;
	
	matrix_npages= Math.ceil(chs_931917.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_931917">';
	// for (var i=0,cv=0;i<chs_931917.length && cv<ippage;i++) {
	// 	ch_html+=  chthumbhtmlSmall_931917(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_931917(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_931917() {
  el = document.getElementById('chplayer_931917');
  if (el) {
    el.parentNode.removeChild(el);
  } 
}
// obsolete
function closeVideoPlayer_931917() {
	// close screen
	closevid_931917();
	// call to flash object
	getFlashObject("videostrip_931917").videoDeselect(0);
}

function playChannel_931917(vnr) {

	// close old one
	closech_931917();
	curr_channel=vnr;
	// open new
	var ch_div = document.createElement('div');
	var title='hello';
	ch_div.id = "chplayer_931917";
	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_931917);
		var left = vp_offsetLeft(wgElm_931917);

		// left or right
	    if (left < document.body.clientWidth/2) {
			ch_left = left +275; // - 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_931917[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_931917();" 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);
}





