/////////////////////////////////////////////
//
// Javascript to include ogg/vorbis & ogg/theora in <object> as well
// as non-standard <embed> html tags. Should degrade pretty gracefully,
// especially after a few updates ;)
//
// The latest, greatest version of this script can be included like this:
// <script type="text/javascript" src="http://kobold.loud.nl/jsOggObj/jsOggObj.js" />
//
// v0.1 by Michael van Schaik, 2008 (LGPL) 
//
///////////////////////////////////

function oggTheoraObject(div_id, url, autoplay, loop, m_width, m_height) {
	/*this.div_id = div_id;
	this.url = url;
	this.autoplay = autoplay;
	this.loop = autoplay;
	this.m_width = m_width;
	this.m_height = m_height;*/
	this.varstoWrite = "";
	this.EMBEDvar = function(varname, varvalue){
		this.varstoWrite += " "+varname+"=\""+varvalue+"\"";
	}
	this.parmstoWrite = "";
	this.OBJparam = function(parmname, parmvalue){
		this.parmstoWrite += " <param name=\""+parmname+"\" value=\""+parmvalue+"\">";
	}
	this.div_towriteto = document.getElementById( div_id );
	this.oldcontent = this.div_towriteto.innerHTML;
	this.reset = function() {
		this.div_towriteto.innerHTML = this.oldcontent;
	}
	this.write = function() {
		// YES! of course this should be changed to the <video> tag later on!
		this.div_towriteto.innerHTML = "<embed type=\"video/ogg\" autoplay=\""+autoplay+"\" loop=\""+loop+"\" src=\""+url+"\" height=\""+m_height+"\" width=\""+m_width+"\" controller=\"true\" scale=\"aspect\">";
		//this.div_towriteto.innerHTML = "<object type=\"video/ogg\" width=\""+m_width+"\" height=\""+m_height+"\"><param name=\"src\" value=\""+url+"\"><param name=\"autoplay\" value=\""+autoplay+"\"> <param name=\"controller\" value=\"true\"> <param name=\"scale\" value=\"aspect\">"+ this.parmstoWrite +"<embed type=\"video/ogg\" autoplay=\""+autoplay+"\" loop=\""+loop+"\" src=\""+url+"\" height=\""+m_height+"\" width=\""+m_width+"\" controller=\"true\" scale=\"aspect\" "+this.varstoWrite+">";
		//this.div_towriteto.innerHTML = "<object type=\"video/ogg\" data=\""+url+"\" width=\""+m_width+"\" height=\""+m_height+"\"><param name=\"src\" value=\""+url+"\">alt : <a href=\""+url+"\">oggtheora</a></object>";
	}
}

function oggVorbisObject(div_id, url, autoplay, loop, m_width, m_height) {
	/*this.div_id = div_id;
	this.url = url;
	this.autoplay = autoplay;
	this.loop = autoplay;
	this.m_width = m_width;
	this.m_height = m_height;*/
	this.varstoWrite = "";
	this.EMBEDvar = function(varname, varvalue){
		this.varstoWrite += " "+varname+"=\""+varvalue+"\"";
	}
	this.parmstoWrite = "";
	this.OBJparam = function(parmname, parmvalue){
		this.parmstoWrite += " <param name=\""+parmname+"\" value=\""+parmvalue+"\">";
	}
	this.div_towriteto = document.getElementById( div_id );
	this.oldcontent = this.div_towriteto.innerHTML;
	this.reset = function() {
		this.div_towriteto.innerHTML = this.oldcontent;
	}
	this.write = function() {
		// YES! of course this should be changed to the <video> tag later on!
		this.div_towriteto.innerHTML = "<embed type=\"audio/ogg\" autoplay=\""+autoplay+"\" loop=\""+loop+"\" src=\""+url+"\" height=\""+m_height+"\" width=\""+m_width+"\" controller=\"true\" scale=\"aspect\">";
		//this.div_towriteto.innerHTML = "<object type=\"video/ogg\" width=\""+m_width+"\" height=\""+m_height+"\"><param name=\"src\" value=\""+url+"\"><param name=\"autoplay\" value=\""+autoplay+"\"> <param name=\"controller\" value=\"true\"> <param name=\"scale\" value=\"aspect\">"+ this.parmstoWrite +"<embed type=\"video/ogg\" autoplay=\""+autoplay+"\" loop=\""+loop+"\" src=\""+url+"\" height=\""+m_height+"\" width=\""+m_width+"\" controller=\"true\" scale=\"aspect\" "+this.varstoWrite+">";
		//this.div_towriteto.innerHTML = "<object type=\"video/ogg\" data=\""+url+"\" width=\""+m_width+"\" height=\""+m_height+"\"><param name=\"src\" value=\""+url+"\">alt : <a href=\""+url+"\">oggtheora</a></object>";
	}
}
