//zet variabelen in js zelf, zodat ze maar 1x moeten aangepast worden voor alle players
var caburl='http://193.191.175.4/CGPlugin.cab#Version=1,3,202,138';
var xpiurl='http://193.191.175.4/CastGateClient.xpi';
var jarurl='http://193.191.175.4/CGClient.jar';

//var server1 = '224.1.2.3:1234';
var server1 = '233.10.51.21:7070';
var server2 = '';


var bRTP = false;

//Gets the name of the client's operating system.
function getOSName() {
	if (navigator.appVersion.indexOf("Win")!=-1) return "Windows"; 
	if (navigator.appVersion.indexOf("Mac")!=-1) return "MacOS"; 
	if (navigator.appVersion.indexOf("X11")!=-1) return "UNIX"; 
	if (navigator.appVersion.indexOf("Linux")!=-1) return "Linux"; 
	return "Unknown OS";
}

//Loads the ActiveX plugin for an ActiveX compatible browser, else the XPI plugin is
//loaded in Mozilla-compliant browsers on Windows and the JAVa plugin is loaded for
//all the other combinations.
function loadPlugin(channel1, channel2, width, height, color, textcolor, bRTP, caburl, xpiurl, appleturl) {
  
	if(window.ActiveXObject) {
		loadActiveX(channel1, channel2, width, height, color, textcolor, caburl);
	}
	else {
		var OSName = getOSName();
		if(OSName=="Windows") {
			loadXPIPlugin(channel1, channel2, width, height, color, textcolor, xpiurl);
		}
		else {
			loadJavaPlugin(channel1, channel2, width, height, color, textcolor, bRTP, appleturl);
		}
	}
	
	
}

//Loads the ActiveX component as plugin.
function loadActiveX(channel1, channel2, width, height, color, textcolor, caburl) {
	document.write('<OBJECT classid="CLSID:F6626826-7767-4BE1-8D27-79D185E13C31" id="CGPlugin" ');
	document.write('codebase="'+caburl+'" height="'+height+'" width="'+width+'">');
	document.write('<PARAM NAME="_Version" VALUE="65536">');
	document.write('<PARAM NAME="_ExtentX" VALUE="2646">');
	document.write('<PARAM NAME="_ExtentY" VALUE="1323">');
	document.write('<PARAM NAME="_StockProps" VALUE="0">');
	document.write('<PARAM NAME="color" value="'+color+'">');
	document.write('<PARAM NAME="textcolor" value="'+textcolor+'">');
	document.write('<PARAM NAME="ch1" VALUE="'+channel1+'">');
	if(channel2.length!=0) {
		document.write('<PARAM NAME="ch2" VALUE="'+channel2+'">');
	}
	document.write('</OBJECT>'); 
}

//Loads the Native Plugin for Mozilla based browsers
function loadXPIPlugin(channel1, channel2, width, height, color, textcolor, xpiurl) {
	document.write('<object id="CGPlugin" type="application/x-CastgateData" ');
	document.write('width="500" height="20" codebase="'+xpiurl+'" ');
	document.write('" CH1="'+channel1+'" CH2="'+channel2+'" color="'+color+'" textcolor="'+textcolor+'">');
	document.write('<P>You need the CastGate Plugin: Get it <A href="'+xpiurl+'" target="_blank">here</a></P>');
	document.write('</object>');
}

//Loads the JAVa plugin
function loadJavaPlugin(channel1, channel2, width, height, color, textcolor, bRTP, appleturl) {
	document.write('<object classid = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" codebase = "http://java.sun.com/products/plugin/autodl/jinstall-1_4-windows-i586.cab#Version=1,4,0,0" width = "'+width+'" height = "'+height+'" name = "CastGateClient">');
	document.write('<param name="code" value="CG.CGClient.class" />');
	document.write('<param name="archive" value="'+appleturl+'" />');
	document.write('<param name="name" value="CGPlugin" />');
	document.write('<param name="type" value="application/x-java-applet" />');
	document.write('<param name="scriptable" value="false" />');
	document.write('<param name="BgColor" value="'+color+'"/>');
	document.write('<param name="channel1" value="' + channel1 + '"/>');
	if(channel2.length>0) {
		document.write('<param name="channel2" value="' + channel2 + '"/>');
	}
	if(bRTP) {
		document.write(' <param name="RTP" value="yes"/>');
	}
	document.write('<coment>');
	document.write('<embed width="'+width+'" height="'+height+'" BgColor="'+color+'" type="application/x-java-applet" ');
	document.write('code="CG.CGClient.class" archive="'+appleturl+'" name="CastGateClient" ');
	document.write('scriptable="false"');
	document.write('channel1="' + channel1 +'" ');
	if(channel2.length>0) {
		document.write('channel2="' + channel2 + '" ');
	}
	if(bRTP) {
		document.write(' RTP="yes"');
	}
	document.write('pluginspage="http://java.sun.com/products/plugin/index.html#download">');
	document.write('</embed> </coment> </object>');
}



function LoadCastGateWMPE(ch1,ch2,b) {
var channel1 = new String(ch1);
var channel2 = new String(ch2);
var bUDP = Boolean(b);

loadPlugin(channel1, channel2, iexpurl, xpiurl, jarurl, 1); 

}

