function getElementsByClassName(className) { 
	var retnode = [];
	var myclass = className;
 	var elem = document.getElementsByTagName('*');
	for (var i = 0; i < elem.length; i++) {
		if (elem[i].id == null || elem[i].id == '') {
			continue;
		}
		var classes =elem[i].className.split(' ');
		for (var j = 0; j < classes.length; j++) {
			
			if (classes[j] == className) {
				retnode.push(elem[i].id);
				continue;
			}
		}
	}  
	return retnode; 
}

function showType(feedType) {
// make all my competitors invisible
	var cdivs = getElementsByClassName('youtubefeed');
	for (var el in cdivs) {
		var d = document.getElementById(cdivs[el]);
		d.style.visibility = 'hidden';
		d.style.display = 'none';
		// el.style.visibility = 'hidden';
		// el.style.display = 'none';
	}

// show the type
	var tdive = document.getElementById(feedType);
	if (tdive) {
		tdive.style.visibility = 'visible';
		tdive.style.display = 'block';
	} else {
		alert("feed type: " + feedType + " does not exist");

	}
}


function showYTVideo(where, which, site, width, disablePopout) {
	var height;
	if (width) {
		if (width == '100%') { 
			height = '100%';
		} else { 
			height =  Math.floor(width / 16 * 9);
		}
	}  else {
		width = 512;
		height = 288;
	}


	var d = document.getElementById(where);
	if(!d) {
		alert("no " + where);
		return;
	}
	var src = srcGet('/?service=getasset&type=video&output_format=json&url=' + which);
       	var info = JSON.parse(src);
	debug(info);

	if (!which) {
		alert("no video id");
		return;
	}
	var attributes = new Object();
	var params = new Object();
	var flashvars = new Object();
	// flashvars.extid = info.extid;
	flashvars.youtube = 'true';
	flashvars.linkTextColor = '#cccccc';
	flashvars.linkTextRolloverColor = '#cc00cc';
	flashvars.bronsonOrb = window.location.hostname;
	flashvars.videoUrl = info['url'];
	if (disablePopout) {
		flashvars.popout = 1;
	}
	flashvars.orbUrl = window.location.hostname;
	

	params.menu = "true";
	params.allowFullScreen = 'true';
	params.allowScriptAccess = 'always';
	try { 
		swfobject.embedSWF('/swf/bronsonHqPlayer.swf', where, width, height, '10.0.0', false, flashvars, params, attributes);
	} catch (e) {
		debug("error embedding swf: " + e);
	}

}
