﻿
// CALENDAR
// COLOR
// SELECTION
// MESSAGE

//#############################################################################
//#############################################################################
//#############################################################################
// CALENDAR

var arCalendarObject = new Array()
function CalendarObject(NewFrame,NewDate,NewLang,InitDraw,InitChange,NewEnabled) {
	var index = arCalendarObject.length; arCalendarObject[index] = this
	this.ObjectIndex	= index
	this.Frame			= NewFrame
	this.IsFrame		= (ListFind("DIV|SPAN|TABLE|TD",NewFrame.tagName) == false)
	this.Document       = (this.IsFrame == true) ? GetFrameDocument(this.Frame) : window.document
	this.Active			= ToDate(NewDate,-1) != -1
	this.Date			= ToDate(NewDate)
	this.Data			= new Array(); for (var i=0;i<6;i++) this.Data[i] = new Array()
	this.Run			= null
	this.Events			= true
	this.Enabled        = (NewEnabled || true) 
	this.Title			= "Calendar"
	this.Lang			= "NL"; if ((NewLang != null) && (NewLang != "")) this.Lang = NewLang	
	this.Langs			= new Array("NL","DE","GB","ES","FR","IT","US")
	this.Formats		= new Array("{w} {d} {m} {y}","{w}, {d}. {m} {y}","{w}, {d} {m} {y}","{w}, {d} de {m} de {y}","{w} {d} {m} {y}","{w} {d} {m} {y}","{w}, {m} {d}, {y}")
	this.SDays			= new Array(["zo","ma","di","wo","do","vr","za"],["so","mo","di","mi","do","fr","sa"],["su","mo","tu","we","th","fr","sa"],["do","lun","ma","mi","ju","vi","s"+Chr(225)],["di","lu","ma","me","je","ve","sa"],["do","lu","ma","me","gi","ve","sa"],["su","mo","tu","we","th","fr","sa"])
	this.FDays			= new Array(["zondag","maandag","dinsdag","woensdag","donderdag","vrijdag","zaterdag"],["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"],["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],["domingo","lunes","martes","mi"+Chr(233)+"rcoles","jueves","viernes","s"+Chr(225)+"bado"],["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"],["domenica","luned"+Chr(236),"marted"+Chr(236),"mercoled"+Chr(236),"gioved"+Chr(236),"venerd"+Chr(236),"sabato"],["sunday","monday","tuesday","wednesday","thursday","friday","saturday"])
	this.FMonths		= new Array(["januari","februari","maart","april","mei","juni","juli","augustus","september","oktober","november","december"],["Januar","Februar","M"+Chr(228)+"rz","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"],["january","february","march","april","may","june","july","august","september","october","november","december"],["enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre"],["janvier","f"+Chr(233)+"vrier","mars","avril","mai","juin","juillet","ao"+Chr(251)+"t","septembre","octobre","novembre","d"+Chr(233)+"cembre"],["gennaio","febbraio","marzo","aprile","maggio","giugno","luglio","agosto","settembre","ottobre","novembre","dicembre"],["january","february","march","april","may","june","july","august","september","october","november","december"])	
	this.GetElement	    = CalendarObject_GetElement
	this.RunKeyDown		= CalendarObject_RunKeyDown
	this.RunClick		= CalendarObject_RunClick
	this.RunDblClick	= CalendarObject_RunDblClick
	this.RunDraw		= CalendarObject_RunDraw
	this.SetActive		= CalendarObject_SetActive
	this.RunChange		= CalendarObject_RunChange
	this.OnKeyDown		= CalendarObject_OnKeyDown
	this.OnChange		= CalendarObject_OnChange
	this.OnClick		= CalendarObject_OnClick
	this.OnDblClick		= CalendarObject_OnDblClick
	this.OnConfirm		= CalendarObject_OnConfirm
	this.OnDelete		= CalendarObject_OnDelete
	this.OnEnter		= CalendarObject_OnEnter
	this.OnEscape		= CalendarObject_OnEscape
	this.OnResult       = CalendarObject_OnResult //RESULT !
	if (InitDraw != false) this.RunDraw()
	if (InitChange != false) this.RunChange(null,null,null,true) 
}
function CalendarObjectRunKeyDown(evt) {
    for (var i=0;i<arCalendarObject.length;i++) {
        var el = arCalendarObject[i].GetElement(); if (el == null) continue
        return arCalendarObject[i].RunKeyDown(evt)
    }
}
AttachEvent(window.document,"keydown",CalendarObjectRunKeyDown)
function CalendarObject_GetElement(sName) {
    sName = sName || ("CalendarTable_" + this.ObjectIndex)
	var doc = this.Document
	if (doc == null) return
	try {
	    var el = doc.getElementById(sName); 
	    return el
    } catch(e) {
        return null
    }
}
function CalendarObject_RunKeyDown(evt,key) {
    if (this.GetElement() == null) return
	if (this.Events == false) return false
    var key = key || GetEventKeyCode(evt)
    if ((IsFirefox() == true) && (key == 61)) key = KeyAdd
    if ((IsFirefox() == true) && (key == 109)) key = KeyMinus
	this.OnKeyDown(key)
	switch (key) {
		case KeyEscape: // escape
			this.OnEscape(this.Date.getDate(),this.Date.getMonth()+1,this.Date.getFullYear())
			return false				
		case KeyEnter: // enter
            if (this.Active == true) this.OnResult(this.Date.getDate(),this.Date.getMonth()+1,this.Date.getFullYear())
			var force = (this.Active == false); this.Active = true
			this.RunChange(this.Date.getDate(),this.Date.getMonth()+1,this.Date.getFullYear(),force)			
			this.OnEnter(this.Date.getDate(),this.Date.getMonth()+1,this.Date.getFullYear())
			return false				
		case KeyDelete: // delete
		    var force = (this.Active == true); this.Active = false
			this.RunChange(this.Date.getDate(),this.Date.getMonth()+1,this.Date.getFullYear(),force)			
			this.OnDelete(this.Date.getDate(),this.Date.getMonth()+1,this.Date.getFullYear())
			return false			
		case KeyHome: // home
			var force = (this.Active == false); this.Active = true
			var d = new Date()
			this.RunChange(d.getDate(),d.getMonth()+1,d.getFullYear(),force)			
			return false				
        case KeyAdd:// add
			var d = new Date(this.Date); var y = d.getYear(); if ((IsFirefox() == true) || (IsSafari() ==true)) y+=1900; d.setYear(y+1)
			this.RunChange(d.getDate(),d.getMonth()+1,d.getFullYear())			
			return false        
        case KeyMinus:// minus
			var d = new Date(this.Date); var y = d.getYear(); if ((IsFirefox() == true) || (IsSafari() ==true)) y+=1900; d.setYear(y-1)
			this.RunChange(d.getDate(),d.getMonth()+1,d.getFullYear())			
			return false        
		case KeyPageUp: // page up
			var d = new Date(this.Date); d.setMonth(d.getMonth()-1)
			this.RunChange(d.getDate(),d.getMonth()+1,d.getFullYear())			
			return false
		case KeyPageDown: // page down
			var d = new Date(this.Date); d.setMonth(d.getMonth()+1)
			this.RunChange(d.getDate(),d.getMonth()+1,d.getFullYear())			
			return false
		case KeyLeft: // left
		    var force = (this.Active != true); this.Active = true
			var d = new Date(this.Date); d.setDate(d.getDate()-1)
			this.RunChange(d.getDate(),d.getMonth()+1,d.getFullYear())
		    return false
		case KeyRight: // right
		    var force = (this.Active != true); this.Active = true
			var d = new Date(this.Date); d.setDate(d.getDate()+1)
			this.RunChange(d.getDate(),d.getMonth()+1,d.getFullYear())
			return false
		case KeyUp: // up
		    var force = (this.Active != true); this.Active = true
			var d = new Date(this.Date); d.setDate(d.getDate()-7)
			this.RunChange(d.getDate(),d.getMonth()+1,d.getFullYear())
			return false
		case KeyDown: // down 
		    var force = (this.Active != true); this.Active = true
			var d = new Date(this.Date); d.setDate(d.getDate()+7)
			this.RunChange(d.getDate(),d.getMonth()+1,d.getFullYear())
			return false
	}	
}
function CalendarObject_RunClick(evt) {    
	if (this.Events == false) return false
    var id = ToString(GetEventID(evt))
    var row = id.split("_")[2]
    var col = id.split("_")[3]
    if (row == null) return
    if (col == null) return
	if (this.Data[row][col] != null) {
		var d = new Date(this.Data[row][col])
		var force = (this.Active == false)
		this.Active = true
		this.RunChange(d.getDate(),d.getMonth()+1,d.getFullYear(),force)
		this.OnClick(d.getDate(),d.getMonth()+1,d.getFullYear())
	}	
}
function CalendarObject_RunDblClick(evt) {
	if (this.Events == false) return false
    var id = ToString(GetEventID(evt))
    var row = id.split("_")[2]
    var col = id.split("_")[3]
    if (row == null) return
    if (col == null) return
	if (this.Data[row][col] != null) {
		var d = new Date(this.Data[row][col])
		var force = (this.Active != true)
		this.Active = true
		this.RunChange(d.getDate(),d.getMonth()+1,d.getFullYear(),force)
		this.OnDblClick(d.getDate(),d.getMonth()+1,d.getFullYear())
		this.OnResult(d.getDate(),d.getMonth()+1,d.getFullYear())
	}	
}
function CalendarObject_SetActive(Active) {
	var force = (this.Active != Active)
	this.Active = Active
	this.RunChange(null,null,null,force)
}
function CalendarObject_RunDraw() {
	var tmp = ""
	if (this.IsFrame == true) {
	    tmp += "<html style=\"border:0px\">\n"
	    tmp += "<head>\n"
	    tmp += "<title>{Title}</title>\n"
	    tmp += "</head>\n"
    	tmp += "<body unselectable=\"on\" leftmargin=0 topmargin=0 rightmargin=0 bottommargin=0 style=\"margin:0px\" onkeydown=\"{Calendar}.RunKeyDown(event);return false\" ondrag=\"return false\" onselectstart=\"return false\">"
    }
	tmp += "<table unselectable=\"on\" cellspacing=1 cellpadding=0 border=0 onclick=\"{Calendar}.RunClick(event)\" ondblclick=\"{Calendar}.RunDblClick(event)\" id=\"CalendarTable_{Index}\" width=100% height={Height} cols=7 style=\"spacing:1px;border:1px solid gray;background-color:{BackColor};{Select}\">\n"
	tmp = tmp.replace("{Height}",(IsSafari() == true) ? "200" : "100%")
	//KeyMinus=189,KeyAdd=187,KeyPageUp=33,KeyPageDown=34
	if (this.Events == true) {
	    tmp += "<tr unselectable=\"on\" height=19><td unselectable=\"on\" colspan=7 style=\"border-bottom:1px solid gray\"><table cellspacing=0 cellpadding=0 border=0 width=100% height=19><tr unselectable=\"on\"><td unselectable=\"on\" style=\"font-family:tahoma;font-size:8pt;width:10px;font-family:arial;cursor:{Cursor}\" onclick=\"{Calendar}.RunKeyDown(event,189)\" title=\"minus year\"><b unselectable=\"on\">&nbsp;-&nbsp;</b></td><td unselectable=\"on\" style=\"font-family:tahoma;font-size:8pt;width:10px;font-family:arial;cursor:{Cursor}\" onclick=\"{Calendar}.RunKeyDown(event,33)\" title=\"minus month\"><b unselectable=\"on\">&lt;&lt;</b></td><td unselectable=\"on\" id=\"CalendarDate{Index}\" style=\"font-family:tahoma;font-size:8pt;color:navy;text-align:center;font-weight:bold;height:23px\">&nbsp;</td><td unselectable=\"on\" style=\"font-family:tahoma;font-size:8pt;width:10px;font-family:arial;cursor:{Cursor}\" onclick=\"{Calendar}.RunKeyDown(event,34)\" title=\"add month\"><b unselectable=\"on\">&gt;&gt;</b></td><td unselectable=\"on\" style=\"font-family:tahoma;font-size:8pt;width:10px;font-family:arial;cursor:{Cursor}\" onclick=\"{Calendar}.RunKeyDown(event,187)\" title=\"add year\"><b unselectable=\"on\">&nbsp;+&nbsp;</b></td></tr></table></td></tr>\n"
	} else {
	    tmp += "<tr unselectable=\"on\" height=19><td unselectable=\"on\" colspan=7 style=\"border-bottom:1px solid gray\"><table cellspacing=0 cellpadding=0 border=0 width=100% height=19><tr unselectable=\"on\"><td unselectable=\"on\" id=\"CalendarDate{Index}\" style=\"font-family:tahoma;font-size:8pt;color:navy;text-align:center;font-weight:bold;height:23px\">&nbsp;</td></tr></table></td></tr>\n"	
	}
	tmp += "<tr unselectable=\"on\" height=19>\n"
	var iLang = 0; for (var i=0;i<this.Langs.length;i++) { if (this.Lang == this.Langs[i]) iLang = i }	
	for (var i=0;i<7;i++) {
		tmp += "<td unselectable=\"on\" style=\"height:19px;font-family:tahoma;font-size:8pt;color:black;text-align:center;font-weight:bold\">" + this.SDays[iLang][i] + "</td>\n"
	}
	tmp += "</tr>\n"
	for (var i=0;i<6;i++) {
		tmp += "<tr unselectable=\"on\">\n"
 		for (j=0;j<7;j++) {
			tmp += "<td unselectable=\"on\" width=33 id=\"CalendarCell_{Index}_" + i + "_" + j + "\">&nbsp;</td>\n"		
		}			
		tmp += "</tr>\n"
  	}
	tmp += "<\/table>"
	if (this.IsFrame == true) {
	    tmp += "<\/body>\n"
	    tmp += "<\/html>\n"
    }    
    tmp = Replace(tmp,"{BackColor}",(this.Enabled == true) ? "white" : "whitesmoke")
    tmp = Replace(tmp,"{Cursor}",(this.Enabled == true) ? "pointer" : "default")
	tmp = Replace(tmp,"{Calendar}",(this.IsFrame == true) ? "parent.arCalendarObject[{Index}]" : "arCalendarObject[{Index}]")
	tmp = Replace(tmp,"{Cursor}",(this.Enabled == true) ? "pointer" : "default")
	tmp = Replace(tmp,"{Select}",(IsFirefox() == true) ? "-moz-user-select: none" : "")
	tmp = Replace(tmp,"{Title}",this.Title)
	tmp = Replace(tmp,"{Index}",this.ObjectIndex)
	if (this.IsFrame == true) {
	    var doc = GetFrameDocument(this.Frame)		
	    doc.open()
	    doc.clear()
	    doc.write(tmp)
	    doc.close()
	    CallFocus(this.Frame)
	    CallFocus(doc)
    } else {
        this.Frame.innerHTML = tmp
    }
}
function CalendarObject_RunChange(day,month,year,force) {
    if (this.GetElement() == null) return
	if (day == null) { day = this.Date.getDate() }
	if (month == null) { month = this.Date.getMonth()+1 }
	if (year == null) { year = this.Date.getFullYear() }
	if ((this.Date.getDate() != day) || ((this.Date.getMonth()+1) != month) || (this.Date.getFullYear() != year) || (force == true)) { 
		var hold = new Date(this.Date)
		this.Date = new Date(year,month-1,day)
		//this.Date = new Date(1900,0,1)
		//this.Date.setDate(day) 
		//this.Date.setMonth(month-1) 
		//this.Date.setYear(year) 
		var ctr = this.GetElement("CalendarDate" + this.ObjectIndex) 
		var f = "&nbsp;"
		var iLang = 0; for (var i=0;i<this.Langs.length;i++) { if (this.Lang == this.Langs[i]) iLang = i }	
		if (this.Active == true) {
			var f = this.Formats[iLang]
			f = f.replace("{w}",this.FDays[iLang][this.Date.getDay()])	
			f = f.replace("{d}",this.Date.getDate())	
			f = f.replace("{m}",this.FMonths[iLang][this.Date.getMonth()])	
			f = f.replace("{y}",this.Date.getFullYear())	
		} else {
			f = "{m} {y}"	
			f = f.replace("{m}",this.FMonths[iLang][this.Date.getMonth()])	
			f = f.replace("{y}",this.Date.getFullYear())	
		}	
		ctr.innerHTML = f
		var run = new Date(this.Date); run.setDate(1)
		var x = -run.getDay()+1; if (x == 1) { x = -6 }; run.setDate(x)
		var update = (this.Run + "") != (run + "")
		this.Run = new Date(run)
		for (var i=0;i<6;i++) {
 			for (j=0;j<7;j++) {
 				var cls = ""
 				if ((this.Active == true) && (run.getMonth() == this.Date.getMonth()) && (run.getDate() == this.Date.getDate())) {
 					cls = "font-family:tahoma;font-size:8pt;background-color:#ff8888;color:black;text-align:center;cursor:{Cursor}"
 				} else if ((run.getMonth() == this.Date.getMonth()) && ((j == 0) || (j == 6))) {
 					cls = "font-family:tahoma;font-size:8pt;background-color:#dddddd;color:black;text-align:center;cursor:{Cursor}"
 				} else if (run.getMonth() == this.Date.getMonth()) {
 					cls = "font-family:tahoma;font-size:8pt;background-color:#f8f8f8;color:black;text-align:center;cursor:{Cursor}"
 				} else {
 					cls = "font-family:tahoma;font-size:8pt;background-color:#aaaaaa;color:black;text-align:center;cursor:{Cursor}"
 				} 				
                cls = Replace(cls,"{Cursor}",(this.Enabled == true) ? "pointer" : "default")
 				if ((update == true) || ((update == false) && (((run + "") == (this.Date + "")) || ((run + "") == (hold + ""))))) {
	 				var cnt = run.getDate()
 					var ctr = this.GetElement("CalendarCell_" + this.ObjectIndex + "_" + i + "_" + j)
 					ctr.style.cssText = cls
 					ctr.innerHTML = cnt
 					this.Data[i][j] = new Date(run)
 				}	
				run.setDate(run.getDate()+1)
			}			
  		}
		this.OnChange(this.Date.getDate(),this.Date.getMonth()+1,this.Date.getFullYear())
	} else if ((this.Date.getDate() == day) && ((this.Date.getMonth()+1) == month) && (this.Date.getFullYear() == year)) { 
		this.OnConfirm(this.Date.getDate(),this.Date.getMonth()+1,this.Date.getFullYear())
	}
}
function CalendarObject_OnKeyDown(key) { }
function CalendarObject_OnChange(day,month,year) { }
function CalendarObject_OnClick(day,month,year) { }
function CalendarObject_OnDblClick(day,month,year) { }
function CalendarObject_OnConfirm(day,month,year) { }
function CalendarObject_OnEscape(day,month,year) { }
function CalendarObject_OnEnter(day,month,year) { }
function CalendarObject_OnDelete(day,month,year) { }
function CalendarObject_OnResult(day,month,year) { }

//#############################################################################
//#############################################################################
//#############################################################################
// COLOR

var arColorObject = new Array()
function ColorObject(NewFrame,InitDraw) {
	var index = arColorObject.length; arColorObject[index] = this
	this.ObjectIndex	= index
	this.Frame			= NewFrame
	this.IsFrame        = (ListFind("SPAN|DIV|TABLE|TD",this.Frame.tagName) == false)
	this.Document       = (this.IsFrame == true) ? GetFrameDocument(this.Frame) : window.document
	this.Title			= "Color"
    this.GetElement     = ColorObject_GetElement
    this.RunDraw        = ColorObject_RunDraw
    this.RunOver        = ColorObject_RunOver
    this.RunOut         = ColorObject_RunOut
    this.RunClick       = ColorObject_RunClick
    this.RunSelect      = ColorObject_RunSelect
    this.RunKeyDown     = ColorObject_RunKeyDown
    this.OnResult       = ColorObject_OnResult
	this.OnEscape		= ColorObject_OnEscape
	if (InitDraw != false) this.RunDraw() 
}
function ColorObject_GetElement(sName) {
    sName = sName || ("ColorTable_" + this.ObjectIndex)
	var doc = this.Document
	if (doc == null) return
	try {
    	var el = doc.getElementById(sName)
	    return el
    } catch(e) {
        return null
    }	    
}
function ColorObjectRunKeyDown(evt) {
    for (var i=0;i<arColorObject.length;i++) {
        var el = arColorObject[i].GetElement(); if (el == null) continue
        return arColorObject[i].RunKeyDown(evt)
    }
}
AttachEvent(window.document,"keydown",ColorObjectRunKeyDown)
function ColorObject_RunKeyDown(evt,key) {
    if (this.GetElement() == null) return
	if (this.Events == false) return false
    var key = key || GetEventKeyCode(evt)
    if ((IsFirefox() == true) && (key == 61)) key = KeyAdd
    if ((IsFirefox() == true) && (key == 109)) key = KeyMinus
	switch (key) {
		case KeyEscape: // escape
			this.OnEscape()
			return false				
	}	
}
function ColorObject_RunDraw() {
	var htm = ""
	if (this.IsFrame == true) {
	    htm += "<html>\n"
	    htm += "<head>\n"
	    htm += "<title>{Title}</title>\n"
	    htm += "</head>\n"
	    htm += "<body leftmargin=0 topmargin=0 rightmargin=0 bottonmargin=0 style=\"margin:0px\">\n"
    }
	htm += "<table cellpadding=0 cellspacing=0 border=0 width=100% height={Height} style=\"background-color:white;border:1px solid gray;{Style}\"><tr><td unselectable=\"on\" align=center valign=middle style=\"text-align:center;vertical-align:middle\"><center>\n"
    htm = htm.replace("{Height}",(IsSafari() == true) ? "180px" : "100%")
	htm += "<table cellpadding=0 cellspacing=0 border=0><tr><td unselectable=\"on\">\n"
    htm += "<table cellspacing=1 cellpadding=0 border=0 id=\"ColorTable_{Index}\" onmouseover=\"{Color}.RunOver(event)\" onmouseout=\"{Color}.RunOut(event)\" onclick=\"{Color}.RunClick(event)\" style=\"cursor:pointer;background-color:#bbddff\">\n"
    htm += "<tr>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#909090\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#989898\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#000000\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#003300\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#006600\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#009900\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#00CC00\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#00FF00\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#330000\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#333300\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#336600\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#339900\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#33CC00\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#33FF00\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#660000\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#663300\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#666600\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#669900\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#66CC00\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#66FF00\" height=\"10\" width=\"10\"></td>\n"
    htm += "</tr>\n"
    htm += "<tr>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#888888\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#A0A0A0\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#000033\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#003333\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#006633\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#009933\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#00CC33\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#00FF33\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#330033\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#333333\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#336633\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#339933\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#33CC33\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#33FF33\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#660033\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#663333\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#666633\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#669933\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#66CC33\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#66FF33\" height=\"10\" width=\"10\"></td>\n"
    htm += "</tr>\n"
    htm += "<tr>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#808080\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#A8A8A8\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#000066\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#003366\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#006666\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#009966\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#00CC66\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#00FF66\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#330066\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#333366\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#336666\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#339966\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#33CC66\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#33FF66\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#660066\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#663366\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#666666\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#669966\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#66CC66\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#66FF66\" height=\"10\" width=\"10\"></td>\n"
    htm += "</tr>\n"
    htm += "<tr>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#787878\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#B0B0B0\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#000099\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#003399\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#006699\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#009999\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#00CC99\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#00FF99\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#330099\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#333399\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#336699\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#339999\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#33CC99\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#33FF99\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#660099\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#663399\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#666699\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#669999\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#66CC99\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#66FF99\" height=\"10\" width=\"10\"></td>\n"
    htm += "</tr>\n"
    htm += "<tr>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#707070\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#B8B8B8\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#0000CC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#0033CC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#0066CC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#0099CC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#00CCCC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#00FFCC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#3300CC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#3333CC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#3366CC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#3399CC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#33CCCC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#33FFCC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#6600CC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#6633CC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#6666CC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#6699CC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#66CCCC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#66FFCC\" height=\"10\" width=\"10\"></td>\n"
    htm += "</tr>\n"
    htm += "<tr>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#686868\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#C0C0C0\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#0000FF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#0033FF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#0066FF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#0099FF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#00CCFF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#00FFFF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#3300FF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#3333FF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#3366FF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#3399FF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#33CCFF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#33FFFF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#6600FF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#6633FF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#6666FF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#6699FF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#66CCFF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#66FFFF\" height=\"10\" width=\"10\"></td>\n"
    htm += "</tr>\n"
    htm += "<tr>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#606060\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#C8C8C8\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#990000\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#993300\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#996600\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#999900\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#99CC00\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#99FF00\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CC0000\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CC3300\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CC6600\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CC9900\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CCCC00\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CCFF00\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FF0000\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FF3300\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FF6600\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FF9900\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FFCC00\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FFFF00\" height=\"10\" width=\"10\"></td>\n"
    htm += "</tr>\n"
    htm += "<tr>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#585858\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#D0D0D0\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#990033\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#993333\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#996633\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#999933\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#99CC33\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#99FF33\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CC0033\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CC3333\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CC6633\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CC9933\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CCCC33\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CCFF33\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FF0033\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FF3333\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FF6633\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FF9933\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FFCC33\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FFFF33\" height=\"10\" width=\"10\"></td>\n"
    htm += "</tr>\n"
    htm += "<tr>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#505050\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#D8D8D8\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#990066\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#993366\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#996666\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#999966\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#99CC66\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#99FF66\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CC0066\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CC3366\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CC6666\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CC9966\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CCCC66\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CCFF66\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FF0066\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FF3366\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FF6666\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FF9966\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FFCC66\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FFFF66\" height=\"10\" width=\"10\"></td>\n"
    htm += "</tr>\n"
    htm += "<tr>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#484848\"height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#E0E0E0\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#990099\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#993399\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#996699\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#999999\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#99CC99\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#99FF99\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CC0099\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CC3399\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CC6699\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CC9999\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CCCC99\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CCFF99\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FF0099\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FF3399\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FF6699\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FF9999\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FFCC99\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FFFF99\" height=\"10\" width=\"10\"></td>\n"
    htm += "</tr>\n"
    htm += "<tr>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#404040\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#E8E8E8\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#9900CC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#9933CC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#9966CC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#9999CC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#99CCCC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#99FFCC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CC00CC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CC33CC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CC66CC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CC99CC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CCCCCC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CCFFCC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FF00CC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FF33CC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FF66CC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FF99CC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FFCCCC\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FFFFCC\" height=\"10\" width=\"10\"></td>\n"
    htm += "</tr>\n"
    htm += "<tr>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#383838\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FFFFFF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#9900FF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#9933FF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#9966FF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#9999FF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#99CCFF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#99FFFF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CC00FF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CC33FF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CC66FF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CC99FF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CCCCFF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#CCFFFF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FF00FF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FF33FF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FF66FF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FF99FF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FFCCFF\" height=\"10\" width=\"10\"></td>\n"
    htm += "<td unselectable=\"on\" bgcolor=\"#FFFFFF\" height=\"10\" width=\"10\"></td>\n"
    htm += "</tr>\n"
    htm += "</table></center>\n"
	htm += "</td></tr>\n"
	htm += "<tr height=10><td unselectable=\"on\" height=10 style=\"padding-top:3px\">\n"
	htm += "<table cellpadding=4 cellspacing=3 border=0 width=100% style=\"background-color:#cccccc\"><tr>"
	htm += "<td unselectable=\"on\" style=\"width:15px;cursor:pointer;border:1px solid gray;background-color:white;color:black;font-family:tahoma;font-size:8pt;vertical-align:middle\" onclick=\"{Color}.RunSelect('')\" onmouseover=\"this.style.backgroundColor='steelblue'\" onmouseout=\"this.style.backgroundColor='white'\" title=\"remove color\">&nbsp;X&nbsp;</td>\n"
	htm += "<td unselectable=\"on\" style=\"width:15px;cursor:pointer;border:1px solid gray;background-color:white;color:black;font-family:tahoma;font-size:8pt;vertical-align:middle\" onclick=\"{Color}.RunSelect('?')\" onmouseover=\"this.style.backgroundColor='steelblue'\" onmouseout=\"this.style.backgroundColor='white'\" title=\"insert color code or name\">&nbsp;?&nbsp;</td>\n"
    if (IsIE() == true) {
        var bCanCreate = false
        try {
            var col = new ActiveXObject("MsComDlg.CommonDialog")
            bCanCreate = true
        } catch(e) { }    
        if (bCanCreate == true) {
        	htm += "<td unselectable=\"on\" style=\"width:50px;cursor:pointer;border:1px solid gray;background-color:white;color:black;font-family:tahoma;font-size:8pt;vertical-align:middle\" onclick=\"{Color}.RunSelect(null)\" onmouseover=\"this.style.backgroundColor='steelblue'\" onmouseout=\"this.style.backgroundColor='white'\" title=\"windows color picker\">&nbsp;Colors...&nbsp;</td>\n"
	    }
	}
	htm += "<td unselectable=\"on\" id=\"ColorSample{Index}\" style=\"border:1px solid gray;background-color:white;color:black;font-family:tahoma;font-size:8pt;text-align:center\">&nbsp;</td>\n"
	htm += "</tr></table>\n"
	htm += "</td></tr></table>\n"
	htm += "</td></tr></table>\n"
	if (this.IsFrame == true) {
        htm += "</body>\n"
        htm += "</html>\n"
	    htm = Replace(htm,"{Color}","parent.arColorObject[{Index}]")
	} else {
	    htm = Replace(htm,"{Color}","arColorObject[{Index}]")
	}
	htm = Replace(htm,"{Index}",this.ObjectIndex)
	htm = Replace(htm,"{Title}",this.Title)
	htm = Replace(htm,"{Select}",(IsFirefox() == true) ? "-moz-user-select: none" : "")
	if (this.IsFrame == true) {
	    var doc = GetFrameDocument(this.Frame)		
	    doc.open()
	    doc.clear()
	    doc.write(htm)
	    doc.close()	
	} else {
	    this.Frame.innerHTML = htm
	}
}
function ColorObject_RunOver(evt) {
    var el = GetEventElement(evt)
    var color = ToString(el.bgColor); if (color == "") return
    var ct = this.GetElement("ColorSample" + this.ObjectIndex)
    ct.style.backgroundColor = color
    ct.innerHTML = "<font style=\"background-color:gray;color:white\">" + color + "</font>"
}
function ColorObject_RunOut(evt) {
    var el = GetEventElement(evt)
    var ct = this.GetElement("ColorSample" + this.ObjectIndex)
    ct.style.backgroundColor = "white"
    ct.innerHTML = "&nbsp;"
}
function ColorObject_RunClick(evt) {
    var el = GetEventElement(evt)
    var color = ToString(el.bgColor); if (color == "") return
    this.RunSelect(color)
}
function ColorObject_RunSelect(color) {
	if (color == null) {
		try {
			var col = new ActiveXObject("MsComDlg.CommonDialog")
		    try {
			    col.CancelError = true
			    col.ShowColor()
			    var c = col.Color
			    var h = "0123456789abcdef"
			    color = "#" +
				    h.charAt(Math.floor(c / 16) % 16) + h.charAt(c % 16) +
				    h.charAt(Math.floor(c / 4096) % 16) + h.charAt(Math.floor(c / 256) % 16) +
				    h.charAt(Math.floor(c / 1048576) % 16) + h.charAt(Math.floor(c / 65536) % 16)
			    this.OnResult(color)
		    } catch (e) {
		        return
		    }
		} catch (e) {
			ShowAlert(e.message || e)
		}
	} else if (color == "?") {
		color = ShowInput("Insert a color code or name: (sample: #ff0000 or Red)")
		if (color == "") return
        this.OnResult(color)
	} else if (color != null) {
        this.OnResult(color)
	}
}
function ColorObject_OnResult(color) { }
function ColorObject_OnEscape() { }

//#############################################################################
//#############################################################################
//#############################################################################
// SELECTION

var arSelectionObject = new Array()
function SelectionObject(NewFrame,NewData,InitDraw) {
	var index = arSelectionObject.length; arSelectionObject[index] = this
	this.ObjectIndex	= index
	this.Frame			= NewFrame
	this.IsFrame        = false
	this.Document       = null
	this.Data           = NewData
    this.GetElement     = SelectionObject_GetElement
    this.RunDraw        = SelectionObject_RunDraw
    this.RunOver        = SelectionObject_RunOver
    this.RunKeyDown     = SelectionObject_RunKeyDown
    this.RunClick       = SelectionObject_RunClick
    this.OnResult       = SelectionObject_OnResult
    this.Index          = -1
	this.Title			= "Selection"
	this.HTML           = null
	if (InitDraw == true) this.RunDraw() 
}
function SelectionObjectRunKeyDown(evt) {
    for (var i=0;i<arSelectionObject.length;i++) {
        var el = arSelectionObject[i].GetElement(); if (el == null) continue
        return arSelectionObject[i].RunKeyDown(evt)
    }
}
AttachEvent(window.document,"keydown",SelectionObjectRunKeyDown)
function SelectionObject_GetElement(sName) {
    sName = sName || ("SelectionTable_" + this.ObjectIndex)
	var doc = this.Document
	if (doc == null) return
	try {
    	var el = doc.getElementById(sName)
    	return el
    } catch(e) {
        return null
    } 	
}
function SelectionObject_RunDraw(Frame) {
    if (Frame != null) this.Frame = Frame
	this.IsFrame = (ListFind("SPAN|DIV|TABLE|TD",this.Frame.tagName) == false)
	this.Document = (this.IsFrame == true) ? GetFrameDocument(this.Frame) : window.document    
	if (this.HTML == null) {
	    var htm = ""
	    var htm2 = ""
	    if (this.IsFrame == true) {
	        htm += "<html style=\"border:0px\">\n"
	        htm += "<head>\n"
	        htm += "<title>{Title}</title>\n"
	        htm += "</head>\n"
	        htm += "<body leftmargin=0 topmargin=0 rightmargin=0 bottonmargin=0 style=\"margin:0px\" onkeydown=\"{Selection}.RunKeyDown(event);return false\" ondrag=\"return false\" oncontextmenu=\"return false\" onselectstart=\"return false\">\n"
        }
	    htm += "<table cellpadding=0 cellspacing=0 border=0 id=\"SelectionTable_{Index}\" style=\"background-color:white;border:1px solid gray;width:100%;height:100%;{Select}\" ondrag=\"return false\" oncontextmenu=\"return false\"><tr><td unselectable=\"on\">\n"
	    htm += "<div style=\"height:{Height};width:{Width};overflow:scroll;overflow-x:auto;overflow-y:scroll;padding:1px;{Scroll}\" unselectable=\"on\">\n"
	    htm += "<table id=\"SelectionItemTable_{Index}\" onmouseover=\"{Selection}.RunOver(event)\" onclick=\"{Selection}.RunClick(event)\" cellpadding=0 cellspacing=0 border=0 cols=3 width=100% style=\"width:100%;cursor:pointer;font-family:tahoma;font-size:8pt\">\n"
	    htm += "<col width=1 height=18 style=\"background-color:{BackColor}\">\n"
	    htm += "<col width=1 height=18 style=\"background-color:{BackColor}\">\n"
	    htm += "<col>\n"
	    var bImage = false
	    for (var i=0;i<this.Data.length;i++) {
		    var s = ""
		    s += "<tr>\n"
            s += "<td unselectable=\"on\"><a href=#></a></td>\n"
            s += "<td unselectable=\"on\">{Image}</td>\n"
	        s += "<td unselectable=\"on\" style=\"padding:2px;padding-left:4px;{Font}\">{Text}</td>\n"
		    s += "</tr>\n"
		    this.Data[i].Image = ToString(this.Data[i].Image)
		    this.Data[i].Font = ToString(this.Data[i].Font)
		    this.Data[i].Text = ToString(this.Data[i].Text) || ToString(this.Data[i])
		    s = Replace(s,"{i}",i)
		    s = Replace(s,"{Image}",(this.Data[i].Image != "") ? ("<img src=\"" + this.Data[i].Image + "\" " + ToString(this.Data[i].ImageFormat) + ">") : "")
		    s = Replace(s,"{Font}",(this.Data[i].Font != "") ? ("font-family:" + this.Data[i].Font) : "")
		    s = Replace(s,"{Text}",this.Data[i].Text)
		    if (this.Data[i].Image != "") bImage = true
		    htm += s
		    if (htm.length > 1000) { htm2 += htm; htm = "" }
	    }
	    htm = htm2 + htm
	    htm = Replace(htm,"{BackColor}",(bImage == true) ? "#ddeeff" : "white")
	    htm += "</table>\n"
	    htm += "</div>\n"
	    htm += "</td></tr></table>\n"	
 	    if (this.IsFrame == true) {
            htm += "</body>\n"
            htm += "</html>\n"
	        htm = Replace(htm,"{Selection}","parent.arSelectionObject[{Index}]")
	    } else {
	        htm = Replace(htm,"{Selection}","arSelectionObject[{Index}]")
	    }
	    htm = Replace(htm,"{Index}",this.ObjectIndex)
	    htm = Replace(htm,"{Title}",this.Title)
	    htm = Replace(htm,"{Scroll}",(IsIE() == true) ? "scrollbar-arrow-color:steelblue;scrollbar-base-color:white;scrollbar-3dlight-color:steelblue;scrollbar-shadow-color:white;scrollbar-darkshadow-color:steelblue;scrollbar-highlight-color:white;scrollbar-track-color:whitesmoke" : "")
	    htm = Replace(htm,"{Select}",(IsFirefox() == true) ? "-moz-user-select: none" : "")
	    htm = Replace(htm,"{Width}",((IsFirefox() == true) || (IsSafari() == true)) ? ((GetElementWidth(this.Frame)-4) + "px") : "100%")
	    htm = Replace(htm,"{Height}",((IsFirefox() == true) || (IsSafari() == true)) ? ((GetElementHeight(this.Frame)-4) + "px") : "100%")
	    this.HTML = htm
    }
	if (this.IsFrame == true) {
	    var doc = GetFrameDocument(this.Frame)		
	    doc.open()
	    doc.clear()
	    doc.write(this.HTML)
	    doc.close()	
	    CallFocus(this.Frame)
	    CallFocus(doc)
	} else {
	    this.Frame.innerHTML = this.HTML
	}  
}	
function SelectionObject_RunOver(evt,tr) {
    if (tr == null) tr = GetEventElement(evt)
    while ((tr != null) && (tr.tagName != "TR")) tr = tr.parentNode
    var tb = this.GetElement("SelectionItemTable_" + this.ObjectIndex)
    if ((this.Index != -1) && (this.Index != tr.rowIndex)) {
        var ro = tb.rows[this.Index]
	    ro.cells[0].style.backgroundColor = ""
	    ro.cells[1].style.backgroundColor = ""
	    ro.cells[2].style.backgroundColor = ""
    }
    this.Index = tr.rowIndex
    tr.cells[0].style.backgroundColor = "#66aaee"
    tr.cells[1].style.backgroundColor = "#66aaee"
    tr.cells[2].style.backgroundColor = "#66aaee"
    if (IsIE() == true) {
        try { CallFocus(tb.rows[tr.rowIndex-1].cells[0].children[0]) } catch(e) {}
        CallFocus(tr.cells[0].children[0])
        try { CallFocus(tb.rows[tr.rowIndex+1].cells[0].children[0]) } catch(e) {}
    } else {
        try { CallFocus(tb.rows[tr.rowIndex-1].cells[0].childNodes[0]) } catch(e) {}
        CallFocus(tr.cells[0].childNodes[0])
        try { CallFocus(tb.rows[tr.rowIndex-1].cells[0].childNodes[0]) } catch(e) {}
    }    
}
function SelectionObject_RunClick(evt,tr) {
    if (tr == null) tr = GetEventElement(evt)
    while ((tr != null) && (tr.tagName != "TR")) tr = tr.parentNode
    var Index = tr.rowIndex
    var Value = this.Data[Index].Value || this.Data[Index].Text || this.Data[Index] || ""
    var Text = this.Data[Index].Text || this.Data[Index] || ""
    this.OnResult(Index,Value,Text)
}
function SelectionObject_RunKeyDown(evt) {
    var key = GetEventKeyCode(evt)
    if ((key == KeyUp) && (this.Data.length > 0)) {
        var Index = (this.Index == -1) ? this.Data.length-1 : (this.Index-1); Index = LimitNumeric(Index,0,this.Data.length-1)
        var tb = this.GetElement("SelectionItemTable_" + this.ObjectIndex)
        var tr = tb.rows[Index] 
        this.RunOver(evt,tr)
        evt.cancelBubble = true
        return false
    }    
    if ((key == KeyPageUp) && (this.Data.length > 0)) {
        var Index = LimitNumeric((this.Index == -1) ? this.Data.length-1 : (this.Index-5),0,this.Data.length-1)
        var tb = this.GetElement("SelectionItemTable_" + this.ObjectIndex)
        var tr = tb.rows[Index] 
        this.RunOver(evt,tr)
        evt.cancelBubble = true
        return false
    }    
    if ((key == KeyDown) && (this.Data.length > 0)) {
        var Index = LimitNumeric((this.Index == -1) ? 0 : (this.Index+1),0,this.Data.length-1)
        var tb = this.GetElement("SelectionItemTable_" + this.ObjectIndex)
        var tr = tb.rows[Index] 
        this.RunOver(evt,tr)
        evt.cancelBubble = true
        return false
    }    
    if ((key == KeyPageDown) && (this.Data.length > 0)) {
        var Index = LimitNumeric((this.Index == -1) ? 0 : (this.Index+5),0,this.Data.length-1)
        var tb = this.GetElement("SelectionItemTable_" + this.ObjectIndex)
        var tr = tb.rows[Index] 
        this.RunOver(evt,tr)
        evt.cancelBubble = true
        return false
    }    
    if ((key == KeyEnter) && (this.Index != -1) && (this.Data.length > 0)) {
        var tb = this.GetElement("SelectionItemTable_" + this.ObjectIndex)
        var tr = tb.rows[this.Index] 
        this.RunClick(evt,tr)
        evt.cancelBubble = true
        return false
    }
}
function SelectionObject_OnResult(Index,Value,Text) { }

//#############################################################################
//#############################################################################
//#############################################################################
// MESSAGE

var Message_OkLabel = null
function MessageOkLabel(text) {
    var win = GetTopWindow()
    try { 
        if (text != null) win.Message_OkLabel = text
    } catch(e) { }    
    return win.Message_OkLabel || "Ok"
}
var Message_CancelLabel = null
function MessageCancelLabel(text) {
    var win = GetTopWindow()
    try { 
        if (text != null) win.Message_CancelLabel = text
    } catch(e) { }            
    return win.Message_CancelLabel || "Annuleren"
}
var Message_CloseLabel = null
function MessageCloseLabel(text) {
    var win = GetTopWindow()
    try { 
        if (text != null) win.Message_CloseLabel = text
    } catch(e) { }            
    return win.Message_CloseLabel || "Sluiten"
}

//#############################################################################
//#############################################################################
//#############################################################################
// MESSAGE

function ShowMessageManager(win,msg,img) { 
	if (win == null) win = window
	if ((win.showModalDialog) && (IsIE() == true)) {
	    var obj = new Object()
	    obj.Window = win
	    obj.CloseLabel = MessageCloseLabel()
	    obj.Message = msg
	    obj.Icon = img
	    obj.Url = "../Lib/MessageWindow.htm" 
	    obj.Features = "dialogWidth:600px;dialogHeight:140px;center:yes;help:no;close:no;unadorned:yes;status:no;scroll:no" 
	    try {
    	    var res = win.showModalDialog(obj.Url,obj,obj.Features)	
        } catch(e) {
            msg = HTMLToText(msg)
            ShowAlert(msg)
        } 
    } else {
        msg = HTMLToText(msg)
        if (Find(img,"Critical",true) != -1) msg = "[ CRITICAL ]\n\n" + msg
        if (Find(img,"Exclamation",true) != -1) msg = "[ EXCLAMATION ]\n\n" + msg
        ShowAlert(msg)
    }
}
function ShowMessage(msg,win) { 
    ShowMessageManager(win,msg,"../Images/Message_Information.gif")
}
function ShowMessageCritical(msg,win) { 
    ShowMessageManager(win,msg,"../Images/Message_Critical.gif")
}
function ShowMessageExclamation(msg,win) { 
    ShowMessageManager(win,msg,"../Images/Message_Exclamation.gif")
}

//#############################################################################
//#############################################################################
//#############################################################################
// INFORMATION

var InformationArguments  = null
var InformationWindow  = null
function ShowInformationManager(win,msg,height,modal) { 
	if (win == null) win = window
	if (modal == null) modal = true
	if (height == null) height = 300
	if ((win.showModalDialog) && (IsIE() == true) && (modal == true)) {
	    var obj = new Object()
	    obj.Window = win
        obj.CloseLabel = MessageCloseLabel()
	    obj.Message = msg
	    obj.Icon = "../Images/Message_Information.gif"
        var Url = "../Lib/InformationWindow.htm" 
        var Fea = "dialogWidth:600px;dialogHeight:" + height + "px;center:yes;help:no;close:no;unadorned:yes;status:no;scroll:no" 
	    try {
    	    var res = win.showModalDialog(Url,obj,Fea)	
        } catch(e) {
            msg = HTMLToText(msg)
            ShowAlert(msg)    
        } 
    } else {
        if ((InformationWindow != null) && (InformationWindow.closed == false)) InformationWindow.close()
	    InformationArguments = new Object()
	    InformationArguments.Window = win
        InformationArguments.CloseLabel = MessageCloseLabel()
	    InformationArguments.Message = msg
	    InformationArguments.Icon = "../Images/Message_Information.gif"
        var Url = "../Lib/InformationWindow.htm" 
        var Fea = "menubar=no,status=no,resizable={r},scrollbars={s},left={x},top={y},width={w},height={h}"
        Fea = Fea.replace("{x}",(screen.availWidth - 600) / 2)         
        Fea = Fea.replace("{y}",(screen.availHeight - height) / 2)         
	    Fea = Fea.replace("{w}",600)
	    Fea = Fea.replace("{h}",height)
        InformationWindow = window.open(Url,"",Fea)
    //} else {
        //msg = HTMLToText(msg)
        //ShowAlert(msg)    
    }
}
function CloseInformationWindow() { // PRIVATE 
 	if ((InformationWindow != null) && (InformationWindow.closed == false)) InformationWindow.close()
}
AttachEvent(window,"unload",CloseInformationWindow)
function ShowInformation(msg,win,modal) { 
    ShowInformationManager(win,msg,300,modal)
}
function ShowInformationSmall(msg,win,modal) { 
    ShowInformationManager(win,msg,200,modal)
}
function ShowInformationMedium(msg,win,modal) { 
    ShowInformationManager(win,msg,300,modal)
}
function ShowInformationLarge(msg,win,modal) { 
    ShowInformationManager(win,msg,400,modal)
}

//#############################################################################
//#############################################################################
//#############################################################################
// TEXT

function ShowTextManager(win,text,height) { 
	if (win == null) win = window
	if ((win.showModalDialog) && (IsIE() == true)) {
	    var obj = new Object()
	    obj.Window = win
	    obj.CloseLabel = MessageCloseLabel()
	    obj.Text = text
        obj.Url = "../Lib/TextWindow.htm" 
        obj.Features = "dialogWidth:600px;dialogHeight:" + height + "px;center:yes;help:no;close:no;unadorned:yes;status:no;scroll:no" 
	    try {
    	    var res = win.showModalDialog(obj.Url,obj,obj.Features)	
        } catch(e) {
            msg = HTMLToText(msg)
            ShowAlert(msg)        
        } 
    } else {
        text = HTMLToText(text)
        ShowAlert(text)        
    }
}
function ShowText(text,win) { 
    ShowTextManager(win,text,350)
}
function ShowTextSmall(text,win) { 
    ShowTextManager(win,text,250)
}
function ShowTextMedium(text,win) { 
    ShowTextManager(win,text,350)
}
function ShowTextLarge(text,win) { 
    ShowTextManager(win,text,450)
}

//#############################################################################
//#############################################################################
//#############################################################################
// QUESTION

function ShowQuestionManager(win,msg,img) {
    // returns true|false 
	if (win == null) win = window
	if ((win.showModalDialog) && (IsIE() == true)) {
	    var obj = new Object()
	    obj.Window = win
	    obj.OkLabel = MessageOkLabel()
	    obj.CancelLabel = MessageCancelLabel()
	    obj.Message = msg
	    obj.Icon = img
	    obj.Result = false
	    obj.Url = "../Lib/QuestionWindow.htm" 
	    obj.Features = "dialogWidth:600px;dialogHeight:140px;center:yes;help:no;close:no;unadorned:yes;status:no;scroll:no" 
	    try {
    	    var res = win.showModalDialog(obj.Url,obj,obj.Features)	
        } catch(e) {
            msg = HTMLToText(msg)
            return ShowConfirm(msg)            
        } 
    	return res.Result == true
    } else {
        msg = HTMLToText(msg)
        if (Find(img,"Critical",true) != -1) msg = "[ CRITICAL ]\n\n" + msg
        if (Find(img,"Exclamation",true) != -1) msg = "[ EXCLAMATION ]\n\n" + msg
        return ShowConfirm(msg)            
    }
}
function ShowQuestion(msg,win) { 
    return ShowQuestionManager(win,msg,"../Images/Message_Question.gif")
}
function ShowQuestionCritical(msg,win) { 
    return ShowQuestionManager(win,msg,"../Images/Message_Critical.gif")
}
function ShowQuestionExclamation(msg,win) { 
    return ShowQuestionManager(win,msg,"../Images/Message_Exclamation.gif")
}

//#############################################################################
//#############################################################################
//#############################################################################
// INPUT

function ShowInputManager(win,msg,text,func) { 
    // returns ''|'text'
	if (win == null) win = window
	if ((win.showModalDialog) && (IsIE() == true)) {
	    var obj = new Object()
	    obj.Window = win
	    obj.OkLabel = MessageOkLabel()
	    obj.CancelLabel = MessageCancelLabel()
	    obj.Message = msg
	    obj.Text = text
	    obj.Function = func
	    obj.Ok = false
	    obj.Url = "../Lib/InputWindow.htm" 
	    obj.Features = "dialogWidth:600px;dialogHeight:150px;center:yes;help:no;close:no;unadorned:yes;status:no;scroll:no" 
	    var res = null
	    try {
    	    res = win.showModalDialog(obj.Url,obj,obj.Features)	
        } catch(e) {
            msg = HTMLToText(msg)
            return ShowPrompt(msg,text)
        }
	    return (res.Ok == true) ? res.Text : ""
    } else {
        msg = HTMLToText(msg)
        return ShowPrompt(msg,text)
    }
}
function ShowInput(msg,text,win,func) {
    return ShowInputManager(win,msg,text,func)      
}

//#############################################################################
//#############################################################################
//#############################################################################
// SELECTION

function ShowSelectionManager(opt,win) { 
	win = win || window
	if ((win.showModalDialog) && (IsIE() == true)) {
	    opt = opt || SelectionOptions
	    var obj = new Object()
	    obj.Window = win
	    obj.OkLabel = MessageOkLabel()
	    obj.CancelLabel = MessageCancelLabel()
	    opt.Result = ""
        obj.Options = opt
	    obj.Url = "../Lib/SelectionWindow.htm" 
	    obj.Features = "dialogWidth:600px;dialogHeight:300px;center:yes;help:no;close:no;unadorned:yes;status:no;scroll:no" 
	    try {
    	    var res = win.showModalDialog(obj.Url,obj,obj.Features)	
    	    SelectionOptions = new Array()
    	    return res.Result
        } catch(e) {
            ShowAlert("Selection not supported: " + (e.message || e))
        } 
    } else {
        var s = ""
        for (var i=0;i<SelectionOptions.length;i++) s += "[" + (i+1) + "]" + Space(4) + HTMLToText(SelectionOptions[i].Name) + "\n"
        s += "\n(insert a selection index number)"
        var r = ShowPrompt(s)
        if (r != "") { 
            r = parseInt(r)
            if (r != NaN) { 
                r = (SelectionOptions[r-1] || "").Value || "" 
            } else {
                r = ""               
            }
        }
        SelectionOptions = new Array()
        return r
    }
}
var SelectionOptions = new Array()
function AddSelectionOption(sName,sValue,sIcon) {
    var obj = new Object()
    obj.Name = sName || ""
    obj.Value = sValue || sName || ""
    obj.Icon = sIcon || ""
    SelectionOptions[SelectionOptions.length] = obj
}
function ShowSelection(opt,win) {
    return ShowSelectionManager(opt,win)      
}

//#############################################################################
//#############################################################################
//#############################################################################
// HTML

var HTMLWindow = null
function ShowHTMLManager(url,htm,tit,win) {
	if (win == null) win = window
	if ((HTMLWindow != null) && (HTMLWindow.closed == false)) {
		HTMLWindow.close()
	}
    var w = 1000; if (w > (screen.availWidth - 100)) w = screen.availWidth - 100
    var h = 800; if (h > (screen.availHeight - 100)) h = screen.availHeight - 100
    var x = (screen.availWidth - w) / 2
    var y = (screen.availHeight - h) / 2
    var fea = "menubar=no,resizable=yes,scrollbars=yes,left={x},top={y},width={w},height={h}"
    fea = fea.replace("{x}",x)
    fea = fea.replace("{y}",y)
    fea = fea.replace("{w}",w)
    fea = fea.replace("{h}",h)
    HTMLWindow = win.open(url || "","HTMLWindow",fea)
    if ((htm || "") != "") {
        HTMLWindow.document.clear()
        HTMLWindow.document.writeln("<html>")	     
        HTMLWindow.document.writeln("<head>")	     
        HTMLWindow.document.writeln("<title>" + tit + "<\/title>")	     
        HTMLWindow.document.writeln("<style>\nhtml{border:0px}\nbody,table,td{font-family:arial;font-size:9pt}\n<\/style>")	     
        HTMLWindow.document.writeln("<\/head>")
        HTMLWindow.document.writeln("<body onkeyup=\"if((event||window.event).keyCode==27)window.close()\">")	     
        HTMLWindow.document.writeln(htm)
        HTMLWindow.document.writeln("<\/body>")
        HTMLWindow.document.writeln("<\/html>")
        HTMLWindow.document.close()
    }      
    return HTMLWindow	    
}
function CloseHTMLManager() {
	if ((HTMLWindow != null) && (HTMLWindow.closed == false)) HTMLWindow.close()
}
AttachEvent(window,"unload",CloseHTMLManager)
function ShowHTML(htm,tit,win) {
    return ShowHTMLManager("",htm,tit,win)
}
function ShowURL(url,tit,win) {
    return ShowHTMLManager(url,"",tit,win)
}

//#############################################################################
//#############################################################################
//#############################################################################

