﻿function BrowserDetect() {
   this.web2meetingCompliant =false;
   var ua = navigator.userAgent.toLowerCase(); 
   //alert("ua="+ua);
   this.userAgent = ua ;
   // browser engine name
   this.isGecko       = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
   this.isAppleWebKit = (ua.indexOf('applewebkit') != -1);

   // browser name
   this.isKonqueror   = (ua.indexOf('konqueror') != -1); 
   this.isSafari      = (ua.indexOf('safari') != - 1);
   this.isOpera       = (ua.indexOf('opera') != -1); 
   this.isAol         = (ua.indexOf('aol') != -1); 
   this.isIE          = (ua.indexOf('msie') != -1 && !this.isOpera && (ua.indexOf('webtv') == -1) ); 
   this.isMozilla     = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
   this.isFirebird    = (ua.indexOf('firebird/') != -1);
   this.isFirefox    = (ua.indexOf('firefox/') != -1); // Add by TA
   this.java=false;
   this.flash=false;
   this.flashmajor=-1;
      this.isVista=false;
      this.isXP=false;
       this.isWin2000=false;
      this.isWin2003=false;
      this.isWin2008=false;
      
 
  var NSTest = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && !this.isOpera && !this.isSafari && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
   this.isNS = false;
  if(NSTest){
   this.isNS = true ;
  }

   // spoofing and compatible browsers
   this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
   this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);
   
   // rendering engine versions
   this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
   this.equivalentMozilla = ( (this.isGecko) ? parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) ) : -1 );
   this.appleWebKitVersion = ( (this.isAppleWebKit) ? parseFloat( ua.substring( ua.indexOf('applewebkit/') + 12) ) : -1 );
   
   // browser version
   this.versionMinor = parseFloat(navigator.appVersion); 
   
   // correct version number
   if (this.isGecko && !this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('/', ua.indexOf('gecko/') + 6) + 1 ) );
   }
   else if (this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
   }
   else if (this.isIE && this.versionMinor >= 4) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
   }
   else if (this.isKonqueror) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
   }
   else if (this.isSafari) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('safari/') + 7 ) );
   }
   else if (this.isOpera) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera') + 6 ) );
   }
   
   this.versionMajor = parseInt(this.versionMinor); 
   
   // dom support TA changed
   this.isDOM1  =false ;
   this.isDOM2Event = false
   if(document.getElementById){
   	 	this.isDOM1  =true ;
   }
   if(document.addEventListener && document.removeEventListener){
    this.isDOM2Event = true;
   }
   
   // css compatibility mode
   this.mode = document.compatMode ? document.compatMode : 'BackCompat';

   // platform
   this.isWin    = (ua.indexOf('win') != -1);
   this.isWin32  = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
  //alert(ua);
   this.isWin2000  = (this.isWin && ( ua.indexOf('nt 5.0') != -1));
   this.isVista  = (this.isWin && ( ua.indexOf('nt 6.0') != -1));
   this.isXP=(this.isWin && ( ua.indexOf('xp') != -1));
   this.isWin2003=(this.isWin && ( ua.indexOf('nt 5.2') != -1));
   //this.isWin2008=(this.isWin && ( ua.indexOf('xp') != -1));
   
   
  //alert("this.isVista  ="+this.isVista  );
   this.isMac    = (ua.indexOf('mac') != -1);
   this.isUnix   = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
   this.isLinux  = (ua.indexOf('linux') != -1);
   
   // specific browser shortcuts
   this.isNS6up = (this.isNS && this.versionMajor >= 6);
   this.isNS7x = (this.isNS && this.versionMajor == 7);
   this.isNS7up = (this.isNS && this.versionMajor >= 7);
   this.isNS72up = (this.isNS && this.versionMinor >= 7.2);
   this.isIE4x = (this.isIE && this.versionMajor == 4);
   this.isIE4up = (this.isIE && this.versionMajor >= 4);
   this.isIE5x = (this.isIE && this.versionMajor == 5);
   this.isIE55 = (this.isIE && this.versionMinor == 5.5);
   this.isIE55down = (this.isIE && this.versionMinor <= 5.5);
   this.isIE5up = (this.isIE && this.versionMajor >= 5);
   this.isIE55up = (this.isIE && this.versionMinor >= 5.5 );
   this.isIE6x = (this.isIE && this.versionMajor == 6);
   this.isIE6up = (this.isIE && this.versionMajor >= 6);
   this.isIE7down = (this.isIE && this.versionMajor <= 7);
   this.isIE4xMac = (this.isIE4x && this.isMac);
  // alert("isIE6up="+this.isIE6up);
}
function ApplimediaConfig(){
this.webroot ="/"; this.captureID = "capturediv";this.drawID = "drawdiv";this.graphics =null;this.browser= new BrowserDetect();this.onLoadListener=new Array();this.buttonImgHeight="28";this.buttonImgWidth="28";
}
ApplimediaConfig.prototype.addOnLoadListener=function(l){
this.onLoadListener.push(l);
};
ApplimediaConfig.prototype.notifyOnLoadListener=function(){
var a=this.onLoadListener;var end = a.length;
for(var i=0;i<end;i+=1){a[i].notifyOnLoad();}
};
var applimediaconfig= new ApplimediaConfig(); 
var w2mconf=applimediaconfig;
var toolMenu=null;
function DOMUtil() {
this.specialArray = new Array("onmouseover","onmouseout","onclick","onchange" ,"onmousedown","onkeydown","onkeypress","onkeyup","onmousemove");
}
var domUtil = new DOMUtil();

DOMUtil.prototype.addAttribute = function(parentNode,attributeName,value){
var node = document.createAttribute(attributeName);
node.value = value;
parentNode.setAttributeNode(node) ;
if(document.all){
if(domUtil.isSpecial(attributeName) ){
var myfunction =null;
var command = "myfunction =function(){"+value+"}";
eval(command);
parentNode.setAttribute(attributeName,myfunction) ;
var evalcommand = "parentNode." + attributeName +  "= myfunction";
eval(evalcommand);
}
else if(attributeName =="class"){
domUtil.setClassAttribute(parentNode,value);
}
}
};
DOMUtil.prototype.isSpecial = function(attributeName){
var ret = false;
var array = domUtil.specialArray;
var end = array.length;
for(var i=0;i<end  && ret === false;i+=1){
if(array[i] === attributeName){ret =true ;}
}
return ret;
};
DOMUtil.prototype.addAttributeArray = function(parentNode,arrayAttr){
var i = 0;
var end = arrayAttr.length;
while(i<end){
var key = arrayAttr[i];
i+=1;
var value = arrayAttr[i];
this.addAttribute(parentNode,key,value);
i+=1;
}
return parentNode;
};
DOMUtil.prototype.setClass =function(el,v){
	domUtil.setClassAttribute(el,v);
};
DOMUtil.prototype.setClassAttribute =function(el,newValue){
var attr="class";if(applimediaconfig.browser.isIE7down===true){attr="className";}el.setAttribute(attr, newValue);
};
DOMUtil.prototype.getClass =function(el){
var ret =el.className;
return ret;
};
DOMUtil.prototype.createIFRAME =function(id,className){
return domUtil.createElement("iframe",id,className);
};
DOMUtil.prototype.createDIV =function(id,className){
return domUtil.createElement("div",id,className);
};
DOMUtil.prototype.createSPAN =function(id,className){
return domUtil.createElement("span",id,className);
};
DOMUtil.prototype.createTABLE =function(id,className){
return domUtil.createElement("table",id,className);
};
DOMUtil.prototype.createTBODY =function(id,className){
return domUtil.createElement("tbody",id,className);
};
DOMUtil.prototype.createTR =function(id,className){
return domUtil.createElement("tr",id,className);
};
DOMUtil.prototype.createTD =function(id,className,valign){
var ret =  domUtil.createElement("td",id,className);
if(valign){ret.valign=valign;}
return ret;
};
DOMUtil.prototype.createIMG =function(id,className,src,title){
var ret = domUtil.createElement("img",id,className);
ret.src=src;
ret.title=title;
return ret;
};
DOMUtil.prototype.createElement =function(type,id,className){
var ret = document.createElement(type);
if(id){ domUtil.addAttribute(ret,"id",id);}
if(className) {domUtil.addAttribute(ret,"class",className);}
return ret;
};
DOMUtil.prototype.createText =function(txt){
return document.createTextNode(txt);
};
DOMUtil.prototype.getById =function(id){
return document.getElementById(id);
};
DOMUtil.prototype.setXY =function(el,x,y){
if(x){el.style.left = x+"px";}
if(y){el.style.top = y+"px";}
};
DOMUtil.prototype.getItem =function(attrib,key){
return attrib.getNamedItem(key).value; 
};

function Tool(){
	this.sessionUserServletWebPath = applimediaconfig.webroot +"SessionUserServlet";
	this.gDestination = null;
	this.quitFlag = false;
	this.gTrace= false;
	this.gDebug= false;
	this.gClosed = false;
	this.alreadyQuit=false;
	this.timeend =0;
    this.requestTime = 1000*60;
    this.ENDTIME = 1000 * 60 * 60 * 6 ;
    this.hex=new Array("00","14","28","3C","50","64","78","8C","A0","B4","C8","DC","F0");
    this.r=1;
 this.g=1;
 this.b=1;
 this.seq=1;
 this.domainpage =null;
 this.externalGoBackURL =null;
 this.enableCache = true;
this.jsCache = new Array();
this.dynamicContent_ajaxObjects = new Array();
}


Tool.prototype.loadXMLDoc = function (url, params) {
	var requesterObject = applimediaRequestManager.createRequest();
	requesterObject.caller = tool;
	requesterObject.sendData(url, params, true);
};

Tool.prototype.createXMLDoc = function () {
var ret =null;
//for IE
if (window.ActiveXObject){
          ret = new ActiveXObject('Microsoft.XMLDOM');
          ret.async="false";
 }//for FF
else if (document.implementation && document.implementation.createDocument){
 ret = document.implementation.createDocument("","",null);
} 
return ret ;
};
Tool.prototype.startWith = function (str, pattern) {
	var ret = false;
	if (str.indexOf(pattern) === 0) {
		ret = true;
	}
	return ret;
};
Tool.prototype.createHTMLArray = function () {
	var array = new Array();
	this.addHTMLArray(array, "&quot;", "\"");
	this.addHTMLArray(array, "&agrave;", "\xe1");
	this.addHTMLArray(array, "&aacute;", "\xe2");
	this.addHTMLArray(array, "&acirc;", "\xe3");
	this.addHTMLArray(array, "&auml;", "\xe4");
	this.addHTMLArray(array, "&Agrave;", "\xc0");
	this.addHTMLArray(array, "&Aacute;", "\xc1");
	this.addHTMLArray(array, "&Acirc;", "\xc2");
	this.addHTMLArray(array, "&Auml;", "\xc3");
	this.addHTMLArray(array, "&egrave;", "\xe8");
	this.addHTMLArray(array, "&eacute;", "\xe9");
	this.addHTMLArray(array, "&ecirc;", "\xea");
	this.addHTMLArray(array, "&euml;", "\xeb");
	this.addHTMLArray(array, "&ccedil;", "\xe7");
	this.addHTMLArray(array, "&Ccedil;", "\xc7");
	this.addHTMLArray(array, "&Egrave;", "\xc8");
	this.addHTMLArray(array, "&Eacute;", "\xc9");
	this.addHTMLArray(array, "&Ecirc;", "\xca");
	this.addHTMLArray(array, "&Euml;", "\xcb");
	this.addHTMLArray(array, "&Igrave;", "\xcc");
	this.addHTMLArray(array, "&Iacute;", "\xcd");
	this.addHTMLArray(array, "&Icirc;", "\xce");
	this.addHTMLArray(array, "&Iuml;", "\xcf");
	this.addHTMLArray(array, "&igrave;", "\xec");
	this.addHTMLArray(array, "&iacute;", "\xed");
	this.addHTMLArray(array, "&icirc;", "\xee");
	this.addHTMLArray(array, "&iuml;", "\xef");
	this.addHTMLArray(array, "&Ugrave;", "\xd9");
	this.addHTMLArray(array, "&Uacute;", "\xda");
	this.addHTMLArray(array, "&Ucirc;", "\xdb");
	this.addHTMLArray(array, "&Uuml;", "\xdc");
	this.addHTMLArray(array, "&ugrave;", "\xf9");
	this.addHTMLArray(array, "&uacute;", "\xfa");
	this.addHTMLArray(array, "&ucirc;", "\xfb");
	this.addHTMLArray(array, "&uuml;", "\xfc");
	this.addHTMLArray(array, "&Ograve;", "\xd3");
	this.addHTMLArray(array, "&Oacute;", "\xd4");
	this.addHTMLArray(array, "&Ocirc;", "\xd5");
	this.addHTMLArray(array, "&Ouml;", "\xd6");
	this.addHTMLArray(array, "&ograve;", "\xf2");
	this.addHTMLArray(array, "&oacute;", "\xf3");
	this.addHTMLArray(array, "&ocirc;", "\xf4");
	this.addHTMLArray(array, "&ouml;", "\xf5");
	this.addHTMLArray(array, "&ntilde;", "\xf1");
	this.addHTMLArray(array, "&iquest;", "\xbf");
	return array;
};
Tool.prototype.addHTMLArray = function (array, htmlValue, javascriptValue) {
	array[array.length] = new Array(htmlValue, javascriptValue);
};
Tool.prototype.sessionEndMessage = function () {
//alert("tool.externalGoBackURL =" + tool.externalGoBackURL);
	if (tool.alreadyQuit === false) {
		window.location.href = tool.externalGoBackURL;
	}
};
Tool.prototype.convert = function (data) {
	var ret = data;
	var array = this.createHTMLArray();
	for (var i = 0; i < array.length; i += 1) {
		var temp = array[i];
		var regex = new RegExp(temp[0], "g");
		ret = ret.replace(regex, temp[1]);
	}
	return ret;
};
Tool.prototype.countInstances = function (content, word) {
	var substrings = content.split(word);
	return substrings.length - 1;
};
Tool.prototype.confirm = function (txt) {
	var ret = false;
	ret = confirm(tool.convert(txt));
	return ret;
};
Tool.prototype.alert = function (txt) {
	alert(tool.convert(txt));
};
Tool.prototype.changeTitleContent = function (newvalue) {
	document.title = newvalue;
};
function replaceDIVText(docDisplay, name, data) {
	var parent = null;
	var content = null;
	if (docDisplay === null) {
		docDisplay = document;
	}
	if (docDisplay.getElementById) {
		content = docDisplay.getElementById(name);
	} else {
		content = docDisplay.divs[name];
	}
	if (content) {
		if (document.all) {
			content.innerHTML = data;
        //alert("data IE" + data + "n content " +content.innerHTML  );
		} else {
			if (content.firstChild) {
				content.firstChild.nodeValue = data;
			}
        //alert("data OTHER " + data + "n content " +content.innerHTML  );
		}
	} 
}
function replaceDIVNode(docDisplay, name, node) {
	var parent = null;
	var content = null;
	if (docDisplay === null) {
		docDisplay = document;
	}
	content = docDisplay.getElementById(name);
	if (content) {
		var replaced = content.replaceChild(node, content.firstChild);
	} 
}
Tool.prototype.setClassAttribute = function (el, v) {
domUtil.setClassAttribute(el,v)
};
Tool.prototype.setColorAttribute = function (el, v) {
	el.style.backgroundColor = v;
};
Tool.prototype.replaceImage = function (imgID, newSrc) {
	var imgObj = document.getElementById(imgID);
	imgObj.src = newSrc;
};
Tool.prototype.getImageWidth = function (myImage) {
	if (document.layers) {
		var img = getImage(myImage);
		return img.width;
	} else {
		return tool.getElementWidth(myImage);
	}
	return -1;
};
Tool.prototype.getImageHeight = function (myImage) {
	if (document.layers) {
		var img = getImage(myImage);
		return img.height;
	} else {
		return tool.getElementHeight(myImage);
	}
	return -1;
};
Tool.prototype.getElementWidth = function (elemID) {
	return tool.getElementDim(elemID)[0];
};
Tool.prototype.getElementHeight = function (elemID) {
	return tool.getElementDim(elemID)[1];
};
Tool.prototype.getElementDim = function (elemID) {
	var elem = document.getElementById(elemID);
	var ret = new Array(elem.offsetWidth,elem.offsetHeight);
	return ret;
};
Tool.prototype.getMouseXY = function (e) {
	var ret = new Array();
	if (applimediaconfig.browser.isIE) { // grab the x-y pos.s if browser is IE
		tempX = event.clientX + document.body.scrollLeft;
		tempY = event.clientY + document.body.scrollTop;
	} else {  // grab the x-y pos.s if browser is NS
		tempX = e.pageX;
		tempY = e.pageY;
	}
	ret[0] = tempX;
	ret[1] = tempY;
	return ret;
};
Tool.prototype.getElementY = function (obj) {
	var ret = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			ret += obj.offsetTop;
			var sctop = 0;
			if (applimediaconfig.browser.isIE) {
				sctop = obj.scrollTop;
			} else {
			  //sctop = obj.offsetTop;
			}
			if (sctop > 0) {
			//alert("sctop value=" + sctop);
				ret -= sctop;
			}
			obj = obj.offsetParent;
		}
	} else {
		if (obj.y) {
			ret += obj.y;
		}
	}
		//alert(" ret y =" + ret);
	return ret;
};
Tool.prototype.getElementX = function (obj) {
	var ret = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			ret += obj.offsetLeft;
			if (obj.scrollLeft) {
				ret -= obj.scrollLeft;
			}
			obj = obj.offsetParent;
		}
	} else {
		if (obj.x) {
			ret += obj.x;
		}
	}
	return ret;
};


//*******************************************************************
Tool.prototype.sendClose = function (sessionname) {
	var requesterObject = applimediaRequestManager.createRequest();
	var data = "&SELECTEDSESSION=" + sessionname + "&action=close&ajax=true";
	requesterObject.caller = new CloseResponseReader();
	requesterObject.sendData(tool.sessionUserServletWebPath, data);
};
//*******************************************************************
function CloseResponseReader() {
	this.readyListener = readyListener;
	function readyListener(requesterObject) {
		var req = requesterObject.requester;
		tool.parseSessionCloseMessage(req);
	}
}
//*******************************************************************
Tool.prototype.parseSessionCloseMessage = function (req) {
	userListManager.endSession();
};

// 1 for visible
function toggleBox(doc, szDivID, iState) {
	if (doc.getElementById(szDivID)) {
		if (iState === true) {
			iState = 1;
		} else {
			if (iState === false) {
				iState = 0;
			}
		}
		var obj = doc.layers ? doc.layers[szDivID] : doc.getElementById ? doc.getElementById(szDivID).style : doc.all[szDivID].style;
		obj.visibility = doc.layers ? (iState ? "show" : "hide") : (iState ? "visible" : "hidden");
		if (doc.layers) {
			doc.layers[szDivID].visibility = iState ? "show" : "hide";
		} else {
			if (doc.getElementById) {
				obj = doc.getElementById(szDivID);
				obj.style.visibility = iState ? "visible" : "hidden";
			} else {
				if (doc.all) {
					doc.all[szDivID].style.visibility = iState ? "visible" : "hidden";
				}
			}
		}
	}
}
Tool.prototype.toggleBox = function (doc, szDivID, iState) {
	toggleBox(doc, szDivID, iState);
};
function command(params) {
	tool.command(tool);
}
function commandArraySlideShow(keyArray, valueArray) {
	commandArray(keyArray, valueArray);
}
function trace(message)
{ if (tool.gTrace)
    alert("TRACE: "+message);
}

function debug(message)
{ if (tool.gDebug)
    alert("DEBUG: "+message);
}
var logtext="";

function log(msg)
{ logtext=msg+"\n"+logtext;
  var ta=domUtil.getById("log");
  if (!ta)
    return;
  if (logtext.length>2500)
    logtext=logtext.substring(0,2500);
  ta.value=logtext;
}
Tool.prototype.command=function(params){
  debug("cmd("+params+")");
  var url="";
  //alert(params);
    url=applimediaconfig.webroot+ "WebCommandServlet" ;
   tool.loadXMLDoc(url,params);
};
function commandArray(list)
{ //alert("commandArray");
  var method="";
  var paramString="";
  var url="";
  for (var i=0; i< list.length ; i+=2)
    {
    var data = urlencode(list[i+1]);
     paramString+=""+list[i]+"="+data+"&";
    }
  var strLen=paramString.length;
  paramString=paramString.slice(0,strLen-1);
  //alert(paramString);
  url=applimediaconfig.webroot +"WebCommandServlet";
   tool.loadXMLDoc(url,paramString);
}
function urlencode(str) {
str = escape(str);
str = str.replace('+', '%2B');
str = str.replace('%20', '+');
str = str.replace('*', '%2A');
str = str.replace('/', '%2F');
str = str.replace('@', '%40');
return str;
}
function replaceContent(docDisplay, docTemp, divID) {
	var templist = null;
	var displaylist = null;
	if (docTemp.getElementById) {
		templist = docTemp.getElementById(divID);
		displaylist = docDisplay.getElementById(divID);
	} else {
		templist = docTemp.divs[divID];
		displaylist = docDisplay.divs[divID];
	}
	if (displaylist && templist) {
      //alert("displaylist.innerHTML :  " +displaylist.innerHTML );
		if (docTemp.all) {
			displaylist.innerHTML = templist.innerHTML;
			templist.innerHTML = "";
		} else {
			var node = displaylist.parentNode;
			node.replaceChild(templist, displaylist);
		}
	} else {
     //alert("DIV id = " +divID+ " displaylist   " +displaylist +" templist "  + templist );
	}
}
Tool.prototype.checkAtLeastOneUserSelected=function(checkbox_form) {
	var ret = false;
	for (var counter = 0; (ret === false) && (counter < checkbox_form.elements.length); counter += 1) {
		var current = checkbox_form.elements[counter];
		if (current.type === "checkbox") {
			if (current.name && current.name.indexOf("user") === 0) {
				ret = checkbox_form.elements[counter].checked;
			} else {
				if (current.name && current.name.indexOf("contactlist") === 0) {
					ret = checkbox_form.elements[counter].checked;
				}
			}
		}
	}
	return ret;
}
Tool.prototype.checkall = function (checkbox_form, value, pattern) {
	var i = 0;
	while (i < checkbox_form.elements.length) {
		var element = checkbox_form.elements[i];
		if (element.type == "checkbox" && this.startWith(element.id, pattern)) {
			element.checked = value;
		}
		i += 1;
	}
};
Tool.prototype.uncheckall = function (checkbox_form, pattern) {
	this.checkall(checkbox_form, false, pattern);
};
function limitAttachPowerPoint(main, form, file, monitor) {
	extArray = new Array(".pps", ".ppt",".pptx",".doc",".docx",".pdf", ".jpeg", ".jpg", ".png", ".gif");
	limitAttachFile(main, form, file, extArray, monitor);
}
function limitAttachFlash(main, form, file) {
	extArray = new Array(".swf");
	limitAttachFile(main, form, file, extArray);
}
function limitAttachZip(main, form, file) {
	extArray = new Array(".zip");
	limitAttachFile(main, form, file, extArray);
}
Tool.prototype.endWith = function (data, pattern) {
	var ret = false;
	var start = data.indexOf(pattern);
	if (start > -1) {
		var sub = data.substring(start);
		if (sub === pattern) {
			ret = true;
		}
	}
	return ret;
};
Tool.prototype.fullscreen = function () {
};
Tool.prototype.hide = function (el) {
	domUtil.setClassAttribute(el, "mainbehind");
};
Tool.prototype.quitTo = function (dest) {
	var loc = document;
	var b = loc.getElementsByTagName("body")[0];
	if (b && applimediaconfig.browser.isIE) {
		b.innerHTML = "";
	}
	loc.location.href = dest;
};
Tool.prototype.changetext = function (id) {
	var el = document.getElementById(id);
	var rainbow = "#" + tool.hex[tool.r] + tool.hex[tool.g] + tool.hex[tool.b];
	el.style.color = rainbow;
};
Tool.prototype.change = function (id) {
	if (this.seq == 6) {
		this.b -= 1;
		if (this.b === 0) {
			this.seq = 1;
		}
	}
	if (this.seq === 5) {
		this.r += 1;
		if (this.r == 12) {
			this.seq = 6;
		}
	}
	if (this.seq === 4) {
		this.g -= 1;
		if (this.g === 0) {
			this.seq = 5;
		}
	}
	if (this.seq === 3) {
		this.b += 1;
		if (this.b === 12) {
			this.seq = 4;
		}
	}
	if (this.seq === 2) {
		this.r -= 1;
		if (this.r === 0) {
			this.seq = 3;
		}
	}
	if (this.seq === 1) {
		this.g += 1;
		if (this.g === 12) {
			this.seq = 2;
		}
	}
	tool.changetext(id);
};
Tool.prototype.starteffect = function (id, interval) {
	if (!interval) {
		interval = 80;
	}
	var flash = setInterval("tool.change('" + id + "')", interval);
};
/**
Now button has been fouled up beyond all recognition. According to W3C its values should be:

    * Left button â 0
    * Middle button â 1
    * Right button â 2

According to Microsoft its values should be:

    * Left button â 1
    * Middle button â 4
    * Right button â 2
    
    * Left button â 1
    * Middle button â 3
    * Right button â 2
*/
Tool.prototype.convertTojavaButton = function (event) {
	var ret = event.button;
	if (applimediaconfig.browser.isIE === true) {
		if (ret === 4) {
			ret = 3;
		}
	} else {
		if (ret === 1) {
			ret = 3;
		} else {
			if (ret === 0) {
				ret = 1;
			}
		}
	}
	return ret;
};
Tool.prototype.gotoURL = function (urlend) {
	window.location.href = applimediaconfig.webroot + urlend;
};
Tool.prototype.inputHiddenContent = function (key, value) {
	return "<input type=\"hidden\" id=\"" + key + "\" name=\"" + key + "\" value=\"" + value + "\" />";
};
Tool.prototype.createTitleLine = function (id, title, leftCol, rightCol, minmax, minmaxcmd, cmdClose) {
	var d = domUtil;
	var ret = d.createTABLE(id + "divtitle", "CellSystemTitle CellSystemTitleBottomLine");
	ret.border = "0";
	ret.vspace = "0";
	ret.cellPadding = "0";
	ret.cellSpacing = "0";
	var tb = d.createTBODY(null, "nomargin");
	var tr = d.createTR(null, "nomargin");
	var i = 0;
	var width = 100 - (leftCol + rightCol) * 4;
	while (i < leftCol) {
		i += 1;
		var s = d.createTD(id + "spantitleleft" + i);
		tr.appendChild(s);
	}
	var td = d.createTD(id + "spantitlemiddle", "titlemiddle");
	td.width = width + "%";
	td.appendChild(d.createText(title));
	tr.appendChild(td);
	i = 0;
	while (i < rightCol) {
		i += 1;
		var idtxt = id + "spantitleright" + i;
	//alert("idtxt =" + idtxt);
		var tdr = d.createTD(idtxt);
		var cb3;
		if (minmax === true) {
			d.setClass(tdr, "arrowbutton");
			cb3 = new CustomButton();
			cb3.click = "mainMenuManager.reverseDisplayUsingID('" + id + "','" + minmaxcmd + "');";
			cb3.type = buttonM.typeARROW;
			cb3.id = id + "minmax";
			cb3.text = "";
			var b = buttonM.createButton(cb3);
			d.setClass(b, buttonM.arrowTopRightClass);
			tdr.appendChild(b);
		}
		tr.appendChild(tdr);
	}
	if (cmdClose) {
		if (cmdClose.length > 1) {
			var tdrclose = d.createTD(idtxt);
			d.setClass(tdrclose, "arrowbutton");
			cb3 = new CustomButton();
			cb3.click = cmdClose;
			cb3.type = buttonM.typeARROW;
			cb3.id = id + "close";
			cb3.text = "";
			b = buttonM.createButton(cb3);
			d.setClass(b, buttonM.closeiconClass);
			tdrclose.appendChild(b);
			tr.appendChild(tdrclose);
		}
	}
	tb.appendChild(tr);
	ret.appendChild(tb);
	return ret;
};
Tool.prototype.titleLineHideCloseButton = function (id) {
	tool.setClassCloseButton(id, "mainbehind");
};
Tool.prototype.titleLineShowCloseButton = function (id) {
	tool.setClassCloseButton(id, "arrowbutton closeicon");
};
Tool.prototype.setClassCloseButton = function (id, classValue) {
	var el = domUtil.getById(id + "close");
	if (el) {
		domUtil.setClass(el, classValue);
	}
};
function CustomButton() {
	this.text = "";
	this.imgAttributeArray = new Array();
	this.id = "";
	this.visible = true;
	this.type = null;
	this.over = null;
	this.out = null;
	this.click = null;
}
CustomButton.prototype.addImgAttrib = function (key, value) {
	this.imgAttributeArray.push(key);
	this.imgAttributeArray.push(value);
};
function ButtonManager() {
	this.typeIMG = "img";
	this.typeCLASSICBIG = "classicbig";
	this.typeARROW = "arrow";
	this.arrowBottomRightClass = "arrowbutton arrowbuttonbottom arrowbuttonright";
	this.arrowTopRightClass = "arrowbutton arrowbuttontop arrowbuttonright";
	this.arrowLeftClass = "arrowbutton arrowbuttonuserleft";
	this.arrowRightClass = "arrowbutton arrowbuttonuserright";
	this.closeiconClass = "arrowbutton closeicon";
}
ButtonManager.prototype.mouseover = function (el) {
	el.style.fontWeight = "bolder";
};
ButtonManager.prototype.mouseout = function (el) {
	el.style.fontWeight = "normal";
};
var buttonM = new ButtonManager();
ButtonManager.prototype.assignMouse = function (el, customButton) {
	var d = domUtil;
	if (customButton.over) {
		d.addAttribute(el, "onmouseover", customButton.over);
	}
	if (customButton.out) {
		d.addAttribute(el, "onmouseout", customButton.out);
	}
	if (customButton.click) {
		d.addAttribute(el, "onclick", customButton.click);
	}
};
ButtonManager.prototype.createButton = function (customButton) {
	var d = domUtil;
	var ret = null;
	var className = null;
	var type = customButton.type;
	if (type == buttonM.typeIMG) {
		ret = document.createElement("BUTTON");
		var img = document.createElement("IMG");
		className = "classicbuttonimg";
		d.addAttribute(ret, "class", className);
		img = d.addAttributeArray(img, customButton.imgAttributeArray);
//buttonM.assignMouse(img,customButton);
		customButton.over = "tool.setClassAttribute(this,'classicbuttonimgover');";
		customButton.out = "tool.setClassAttribute(this,'classicbuttonimg');";
		buttonM.assignMouse(ret, customButton);
		ret.appendChild(img);
	} else {
		if (type == buttonM.typeCLASSICBIG) {
// alert("type==buttonM.typeCLASSICBIG ");
			ret = d.createSPAN();
			var input = document.createElement("input");
			className = "classicbutton classicbuttonbig";
			d.addAttribute(input, "type", "button");
			d.addAttribute(input, "class", className);
			customButton.over = "buttonM.mouseover(this);";
			customButton.out = "buttonM.mouseout(this);";
			buttonM.assignMouse(input, customButton);
			d.addAttribute(input, "id", customButton.id);
			d.addAttribute(input, "title", customButton.text);
			d.addAttribute(input, "value", customButton.text);
			ret.appendChild(input);
		} else {
			if (type == buttonM.typeARROW) {
				ret = document.createElement("BUTTON");
				className = "arrowbutton";
				d.addAttribute(ret, "id", customButton.id);
				buttonM.assignMouse(ret, customButton);
			}
		}
	}
	d.addAttribute(ret, "class", className);
	d.addAttribute(ret, "title", customButton.text);
	return ret;
};
Tool.prototype.resizeEl = function (el, w, h) {
	if (w) {
		el.style.width = w + "px";
	}
	if (h) {
		el.style.height = h + "px";
	}
};
Tool.prototype.resize = function (id, w, h) {
	var el = domUtil.getById(id);
	if (el) {
		tool.resizeEl(el, w, h);
	}
};
Tool.prototype.getWindowWidth = function () {
	return tool.getWindowSize()[0];
};
Tool.prototype.getWindowHeight = function () {
	return tool.getWindowSize()[1];
};
/* width and height*/
Tool.prototype.getWindowSize = function () {
	var ret = new Array();
	var w = 0, h = 0;
	var doc = document;
	if (typeof (window.innerWidth) == "number") {
    //Non-IE
		w = window.innerWidth;
		h = window.innerHeight;
	} else {
		if (doc.documentElement && (doc.documentElement.clientWidth || doc.documentElement.clientHeight)) {
    //IE 6+ in 'standards compliant mode'
			w = doc.documentElement.clientWidth;
			h = doc.documentElement.clientHeight;
		} else {
			if (doc.body && (doc.body.clientWidth || doc.body.clientHeight)) {
    //IE 4 compatible
				w = doc.body.clientWidth;
				h = doc.body.clientHeight;
			}
		}
	}
	ret[0] = w;
	ret[1] = h;
	return ret;
};

function Hashtable() {
	this.hash = new Array();
	this.keys = new Array();
}

Hashtable.prototype.hash = null;
Hashtable.prototype.keys = null;
Hashtable.prototype.location = null;

Hashtable.prototype.put = function (key, value) {
	if (value === null) {
		alert("Hashtable value is null");
		return;
	}
	if (this.containsKey(key) ===false) {
		this.keys.push(key);
	}
	this.hash[key] = value;
};
Hashtable.prototype.containsKey = function (key) {
	var ret = false;
	var end = this.keys.length;
	for (var i = 0; i < end && ret === false; i += 1) {
		var el = this.keys[i];
		if (el !== null && el === key) {
			ret = true;
		}
	}
	return ret;
};
Hashtable.prototype.get = function (key) {
	return this.hash[key];
};
Hashtable.prototype.remove = function (key) {
	for (var i = 0; i < this.keys.length; i += 1) {
	var k = this.keys[i];
		if (key == k) {
			this.hash[k] = null;
			this.keys.splice(i, 1);
			return;
		}
	}
};
Hashtable.prototype.size = function () {
	return this.keys.length;
};
/**
 * getKey
 * Return: The first key contains the given value, or null if not found
 */
Hashtable.prototype.getKeyOfValue = function (value) {
	for (var i = 0; i < this.keys.length; i += 1) {
		if (this.hash[this.keys[i]] == value) {
			return this.keys[i];
		}
	}
	return null;
};
/**
 * toString
 * Returns a string representation of this Hashtable object in the form of a set of entries,
 * enclosed in braces and separated by the ASCII characters ", " (comma and space).
 * Each entry is rendered as the key, an equals sign =, and the associated element,
 * where the toString method is used to convert the key and element to strings.
 * Return: a string representation of this hashtable.
 */
Hashtable.prototype.toString = function () {
	try {
		var s = new Array(this.keys.length);
		s[s.length] = "{";
		for (var i = 0; i < this.keys.length; i += 1) {
			s[s.length] = this.keys[i];
			s[s.length] = "=";
			var v = this.hash[this.keys[i]];
			if (v) {
				s[s.length] = v.toString();
			} else {
				s[s.length] = "null";
			}
			if (i != this.keys.length - 1) {
				s[s.length] = ", ";
			}
		}
	}
	catch (e) {
		//do nothing here :-)
	}
	finally {
		s[s.length] = "}";
	}
	return s.join("");
};
/**
 * add
 * Concatanates hashtable to another hashtable.
 */
Hashtable.prototype.add = function (ht) {
	try {
		ht.moveFirst();
		while (ht.next()) {
			var key = ht.getKey();
			//put the new value in both cases (exists or not).
			this.hash[key] = ht.getValue();
			//but if it is a new key also increase the key set
			if (this.get(key) !== null) {
				this.keys[this.keys.length] = key;
			}
		}
	}
	catch (e) {
		//do nothing here :-)
	}
	finally {
		return this;
	}
};
Hashtable.prototype.iterator = function () {
	var end = this.keys.length;
	var ret = new Array();
	for (var i = 0; i < end; i += 1) {
		var el = this.get(this.keys[i]);
		ret.push(el);
	}
	return ret;
};




Tool.prototype.ajax_showContent=function(divId,ajaxIndex,url,tooltip)
{
var array=tool.dynamicContent_ajaxObjects;
var content=array[ajaxIndex].response;
//alert("ajaxIndex="+ajaxIndex+" divId="+divId+" content=["+content+"]");
	domUtil.getById(divId).innerHTML = content;
	if(tool.enableCache){
		tool.jsCache[url] = 	array[ajaxIndex].response;
	}
	array[ajaxIndex] = false;
	if(tooltip===true){tooltipFactory.positionTooltip()};
};

Tool.prototype.ajax_loadContent=function(divId,url,tooltip)
{
var t = tool;
	if(t.enableCache===true && t.jsCache[url]){
		domUtil.getById(divId).innerHTML = t.jsCache[url];
		return;
	}
	var ajaxIndex = t.dynamicContent_ajaxObjects.length;
	domUtil.getById(divId).innerHTML = 'Loading content - please wait';
	var s = new sack();
	t.dynamicContent_ajaxObjects[ajaxIndex] =s;
	s.requestFile = url;	// Specifying which file to get
	s.onCompletion = function(){ tool.ajax_showContent(divId,ajaxIndex,url,tooltip); };	// Specify function that will be executed after file has been found
	s.runAJAX(null);		// Execute AJAX function	
};

function createXMLHttpRequest(){
var ret =null;
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        ret = new XMLHttpRequest();
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        try{
			ret=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(err){
		ret=new ActiveXObject("Msxml2.XMLHTTP");
		}
    }
return ret ;
}
/* Simple AJAX Code-Kit (SACK) */
/* 2005 Gregory Wild-Smith */
/* www.twilightuniverse.com */
/* Software licenced under a modified X11 licence, see documentation or authors website for more details */

function sack(file){
	this.AjaxFailedAlert = "Your browser does not support the enhanced functionality of this website, and therefore you will have an experience that differs from the intended one.\n";
	this.requestFile = file;
	this.method = "POST";
	this.URLString = "";
	this.encodeURIString = true;
	this.execute = false;

	this.onLoading = function() { };
	this.onLoaded = function() { };
	this.onInteractive = function() { };
	this.onCompletion = function() { };

	this.createAJAX = function() {
	this.xmlhttp = createXMLHttpRequest();
	};
	
	this.setVar = function(name, value){
		if (this.URLString.length < 3){
			this.URLString = name + "=" + value;
		} else {
			this.URLString += "&" + name + "=" + value;
		}
	}
	
	this.encVar = function(name, value){
		var varString = encodeURIComponent(name) + "=" + encodeURIComponent(value);
	return varString;
	}
	
	this.encodeURLString = function(string){
	var ret = string;
	if(ret.length>0){
		varArray = ret.split('&');
		var end =varArray.length;
		for (i = 0; i <end ; i+=1){
			urlVars = varArray[i].split('=');
			if (urlVars[0].indexOf('amp;') != -1){
				urlVars[0] = urlVars[0].substring(4);
			}
			varArray[i] = this.encVar(urlVars[0],urlVars[1]);
		}
		ret=varArray.join('&');
		}
	return ret ;
	}
	
	this.runResponse = function(){
		eval(this.response);
	}
	
	this.runAJAX = function(urlstring){
		this.responseStatus = new Array(2);
		if(this.failed && this.AjaxFailedAlert){ 
			alert(this.AjaxFailedAlert); 
		} else {
		//alert("this.URLString=["+this.URLString+"] urlstring=["+urlstring+"]");
			if (urlstring !==null){ 
				if (this.URLString.length > 0){
					this.URLString = this.URLString + "&" + urlstring; 
				} else {
					this.URLString = urlstring; 
				}
			}
			if (this.encodeURIString){
				var timeval = new Date().getTime(); 
				this.URLString = this.encodeURLString(this.URLString);
				this.setVar("rndval", timeval);
			}
			//alert("this.URLString=["+this.URLString+"]");
			if (this.element) { this.elementObj = document.getElementById(this.element); }
			if (this.xmlhttp) {
				var self = this;
				if (this.method == "GET") {
					var totalurlstring = this.requestFile + "?" + this.URLString;
					//alert("totalurlstring="+totalurlstring);
					this.xmlhttp.open(this.method, totalurlstring, true);
				} else {
					this.xmlhttp.open(this.method, this.requestFile, true);
				}
				if (this.method == "POST"){
  					try {
						this.xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded')  
					} catch (e) {}
				}
				this.xmlhttp.send(this.URLString);
				this.xmlhttp.onreadystatechange = function() {
					switch (self.xmlhttp.readyState){
						case 1:
							self.onLoading();
						break;
						case 2:
							self.onLoaded();
						break;
						case 3:
							self.onInteractive();
						break;
						case 4:
							self.response = self.xmlhttp.responseText;
							self.responseXML = self.xmlhttp.responseXML;
							self.responseStatus[0] = self.xmlhttp.status;
							self.responseStatus[1] = self.xmlhttp.statusText;
							self.onCompletion();
							if(self.execute){ self.runResponse(); }
							if (self.elementObj) {
								var elemNodeName = self.elementObj.nodeName;
								elemNodeName.toLowerCase();
								if (elemNodeName == "input" || elemNodeName == "select" || elemNodeName == "option" || elemNodeName == "textarea"){
									self.elementObj.value = self.response;
								} else {
									self.elementObj.innerHTML = self.response;
								}
							}
							self.URLString = "";
						break;
					}
				};
			}
		}
	};
this.createAJAX();
}

Array.prototype.remove=function(s){
var i =0;
var index = -1;
for(;i<this.length && index===-1;i+=1){
var el =this[i];
if(el===s){index=i;}
}
if(index != -1)this.splice(index, 1);
};