function GetQuest3DPlayer () {
	return document.getElementById("Quest3DObject");
}

function DetectQuest3DPlayer () {
	var detected = false;
	if (navigator.appVersion.indexOf("MSIE") != -1 && navigator.appVersion.toLowerCase().indexOf("win") != -1) {
			detected = DetectQuest3DPlayerActiveX();
	}else {
		if (navigator.mimeTypes && navigator.mimeTypes["application/quest"]) {
			if (navigator.mimeTypes["application/quest"].enabledPlugin && navigator.plugins && navigator.plugins["Quest3D Player"]) {
				detected = true;
			}
		}
	}
	return detected;
}

function CreateQuest3DPLayer(URL, width, height){
	width = (width==null ? 640 : width);
	height = (height==null ? 480 : height);
	URL = (URL==null ? "no 3d specified in html" : URL);

	if (DetectQuest3DPlayer()) {
		if (navigator.appVersion.indexOf("MSIE") != -1){
			document.write('<SCRIPT LANGUAGE="javascript" FOR=Quest3DObject Event="OnEvent">\n');
			document.write('onEvent();\n');
			document.write('</SCRIPT>\n');
			document.write('<object id="Quest3DObject" classid="clsid:84EB0322-E663-46FF-88DD-1E2175BA90FA" width="'+width+'" height="'+height+'" CODEBASE="http://www.quest3d.com/webplugin/download/quest3dactivex41.cab"> \n');
			document.write('  <param name="URL" value="'+URL+'" /> \n');
			document.write('  <param name=name="BackColor" value="16777215" /> \n');
			document.write('  <param name="CheckUpdate" value=1 /> \n');
			document.write('</object>');
		}else{
			document.write('<embed id="Quest3DObject" documentURL ="'+ document.URL +'"  src="'+URL+'" type="application/quest" width=' + width + ' height=' + height + ' checkUpdate=1>\n');
		}
	}else{
		installerURL = "http://quest3d.com/webplugin/quest3dplayer_4_2_0_install.exe";
		document.write('<div align="center" width="'+width+'" height="'+height+'"> \n');
		document.write('<table border="0" width="'+width+'" height="'+height+'" style="border-collapse: collapse" bgcolor="#FFFFFF"><tr><td align="center">');
		document.write('<a href= ' + installerURL + '><img src="http://www.quest3d.com/webplugin/getquest3dplayer.png" border="0"/></a>\n');
		document.write('</td></tr></table></div> \n');

		AutomaticReload();
	}
}

function AutomaticReload () {
	navigator.plugins.refresh();
	if (DetectQuest3DPlayer())
		window.location.reload();
	setTimeout('AutomaticReload()', 500)
}

function QSetValue(group, channelname, value){
	GetQuest3DPlayer().SetChannelValue(group, channelname, value);
}
function QSetText(group, channelname, text){
	GetQuest3DPlayer().SetChannelText(group, channelname, text);

}

function QGetValue(group, channelname, value){
	return GetQuest3DPlayer().ChannelValue(group, channelname);
}
function QGetText(group, channelname, text){
	return GetQuest3DPlayer().ChannelText(group, channelname);
}

