function videoInit() {
	if (!document.getElementsByTagName) return;
    if (arguments.callee.done) return;
    arguments.callee.done = true;
	var el = $$('.reel');
	if (el.length == 0) return
	var curEl = null;
	for (var i = 0; i < el.length; i++) {
		el[i].onclick = videoShow;
		if (lastVideo == i) curEl = el[i]
	}
	if (curEl) videoMake(curEl)
}

window.addEvent('domready', videoInit);

/*********************************************************************************/

function videoShow(e) {
	var e = e || window.event;
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
	if (this == videoCur) return;
	videoMake(this);
}

function videoMake(el) {
	if (videoCur) {
		videoCur.className = 'reel'
		videoCur.innerHTML = $('reelHolder').innerHTML
	}
	
	videoCur = el
	$('reelHolder').innerHTML = videoCur.innerHTML
	
	var vh = $('videoHolder').innerHTML
	vh = vh.replace(/__caption__/g, el.getAttribute('videoCaption'))
	vh = vh.replace(/__size__/g, el.getAttribute('videoSize'))
	vh = vh.replace(/__video__/g, el.getAttribute('videoUrl'))
	vh = vh.replace(/__width__/g, el.getAttribute('videoWidth'))
	vh = vh.replace(/__height__/g, 20 + parseInt(el.getAttribute('videoHeight')))
	videoCur.className = 'video'
	videoCur.innerHTML = vh
}

var videoCur = false, lastVideo = -1;


