/* javascript for vplayer (wordpress plugin) by shahee ilyas */

var vplayer_onclick
var vp_status = 1
function playMovie (path, duration, id, width, height) {
	var duration = duration || 30;
	var width = width || 320;
	var height = height || 240;
	var src = path + "&dur=" + duration;
	var vp = document.getElementById(id);
	vplayer_onclick = vp.getAttribute('onclick')
	clear(vp)
	flash = '<object type="application/x-shockwave-flash" width="' + width + '" height="' + height + '" data="' + src + '"><param name="movie" value="' + src + '" /></object>';
	inserthtml(vp, flash);
	vp_status = 0;
	vp.removeAttribute('onclick');
}

function movieSwitch (path, duration, id, isrc, width, height) {
	var vp = document.getElementById(id);
	if (!vp_status) {
		clear (vp)
		vp.setAttribute('onclick',vplayer_onclick);
		html = '<img src="' + isrc + '" />'
		inserthtml(vp, html);
		vp_status = 1
	} else {
		playMovie (path, duration, id, width, height)
	}
}

function inserthtml (obj, html) {
	obj.innerHTML = html;
	obj.style.visibility = "visible";
}

function clear(obj) {
 	obj.innerHTML = "";
	obj.style.visibility = "hidden";
}
