function Param() {
	this.key = null;
	this.value = null;
}

function JavaMonitor() {
	this.jsid = "";
	this.enabled = true;
	this.stop = false;
	this.javainstall = false;
	this.width = 1;
	this.height = 1;
	this.archive = "";
	this.service = "";
	this.paramArray = new Array();
	this.attribArray = new Array();
	this.jshelpid = null;
	this.helpContent=applimediaconfig.webroot+"jsp/applet/helpcontent.jsp?service=test";
}
JavaMonitor.prototype.stopappletdetection = function() {
	// alert("stopappletdetection");
	javaMonitor.stop = true;
	if (javaMonitor.enabled === true) {
		javaMonitor.hide();
	}
};
JavaMonitor.prototype.hide = function() {
	var help = domUtil.getById(this.jshelpid);
	if(help){
		tool.hide(help);
	}
};
JavaMonitor.prototype.display = function() {
	if (this.stop === false) {
		this.displayHelp();
	}else {
		this.hide();
	}
};
JavaMonitor.prototype.addParam = function(key, value) {
	var p = new Param();
	p.key = key;
	p.value = value;
	this.paramArray.push(p);
};
JavaMonitor.prototype.addAttrib = function(key, value) {
	var p = new Param();
	p.key = key;
	p.value = value;
	this.attribArray.push(p);
};
JavaMonitor.prototype.init = function() {
	//alert("start init");
	this.addAttrib("classid", "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93");
	var stylevalue = "width:" + this.width + "px;height: " + this.height
			+ "px;visibility: visible;position: relative;top: 0px;left: 0px";
	this.addAttrib("style", stylevalue);
	var id = "viewverapplet" + this.service;
	this.addAttrib("name", id);
	this.addAttrib("id", id);
	this.addAttrib("archive", this.archive);
	this.addAttrib("codebase", "http://java.sun.com/update/1.6.0/jinstall-6u13-windows-i586.cab#Version=1,5,0,0");
	
	this.addParam("type", "application/x-java-applet");
	if(this.jshelpid===null){
		this.jshelpid = this.jsid;
	}

}

JavaMonitor.prototype.build = function() {
	var d = domUtil;
	var parent = d.getById(this.jsid);

	
	if (applimediaconfig.browser.isIE === true) {
		//alert("javamonitor is IE");
		//TA BUG WITH OBJECT TAG AND DOM THEREFORE USE INNERHTML INSTEAD
		var content="";
		content+="<object";
		var a = this.attribArray;
		var end = a.length;
		for (i = 0; i < end; i += 1) {
			var p = a[i];
			
		//if(p.key !="style"){
		var c= 	p.key+"=\""+ p.value+"\"";
		//alert("c=["+c+"]");
			content+=" "+c;
		// }
		}
		content+=" >"
		a = this.paramArray;
		end = a.length;
		for (i = 0; i < end; i += 1) {
			var p = a[i];
			var key = p.key;
			//alert("addAttribute key=[" + key + "] value=[" + p.value + "]");
			content+="<param name=\""+key+"\" value=\""+ p.value+"\" />";
		}
		content+="</object>";
		parent.innerHTML=content;
	} else {
		var obj = d.createElement("embed");
		var a = this.attribArray;
		var end = a.length;
		for (i = 0; i < end; i += 1) {
			var p = a[i];
			d.addAttribute(obj, p.key, p.value);
		}
		a = this.paramArray;
		end = a.length;
		for (i = 0; i < end; i += 1) {
			var p = a[i];
			d.addAttribute(obj, p.key, p.value);
		}
		parent.appendChild(obj);
	}
};

JavaMonitor.prototype.displayHelp =function(){
	//var txt = "webApplicationSharingListener.flash="+webApplicationSharingListener.flash +" moderator="+moderator;
	//alert(txt);
	//var it = JavaMonitor;
	var id = this.jshelpid;
	tool.ajax_loadContent(id,this.createURL(),false);
	var el =domUtil.getById(id);
	if(el){domUtil.setClass(el,"");}
};
JavaMonitor.prototype.createURL =function(){
	var ret=this.helpContent;
	var d= new Date();
	ret +="&ts="+d.getTime();
	//alert("createURL=["+ret+"]");
	return ret;
};
