function createWindow(classid, jars, title, width, height) {
  var agent = navigator.userAgent.toLowerCase();
  var newWin = window.open("","", "width="+width+",height="+height+",scrollbar=no,status=no,statusbar=no,resizable=no");
  newWin.document.write("<html>\n");
  newWin.document.write(" <head><title>" + title + "</title>\n");
  newWin.document.write(" <style type=\"text/css\">body { margin: 0; padding: 0; }</style>\n");
  newWin.document.write("<script type='text/javascript'> function setTitle(msg) {if(msg.length !=0) {document.title =msg} else {document.title = '"+title+"'}} </script>");
  newWin.document.write(" </head><body>\n");
	if (agent.indexOf("msie")==-1) { // not IE
    newWin.document.write('<object classid="java:'+classid+'"');
    newWin.document.write('		codetype="application/java"');
    newWin.document.write('		archive="'+jars+'"');
    newWin.document.write('		width="'+width+'" height="'+height+'">');
    newWin.document.write('	<param name="mayscript" value="Y">');
    newWin.document.write('</object>');
	} else {
		newWin.document.write('<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"');
		newWin.document.write('			codebase="http://java.sun.com/update/1.5.0/jinstall-1_5_0_02-windows-i586.cab#Version=1,5,0,0"')
		newWin.document.write('			width="'+width+'" height="'+height+'">');
		newWin.document.write('<param name="code" value="'+classid+'" />');
		newWin.document.write('<param name="archive" value="'+jars+'" />');
		newWin.document.write('<param name="type" value="application/x-java-applet;jpi-version=1.5.0" />');
		newWin.document.write('</object>');

	}
  newWin.document.write("</body>\n</html>\n");
}

function createWindowVCR(classid, jars, title, width, height, awidth, aheight) {
  var agent = navigator.userAgent.toLowerCase();
  var newWin = window.open("","", "width="+width+",height="+height+",scrollbar=no,status=no,statusbar=no,resizable=no");
  
  newWin.document.write("<html>\n");
  newWin.document.write(" <head><title>" + title + "</title>\n");
  newWin.document.write(" <style type=\"text/css\">body { margin: 0; padding: 0; }</style>\n");
  newWin.document.write(" </head>\n<body>\n");
	if (agent.indexOf("msie")==-1) { // not IE
    newWin.document.write('<object classid="java:'+classid+'"');
    newWin.document.write('		codetype="application/java"');
    newWin.document.write('		archive="'+jars+'"');
    newWin.document.write('		width="'+awidth+'" height="'+aheight+'">');
    newWin.document.write('	<param name="mayscript" value="Y">');
    newWin.document.write('</object>');
	} else {
		newWin.document.write('<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"');
		newWin.document.write('			codebase="http://java.sun.com/update/1.5.0/jinstall-1_5_0_02-windows-i586.cab#Version=1,5,0,0"')
		newWin.document.write('			width="'+awidth+'" height="'+aheight+'">');
		newWin.document.write('<param name="code" value="'+classid+'" />');
		newWin.document.write('<param name="archive" value="'+jars+'" />');
		newWin.document.write('<param name="type" value="application/x-java-applet;jpi-version=1.5.0" />');
		newWin.document.write('</object>');

	}
  newWin.document.write("</body>\n</html>\n");
}

function createVCRTarget() {
	createWindowVCR('edu.wisc.trace.targetsamples.vcr.VCRLauncher', 'vcr-s.jar, targetsdk-s.jar, xercesImpl-s.jar, clink-s.jar', 'VCR '+ ++vcrs, '300', '110','325', '300');
	return true;	
}

function createSwingClient() {
	createWindow('edu.wisc.trace.urcsamples.swingclient.SwingClientLauncher', 'swingclient-s.jar, urcsdk-s.jar, xercesImpl-s.jar, clink-s.jar', 'Swing Client ' + ++swings, '370', '620');
	return true;
}


function createBabbleUrc() {
	alert("not implemented");
}

function createTVTarget() {
	createWindow('edu.wisc.trace.targetsamples.tv.TVLauncher', 'tv-s.jar, targetsdk-s.jar, xercesImpl-s.jar, clink-s.jar, plugin.jar', 'TV ' + ++tvs, '765', '521');
	return true;	
}

function createAlarmClockTarget() {
	createWindow('edu.wisc.trace.targetsamples.alarmclock.AlarmClockLauncher', 'alarmclock-s.jar, targetsdk-s.jar, xercesImpl-s.jar, clink-s.jar', 'Alarm Clock ' + ++alarms, '410', '125');
	return true;	
}

function createLightSwitchTarget() {
	createWindow('edu.wisc.trace.targetsamples.lightswitch.LightSwitchLauncher', 'lightswitch-s.jar, targetsdk-s.jar, xercesImpl-s.jar, clink-s.jar', 'Light Switch ' + ++lights, '600', '300');
	return true;	
}

var vcrs = 0;
var alarms = 0;
var swings = 0;
var lights = 0;
var tvs = 0;
