var domVideoLinks = function(theID,useLightbox){
	if ( !document.getElementById || !document.getElementsByTagName ) { return; }
	var theLinks = document.getElementById('videobox_'+theID).getElementsByTagName('a');
	if ( theLinks.length == 0 || useLightbox ) { return; }
	for ( a = 0 ; a < theLinks.length ; a++ ) {
		theLinks[a].ythref = theLinks[a].href;
		theLinks[a].href = "#";
		theLinks[a].target = "_self";
		theLinks[a].onclick = function(){
			var YoutubeURL = this.ythref.split(/[\/?&=]+/);
			var theMode = YoutubeURL.shift();
			var theSite = YoutubeURL.shift();
			var theVideoURL = theMode + '//';
			var theWidth = parseInt(document.getElementById('video_'+theID).width,10);
			var theHeight = parseInt(document.getElementById('video_'+theID).height,10);
			switch( theSite ) {
				case 'www.youtube.com' :
					theVideoURL = theVideoURL + theSite + '/v/' + YoutubeURL[2] + '&hl=en&fs=1&rel=0';
					break;
				case 'exposureroom.com' :
				case 'www.exposureroom.com' :
					theVideoURL = 'http://exposureroom.com/flash/xrVideoPlayer.swf?domain=exposureroom.com/&size=md&titleColor=black&assetId='+YoutubeURL.pop();
					break;
			}
			document.getElementById('videoplayer_'+theID).innerHTML = '<object id="video_'+theID+'" type="application/x-shockwave-flash" data="'+theVideoURL+'" width="'+theWidth+'" height="'+theHeight+'"><param name="movie" value="'+theVideoURL+'" /><param name="wmode" value="transparent" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /></object>';
			for ( x = 0 ; x < theLinks.length ; x++ ) {
				theLinks[x].className = '';
			}
			this.className = 'active';
			return false;
		};
	}
}
window.addEvent('domready',function(){
	var theMenus = document.getElementsByTagName('ul');
	for ( var m = 0 ; m < theMenus.length ; m++ ) {
		if ( theMenus[m].className == 'cms_videolinks' || theMenus[m].className == 'cms_videobox' ) {
			var theParent = theMenus[m].parentNode;
			var theElementID = theParent.id.split('_')[1];
			domVideoLinks(theElementID,(theMenus[m].className == 'cms_videobox'));
		}
	}
});