﻿/** GLOBAL VARIABLES **************************************************/

var _NL = "\n";
var _TAB = "\t";
var Guid = { Empty: "00000000-0000-0000-0000-000000000000" };
window["undefined"] = window["undefined"];
Date.MinValue = new Date(0,0,1,0,0,0); Date.MinValue.setFullYear(1);
function Guid(guid)
{
	this._a   	 = new Number(0);
	this._b   	 = new Number(0);
	this._c   	 = new Number(0);
	this._d   	 = new Number(0);
	this._e   	 = new Number(0);
	this._f   	 = new Number(0);
	this._g   	 = new Number(0);
	this._h   	 = new Number(0);
	this._i   	 = new Number(0);
	this._j   	 = new Number(0);
	this._k   	 = new Number(0);
	this.Empty	 = Guid.Empty;
	this.NewGuid = function () { return generateNewGuid();}
}


/** COLOR ARRAY **/
var globalColorArray = {
	"activeborder":			"#d4d0c8",
	"activecaption":			"#c0c0c0",
	"activecaptiontext":			"#0e1010",
	"aliceblue":			"#f0f8ff",
	"antiquewhite":			"#faebd7",
	"appworkspace":			"#808080",
	"aqua":			"#00ffff",
	"aquamarine":			"#7fffd4",
	"azure":			"#f0ffff",
	"beige":			"#f5f5dc",
	"bisque":			"#ffe4c4",
	"black":			"#000000",
	"blanchedalmond":	"#ffebcd",
	"blue":				"#0000ff",
	"blueviolet":			"#8a2be2",
	"brown":			"#a52a2a",
	"burlywood":			"#deb887",
	"cadetblue":			"#5f9ea0",
	"chartreuse":			"#7fff00",
	"chocolate":			"#d2691e",
	/*"control":			"#e0dfe3",
	"controldark":			"#9d9da1",
	"controldarkdark":			"#716f64",
	"controllight":			"#f1efe2",
	"controllightlight":	"#ffffff",
	"controltext":			"#000000",*/
	"coral":			"#ff7f50",
	"cornflowerblue":	 "000000",
	"cornsilk":			"#fff8dc",
	"crimson":			"#dc143c",
	"cyan":			"#00ffff",
	"darkblue":			"#00008b",
	"darkcyan":			"#008b8b",
	"darkgoldenrod":			"#b8860b",
	"darkgray":			"#a9a9a9",
	"darkgreen":			"#006400",
	"darkkhaki":			"#bdb76b",
	"darkmagenta":			"#8b008b",
	"darkolivegreen":			"#556b2f",
	"darkorange":			"#ff8c00",
	"darkorchid":			"#9932cc",
	"darkred":			"#8b0000",
	"darksalmon":			"#e9967a",
	"darkseagreen":			"#8fbc8b",
	"darkslateblue":			"#483d8b",
	"darkslategray":			"#2f4f4f",
	"darkturquoise":			"#00ced1",
	"darkviolet":			"#9400d3",
	"deeppink":			"#ff1493",
	"deepskyblue":			"#00bfff",
	"desktop":			"#dcdce2",
	"dimgray":			"#696969",
	"dodgerblue":			"#1e90ff",
	"firebrick":			"#b22222",
	"floralwhite":			"#fffaf0",
	"forestgreen":			"#228b22",
	"fuchsia":			"#ff00ff",
	"gainsboro":			"#dcdcdc",
	"ghostwhite":			"#f8f8ff",
	"gold":			"#ffd700",
	"goldenrod":			"#daa520",
	"gray":			"#808080",
	"graytext":			"#aca899",
	"green":			"#008000",
	"greenyellow":			"#adff2f",
	"highlight":			"#b2b4bf",
	"highlighttext":			"#000000",
	"honeydew":			"#f0fff0",
	"hotpink":			"#ff69b4",
	"hottrack":			"#648bcb",
	"inactiveborder":			"#d4d0c8",
	"inactivecaption":			"#ffffff",
	"inactivecaptiontext":			"#a2a1a1",
	"indianred":			"#cd5c5c",
	"indigo":			"#4b0082",
	"info":			"#ffffe1",
	"infotext":			"#000000",
	"ivory":			"#fffff0",
	"khaki":			"#f0e68c",
	"lavender":			"#e6e6fa",
	"lavenderblush":			"#fff0f5",
	"lawngreen":			"#7cfc00",
	"lemonchiffon":			"#fffacd",
	"lightblue":			"#add8e6",
	"lightcoral":			"#f08080",
	"lightcyan":			"#e0ffff",
	"lightgoldenrodyellow":			"#fafad2",
	"lightgray":			"#d3d3d3",
	"lightgreen":			"#90ee90",
	"lightpink":			"#ffb6c1",
	"lightsalmon":			"#ffa07a",
	"lightseagreen":			"#20b2aa",
	"lightskyblue":			"#87cefa",
	"lightslategray":			"#778899",
	"lightsteelblue":			"#b0c4de",
	"lightyellow":			"#ffffe0",
	"lime":			"#00ff00",
	"limegreen":			"#32cd32",
	"linen":			"#faf0e6",
	"magenta":			"#ff00ff",
	"maroon":			"#800000",
	"mediumaquamarine":			"#66cdaa",
	"mediumblue":			"#0000cd",
	"mediumorchid":			"#ba55d3",
	"mediumpurple":			"#9370db",
	"mediumseagreen":			"#3cb371",
	"mediumslateblue":			"#7b68ee",
	"mediumspringgreen":			"#00fa9a",
	"mediumturquoise":			"#48d1cc",
	"mediumvioletred":			"#c71585",
	"menu":			"#ffffff",
	"menutext":			"#000000",
	"midnightblue":			"#191970",
	"mintcream":			"#f5fffa",
	"mistyrose":			"#ffe4e1",
	"moccasin":			"#ffe4b5",
	"navajowhite":			"#ffdead",
	"navy":			"#000080",
	"oldlace":			"#fdf5e6",
	"olive":			"#808000",
	"olivedrab":			"#6b8e23",
	"orange":			"#ffa500",
	"orangered":			"#ff4500",
	"orchid":			"#da70d6",
	"palegoldenrod":			"#eee8aa",
	"palegreen":			"#98fb98",
	"paleturquoise":			"#afeeee",
	"palevioletred":			"#db7093",
	"papayawhip":			"#ffefd5",
	"peachpuff":			"#ffdab9",
	"peru":			"#cd853f",
	"pink":			"#ffc0cb",
	"plum":			"#dda0dd",
	"powderblue":			"#b0e0e6",
	"purple":			"#800080",
	"red":			"#ff0000",
	"rosybrown":			"#bc8f8f",
	"royalblue":			"#4169e1",
	"saddlebrown":			"#8b4513",
	"salmon":			"#fa8072",
	"sandybrown":			"#f4a460",
	"scrollbar":			"#d4d0c8",
	"seagreen":			"#2e8b57",
	"seashell":			"#fff5ee",
	"sienna":			"#a0522d",
	"silver":			"#c0c0c0",
	"skyblue":			"#87ceeb",
	"slateblue":			"#6a5acd",
	"slategray":			"#708090",
	"snow":			"#fffafa",
	"springgreen":			"#00ff7f",
	"steelblue":			"#4682b4",
	"tan":			"#d2b48c",
	"teal":			"#008080",
	"thistle":			"#d8bfd8",
	"tomato":			"#ff6347",
	"transparent":			"#ffffff",
	"turquoise":			"#40e0d0",
	"violet":			"#ee82ee",
	"wheat":			"#f5deb3",
	"white":			"#ffffff",
	"whitesmoke":			"#f5f5f5",
	/*"window":			"#ffffff",
	"windowframe":			"#000000",
	"windowtext":			"#000000",*/
	"yellow":			"#ffff00",
	"yellowgreen":			"#9acd32"
	,
	//de-DE 
	"schwarz":			"#000000",
	"blau":				"#0000ff",
	"blauviolett":			"#8a2be2",
	"braun":			"#a52a2a",
	"kakao":			"#d2691e",
	"schokolade":			"#d2691e",
	"dunkelblau":			"#00008b",
	"dunkelgrau":			"#a9a9a9",
	"dunkelgrün":			"#006400",
	"dunkelkhaki":			"#bdb76b",
	"dunkelmagenta":			"#8b008b",
	"dunkelolivgrün":			"#556b2f",
	"dunkelorange":			"#ff8c00",
	"dunkelorchid":			"#9932cc",
	"dunkelrot":			"#8b0000",
	"dunkellachs":			"#e9967a",
	"dunkelseegrün":			"#8fbc8b",
	"dunkeltürkis":			"#00ced1",
	"dunkelviolett":			"#9400d3",
	"tiefpink":			"#ff1493",
	"tiefhimmelblau":			"#00bfff",
	"ziegelstein":			"#b22222",
	"waldgrün":			"#228b22",
	"golden":			"#ffd700",
	"grau":			"#808080",
	"grün":			"#008000",
	"grüngelb":			"#adff2f",
	"lavendel":			"#e6e6fa",
	"rasengrün":			"#7cfc00",
	"hellblau":			"#add8e6",
	"hellgrau":			"#d3d3d3",
	"hellgrün":			"#90ee90",
	"hellpink":			"#ffb6c1",
	"helllachs":			"#ffa07a",
	"hellseegrün":			"#20b2aa",
	"hellhimmelblau":			"#87cefa",
	"hellstahlblau":			"#b0c4de",
	"hellgelb":			"#ffffe0",
	"mittelblau":			"#0000cd",
	"mittelseegrün":			"#3cb371",
	"mitteltürkis":			"#48d1cc",
	"oliv":			"#808000",
	"orange":			"#ffa500",
	"orangerot":			"#ff4500",
	"pflaumen":			"#dda0dd",
	"rot":			"#ff0000",
	"königsblau":			"#4169e1",
	"lachs":			"#fa8072",
	"sandbraun":			"#f4a460",
	"seegrün":			"#2e8b57",
	"silbern":			"#c0c0c0",
	"himmelblau":			"#87ceeb",
	"schneeweiß":			"#fffafa",
	"stahlblau":			"#4682b4",
	"tomate":			"#ff6347",
	"türkis":			"#40e0d0",
	"violett":			"#ee82ee",
	"weizen":			"#f5deb3",
	"weiß":			"#ffffff",
	"weiss":			"#ffffff",
	"gelb":			"#ffff00",
	"gelbgrün":			"#9acd32"
};


function getColorKeys()
{
	var arr = new Array();
	for (var key in globalColorArray)
	{
		arr.push(key);
	}	
	return arr;
}

function getColorValues ()
{
	var arr = new Array();
	for (var key in globalColorArray)
	{
		arr.push(globalColorArray[key]);
	}	
	return arr;
}
function convertInt2Hex (  f )
{
	var i1, i2;
	var result;
	var h = String("0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F").split(",");
	i1 =  Math.round (Math.floor((Number(f)/16)));
	i2 = f - (i1*16);
	result =  h [i1] + h [i2];
	return result;
}
function convertHex2Int ( f )
{
	var i1,i2, result;
	i1 = String(f).substr(0, 1);
	i2 = String(f).substr(1,1);
	result = ((getHex2Int (i1)*16) + getHex2Int (i2));
	return result;
}
function convertHex2RGB ( hexCode )
{
	if(!hexCode) return null;
	if(String(hexCode).startsWith("#"))
		hexCode = String(hexCode).substr(1);
	return [
		convertHex2Int (hexCode.substr(0,2))
		,convertHex2Int (hexCode.substr(2,2))
		,convertHex2Int (hexCode.substr(4,2))
	];	
}
function convertRGB2Hex (rgbArray)
{
	if(rgbArray==null) return;
	
	return "#" + convertInt2Hex(rgbArray[0]) + 
		convertInt2Hex(rgbArray[1]) + 
		convertInt2Hex(rgbArray[2]);
		
}
function getHex2Int (  hex)
{
	var i;
	var h = String("0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F").split(",");
	
	hex=hex.toUpperCase();
	for (i = 0; i<16; i++)
	{	
		if ( hex == h[i])
		{
			return i;
		}
	}
	return 0;
}
// ###################################################################################
function isMS()
{
	if(navigator.appName.indexOf("Microsoft")>=0) return true;
	return false;
}
function isNS()
{
	
	if(navigator.appName=="Netscape")
		return true;
	else
		return false;
}
function Obj (objId)
{
	return document.getElementById (objId);	
}
function $() {
 var elements = new Array();

  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);

    if (arguments.length == 1)
      return element;

    elements.push(element);
  }

  return elements;
}
function hideObj (obj)
{
	obj.style.visibility='hidden';
}
function showObj (obj)
{
	obj.style.visibility='visible';
}
function displayObj(obj)
{
	obj.style.display='';
}
function undisplayObj(obj)
{
	obj.style.display='none';

}
//Returns a new empty object, if the passed paramter is null
function n$ (obj, defaultObject)
{
	return (obj ? obj : (defaultObject ? defaultObject : new Object()));
}
function convertDateToString (date, shortYear)
{
	if(currentCulture==null) currentCulture = "de-DE";
	var d, m, y;
	d = date.getDate();
	m = date.getMonth()+1; 
	y = date.getFullYear();
	if (shortYear)
		y = String(y).substr (2);
	
	if (currentCulture=="de-DE")
	{
		if(m<10) m = "0" + m;
		if(d<10) d = "0" + d;
		return d + "." + m + "." + y;
	}
	else if (currentCulture=="en-US")
	{
		return m + "/" + d + "/" + y;
	}
	else if (currentCulture=="nl-NL")
	{
		return m + "-" + d + "-" + y;
	}
	else if (currentCulture=="es-ES")
	{
		return m + "-" + d + "-" + y;
	}
	else
	{
		
		if(m<10) m = "0" + m;
		if(d<10) d = "0" + d;
		return d + "/" + m + "/" + y;
	}
}
Date.prototype.toLocaleString = function ()
{
	return convertDateToString (this);
		
}
function clearTable(table, keepFirstRow)
{
	if(table==null) return;
	var tBody = table.lastChild;
	var limit = 0;
	if(keepFirstRow) limit = 1;
	for (var r= table.rows.length-1; r>=limit; r--)
	{
		tBody.removeChild(table.rows[r]);
		
	}
}
function getActualDateString(formatFullDate,showTime,showSeconds)
{
	var d = new Date();
	var t = d.toLocaleTimeString();
	
	if (formatFullDate)
	{
		if (showTime)
			return d.toLocaleShortDateString() + ", "+ t;
		else
			return d.toLocaleShortDateString();
	}
	else
	{
		var ds = d.toLocaleShortDateString();// (d.getDate()<=9?"0":"") + d.getDate() + "." + 
			//(d.getMonth()<=8?"0":"") + (d.getMonth()+1) + "." + d.getFullYear();
		if (showTime)
		{
			if (showSeconds==true)
				ds = d.toLocaleShortDateString () + ", "+ t;
			else
				ds = toLocaleShortDateString ()  +", "  + t;//;ds + ", "+ d.getHours()+":" + (d.getMinutes()<10?"0":"")+d.getMinutes();
			
		}
		return ds;
	}
	
	
}
function Trim(str)
{
	if(!str) return str;
	if(str.length < 1){
		return "";
	}
	str = RTrim(str);
	str = LTrim(str);
	if(str =="")
	{
		return "";
	}
	else
	{
		return str;
	}
}

function RTrim(str)
{
	var len = str.length;
	var res = "";
	if(len < 0)
	{
		return "";
	}
	var i = len--;
	while(i > -1)
	{
		if(str.charCodeAt(i) > 32)
		{
			res = str.substring(0,i +1);
			break;
		}
		i--;
	} 
	return res;

} 


function LTrim(str)
{
	var len = str.length;	
	if(len < 1)
	{
		return "";
	}
	var res = "";
	var i = 0;

	while(i < len)
	{
		
		if(str.charCodeAt(i) > 32)
		{
			res = str.substring(i,len);
			break;
		}
		i++;
	}
	return res;
}


function getWindowWidth () 
{
  if (window.innerWidth) 
  {
    return window.innerWidth;
  } 
  else if (document.body && document.body.offsetWidth) {
    return document.body.offsetWidth;
  } else 
  {
    return 0;
  }
}

function getWindowHeight () 
{
  if (window.innerHeight) 
  {
    return window.innerHeight;
  } 
  else if (document.body && document.body.offsetHeight) 
  {
    return document.body.offsetHeight;
  } 
  else 
  {
    return 0;
  }
}


function validateNumber(inp)
{
	if (inp==null) inp = this;
	if (inp==null) return false;
	if(inp.value==null || inp.value=="") return false;
	var val = inp.value;
	if(!isNumeric(val))
	{
		alert (GetString("InvalidNumberWarning"));
		inp.focus();
		return true;
	}
	return false;	
	if(val=="-")
	{
		
		inp.focus();
		return;
	}
	if(val.toString().substr(0,1)=="-")
		val = val.substr(1);
	
	//Replace Comma
	val = val.replace(",",".");
	var t = Number(val);
	if (t>=0)
		return true;	
	else
	{
		alert (GetString("InvalidNumberWarning"));
		inp.focus();
		
	}
}
function validateTime (timeString)
{
	if (!timeString) return false;
	if (timeString.indexOf (":")==-1) return false;
	var parts = timeString.split (":");
	if(!parts || parts.length<2) return false;

	if (!isNumeric(parts[0]) || !(Number(parts[0])>=0 && Number(parts[0])<=24)) return false;
	if (!isNumeric(parts[1]) || !(Number(parts[1])>=0 && Number(parts[1])<=59)) return false;
	if (parts.length>2 && (!isNumeric(parts[2]) || !(Number(parts[1])>=0 && Number(parts[1])<=59))) return false;
		
	return true;
}
function validateDate(inp)
{
	if (inp==null) return false;
	if(inp.value==null || inp.value=="") return false;
	var val = inp.value;
	var res = false;
	var parts = null;
	var timeString = null;
	//Check if the date also contains the time 
	
	if (val.indexOf (" ")>0) //Contains time 
	{
		timeString = val.substr (val.indexOf (" ")+1);
		val = val.substr (0, val.indexOf (" "));
		if (!validateTime (timeString))
		{
			alert (GetString("InvalidDateWarning"));
			inp.focus();
			return;
		}
	}
	
	if(val.indexOf(".")>=0) //German format
	{
		parts = val.split(".");
	}
	else if(val.indexOf("-")>=0) //Dutch format
	{
		parts = val.split("-");
	}
	else if(val.indexOf("/")>=0) //English format
	{
		parts = val.split("/");
		//if(currentCulture=="en-US")
			if(parts.length>=3) // US-English format
			{
				var tmp = parts[1];
				parts[1] = parts[0]; //Switch day and month
				parts[0] = tmp;
			}
	}
	if(parts!=null && parts.length>=3)
	{
		var d = parts[0];
		var m = parts[1];
		var y = parts[2];
		
		if(Number(d)>=1 && Number(d)<=31)
			if(Number(m)>=1 && Number(m)<=12)				
				if(Number(y)>=0)
				{		
					if(String(y).length<=2)
					{
						if(Number(y)<=20)	//2000 till 2020
						{
							
							y =2000 + Number(y);
							
						}
						else				//1921 till 1999
							y =1900 + Number(y);
					}
						
					var check = new Date(Number(y),Number(m)-1,Number(d));
					
					var comp = new Date(1,0,1,0,0,0);// 1. Jan 1, 00:00:00
					
					if(check>=comp)
						res = true;
				}
	}
	if (!res)
	{
		alert (GetString("InvalidDateWarning"));
		inp.focus();
	}
	return res;
}
function getBrowserName()
{
	var ua = navigator.userAgent;
	if(ua.indexOf("Opera")>=0)
		return "Opera";
	else if(ua.indexOf("Chrome")>=0)
		return "Chrome";
	else if(ua.indexOf("Firebird")>=0)
		return "Firebird";
	else if(ua.indexOf("Firefox")>=0)
		return "Firefox";
	else if(ua.indexOf("Netscape")>=0)
		return "Netscape";	
	else if(ua.indexOf("MSIE")>=0)
		return "MSIE";	
	else if(ua.indexOf("Safari")>=0)
		return "Safari";	
	else 
		return "Unknown browser";
}
function getBrowserVersion()
{
	var ua = navigator.userAgent;if(ua==null) return "";
	var bname = getBrowserName(); if(bname==null) return "";
	
	if(bname=="MSIE")
	{
		name_version=ua.match("MSIE [0-9\.]+");
		if(name_version==null) return "";		
		return name_version.toString().match (/[0-9\.]+/);
	}
	var name_version = ua.match(bname + "/\.+");if(name_version==null) return "";
	if(bname=="Opera" || bname=="Netscape" || bname == "Chrome" )
	{
		
		return name_version.toString().split("/")[1].match("[0-9\.]+");
	}
	else if(bname == "Safari")
	{
		name_version = ua.match("Version/\.+");
		return name_version.toString().split("/")[1].match("[0-9\.]+");
	}

	return name_version.toString().split("/")[1];
}


function getBrowserInfo(html)
{
	var br = "\r\n";
	if(navigator.platform!="Win32")
		br = "\n";
	if(html) br = "<br>";
	var res =	
			"appCodeName:  " + 			navigator.appCodeName + br + 
			"appMinorVersion:  " +  	navigator.appMinorVersion+ br + 
			"appName:  " +  			navigator.appName + br + 
			"appVersion:  " +  			navigator.appVersion + br + 
			"userAgent:  " +  			navigator.userAgent+ br + 
			"userLanguage:  " +  		navigator.userLanguage+ br + 
			"userProfile:  " +  		navigator.userProfile+ br + 
			"platform:  " +  			navigator.platform+ br + 
			"opsProfile:  " +  			navigator.opsProfile+ br + 
			"onLine:  " +  				navigator.onLine+ br + br + 
			//"mimeTypes:  " +  			br + 
			//							getMimeTypes(navigator.mimeTypes,html) + br +br+ 
			"cpuClass:  " +  			navigator.cpuClass+ br + 
			"cookieEnabled:  " +  		navigator.cookieEnabled+ br +
			"systemLanguage:  " +  		navigator.systemLanguage+ br +
			"javaEnabled:  " +  		navigator.javaEnabled()+ br +
			"taintEnabled:  " +  		navigator.taintEnabled()+ br +br;
			//"plugins:  " +  			getMimeTypes(navigator.plugins,html);
	
	return res;
				
}

function getMimeTypes(mt,html)
{
	var br = "\r\n";
	if(navigator.platform!="Win32")
		br = "\n";
	if(html) br = "<br>";
	var res = "";
	if(mt!=null && mt.length>=1)
	{
		
		for(var i=0; i<mt.length; i++)
		{
			res +="    " + mt.item(0) + ": " + arrayToString(mt.item(0),html) + br;
		}
	}
	return res;
}

function arrayToString(arr,html)
{
	var br = "\r\n";
	if(navigator.platform!="Win32")
		br = "\n";
	if(html) br = "<br>";
	
	var res="";
	if(arr==null) return "";
	if(arr.length==0) return "";
	for (var key in arr)
	{
		res+= key + ": " + arr[key] + br;
	}
	return res;
}

function setCookie (name, value, expires, path, domain, secure) {
	document.cookie = name + "=" + escape(value) +
    	((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}
	
function getCookie(name, subname) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	if(subname!=null && setStr!=null)
	{
		var arr = setStr.split("&");
		for(var i=0; i< arr.length; i++)
		{
			var arr2 = arr[i].split("=");
			if(arr2.length>=2)
			{
				if(arr2[0]==subname)
					return arr2[1];
			}
		}
	}
	return(setStr);
}
function deleteCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			
			setStr = cookie.replace(cookie.substring(offset, end)+";","");
			document.cookie = setStr;
		}
	}
	
}
function getQueryString(name,querystring) {
	if(querystring==null)
		querystring = document.location.search.substr(1);
	var search = "" + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (querystring.length > 0) {
		offset = querystring.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = querystring.indexOf("&", offset)
			if (end == -1) {
				end = querystring.length;
			}
			setStr = unescape(querystring.substring(offset, end));
		}
	}
	return(setStr);
}
function setQueryString (name, newValue, querystring) {
	if(querystring==null)
		querystring = document.location.search.substr(1);
	var search = "" + name + "=";
	var parts = querystring.split ("&");
	
	var newString = "";
	var found = false;
	for (var i=0; i < parts.length; i++)
	{
		var arr = String(parts [i]).split ("=");
		var sName = arr [0];
		var sVal = (arr.length >1 ? arr [1] : null);
		
		if (sName == name)
		{
			sVal = newValue;
			found = true;
		}
		
		newString += (newString!="" ? "&" : "") + 
			sName + "=" + (!isEmpty(sVal) ? sVal : "");
	}
	if (!found)
	{
		newString += (newString!="" ? "&" : "") + 
			name + "=" + (!isEmpty(newValue) ? newValue : "");
		
	}
	return newString;
}

function displayPopupAtRelativeLocation (EVENT, popup, objDiv, divWidth, divHeight,offsetLeft, offsetTop, wind, doc)
{
	
	if(wind==null) wind = window;
	if(doc == null) doc  = document;
	var left=100, top=100;
	objDiv.style.display = "";	
	if (isNS())
	{
		left = EVENT.pageX;
		top = EVENT.pageY;	
		
		//Wenn Top > Fensterhöhe
		if ( (top + divHeight) > ( wind.pageYOffset + wind.innerHeight ))
			top = wind.pageYOffset + wind.innerHeight - divHeight;
		//Wenn  Top < 0 
		if (top < wind.pageYOffset)
			top = wind.pageYOffset-10;

		//Wenn Left+Width > Fensterbreite
		if ( (left+divWidth) > ( wind.pageXOffset + wind.innerWidth ) )
			left = wind.pageXOffset + wind.innerWidth - divWidth;
		//Wenn Lef < 0
		if ( left < wind.pageXOffset )
			left = wind.pageXOffset+10;
	}
	else
	{
		left = EVENT.x + doc.body.scrollLeft+ offsetLeft+left;
		top = EVENT.y + doc.body.scrollTop+ offsetTop+top;	
		
		//Debug-Info:
		//window.status= objDiv.currentStyle.height; //top + " - " + document.body.offsetHeight;
		
		
		//Wenn Top > Fensterhöhe
		if ( (top + divHeight) > ( doc.body.offsetHeight + doc.body.scrollTop) )
			top = EVENT.y + doc.body.scrollTop - divHeight;
		//Wenn  Top < 0 
		if (top < doc.body.scrollTop)
			top = EVENT.y + doc.body.scrollTop;
		//Wenn Left+Width > Fensterbreite
		if ( (left+divWidth) > ( doc.body.offsetWidth + doc.body.scrollLeft) )
			left = EVENT.x + doc.body.scrollLeft - divWidth;
		//Wenn Lef < 0
		if ( left < doc.body.scrollLeft )
			left = EVENT.x + doc.body.scrollLeft;
				
	}
	popup.show(left,top,divWidth, divHeight,document.body);
	
}

//Displays an object at a location relative to the cursor
function displayAtRelativeLocation (EVENT, objDiv, divWidth, divHeight,offsetLeft, offsetTop, wind)
{
	if(wind==null) wind = window;
	var doc  = wind.document;
	var left=100, top=100;
	
	if (isNS())
	{
		left = EVENT.pageX;
		top = EVENT.pageY;	
		
		//Wenn Top > Fensterhöhe
		if ( (top + divHeight) > ( wind.pageYOffset + wind.innerHeight ))
			top = wind.pageYOffset + wind.innerHeight - divHeight;
		//Wenn  Top < 0 
		if (top < wind.pageYOffset)
			top = wind.pageYOffset-10;

		//Wenn Left+Width > Fensterbreite
		if ( (left+divWidth) > ( wind.pageXOffset + wind.innerWidth ) )
			left = wind.pageXOffset + wind.innerWidth - divWidth;
		//Wenn Lef < 0
		if ( left < wind.pageXOffset )
			left = wind.pageXOffset+10;
			
			
			
	}
	else
	{
		left = EVENT.x + doc.body.scrollLeft+ offsetLeft;
		top = EVENT.y + doc.body.scrollTop+ offsetTop;	
		
		//Debug-Info:
		//window.status= objDiv.currentStyle.height; //top + " - " + document.body.offsetHeight;
		
		
		//Wenn Top > Fensterhöhe
		if ( (top + divHeight) > ( doc.body.offsetHeight + doc.body.scrollTop) )
			top = EVENT.y + doc.body.scrollTop - divHeight;
		//Wenn  Top < 0 
		if (top < doc.body.scrollTop)
			top = EVENT.y + doc.body.scrollTop;
		//Wenn Left+Width > Fensterbreite
		if ( (left+divWidth) > ( doc.body.offsetWidth + doc.body.scrollLeft) )
			left = EVENT.x + doc.body.scrollLeft - divWidth;
		//Wenn Lef < 0
		if ( left < doc.body.scrollLeft )
			left = EVENT.x + doc.body.scrollLeft;
				
	}
	//objDiv.style.left =left;
	//objDiv.style.top = top ;
	//objDiv.style.display = "";		
	
	
	
	
}


function ObjectParameters (obj)
{
	this.top  =obj.style.top; this.top=(this.top!=null?new Number(this.top.substr(0,this.top.length-2)):null);		
	this.left  =obj.style.left; this.left=(this.left!=null?new Number(this.left.substr(0,this.left.length-2)):null);		
	this.height  =obj.style.height; this.height=(this.height!=null?new Number(this.height.substr(0,this.height.length-2)):null);
	this.width  =obj.style.width; this.width=(this.width!=null?new Number(this.width.substr(0,this.width.length-2)):null);

}
//var oAttributesPopup=window.createPopup();
var oAttributesPopup;
if (!navigator.appName=="Netscape")
{
	oAttributesPopup=window.createPopup();
}
var sortres ="";
function sortCollection(coll)
{
	var keys=new Array();
	for (var key in coll)
	{
		keys.push(key);
	}
	keys.sort();
	var newColl = new Array();
	for (var k=0; k < keys.length; k++)
	{
		var key = keys[k];
		newColl[key] = coll[key];
	}
	return newColl;
}

function sortAttributes(a,b)
{
	return -1;
}
function alert$(o)
{
	alert($$(o));
}

if(isMS())
{
	window.execScript ("window.alert§ = function (){ var res = \"\"; var separator = \",\"; for (var arg=0; arg<arguments.length; arg++) {res += (arg>0?separator:\"\") + arguments[arg];} alert(res);}");
}

function popup$ (o)
{
	var html = $$(o,true);
	if(document.all)
	{
		var win = window.createPopup();
		win.document.body.style.backgroundColor="whitesmoke";
		win.document.body.style.border="1px solid gray";
		win.document.body.innerHTML = "<div style='overflow:auto;width:100%;height:100%'>" + html + "</div>";
		win.show(10,10,200,200,window.document.body);
	}
}
function $$(obj,html)
{
	return $Attr(obj,html);
}
function $Attr(obj,html)
{
	return getAttributes(obj,html);
}
//Returns a list of attributes 
function getAttributes(obj,html)
{
	var lastObject = null;
	var lastKey = null;
	//try
	{
		
		if(obj==null) return;
		var res = "";
		
		//Basic info:
		var tt = getTagAndType(obj,true);
		res = tt.tag + (obj.id? " \"" + obj.id + "\" ":"") + (tt.type? " [" + tt.type + "] ":"") + "\n\n";
		
		var keys=new Array();
		var maxLength = 0;
		var longestWord = null;
		
		//Check if it is a xml nodes collection
		if(typeof(obj)=="object" &&
			obj.expr !=null && obj.context !=null )
		{
			return  "length:	" + obj.length + "\n" + 
			"expr:	" + obj.expr + "\n" + 
			"context:	" + obj.context;
		}
		//Check if it is an xml node
		if(typeof(obj)=="object" &&
			obj.nodeType ==1 && obj.nodeTypeString == "element"
			&& obj.xml)
		{
			keys = new Array( "nodeName","nodeValue","nodeType","parentNode","childNodes","firstChild","lastChild","previousSibling","nextSibling","attributes","ownerDocument","nodeTypeString","text","specified","definition","nodeTypedValue","dataType","xml","parsed","namespaceURI","prefix","baseName","tagName");
			maxLength = 15;
			longestWord = "previousSibling";
		}
		else
		{
			for (var a in obj)
			{
				keys[keys.length]=a;
				var strValue = "";
				try
				{
					try {
						strValue = obj[a].toString();
					}
					catch (err){
						try
						{
							strValue = String (obj[a]);
						}catch (err){
							strValue="unavailable";
						}
					}
					if(isEmpty(strValue)) continue;
					//if(isNull(strValue)) strValue = "null";
					//else if(isEmpty(strValue)) strValue = "";
					
					if(a =="innerHTML" || a=="outerHTML" || a=="innerText" || a=="outerText") { continue;}
					if( strValue.indexOf("function ")==0 || strValue.indexOf("function(")==0)
						strValue = "[ FUNCTION ]";
						
					var str = String(a) + ": " + strValue;
					if(str.length>maxLength) maxLength = str.length;
				}catch (err2) {}
				
			}
		}
		keys.sort();
		if(maxLength>50) maxLength = 50;
		if(!html)
		{
			var cellsPerRow = 0;
			for (var group in jsObjectProperties)
			{
				cellsPerRow = 0;
				//Attributes of the group 
				var attributes = jsObjectProperties[group];
				var groupProps = "";
				for (var k=0; k< attributes.length; k++)
				{
					//No inner or outer html
					var strKey = new String(attributes[k]);
					try {lastObject = obj[attributes[k]];}catch (err){}
					lastKey = attributes[k];
					var strValue  = "";
					try
					{
						strValue = obj[attributes[k]].toString();
						
					}catch (err){
						try
						{
							strValue = String (obj[attributes[k]]);
						}catch (err){
							strValue="unavailable";
						}
					}
					//Check if null 
					if(isEmpty(strValue)) continue;
					//if(isNull(strValue)) strValue = "null";
					//else if(isEmpty(strValue)) strValue = "";
					
					if(strKey=="innerHTML" || strKey =="outerHTML" || strKey=="innerText" || strKey=="outerText") { continue;}
					if( strValue.indexOf("function ")==0 || strValue.indexOf("function(")==0)
						strValue = "[ FUNCTION ]";
					var textLength = (strKey + ": " + strValue).length;
					var spaces = "";
					var countSpaces = maxLength - (strKey + ": " + strValue).length;
					for (var s=0; s < countSpaces; s++) spaces+=" ";
					//if(countSpaces>2)
						spaces+="\t";
					groupProps+= strKey + ": " + strValue;
					cellsPerRow++;
					if (cellsPerRow >=3 )
					{
						groupProps+="\n";
						cellsPerRow =0;
					}
					else
						groupProps+=spaces;
				}
				if(groupProps!="")
				{
					//Group title 
					res +="/***** " + String(group).toUpperCase() + " *****/\n\n";
					res+=groupProps;
					res+="\n\n";
				}
				
			}
			res+="\n";
			//Attributes which are not in the grouped collection yet 
			res +="/***** (VARIOUS) *****/\n";
			for (var k in keys)
			{
				
				//No inner or outer html
				var strKey = new String(keys[k]);
				try {lastObject = obj[keys[k]];}catch (err){}
				lastKey = keys[k];
				if(jsObjectPropertiesCollection[strKey]!=null) continue;
				var strValue  = "";
				try
				{
					strValue = obj[keys[k]].toString();
				}catch (err){
					try
					{
						strValue = String (obj[keys[k]]);
					}catch (err){
						strValue="unavailable";
					}
				}
				if(isNull(strValue)) strValue = "null";
				else if(isEmpty(strValue)) strValue = "";
				if(strKey=="innerHTML" || strKey =="outerHTML" || strKey=="innerText" || strKey=="outerText") { continue;}
				if( strValue.indexOf("function ")==0 || strValue.indexOf("function(")==0)
					strValue = "[ FUNCTION ]";
				var textLength = (strKey + ": " + strValue).length;
				var spaces = "";
				var countSpaces = maxLength - (strKey + ": " + strValue).length;
				for (var s=0; s < countSpaces; s++) spaces+=" ";
				//if(countSpaces>2)
					spaces+="\t";
				res+= strKey + ": " + strValue;
				cellsPerRow++;
				if (cellsPerRow >=3 )
				{
					res+="\r\n";
					cellsPerRow =0;
				}
				else
					res+=spaces;
				
			}
			return res;
		}
		else
		{
			res="<table border=1 cellpadding=2 style='font-family:Arial;font-size:8pt;width:100%' cellpadding=2 cellspacing=0>";
			res+="<tr>";
			var cellsPerRow = 0;
			for (var k in keys)
			{
				//No inner or outer html
				var strKey = new String(keys[k]);
				lastObject = obj[keys[k]];
				lastKey = keys[k];
				var strValue  = "";
				try
				{
					strValue = obj[keys[k]].toString();
				}catch (err){
					try
					{
						strValue = String (obj[keys[k]]);
					}catch (err){
						strValue="unavailable";
					}
				}
				if(isNull(strValue)) strValue = "null";
				else if(isEmpty(strValue)) strValue = "";
				
				if(strKey=="innerHTML" || strKey =="outerHTML" || strKey=="innerText" || strKey=="outerText") { continue;}
				if( strValue.indexOf("function ")==0 || strValue.indexOf("function(")==0)
					strValue = "[ FUNCTION ]";
				var textLength = (strKey + ": " + strValue).length;
				
				res+= "<th align=left>" + strKey + "</th><td>" + strValue + "&nbsp;</td>";
				cellsPerRow++;
				if (cellsPerRow >=2 )
				{
					res+="</tr><tr>";
					cellsPerRow =0;
				}
				
			}
			
			res+="</tr></table>";
			return res;
		}
	}
	//catch (err)
	{
		
		return "Fehler: "+ lastKey + ": " + lastObject + "\n" + err.message;
	}
}
function msgBox (msg,width,height,resizable,scrollbars)
{
	try
	{
		if(!width) width = 500;
		if(!height) height = 300;
		var x = (window.screen.availWidth - width)/2;
		var y = (window.screen.availHeight - height)/2;
		
		var win = window.open("about:blank","MessageBox","left=" + x + ",top=" + y + ",width=" + width +",height=" +height + ",resizable=" + (resizable!=false?"yes":"no") +",scrollbars=" + (scrollbars!=false?"yes":"no"));
		
		win.document.write ("<pre>" + HtmlEncode(msg) + "<pre>");
		win.focus();
	}catch (err)
	{
		window.status = (err.message?err.message:err.description);
	}
}
function getStyleSheet(st)
{
	var res = "";
	if(st==null) return;
	if(st.rules==null)return;
		if (navigator.appName=="Netscape")
		{
			oAttributesPopup=window.open();
		}
		oAttributesPopup.document.body.style.backgroundColor="whitesmoke";
		oAttributesPopup.document.body.style.border="1px solid gray";
		
		res="<table style='font-family:Arial;font-size:8pt' cellpadding=2 cellspacing=0>";
		
		for (var r in st.rules)
		{
			if(st.rules[r].style!=null && st.rules[r].style["cssText"]!=null)
			{
				res+="<tr><td valign=top><b>"+st.rules[r].selectorText+"</b></td>" +
					"<td  valign=top>" + 
					getStyleList(st.rules[r].style["cssText"],true) + 
					 "</td></tr>";
			}
		}
		res+="</table>";
		oAttributesPopup.document.body.innerHTML = "<div style='overflow:auto;width:100%;height:100%'>" + res + "</div>";
		oAttributesPopup.show(100,100,500,500,window.document.body);
		
}
function getStyleList(st,html)
{
	if(st==null) return "";
	if(html==null) html=false;
	var styles=st.split(";");
	var res="";
	if(!html)
	{
		for(var s in styles)
		{
			var s2=styles[s].split(":");
			if(s2==null) continue;
			res+=s2[0]+":\t" + s2[1]+"\r\n";
		}
	}
	else
	{
		res="<table style='font-family:Arial;font-size:8pt' cellpadding=0 cellspacing=0>";
		for(var s in styles)
		{
			var s2=styles[s].split(":");
			if(s2==null) continue;
			
			res+="<tr><td><font color=blue><b>" + s2[0] +"</b></font></td><td>&nbsp;" +	s2[1]+"</td></tr>";
		}
		res+="</table>";
	}
	return res;
}
function scrollListBox (lb_id,step)
{
	
	var lb = Obj(lb_id);
	if(lb==null) return;
	var index = lb.selectedIndex;
	index += step;
	if(index<0) index=0;
	if(index>(lb.options.length-1)) index = lb.options.length-1;
	lb.selectedIndex = index;	
	if(window.cancelOverwriting!=null)
		window.cancelOverwriting(null);
}
//An alias
function setListBoxIndex(lb,val,ignoreCase,addIfMissing){ setListboxIndex(lb,val,ignoreCase,addIfMissing);}
function setListboxIndex (lb,val,ignoreCase, addIfMissing, noOnChangeEvent)
{
	//lb.style.border="1px solid black";
	
	if(ignoreCase==null) ignoreCase = true;
	if(lb==null) return;
	
	
	for (var o=0; o<lb.options.length;o++)
	{
		if(ignoreCase)
		{
			
			if(String(lb.options[o].value).toLowerCase()==String(val).toLowerCase())
			{
				lb.options[o].selected=true;
				//Fire event
				if (!noOnChangeEvent)
					callEvent(lb,"onchange");
				return;
			}
		}
		else
		{
			
			if(String(lb.options[o].value)==String(val))
			{
				lb.options[o].selected=true;
				//Fire event
				callEvent(lb,"onchange");
				return;
			}
		}			
	}
	if(addIfMissing)
	{
		lb.options[lb.options.length] = new Option (val, val);
		lb.selectedIndex = lb.options.length-1;
	}
	else
		lb.selectedIndex=-1;
	
}
function scrollerDown (scroller)
{
	if (scroller==null) return;
	scroller.style.borderTop = "1px solid black";
	scroller.style.borderLeft = "1px solid black";
	scroller.style.borderRight = "1px solid white";
	scroller.style.borderBottom = "1px solid white";
	

}
function scrollerUp (scroller)
{
	if (scroller==null) return;
	scroller.style.borderTop = "1px solid white";
	scroller.style.borderLeft = "1px solid white";
	scroller.style.borderRight = "1px solid black";
	scroller.style.borderBottom = "1px solid black";	
}
function getCurrentStyleValue(class_name, style_name, sheet_name)
{
	if(document.styleSheets==null) return "";
	//First find thestylesheet
	for(var s=0; s<document.styleSheets.length; s++)
	{
		var stSheet = document.styleSheets[s];		
		
		if(sheet_name!=null && stSheet.href!=null && 
			stSheet.href.toLowerCase().indexOf(sheet_name.toLowerCase())==-1)
		{
			if(stSheet.imports!=null)
			{
				for (var imp=0; imp<stSheet.imports.length; imp++)
				{
					var stSheet2 = stSheet.imports[imp];
					
					if(sheet_name!=null && stSheet2.href!=null && 
						stSheet2.href.toLowerCase().indexOf(sheet_name.toLowerCase())==-1)
						continue;
					var res = getStyleSheetRuleValue (stSheet2, class_name, style_name);
					return res;
				}
			}
			else if (stSheet.cssRules!=null)
			{
				for (var cr = 0; cr<stSheet.cssRules.length;cr++)
				{
					var r = stSheet.cssRules[cr];
					if(r.type==3)
					{
						var stSheet2 = r.styleSheet;
						
						if(sheet_name!=null && stSheet2.href!=null && 
							stSheet2.href.toLowerCase().indexOf(sheet_name.toLowerCase())==-1)
							continue;
						var res = getStyleSheetRuleValue (stSheet2, class_name, style_name);
						return res;
					}
				} 
				continue;
			}
			else
				continue;
		}	
		var res = getStyleSheetRuleValue (stSheet, class_name, style_name);
		return res;
	}	
	return null;
}
var cssStyleReplace =/(-[a-z])/gi;
var cssStyleFunction = function(m,a){return a.charAt(1).toUpperCase()};
var cssPropCache  = {};
function getCssValue (el, prop)
{
	var v, cs, camel;
	if (prop == "opacity")
	{
		if (typeof el.style.filter == "string")
		{
			var m=el.style.filter.match (/alpha\(opacity=(.*)\)/i);
			if (m) 
			{
				var fv = parseFloat (m [1]);
				if (!isNaN (fv))
				{
					return fv ? fv / 100 : 0;
				}
			}
		}
		return 1;
	}
	else 
	{
		if (prop == "float")
		{
			prop = "styleFloat";
		}
	}
	
	if (! (camel = cssPropCache [prop]))
	{
		camel = cssPropCache [prop] = prop.replace (cssStyleReplace , cssStyleFunction);
	}
	
	if (v = el.style [camel])
	{
		return v;
	}
	
	if (cs = el.currentStyle)
	{
		return cs [camel];
	}
	
	return null;
}
function getDefaultView (obj)
{
	return document.defaultView ? document.defaultView.getComputedStyle (obj,null) 
		: obj.currentStyle;
}
function getStyleValue (o, cssRule)
{
	var strValue = "";
    if(document.defaultView && document.defaultView.getComputedStyle){
        strValue = document.defaultView.getComputedStyle(o, "").getPropertyValue(cssRule);
    }
    else if(o.currentStyle){
        cssRule = cssRule.replace(/\-(\w)/g, function (strMatch, p1){
            return p1.toUpperCase();
        });
        strValue = o.currentStyle[cssRule];
    }
 //   debugger;
    if(strValue==null || strValue=="" || strValue=="auto")
    {
		switch (cssRule.toLowerCase())
		{
			case "height":
				return o.offsetHeight;
			case "width":
				return o.offsetWidth;
			case "left":
				return o.offsetLeft;
			case "top":
				return o.offsetTop;
		}
    }
    return strValue;
}
function getObjectWidth(cell)
{
	if(!cell) return 0;
	var stWidth = int(cell.currentStyle.width);
	if (stWidth>0) return stWidth;
	
	var clientWidth = int(cell.clientWidth);
	var padLeft = int(cell.currentStyle.paddingLeft);
	var padRight = int(cell.currentStyle.paddingRight);
	return clientWidth - padLeft - padRight;
}
function getObjectHeight(cell)
{
	if(!cell) return 0;
	var stHeight= int(cell.currentStyle.height);
	if (stHeight>0) return stHeight;
	
	var clientHeight = int(cell.clientHeight);
	var padTop = int(cell.currentStyle.paddingTop);
	var padBottom = int(cell.currentStyle.paddingBottom);
	return clientHeight - padTop - padBottom;
}
function getObjectBorderStyle(o, part)
{
	if(!o) return "";
	if(document.defaultView && document.defaultView.getComputedStyle)
	{
        return document.defaultView.getComputedStyle(o, "").getPropertyValue("border" + part);
    }
    else
		return	o.currentStyle["border" + part + "Width"] + " " +
			o.currentStyle["border" + part + "Style"] + " " +
			o.currentStyle["border" + part + "Color"];
		
}
function getObjectBorderCssText(o, part)
{
	if(!o) return "";
	return "border-top: " + getObjectBorderStyle (o, "Top") + ";"
		+ "border-right: " + getObjectBorderStyle (o, "Right") + ";"
		+ "border-bottom: " + getObjectBorderStyle (o, "Bottom") + ";"
		+ "border-left: " + getObjectBorderStyle (o, "Left") + ";"
		
}
function getStyleSheetRuleValue (stSheet, ruleName,style_name)
{
	if(stSheet==null || ruleName==null || style_name==null) return null;
	var rules  = stSheet.rules;
	if(rules==null) rules = stSheet.cssRules;
	if(rules==null ) return null;
	
	for (var r = 0; r < rules.length; r++)
	{
		var rule = rules[r];
		if(rule.selectorText!=null && rule.selectorText.toLowerCase()==ruleName.toLowerCase())
		{
			if(!style_name) return rule.cssText;
			var styles = rule.style;
			if(styles==null) continue;
			var res =styles[style_name];
			if(res==null || res=="")
				res = styles[style_name.toUpperCase()];
			return res;
		}
	}	
	return null;	
}
function getStylesheetVariable(sh_name,variable,style, return_value_if_not_found)
{
	
	if(sh_name==null || variable==null) return return_value_if_not_found;
	if(document.styleSheets==null) return return_value_if_not_found;
	
	var st=null;
	//First find the right stylesheet
	for(var s=0; s<document.styleSheets.length; s++)
	{
		if(document.styleSheets[s].href!=null && 
			document.styleSheets[s].href.toLowerCase().indexOf(sh_name.toLowerCase())>=0)
		{
			st = document.styleSheets[s];
			break;
		}	
	}
		
	if(st==null) return return_value_if_not_found;
	//Second, find the right rule
	var rules  = st.rules;
	if(rules==null) rules = st.cssRules;
	if(rules==null ) return return_value_if_not_found;
	
	for (var r = 0; r < rules.length; r++)
	{
		var rule = rules[r];
		if(rule.selectorText!=null && rule.selectorText.toLowerCase()==variable.toLowerCase())
		{
			var styles = rule.style;
			if(styles==null) continue;
			return styles[style];
		}
	}
	return return_value_if_not_found;
}
function convertCssRuleToJsProperty(cssRule)
{	
	cssRule = cssRule.replace(/\-(\w)/g, function (strMatch, p1){
            return p1.toUpperCase();
        });
   
	return cssRule;
}
function convertJsPropertyToCssRule(propName)
{	
	if(!propName) return null;
	var res = "";
	var letter = "";
	for (var i=0; i<propName.length;i++)
	{
		letter = propName.substr(i,1);
		if(letter.toLowerCase()!=letter && i>0)
			res+= "-";
		res += letter.toLowerCase();
	}
	return res;
}


var childrenCollectionResult = null;
function getChildObject(obj,tagname,id)
{
	if(obj==null || tagname==null) return null;
	if(!obj.hasChildNodes()) return null;
	childrenCollectionResult = new Array();
	scanObjectForChildren(obj,tagname);
	return childrenCollectionResult;
}

function scanObjectForChildren(obj,tagname){
	var children = obj.childNodes;	
	
	for(var i=0; i<children.length; i++)
	{
		var child = children[i];		
		if(child!=null && child.tagName!=null)
		{
			if(child.tagName.toLowerCase() == tagname.toLowerCase())
				childrenCollectionResult[childrenCollectionResult.length] = child;
			scanObjectForChildren(child,tagname);
		}
	}
}

function convertColorNameToHex(color)
{
	if(isEmpty(color)) return color;
	
	
	if(globalColorArray!=null)
		return globalColorArray[color.toLowerCase()];
	return null;
}

function convertColorToHex(color)
{
	if(isEmpty(color)) return color;
	color = String(color);
	if(color.startsWith ("#")) return color;
	if(color.indexOf(",")>0) //Rgb
	{
		var rgb = color.split(",");
		color = convertRGB2Hex(rgb);
		return color;
	}
	if(globalColorArray!=null)
		return globalColorArray[color.toLowerCase()];
	return null;
}

function convertHexToColorName(hex)
{
	
	if(globalColorArray==null) return;
	
	for(var cn in globalColorArray)
	{
		if(globalColorArray[cn].toLowerCase()==hex.toLowerCase())
			return cn;
	}
	return null;
}
/** SOME USEFUL CLASSES **/
function DimensionClass ()
{
	this.dimension	= null;
	this.unit		= "px";
} 
function getDimension(size)
{
	var res = new DimensionClass();
	
	if(size==null || size=="") return res;
	if(parseInt(size)==size)
	{
		res.dimension = size;		
	}
	else
	{
		res.dimension = parseInt(size);
		res.unit = size.substr(res.dimension.length+1);
	}
	return res;
}
/** IMAGE CLASS **/
function ImageClass (img)
{
	this.imgObject = img; //Image object
	this.name = null; //Image name
	this.origWidth=null; //Original size
	this.origHeight=null;
	this.optWidth=null; //Optimal size
	this.optHeight=null;
	this.udWidth=null; //User defined size
	this.udHeight=null;	
	this.src = img.src; //Source
	this.border = "0"; //Border
	this.borderWidth ="0"; 
	this.borderColor ="#000000";
	this.borderStyle ="solid";
	this.vSpace	= 0; //Spacing
	this.hSpace = 0; 
	this.align = "absmiddle"; //Alignment
	this.alt = img.src;	//Alternative text
	this.title = img.src;
}

function formatFileSize (file_size)
{

	if(file_size<=1024)
	{
		return file_size + " bytes";
	}	
	if(file_size<=(1024*1024/2))
	{
		var size = file_size/1024;
		return Math.round(size*100)/100 + " KB";
	}
	if(file_size<=1024*1024*1024)
		return Math.round(file_size/(1024*1024)*100)/100 + " MB";
	else
		return Math.round(file_size/(1024*1024*1024)*100)/100 + " GB";
	return file_size;
}
var showTmp = true;
var r2 = "";

function findInArray(arr, val)
{
	if (val==null) return -1;
	for (var i=0; i<arr.length; i++)
	{
		var val2 = arr[i];
		try
		{
			//r2 += (String(val2)).toLowerCase() + "==" + (String(val)).toLowerCase() + ": " + ( String(val2)).toLowerCase()==(String(val)).toLowerCase() + "\n";
			//r2+= (String(val2)).toLowerCase() + "==" + ( String(val)).toLowerCase() + "\n";
			if(val2 != null && ( String(val2)).toLowerCase()==(String(val)).toLowerCase())
			return i;
		}catch (err){}
	}
	/*if(showTmp) 
	{
		alert(r2);
		showTmp=false;
	}*/
	return -1;
}

function isInArray(arr,val, strict)
{
	if (val==null) return false;
	for (var i=0; i<arr.length; i++)
	{
		var val2 = arr[i];
		try
		{
			//r2 += (String(val2)).toLowerCase() + "==" + (String(val)).toLowerCase() + ": " + ( String(val2)).toLowerCase()==(String(val)).toLowerCase() + "\n";
			//r2+= (String(val2)).toLowerCase() + "==" + ( String(val)).toLowerCase() + "\n";
			if(strict)
			{
				 if (val2==val) return true;
			}
			else
			{
				if(val2!=null && ( String(val2)).toLowerCase()==(String(val)).toLowerCase())
					return true;
			}
		}catch (err){}
	}
	
	return false;
}
function collectionToArray (collection)
{
	if (!collection) return [];
	var arr = new Array ();
	
	if (!isNull(collection.length))
	{
		for (var i=0; i < collection.length; i++)
			arr.push (collection [i]);
	}	
	else 
		for (var i in collection)
			arr.push (collection [i]);
		
	return arr;
}
function isKeyInArray(arr,val)
{
	if (val==null) return false;
	for (var key in arr)
	{
		try
		{
			if((String(key)).toLowerCase()==(String(val)).toLowerCase())
			return true;
		}
		catch (err){}
	}
	return false;
}

/*
 * findElementByAttribute
 *
 * parameter:
 *
 * array		- the array to be searched
 * attribute	- name of the attribute (or property) to look for
 * value		- the value to look for
 * returnObject	- boolean value, true: return the object which was found, false: return the position in the array
 *
 *
 * return value:
 *
 * The return value depends on "returnObject" parameter.
 * If "returnObject" is true, the return value is the object if "value" was found, otherwise null.
 * If "returnObject" is false, the return value is the position in the given array if "value" was found, otherwise -1.
 *
 * If either of "array", "attribute" or "value" is null, the function returns -1 (as a position) or null (as an object)
 *
 *
 * remarks:
 *
 * If there is one ore more elements for which "value" matches, only the first is returned.
 * Searching is case-sensitive.
 *
 *
 * example: 
 *
 * [ "a" is an array of objects which have a property "guid" ]
 *
 * var obj = findElementByAttribute(a, 'guid', 'CB593BB2-38EB-4896-B576-CB01B00E6730', true);
 * var index = findElementByAttribute(a, 'guid', 'CB593BB2-38EB-4896-B576-CB01B00E6730', false);
 *
 * Both calls look for an object with property "guid" and value "CB593BB2-38EB-4896-B576-CB01B00E6730".
 * The first returns the object, the second returns the position in array "a".
 *
 */
function findElementByAttribute(array, attribute, value, returnObject)
{
	if (returnObject == null)
	{
		returnObject = false;
	}

	if ((array == null) || (attribute == null) || (value == null))
	{
		if (returnObject)
		{
			return null;
		}
		else
		{
			return -1;
		}
	}
	
	var result = -1;
	
	for (var i = 0; i < array.length; i++)
	{
		if (array[i][attribute] == value)
		{
			result = i;
			break;
		}
	}
	
	if (returnObject)
	{
		if (result > -1)
		{
			return array[result];
		}
		else
		{
			return null;
		}
	}
	else
	{
		return result;
	}
}

//Gibt die Nachricht nur auf dem PC des Entwicklers aus
function alert2 (txt)
{
	if ((String(document.location.href)).toLowerCase().indexOf(".local.de")>0)
		alert(txt);
}

String.prototype.stripTags = stripTags;
String.prototype.like = String.prototype["in"] = function (){
	if (arguments == null || arguments.length == 0) return false;
	for (var i=0; i < arguments.length; i++)
	{
		if (this.indexOf (String (arguments[i]))>=0) return true;
	}
	return false;
};

//Removing all html tags
function stripTags (str)
{
	if(str==null) str = this;
	var res = String(str);
	res = res.replace(/(<(\/?[^>]+)>)/ig,"");
	return res;
}

function getPopupPosition(EVENT, divHeight, divWidth, offsetLeft, offsetTop, inner_div)
{
	
	var left=100, top=100;
	
	if (isNS())
	{
		left = EVENT.pageX+offsetLeft;
		top = EVENT.pageY+offsetTop;	
		
		//Wenn Top > Fensterhöhe
		if ( (top + divHeight) > ( window.pageYOffset + window.innerHeight ))
			top = window.pageYOffset + window.innerHeight - divHeight;
		//Wenn  Top < 0 
		if (top < window.pageYOffset)
			top = window.pageYOffset-10;

		//Wenn Left+Width > Fensterbreite
		if ( (left+divWidth) > ( window.pageXOffset + window.innerWidth ) )
			left = window.pageXOffset + window.innerWidth - divWidth;
		//Wenn Lef < 0
		if ( left < window.pageXOffset )
			left = window.pageXOffset+10;
	}
	else
	{
		//Scroll parameters
		var scrollLeft, scrollTop;
		var o1 = inner_div;
		var o2 = document.body;
		
		scrollLeft = o2.scrollLeft;
		scrollTop = o2.scrollTop;
		
		if (o1!=null)
		{
			scrollLeft += o1.scrollLeft;
			scrollTop  += o1.scrollTop;
		}
		//Window dimensions
		var winHeight, winWidth;
		winHeight = o2.clientHeight + o2.scrollTop;
		winWidth = o2.clientWidth + o2.scrollLeft; 
		if(o1!=null)
		{
			winHeight = o1.clientHeight + o1.scrollTop;
			winWidth = o1.clientWidth + o1.scrollLeft; 
		}
		
		
		
		left = EVENT.x + scrollLeft+ offsetLeft;
		top = EVENT.y+ offsetTop +  + scrollTop;	
		
		window.status = "";
		/* Check TOP parameter */
		// top + div height > window height
		if ( (top + divHeight) > winHeight)
		{
			top = winHeight - divHeight;
		}
			
		// top < 0
		if (top < scrollTop)
			top = scrollTop;
		
		/* Check LEFT parameter */		
		// left + div width > window width		
		if ((left + divWidth) > winWidth)
			left = winWidth - divWidth;
		
		//Left < 0
		if (left < scrollLeft)
			left = scrollLeft; 
		
	}
	var res = new Object();
	res.left = left;
	res.top = top;
	return res;
}
function isNumeric(txt)
{
	if(txt==null) return false;
	var tmp = String(txt);
	if(tmp.substr(0,1)=="0" && tmp.length==1) return true;
	var rex = new RegExp("^[-]{0,1}[0-9]{0,}[.|,]{0,1}[0-9]{1,}$","ig");
	return rex.test(tmp);
}
function isAlphaNumeric(char)
{
	return (char>='a' && char <='z') 
			||
			(char>='A' && char <='Z') 
			||
			(char>=0 && char <=9);
}
var alert_once = true;
function alertOnce(txt)
{
	if(alert_once)
		alert(txt);
	alert_once=false;
}
String.prototype.startsWith = startsWith;
String.prototype.endsWith = endsWith;

function startsWith (txt, ignoreCase)
{
	if(ignoreCase==null) ignoreCase = true;
	if(txt==null) return false;
	if(txt.length>this.length) return false;
	if(ignoreCase)
	{
		return (this.toLowerCase().indexOf(txt.toLowerCase())==0);
	}
	else
		return (this.indexOf(txt)==0);
	
}

function endsWith (txt, ignoreCase)
{
	if(txt==null) return false;
	if(txt.length>this.length) return false;
	if(ignoreCase)
	{
		return (this.toLowerCase().substr(this.length-txt.length)==txt.toLowerCase());
	}
	else
		return (this.substr(this.length-txt.length)==txt);
	
}
String.prototype.removeLastString = removeLastString;
String.prototype.removeFirstString = removeFirstString;

function removeLastString (txt, ignoreCase)
{
	if(ignoreCase==null) ignoreCase = true;
	if(txt==null) return this;
	if(txt.length>this.length) return this;
	if (!this.endsWith (txt, ignoreCase)) return this;
	
	return this.substr(0, this.length-txt.length);
	
}
function removeFirstString (txt, ignoreCase)
{
	if(ignoreCase==null) ignoreCase = true;
	if(txt==null) return this;
	if(txt.length>this.length) return this;
	if (!this.startsWith (txt, ignoreCase)) return this;
	
	return this.substr(txt.length);
	
}
function copyAttributes (fromElement, toElement)
{
	try
		{
		if(fromElement.attributes!=null)
			for(var attr in fromElement.attributes)
			{
				toElement.setAttribute(attr,fromElement.getAttribute(attr));
				
			}
	}catch (err) {}
}
function applyDefault (thisConfig, fromConfig){
	if (!thisConfig || !fromConfig) return thisConfig
	
	
	var key;
	for (key in fromConfig)
	{
		if (fromConfig [key]==undefined) continue
		if (thisConfig [key] == undefined &&
			thisConfig [key] !== null &&
			typeof (thisConfig [key]) !== "boolean") 
		{
			thisConfig [key] = fromConfig [key]	
		}
	}
	
	return thisConfig
	
}
function cloneHtmlElement(el, copyAllContents)
{

	clone = el.cloneNode(true);
	try
		{
		if(el.attributes!=null)
			for(var attr in el.attributes)
			{
				clone.setAttribute(attr,el.getAttribute(attr));
				
			}
		clone.style.cssText = el.style.cssText + el.currentStyle.cssText;
		
	}catch (err) {}
	
	if(clone.tagName!=null && 
		(clone.tagName.toLowerCase()=="td" || clone.tagName.toLowerCase()=="th") )
	{
		if (!copyAllContents)
			clone.innerHTML = "&nbsp;";
		if (window.contextmenuTableCell)
			clone.oncontextmenu = window.contextmenuTableCell;
		if (window.displayVerticalAlignmentButtons)
			clone.onclick = window.displayVerticalAlignmentButtons;
	}
	else if(clone.tagName!=null && clone.tagName.toLowerCase()=="tr" &&
		clone.childNodes!=null)
	{
		for(var c=0; c<clone.childNodes.length; c++)
		{
			if (!copyAllContents)
				clone.childNodes[c].innerHTML="&nbsp;";
			if (window.contextmenuTableCell)
				clone.childNodes[c].oncontextmenu = window.contextmenuTableCell;
			if (window.displayVerticalAlignmentButtons)
				clone.childNodes[c].onclick = window.displayVerticalAlignmentButtons;
		}		
	}
	return clone;
}
function cloneHtmlElement2(el, copyAllContents)
{
	clone = el.cloneNode(true);
	try
		{
		if(el.attributes!=null)
			for(var attr in el.attributes)
			{
				clone.setAttribute(attr,el.getAttribute(attr));
				
			}
		clone.style.cssText = el.style.cssText + el.currentStyle.cssText;
		
	}catch (err) {}
	
	if(clone.tagName!=null && 
		(clone.tagName.toLowerCase()=="td" || clone.tagName.toLowerCase()=="th") )
	{
		if (!copyAllContents)
			clone.innerHTML = "&nbsp;";
	}
	else if(clone.tagName!=null && clone.tagName.toLowerCase()=="tr" &&
		clone.childNodes!=null)
	{
		for(var c=0; c<clone.childNodes.length; c++)
		{
			if (!copyAllContents)
				clone.childNodes[c].innerHTML="&nbsp;";			
		}		
	}
	return clone;
}

function isGuid (guid)
{
	if(!guid) return false;
	var guid2 = String(guid);
	if(guid2.startsWith("{"))
		guid2 = guid2.substr(1);
	if(guid2.endsWith("}"))
		guid2 = guid2.substr(0, guid2.length-1);
	
	var regEx = new RegExp(/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/ig);
	return regEx.test(guid2);
	return true;
}
function generateNewGuid(noBrackets)
{
	var new_guid = "";
	for(var c = 0; c < 32; c++)
	{
		new_guid += Math.floor(Math.random () * 0xF ).toString(0xF);
		if (c == 7 || c == 11 || c == 15 || c == 19)
			new_guid+= "-";

	}
	if(noBrackets)
		return new_guid;
	return "{" + new_guid + "}";
}

//no brackets, no "-"
function generateNewGuid2()
{
	var new_guid = "";
	for(var c = 0; c < 32; c++)
	{
		new_guid += Math.floor(Math.random () * 0xF ).toString(0xF);
	}
	return new_guid;
	
}

function getVirtualPath ()
{
	
	var path = document.location.pathname;

	var pos2 = path.indexOf("/",1);
	if(pos2>=0)
	{
		path = path.substr(0,pos2)+"/";
		if(path.substr(0,1)!="/")
			path = "/" + path;
		return path;
	}
	return "/";
}
function getPathWithoutVirtualFolder(path, vpath)
{
	if(path==null)return null;
	
	if(vpath==null) vpath = getVirtualPath();
	var proto = document.location.protocol;
	var host =  document.location.host;
	var pos = proto.length+2 + host.length;
	var location = document.location.href;
	path = path.substr(pos);
	if(path.indexOf("?")>0)
		path = path.substr(0, path.indexOf("?"));
	return path.substr(vpath.length);
}
function removeWebUrlFromFullUrl (url)
{
	if(!url) return url;
	var webUrl = getWebUrl().toLowerCase();
	if(!webUrl) return;
	
	var urlToLower = url.toLowerCase();
	if (urlToLower.indexOf(webUrl)==0)
	{
		var startPos = 	webUrl.length;
		return (url.substr(startPos));
	}
	return url;
}

function getWebUrl ()
{
	if(!document || !document.location || !document.location.host) return null;
	var proto = document.location.protocol;
	var host =  document.location.host;
	return proto + "//" + host;
}
function showMsg(txt)
{	
	window.status = txt;
}
//Compare if the given property is not null and is the same as the compare_with parameter
function equals (prop, compare_with, case_sensitive)
{
	if(prop==null || compare_with == null) return false;
	if ( case_sensitive )
		return prop==compare_with;
	else
		return prop.toLowerCase()==compare_with.toLowerCase();
}
function CopyText(obj, strip_tags)
{
	if (obj==null) return;
	if( equals (obj.tagName, "textarea") || 
		(equals (obj.tagName, "input") && equals (obj.type, "text")))
	{
		window.clipboardData.setData("Text", 
		(stripTags? unescape(stripTags(obj.value)):obj.value));
	}
	else
	{
		window.clipboardData.setData("Text", 
		(stripTags? unescape(stripTags(obj.innerHTML)):obj.innerHTML)
		);
	}
}
function Round (number, radix)
{
	if(radix==0 || radix==null) return Math.round(number);
	return Math.round( number*(Math.pow(10,radix)))/Math.pow(10,radix);
}
function getTagAndType(o, case_sensitive)
{
	var ignoreCase = !case_sensitive;
	var tt = new Object();
	tt.tag = null;
	tt.type = null;
	if(o==null) return tt;
	if(o.tagName!=null)
		tt.tag = (ignoreCase?o.tagName.toLowerCase():o.tagName);
	if(o.type!=null)
		tt.type = (ignoreCase?o.type.toLowerCase():o.type);
	return tt;
}
function doAutoResizing()
{
	
	var inp = ( arguments[0]? arguments[0]: this);
	if(inp==null)return;
	var tt = getTagAndType(inp);
	if(tt.tag!="div" && tt.tag!="textarea" && tt.type !="text") return;
	var newHeight, newWidth;
	newHeight = inp.clientHeight;
	newWidth  = inp.clientWidth;
	if(tt.tag=="div" || tt.tag=="textarea")
	{
		newHeight = parseInt(inp.scrollHeight);
		
	}
	else if (tt.tag=="input" && tt.type=="text")
	{
		
		newWidth = parseInt(inp.scrollWidth);
		
	}
	if(inp.minWidth!=null && newWidth < inp.minWidth)
		newWidth = inp.minWidth;
	if(inp.minHeight!=null && newHeight < inp.minHeight)
		newHeight = inp.minHeight;
		
	inp.style.height = newHeight +"px";
	inp.style.width = newWidth +"px";
}	

function makeAutoResizable (o,minWidth, minHeight)
{
	if(!o) return;
	o.onchange = o.onclick = o.ondrop = o.onkeypress = o.onmouseup = doAutoResizing;
	o.minWidth = (minWidth==null? o.offsetWidth:minWidth);
	o.minHeight = (minHeight==null? o.offsetHeight: minHeight);
}

function makeAutoIncreasing (o, minValue,maxValue, withInputCheck, inputType)
{
	if(!o) return;
	if (inputType=="date")
		addEvent(o, "onkeydown", increaseDateTimeValueOfField);	
	else if (inputType=="color")
		addEvent(o, "onkeydown", increaseColorValueOfField);	
	else
		addEvent(o, "onkeydown", increaseNumericValueOfField);	
	
	if(withInputCheck)
		addEvent(o,"onchange", function (e)
		{
			var input = getEventSource(e);
			if(!input) return;
			var currentValue = input.value;
			if(!currentValue) return;
			
			//Skip the color values (for this version)
			if(String(currentValue).startsWith("#")) return;
			
			//Get min/max
			var minVal = o.getAttribute("minValue");
			var maxVal = o.getAttribute("maxValue");
			
			//Convert to numbers
			if(!isEmpty(minVal))			minVal			= float(minVal);
			if(!isEmpty(maxVal))			maxVal			= float(maxVal);
			if(!isEmpty(currentValue))		currentValue	= float(currentValue);
			
			//Compare
			if(currentValue<minVal) currentValue = minVal;
			if(currentValue>maxVal) currentValue = maxVal;
			input.value = String(currentValue).replace(".",",");
		});
	
	if(!isNull(minValue))
		o.setAttribute("minValue", minValue);
	if(!isNull(maxValue))
		o.setAttribute("maxValue", maxValue);
	if(!o.title)
		o.title = "Benutzen Sie die Tasten 'Nach oben' und 'Nach unten', um den Wert in diesem Feld um 1 zu erhöhen bzw. zu reduzieren.\nHalten Sie die Steuerungstaste gedrückt, so wird das Ganze in 10er-Schritten ausgeführt!";
}
function increaseNumericValueOfField(e)
{
	if(e==null) return false;
	var inp = getEventSource(e);
	if(inp==null || inp.type!="text") return false;
	var keyCode = e.keyCode;
	var left, right, up, down;
	up		= 38;
	down	= 40;
	if(	e.keyCode!=down &&
		e.keyCode!=up) return true;
	
	var val = inp.value; if(isNull(val)) return false;
	var step = 39-keyCode;	
	//Steps in 10?
	if(e.ctrlKey) step*=10;
	
	//Check the value: hex color code?
	var colorMode = false;
	if(String(val).startsWith("#") && String(val).length==7)
	{
		increaseColorValueOfField (e);
		return true;
	}
	else //Numeric
	{
		val = float(String(val).replace(",","."));
		if(isNaN(val)) return false;
		val += step;
		//Round (2 digits)
		val = (int(val*100))/100;
		var min = inp.getAttribute("minValue");
		var max = inp.getAttribute("maxValue");
		if(!isNull(min) && val< min) val=min;
		if(!isNull(max) && val> max) val=max;
	}
	
	inp.value = String(val).replace(".",",");
	callEvent(inp,"onchange");
}
function increaseColorValueOfField(e)
{
	if(e==null) return false;
	var inp = getEventSource(e);
	if(inp==null || inp.type!="text") return false;
	var keyCode = e.keyCode;
	var left, right, up, down;
	up		= 38;
	down	= 40;
	if(	e.keyCode!=down &&
		e.keyCode!=up) return true;
	
	var val = inp.value; if(isNull(val)) return false;
	var step = 39-keyCode;	
	//Steps in 10?
	if(e.ctrlKey) step*=10;
	
	//Check the value: hex color code?
	if(String(val).startsWith("#") && String(val).length==7)
	{
	
		if(val.toLowerCase()=="#ffffff" && step>0)
			val = val;
		else  if (val.toLowerCase()=="#000000" &&  step < 0)
			val = val;
		else
		{	
			var rgb = convertHex2RGB (val);
			rgb[2] += step;
			if(rgb[2] > 255 )
			{
				rgb[2] = 0;
				rgb[1]++;
				if(rgb[1]>255)
				{
					rgb[1] = 0;
					rgb[0]++;
					if(rgb[0]>255) 
						rgb[0] = 255;
				}
			}
			else if (rgb[2] < 0 )
			{
				rgb[2] = 255;
				rgb[1]--;
				if(rgb[1]<0)
				{
					rgb[1] = 255;
					rgb[0]--;
					if(rgb[0]<0) 
						rgb[0] = 0;
				}
			}
			val = convertRGB2Hex(rgb);
		}
	}
	else
		return true;
		
	inp.value = String(val).replace(".",",");
	callEvent(inp,"onchange");
}
function increaseDateTimeValueOfField(e)
{
	if(e==null) return false;
	var inp = getEventSource(e);
	
	if(inp==null || inp.type!="text") return false;
	if (inp.value=="") return false;
	var keyCode = e.keyCode;
	var left, right, up, down;
	up		= 38;
	down	= 40;
	if(	e.keyCode!=down &&
		e.keyCode!=up) return true;
	
	var val = inp.value; if(isNull(val)) return false;
	var step = 39-keyCode;	
	//Steps in 10?
	if(e.ctrlKey) step*=10;
	
	//Check the value: hex color code?
	var colorMode = false;
	var d = convertStringToDate (String (val));
	var rg = null;

	if(d && d.getFullYear )
	{
		//Try to get the selected part
		rg = document.selection.createRange();
		if (rg.parentElement ()== inp)
		{
			var selectionPosition = getPositionOfSelectedDatePart (inp,rg);
		
			var increasedDate = d;
			var datePartToReplace = null;
			if (selectionPosition >= 0 && selectionPosition <=2) //Day
			{
				increasedDate = new Date (d.getFullYear (), d.getMonth(), d.getDate() +step);
				datePartToReplace = 0;
			}
			else if (selectionPosition >= 3 && selectionPosition <= 5) //Month
			{
				increasedDate = new Date (d.getFullYear (), d.getMonth()+step, d.getDate());
				datePartToReplace = 1;
			}
			else if (selectionPosition >= 6 && selectionPosition <= 10) //Year 
			{
				increasedDate = new Date (d.getFullYear () +step, d.getMonth(), d.getDate());
				datePartToReplace = 2;
			}
			else
			{
				increasedDate = new Date (d.getFullYear (), d.getMonth(), d.getDate() +step);
				datePartToReplace = -1;
			}
			
			val = convertDateToString(increasedDate);
			inp.value = val;
			
			//Re-select the range
			if (datePartToReplace!=-1)
			{
				for (var i=0; i < datePartToReplace*3; i++)
				{
					rg.move ("character", 1);
				}
				rg.move ("character", 1);
				rg.expand("word", 1);
				rg.select();
				
				callEvent(inp,"onchange");					
				return;
				
			}
		}
		else
			val = convertDateToString(d);
	}
	else
		return true;
	
	inp.value = val;
	
	callEvent(inp,"onchange");
	
	function getPositionOfSelectedDatePart (inp, rg)
	{
		//Move to the left
		var pos = 0;
		var rg2 = document.selection.createRange ();
		var trials = 10;
		while (true)
		{
			if (trials--<0) break;
			if (rg2.move ("character",-1)==0)
				break;
			pos++;
		}
		return pos;
	}
}
function getNodeValue(node)
{
	if(node==null)return null;
	if(!document.all) return node.textContent;
	else return node.text;
}
function getXmlFieldValue (fieldName, xmlNode)
{
	if(xmlNode==null || xmlNode.childNodes==null) return;
	for (var ch=0; ch < xmlNode.childNodes.length; ch++)
	{
		var node = xmlNode.childNodes[ch];
		if (node.nodeName == fieldName)
			return getNodeValue(node);
	}
	return null;
}
function AddProperties (xmlNode, curObject)
{
	if(xmlNode==null || xmlNode.childNodes==null) return;
	for (var ch=0; ch < xmlNode.childNodes.length; ch++)
	{
		var node = xmlNode.childNodes[ch];
		
		if(node.nodeType!=3)
		{
			var t = new String( getNodeValue(node));
			var dDate = null;
			if(t!=null)
			{
				if(t!="false" && t!="true")
				{
					t = t.replace(/\r/ig,escape("\r"));
					t = t.replace(/\n/ig,escape("\n"));
					dDate = parseDate(t);
					
					
					if(t.startsWith ("0") && t.length>1)
						t = "\"" + t + "\"";
					else if(!isNumeric(t) && !t.startsWith("new Array")) 
					{
						if( dDate !=null)
						{
							
							t = "new Date (" + 
								String(dDate.getFullYear()) + ","+ 
								String((dDate.getMonth())) + "," + 
								String(dDate.getDate ()) + "," + 
								String(dDate.getHours()) + "," + 
								String(dDate.getMinutes ()) + "," + 
								String(dDate.getSeconds ()) + "," + 
								String(dDate.getMilliseconds ()) + ")";
						}
						else
						{
							t = t.replace(/\"/g, "\\\"");
							//t = t.replace(/^'/, "");
							//t = t.replace(/'$/, "");
							t = "\"" + t + "\"";
						}
					}
					
				}
			}
			
			if(t==null)
				t="null";
			else if(t=="")
				t="\"\"";
				
			try
			{
				eval("curObject." + node.nodeName + " = " + t + ";");				
			}
			catch (err)
			{
				//alert(t);
			}
		}
		
	}	
	return curObject;
	
}
function parseDate(str)
{
	var s= new String(str);
	
	/** C# internal format **/
	var datePart = s.match("[12][0-9][0-9][0-9]-[01][0-9]-[0123][0-9]");
	if(datePart==null)return null;
	var timePart = s.match("[0-2][0-9]:[0-5][0-9]:[0-9][0-9].[0-9]{0,}");
	if(!timePart) timePart = s.match("[0-2][0-9]:[0-5][0-9]:[0-9][0-9]");
	var y,m,d,h,n,s,ms;
	var newDate = null;
	if(datePart)
	{
		datePart = String(datePart);
		newDate = new Date();
		var parts = datePart.split("-");
		newDate.setFullYear(parseInt(parts[0],10));
		newDate.setMonth(parseInt(parts[1],10)-1);
		newDate.setDate(parseInt(parts[2],10));
	}
	if(timePart && newDate)
	{
		timePart = String(timePart);
		var parts = timePart.split(":");
		
		var secs = parts[2];
		if(secs.indexOf(".")>0)
		{
			var secParts = secs.split(".");
			newDate.setHours (
				/*Hours*/parseInt(parts[0],10),
				/*Minutes*/parseInt(parts[1],10),
				/*Seconds*/parseInt(secParts[0],10), 
				/*Milliseconds*/parseInt("0." + secParts[1],10)
				);
			
		}
		else
			newDate.setHours (
				/*Hours*/parseInt(parts[0],10),
				/*Minutes*/parseInt(parts[1],10),
				/*Seconds*/parseInt(secs,10)							
				);
		
	}
	return newDate;
}
function isChildOf (supposedChild, supposedParent)
{
	if(!supposedChild || !supposedParent)
		return false;
	
	if (supposedChild==supposedParent) return true; //Both arguments represent the same element
	
	while(supposedChild)
	{
		if(supposedChild.parentNode==supposedParent) return true;
		supposedChild = supposedChild.parentNode;
	}
	return false;
	
}

function isNull()
{	

	if(!arguments) return true;
	for (var i=0; i<arguments.length; i++)
	{
		var o = arguments[i];	
		if(String(o)=="0") return false;
		if(o==null)return true;
		if(o==undefined) return true;
		if(typeof(o)=="undefined") return true;
		if(typeof(o)=="null") return true;		
		try
		{
			if(o.toString()=="null") return true;
		}
		catch (err) {}
		try
		{
			if(String(o)=="null") return true;
		}catch (err) {}
		try
		{
			if(o.toString()=="undefined") return true;
		}
		catch (err) {}
		try
		{
			if(String(o)=="undefined") return true;
		}
		catch (err) {}
		//What else?
	}	
	return false;
}
function isEmpty()
{	
	if(!arguments) return true;
	for (var i=0; i<arguments.length; i++)
	{
		if(String(arguments[i])=="0") return false;
		if(isNull(arguments[i]))return true;
		if(arguments[i]=="") return true;		
	}	
	
	return false;
}
function join ()
{
	var res = "";
	var separator = arguments[arguments.length-1];
	for (var arg=0; arg<arguments.length-1; arg++)
	{
		res += (arg>0?separator:"") + arguments[arg];
	}
	return res;
}
function parseNumber(o)
{
	if(isEmpty(o))return 0;
	var str =  String(o);
	
	var str2 = new String("");
	
	for (var c=0; c < str.length; c++)
	{
		var ch =  str.charAt(c);
		if((ch >= '0' && ch <= '9')
			|| ch=='.' 
			|| ch==',')
		str2+=ch;
	}
	//remove leading "0"
	var ch = str2.charAt(0);
	while (ch=='0' && (str2.length>1 && str2.charAt(1)!="." && str2.charAt(1)!=","))
	{
		str2 = str2.substr(1);
		ch = str2.charAt(0);
	}
	
	//Adjust if the number is like "xx.xxx,xx" or "xx,xxx.xx" or "xx.xxx.xx"
	if(str2.indexOf (".") < str2.indexOf(",") && str2.indexOf(".")>0)			 //case "xx.xxx,xx"
		str2 = str2.replace(".", "");
	else if (str2.indexOf (",")< str2.indexOf(".") && str2.indexOf(",")>0)		 //case "xx,xxx.xx" 
		str2 = str2.replace(",", "");
	else if (str2.indexOf(".")!=str2.lastIndexOf(".") && str2.indexOf(".")>0)	 //case "xx.xxx.xx"
		str2 = str2.replace(".", "");
	else if (str2.indexOf(",")!=str2.lastIndexOf(",") && str2.indexOf(",")>0)	 //case "xx,xxx,xx"
		str2 = str2.replace(",", "");
	
	if(str.charAt(0)=="-")
		str2 = "-" + str2;
	
	return str2.replace(",",".");
}
function int(o)
{
	var res = parseInt(parseNumber(o));
	if(isNaN(res))return 0;
	return res;
}
function float (o)
{
	var res = parseFloat(parseNumber(o));
	if(isNaN(res))return 0;
	return res;
}
function bool (o)
{
	return o == true 
			|| o == "true" 
				|| o == "1" 
					|| o == 1;
	
}
//A fake for HtmlEncoding:
//converts only the braces, quotes and German Umlauts
//feel free to add more encoding

function HtmlEncode (str, lightEncoding)
{
	if(str==null) return null;
	/** this works only partly
	var div = document.createElement('div');
	var text = document.createTextNode(str);
	div.appendChild(text);
	return div.innerHTML;
	**/

	
	str = String(str);
	//Braces
	str = str.replace(/>/ig, "&gt;");
	str = str.replace(/</ig, "&lt;");
	
	if (lightEncoding) return str;
	
	//Quotes
	str = str.replace(/"/ig, "&quot;");
	
	//Umlauts
	/* ä */
	str = str.replace(/ä/g, "&auml;");	
	str = str.replace(/Ä/g, "&Auml;");	
	/* ö */
	str = str.replace(/ö/g, "&ouml;");	
	str = str.replace(/Ö/g, "&Ouml;");	
	/* ü */
	str = str.replace(/ü/g, "&uuml;");	
	str = str.replace(/Ü/g, "&Uuml;");	
	/* ß */
	str = str.replace(/ß/g, "&szlig;");
	
	/* § */
	//str = str.replace(/§/ig, "&sect;");	
	
	return str;	
}

function HtmlEncodeForXml (str, withAmpersand)
{
	if(str==null) return null;
	
	str = String(str);
	
	//Ampersand
	if (withAmpersand)
	{
		str = str.replace(/&/ig, "&amp;");
	}
	
	//Braces
	str = str.replace(/>/ig, "&gt;");
	str = str.replace(/</ig, "&lt;");

	return str;	
}

function HtmlDecode(str, light)
{
	if(str==null) return null;
	
	str = String(str);
	//Braces
	str = str.replace(/&gt;/ig, ">");
	str = str.replace(/&lt;/ig, "<");
	
	//Quotes
	str = str.replace(/&quot;/ig, "\"");
	
	
	//Space
	if (!light)
		str = str.replace(/&nbsp;/ig, " ");
	return str;	
}

function HighlightTags(html, style, formatLineBreaks)
{
	//Init
	if(!html) return html;
	html = String(html);
	
	if(!style) style = "color:blue;font-weight:bold";
	
	
	//opening and closing tags design
	var openTag  = "<span style=\"" + style + "\">";
	var closeTag = "</span>";
	
	//Reg expression
	var regEx = new RegExp(/<([\/]{0,1}[^\/<>]+)>/ig);
	
	//Replacement?
	
	var repl = 
		openTag + "&lt;$1&gt;" + closeTag;
	
	html = html.replace(regEx,repl);
	return html;
}

function convertRoman2Arabic(rome)
{
	var tokens = new Array("M",  "CM", "D", "CD", "CCC", "CC", "C", "XC", "L", "XL", "XXX", "XX", "X", "IX", "V", "IV", "III", "II", "I");
var values = new Array( 1000, 900,  500, 400,  300,   200,  100, 90,   50,  40,   30,    20,   10,  9,    5,   4,    3,     2,    1); 
var invalid = new Array("CMCM",  "CMD",  "CMCD", "CMC", "DD", "DCD", "CDCD", "CDC", "CCCC", "XCXC",  "XCL", "XCXL", "XCX", "LL", "LXL", "XLXL", "XLX", "XXXX", "IXIX",  "IXV", "IXIV", "IXI", "IVIV", "IVI", "IIII");
var replace = new Array("MDCCC", "MCD",  "MIII", "M",   "M",  "CM",  "DCCC", "D",   "CD",   "CLXXX", "CXL", "CIII", "C",   "C",  "XC",  "LXXX", "L",   "XL",   "XVIII", "XIV", "XIII", "X",   "VIII", "V",   "IV");

	rome.replace(/ /g, "");
	rome= rome.toUpperCase();
	rome = rome.replace(/[^IVXLCDM]/g, "");
	
	var pos = 0;
	var val = 0;

	var t1 = -1;

	while ( pos < rome.length )
	{
		var t = getNextToken(rome, pos);
		if ( t1 != 0 )
		{
			if ( values[t1] < values[t] )
			{
				//Syntay error
				return null;
			}
		}
		if ( t < 0 )
			return;
		pos += tokens[t].length;
		val += values[t];
		t1 = t;
	}
	
	return val;
	
	function getNextToken(s, pos)
	{

		for (i=0; i<invalid.length; i++)
		{
			if ( s.indexOf(invalid[i], pos) == pos )
			{
				return -1;
			}
		}

		for (i=0; i<tokens.length; i++)
		{
			if ( s.indexOf(tokens[i], pos) == pos )
				return i;
		}
		return -1;
	}
	
}
function convertArabic2Roman(arab)
{
	var values = new Array(1000000, 900000, 500000, 400000, 100000, 90000, 50000, 40000, 10000, 9000, 5000, 4000, 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1);
	
	var strings = new Array(
		"<span style='text-decoration: overline'>M</span>",
		"<span style='text-decoration: overline'>CM</span>",
		"<span style='text-decoration: overline'>D</span>",
		"<span style='text-decoration: overline'>CD</span>",
		"<span style='text-decoration: overline'>C</span>",
		"<span style='text-decoration: overline'>XC</span>",
		"<span style='text-decoration: overline'>L</span>",
		"<span style='text-decoration: overline'>XL</span>",
		"<span style='text-decoration: overline'>X</span>",
		"<span style='text-decoration: overline'>IX</span>",
		"<span style='text-decoration: overline'>V</span>",
		"<span style='text-decoration: overline'>IV</span>",
		"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I" );
	
	var num = parseInt(arab);
	if (isNaN(num) )
	{
		return null;
   	}
	if ( num > 3999999 || num < 1)
	{
		return null;
	}
	var res = "";
	var work = num;
	while ( work > 0 )
	{
		var i;
		for (i=0; i< values.length; i++)
		{
			if ( work >= values[i] )
			{
				res += strings[i];
				work -= values[i];
				break;
			}
		}
	}
	return res;
}
function convertStringToDate(s)
{
	try
	{
		//debugger;
		var d = s.toString().replace(/,/ig,".");
		var t = null;
		if(s.indexOf(" ")>0) //Contains time string
		{
			d = s.split(" ")[0];
			t = s.split(" ")[1];
		}
		var sep = "."; 
		if(d.indexOf("/")>0)
			sep = "/";
		else if(d.indexOf("-")>0)
			sep = "-";
		var day,month,year;
		var arr = d.split(sep);
		day		=   arr[0];
		month	=	arr[1]; if(int(month)>12) { day = month; month = arr[0] }
		if (arr.length<3) arr [2] = (new Date()).getFullYear().toString();
		year	=	arr[2]; 
		if(year.length==2)
		{
			year = int(year);
			if(year>49) year = 1900 + year;
			else year = 2000 + year;
		}
		
		//Time
		var hour=0,minute=0,second=0;
		if (t)
		{
			arr = t.split(":");
			if (arr)
			{
				if (arr.length>0) hour = arr [0];
				if (arr.length>1) minute = arr [1];
				if (arr.length>2) second = arr [2];
			}
			
		}
		
		return new Date(int(year), int(month)-1, int(day), int(hour), int(minute), int(second));		
		//return Date.parse(String(s));
	}catch (err)
	{
		return null;
	}
}
function importJavaScript (src)
{
	if(document==null)return;
	var headTag = document.getElementsByTagName("HEAD")[0];
	if(headTag==null)return;
	var jScript= document.createElement("SCRIPT"); 
	jScript.setAttribute("type", "text/javascript");
	jScript.setAttribute("src", src);
	headTag.appendChild(jScript);	
}
//Concatting associative arrays
function mergeArray (anotherArray)
{	
	if(anotherArray==null) return this;
	
	try
	{
		for (var p in anotherArray)
		{
			try
			{
				if(p.toString().toLowerCase().indexOf("function ")!=0)
					this[p] = anotherArray[p];
			} catch (err){}
		}
	}catch(err2){}
	return this;
};
function $arr (objects)
{
	if (GetInstanceName (objects)!="Array")
		objects = [objects];
	
	return objects;
}

function addEvent (objectsArray, eventsArray, handler, delayInMilliseconds)
{
	if(!eventsArray || !objectsArray || !handler) return;
	
	
	//modify event_name
	objectsArray = $arr(objectsArray);
		
	eventsArray = $arr(eventsArray);
	
	for (var e=0; e < eventsArray.length; e++)
	{	
		var event_name = eventsArray [e];
		if(event_name.toLowerCase().startsWith("on"))
			event_name = event_name.substr(2);
			
		for (var i=0; i < objectsArray.length; i++)
		{
			var object = objectsArray [i];
			if(document.all)
				object.attachEvent("on" + event_name, handler);
			else
				object.addEventListener(event_name, handler, false);
		}
		
		if (event_name.equals ("load", "onload"))
		{
			if (window.ScriptImportManager && window.ScriptImportManager.addOnLoadEvent)
				window.ScriptImportManager.addOnLoadEvent (handler);
		}
	}
	
	
}
function removeEvent (objectsArray, eventsArray, handler)
{
	if(!objectsArray) return;
	if(!eventsArray) return;
	//modify event_name
	objectsArray = $arr(objectsArray);
		
	eventsArray = $arr(eventsArray);
	
	for (var e=0; e < eventsArray.length; e++)
	{	
		var event_name = eventsArray [e];
		
			
		//modify event_name
		if(event_name.toLowerCase().startsWith("on"))
			event_name = event_name.substr(2);
	
		for (var i=0; i < objectsArray.length; i++)
		{
			var object = objectsArray [i];
			if(document.all)
				object.detachEvent("on" + event_name, handler);
			else
				object.removeEventListener(event_name, handler, false);
		}
	}
}
function callEvent (objectsArray, eventsArray)
{
	if(!objectsArray) return;
	if(!eventsArray) return;
	//modify event_name
	objectsArray = $arr(objectsArray);
		
	eventsArray = $arr(eventsArray);
	
	for (var e=0; e < eventsArray.length; e++)
	{	
		var event_name = eventsArray [e];
		
			
		//modify event_name
		if(event_name.toLowerCase().startsWith("on"))
			event_name = event_name.substr(2);
	
		for (var i=0; i < objectsArray.length; i++)
		{
			var object = objectsArray [i];
			
			if(document.all || !document.createEvent)
			{
				object.fireEvent("on" + event_name);
			}
			else
			{
				var events = "Events";
				//Check the event type
				event_name = event_name.toLowerCase();
				if (event_name.indexOf("click")>=0 
					|| event_name.indexOf("mouse")>=0)
					events = "MouseEvents";
				else if (event_name.indexOf("key")>=0 
					|| event_name.indexOf("cut")>=0)
					events = "KeyEvents";
				
				var evt = document.createEvent(events);
				evt.initEvent(event_name, true, true);
				object.dispatchEvent(evt);
			}
		}
	}
}
function calculatePercentage(n100,nX)
{
	if(n100==0) return 0;
	return Math.round(((nX*100)/n100)*100)/100;
}
function GetInstanceName(o)
{
	if(o==null) return null;
	if(!o.constructor) return typeof(o);
	var c = o.constructor;
	c = c.toString();
						
	//var regExp = new RegExp(/function[ ]+([a-zA-Z0-9]+)[ \(\r\n]+/); //function FunctionName ...
	//regExp.ignoreCase = false;
	var res = GetFunctionName (c);//regExp.exec(c);
	/*
	if(res!=null && res[1]!=null)
	{
		return res[1];
	}
	*/
	if (res!=null) return res;
	
	return typeof(o);
}
function GetFunctionName (functionDeclaration)
{
	if (!functionDeclaration) return null;
	
	var regExp = new RegExp(/function[ ]+([a-zA-Z0-9.]+)[ \(\r\n]+/); //function FunctionName ...
	regExp.ignoreCase = false;
	
	var res = regExp.exec(functionDeclaration);
	
	if(res!=null && res[1]!=null)
	{
		return res[1];
	}
	else 
	{
		if (new RegExp(/function\b/ig).test (functionDeclaration))
			return functionDeclaration.replace(/\n/gi, ' ').replace(/\t/gi, '');// "anonymous";
		else
			return null;
	}
}
function GetFunctionBody(o)
{
	if(o==null) return null;
	var sC = null;
	if(typeof(o)=="object" && o.constructor!=null)
	{
		sC = o.constructor.toString();
	}
	else if(typeof(o)=="function")
	{
		sC = o.toString();
	}
	if(sC==null)return null;
	var rex = new RegExp(/{([^{}]+)}/ig);
	var res = rex.exec(sC);
	if(res!=null && res[1]!=null)
	{
		var s = res[1];
		s = Trim(s);
		var rex2 = new RegExp(/\t/g);
		
		s = s.replace(rex2,"");
		return s;
	}
	return res;
}
 Object.fromXml = function(xmlText, xmlObject) {
        if (!xmlObject && xmlText) {
            var xmlDoc = JSO.Ajax.GetXmlDocument(xmlText);

            if (!xmlDoc)
                return null;

            xmlObject = xmlDoc.firstChild;
            if (xmlObject && xmlObject.nodeName.toLowerCase() == "xml") {
            xmlObject = xmlDoc.firstChild.nextSibling;
        }
    }

    if (!xmlObject)
        return null;

    return Object.fromXmlNode(null, xmlObject);
}
Object.fromXmlNode = function(objectToPopulate, xmlObject) {
        if (!objectToPopulate)
            objectToPopulate = new Object();
        if (!xmlObject)
            return;

        if (xmlObject.childNodes)
            for (var i = 0; i < xmlObject.childNodes.length; i++) {
                var r = xmlObject.childNodes[i];

                if (r && r.nodeType == 1) {
                    var stringValue = new String((r.textContent || r.text));

                    var dateValue = null;
                    var boolValue = null;
                    var numericValue = null;
                    try {
                        // Object?
                        if (r.childNodes
                                && r.childNodes.length > 0
                                && !(r.childNodes.length == 1 && r.childNodes[0].nodeName == "#text")) {
                                	
                            objectToPopulate[r.nodeName] = Object
                                    .fromXmlNode(null, r);
                        } else if (stringValue != null && stringValue != "") {
                            // Boolean
                            if (stringValue == "false"
                                    || stringValue == "true") {
                                boolValue = (stringValue == "true");
                                objectToPopulate[r.nodeName] = boolValue;
                            } else {
                                // Date
                                dateValue = parseDate (stringValue);
                                if (dateValue != null) {
                                    objectToPopulate[r.nodeName] = dateValue;
                                } else {
                                    // Numeric

                                    if (isNumeric(stringValue)) {
                                        numericValue = parseNumber(stringValue);
                                        objectToPopulate[r.nodeName] = numericValue;
                                    } else // Text
                                    {
                                        objectToPopulate[r.nodeName] = stringValue;
                                    }
                                }
                            }
                        }
                        
                       else { 
                       		objectToPopulate [r.nodeName] = stringValue; 
                         }
                         

                    } catch (err) {
                        if (Workspace) Workspace.Alert (err.message)
                    }
                }
            }

        return objectToPopulate;
    }
Number.prototype.between = function (a,b)
{
	var num = this;
	if(typeof(num)!="number") 
		num = Number(num);
	if(typeof(num)!="number") 
		return false;
	return num>=a && num <=b;
}
Number.prototype.equals = function ()
{
	var num = this;
	if(typeof(num)!="number") 
		num = Number(num);
	if(typeof(num)!="number") 
		return false;
	
	if(arguments==null ||arguments.length==0) return false;
	for (var a=0; a< arguments.length; a++)
	{
		if(Number(arguments[a])==num)
			return true;
	}
	return false;
}

String.prototype.lastIndexOf = function (search)
{
	var string = this;
	
	if(typeof(string)!="string" && GetInstanceName(string)!="String")
		string = String(string);
	if (string.length==0) return -1;
	if(search==null || search.length==0) return -1;
	
	var pos = string.indexOf(search,0);
	if(pos==-1) return -1;
	var lastPos = pos;
	while (pos!=-1)
	{
		lastPos = pos;
		pos = string.indexOf(search,pos+search.length);
	}
	return lastPos;
}

String.prototype.equals= function ()
{
	var str = this;
	if(typeof(str)!="string") 
		str = String(str);
	if(typeof(str)!="string") 
		return false;
		
	if(arguments==null ||arguments.length==0) return false;
	for (var a=0; a< arguments.length; a++)
	{
		if(arguments[a]==str)
			return true;
	}
	return false;
}
String.prototype.reverse = function() {
	var reverted = "";
	for (var i = this.length - 1; i >= 0; i--)
		reverted = reverted.concat(this.charAt(i));

	return reverted;
}
function getObjectSize (obj)
{
	if (!obj) return [0,0];
	var res = [0,0];
	
	if (obj.style.display == "none" || (obj.offsetParent && obj.offsetParent.style.display == "none"))
	{
		var hiddenObject = (obj.style.display == "none" ? obj : obj.offsetParent);
		var origVisibility = hiddenObject.style.visibility || "visible";
		
		hiddenObject.style.visibility = "hidden";
		hiddenObject.style.display = "";
		res = [obj.offsetWidth, obj.offsetHeight];
		hiddenObject.style.display = "none";
		hiddenObject.style.visibility = origVisibility;
	}
	else 
		res = [obj.offsetWidth, obj.offsetHeight];
	
	return res;
	
}
function getObjectFullSize (obj)
{
	
	var res = getObjectSize(obj);
	
	if (CurrentNavigator.isIE)
	{
		res [0] += int(getStyleValue(obj,"border-left-width")) +
			int(getStyleValue(obj,"border-right-width"));
		
		res [1] += int(getStyleValue(obj,"border-top-width")) +
			int(getStyleValue(obj,"border-bottom-width"));
	}
	
	return res;
}
$obj = function (obj)
{
	$obj.fly = obj;
	function get (cssName)
	{
		return getStyleValue($obj.fly,cssName);
	}
	this.width = function()
	{
		return  JSO.Layout.GetSize($obj.fly)[0];// getObjectFullSize($obj.fly)[0];
	};
	this.height = function()
	{
		return JSO.Layout.GetSize($obj.fly)[1];//getObjectFullSize($obj.fly)[1];
	};
	this.pos = function()
	{
		return getObjectPosition4 ($obj.fly);
	};
	
	
	this.margin = {
		left :function()
		{
			return int(get("margin-left"));
		}
		,right :function()
		{
			return int(get("margin-right"));
		}
		,top :function()
		{
			return int(get("margin-right"));
		}
		,bottom :function()
		{
			return int(get("margin-bottom"));
		}
	};
	this.padding = {
		left :function()
		{
			return int(get("padding-left"));
		}
		,right :function()
		{
			return int(get("padding-right"));
		}
		,top :function()
		{
			return int(get("padding-right"));
		}
		,bottom :function()
		{
			return int(get("padding-bottom"));
		}
	}
	
	this.border = { left : { width: function (){ return int(get("border-left-width"))}
							 ,color: function (){ return get("border-left-color")}
							 ,style: function (){ return get("border-left-style")}}
							 
					,right : { width: function (){ return int(get("border-right-width"))}
							 ,color: function (){ return get("border-right-color")}
							 ,style: function (){ return get("border-right-style")}}	
					,top : { width: function (){ return int(get("border-top-width"))}
							 ,color: function (){ return get("border-top-color")}
							 ,style: function (){ return get("border-right-style")}}	
					,bottom : { width: function (){ return int(get("border-top-width"))}
							 ,color: function (){ return get("border-top-color")}
							 ,style: function (){ return get("border-top-style")}}			 
				};
	
	return this;
}
function getObjectTop(obj)
{
	var top = 0;
	var o = obj;
	var lastObj = null;
	while (o)
	{
		top+=int(o.offsetTop);
		if(o==document.body)
		{
			if(o.document.parentWindow.frameElement)
			{
				top += o.document.parentWindow.frameElement.offsetTop;
				o = o.document.parentWindow.frameElement.offsetParent;
			}	
			else 
				o = o.offsetParent;
		}
		else
			o = o.offsetParent;
	}
	return top;
}

function getObjectLeft(obj)
{
	var left = 0;
	var o= obj;
	while (o)
	{
		left +=int(o.offsetLeft);
		if(o==document.body)
		{
			if(o.document.parentWindow.frameElement)
			{
				left += o.document.parentWindow.frameElement.offsetLeft;
				o = o.document.parentWindow.frameElement.offsetParent;
			}	
			else 
				o = o.offsetParent;
		}
		else
			o = o.offsetParent;	
	}
	return left;
}
function getObjectPosition(obj) {
	var left,top;
	left=top =0;
	var o= obj;
	if (o.offsetParent) {
		
		while (o) {
			left += o.offsetLeft; if(o==obj && o.clientLeft) left+= o.clientLeft;
			top += o.offsetTop;   if(o==obj && o.clientTop) top+= o.clientTop;
			o = o.offsetParent;
		}
	}
	return [left,top];
}
function ObjectPositin_C (E)
{
	var B = new ObjectPosition_FlyWeight();
	B.dom = E;
	return B;
}
function ObjectPositin_GetScroll (d)
{
	var doc = document;
	if (d==doc || d == doc.body)
	{
		var l, t;
		if (CurrentNavigator.isIE && CurrentNavigator.isStrict)
		{
			l = doc.documentElement.scrollLeft || (doc.body.scrollLeft || 0);
			t = doc.documentElement.scrollTop || (doc.body.scrollTop || 0);
		}
		else 
		{
			l = window.pageXOffset || (doc.body.scrollLeft || 0);
			t = window.pageYOffset || (doc.body.scrollTop || 0);
		}
		return { left: l, top : t};
	}
	else 
	{
		return { left: d.scrollLeft, top : d.scrollTop };
	}
}
function getClientSize (withCheck)
{
	
	if(CurrentNavigator.isGecko) 
		return [window.innerWidth, window.innerHeight]; 
	else if(CurrentNavigator.isOpera )
		return [window.innerWidth, window.innerHeight]; 
	else if (CurrentNavigator.isIE || CurrentNavigator.isIE7)
	{
		if(!document.compatMode || document.compatMode == "BackCompat")
		{
			return [document.body.clientWidth, document.body.clientHeight];			
		}
		else 
		{
			if (withCheck && document.body.clientWidth && document.body.clientHeight)
				return [document.body.clientWidth, document.body.clientHeight];
			else
				return [document.documentElement.clientWidth, document.documentElement.clientHeight]; 
		}
	}
	
	//None of the known browsers?
	var div = document.createElement ("div"), s = div.style; 
	s.position = "absolute"; 
	s.bottom = s.right = "0px"; 
	document.body.appendChild(div); 
	var clientSize  = [div.offsetLeft, div.offsetTop]; 
	document.body.removeChild(div); 
	
	return clientSize; 
}

function getObjectPosition4 (obj)
{
	//Check the element type 
	if(/^body$/i.test(obj.tagName)) return [0,0];
	
	var scrollLeft = 0, scrollTop = 0;
	var isDiv = /^div$/i.test(obj.tagName);
	var result, tmp; 
	
	//Get scroll left,top 
	if(isDiv && obj.scrollLeft)		scrollLeft	= obj.scrollLeft; 
	if(isDiv && obj.scrollTop)		scrollTop	= obj.scrollTop; 
	
	//Check parent node
	if(obj.parentNode && obj.parentNode !== obj.offsetParent) 
	{
		if (obj.parentNode.scrollTop)
			scrollTop += obj.parentNode.scrollTop; 
		if (obj.parentNode.scrollLeft)
			scrollTop += obj.parentNode.scrollLeft; 
	}
	result = [
		obj.offsetLeft - scrollLeft, obj.offsetTop - scrollTop]; 
	
	//Check offset parent 
	if(obj.offsetParent) 
	{
		tmp = getObjectPosition4 (obj.offsetParent); 
		result[0] += tmp[0]; 
		result[1] += tmp[1]; 
	}
	return result; 
}
function getPositioning (obj)
{
    var parent=obj
      	,offsetLeft=0
      	,offsetTop=0
      	,view = getDefaultView (obj);
      	
    while (parent && parent!=document.body && parent!=document.firstChild)
    {
      	offsetLeft+=parseInt(parent.offsetLeft);
      	offsetTop+=parseInt(parent.offsetTop);
      	parent=parent.offsetParent
    }
    return {
      		"bottom"		:view["bottom"]
      		,"left"			:view["left"]
      		,"marginTop"	:view["marginTop"]
      		,"marginLeft"	:view["marginLeft"]
      		,"offsetLeft"	:offsetLeft
  			,"offsetTop"	:offsetTop
  			,"position"		:view["position"]
  			,"right"		:view["right"]
  			,"top"			:view["top"]
  			,"z-index"		:view["zIndex"]
		};
}

function getObjectPosition3 (G) {
    var F, K, M, N, J = (document.body || document.documentElement); 
    G = $(G); 
    if(G == J) {
        return[0, 0]
    }
    if(G.getBoundingClientRect) 
    {
        M = G.getBoundingClientRect(); 
        N = ObjectPositin_GetScroll(document); 
		return[M.left + N.left, M.top + N.top]
	}
    var OO = 0, L = 0; F = G; 
    var E = getCssValue (G, "position") == "absolute"; 
    while(F) {
        OO += F.offsetLeft; L += F.offsetTop; if(!E && getCssValue (F, "position") == "absolute") 
        {
			E = true
		}
        if(CurrentNavigator.isGecko) 
        {
			K = C(F); 
			var P = parseInt (getCssValue (K, "borderTopWidth"), 10) || 0; 
			var H = parseInt(getCssValue (K, "borderLeftWidth"), 10) || 0; 
			OO += H; 
			L += P; 
			if(F != G && getCssValue (K, "overflow") != "visible") 
			{
				OO += H; 
				L += P
			}
        }
        F = F.offsetParent
	}
    if(CurrentNavigator.isSafari && E) 
    {
        OO -= J.offsetLeft; 
        L -= J.offsetTop
    }
    if(CurrentNavigator.isGecko &&!E) 
    {
        var I = ObjectPositin_C (J); 
        I = J;
        OO += parseInt(getCssValue (I, "borderLeftWidth"), 10) || 0; 
        L += parseInt(getCssValue (I, "borderTopWidth"), 10) || 0
    }
    F = G.parentNode; 
    while(F && F != J) {
        if(!CurrentNavigator.isOpera || (F.tagName != "TR" && getCssValue(F, "display") != "inline")
	) 
	{
        OO -= F.scrollLeft; L -= F.scrollTop
	}
    F = F.parentNode
    }
    return[OO, L];
}
               
               
function getObjectPosition2 (obj) {
	var left,top;
	left=top =0;
	var o= obj;
	if (o.offsetParent) {
		
		while (o) 
		{
			left += o.offsetLeft - o.scrollLeft; if(o==obj) left += o.clientLeft;
			top += o.offsetTop - o.scrollTop;   if(o==obj) top += o.clientTop;
			
			//Remove scroll left/top
			if (o==document.body)
			{
				left +=o.scrollLeft;
				top += o.scrollTop;
			}
			o = o.offsetParent;
		}
	}
	return [left,top];
}
function rerenderElement (element)
{
	if (!element) return;
	try {
		var n = document.createTextNode(" ");
		element.appendChild(n);
		element.removeChild(n);
		
		var origPaddingLeft = element.style.paddingLeft;
		element.style.paddingLeft = "1px";
		if (origPaddingLeft)
			element.style.paddingLeft  = origPaddingLeft;
		else
			element.style.paddingLeft  = "0px";
		
		var origZoom = element.style.zoom;
		element.style.zoom  = "100%";
		if (origZoom)
			element.style.zoom = origZoom;
		
			
	} catch(e) { }
}
function setFocus(el, withSelect)
{
	try
	{
		if(el==null) return;
		el.focus();
		if (withSelect)
		el.select ();
	}
	catch (ex)
	{
	}
}
function getEventSource(e)
{
	return (isMS()? e.srcElement: e.target);
}
/**
 * Extending the event object
 * @param {} Event
 */
function $e (Event)
{
	var e = cloneObject(Event);
	
	e.src = getEventSource(e);//The keyword "source" is already reserved, sorry!
	e.receiver = e.toElement || e.relatedTarget || {};
	
	if (e.clientX == undefined)
	{
		e.currentX = e.clientX = e.pageX;
		e.currentY = e.clientY = e.pageY;
	}
	else
	{
		e.currentX = e.clientX + document.body.scrollLeft
				+ document.documentElement.scrollLeft;
		e.currentY = e.clientY + document.body.scrollTop
				+ document.documentElement.scrollTop;
	}
	

	
	e.Event = Event;
	e.stopDefault = function ()
	{
		if (e.Event.stopPropagation) e.Event.stopPropagation();
		if (e.Event.preventDefault) e.Event.preventDefault();
		else e.Event.cancelBubble = true;
		if (e.stopPropagation) e.stopPropagation();
		if (e.preventDefault) e.preventDefault();
		else e.cancelBubble = true;
		
		
	}
	e.clearSelection = function()
	{
		if (document.selection && document.selection!=undefined & document.selection.clear ) document.selection.clear();
		else if(window.getSelection) {
		  var sel = window.getSelection()
		       sel.removeAllRanges();
		}
	}
	
	return e;
}
function isTag (tag, o, type)
{
	if(tag==null) return false;
	if(o==null) return false;
	
	var tagName = o.tagName;
	if(tagName==null) return false;
	if(type==null)
		return (tagName.toLowerCase()==tag.toLowerCase());
	else
	{
		if(tagName.toLowerCase()!=tag.toLowerCase()) return false;
		if(o.type==null) return false;
		return (o.type.toLowerCase()==type.toLowerCase());
	}
	return false;
}
function openUtilsSelectionWindow ()
{
	window.showModalDialog (getVirtualPath() + "system/utils_selection.aspx",
		null, 
		"dialogHeight:500px;dialogWidth:600px;edge:sunken;help:no;resizable:no;scroll:yes;status:yes;unadorned:yes");
		
}
function openUtilsSelectionWindow2 ()
{
	window.showModalDialog (getVirtualPath() + "system/utils_selection2.aspx",
		null, 
		"dialogHeight:500px;dialogWidth:600px;edge:sunken;help:no;resizable:no;scroll:yes;status:yes;unadorned:yes");
		
}
function openQuickLogin()
{
	var loginWin = window.open (getVirtualPath() + "login/quicklogin.aspx","QuickLogin", 
		"width=800,height=230,scrollbars=no,resizable=no");
	loginWin.focus();
		
}
var fullNavigatorVersion = getBrowserVersion ().toString();
if (fullNavigatorVersion.indexOf ("(")>0) fullNavigatorVersion = fullNavigatorVersion.substr (0, fullNavigatorVersion.indexOf ("("));
var majorNavigatorVersion = fullNavigatorVersion.match (/[0-9]+/);




function reloadXmlFiles ()
{
	window.showModalDialog (getVirtualPath() + "qs_report/wizards/reload_xml_files.aspx",
		null, 
		"dialogHeight:150px;dialogWidth:300px;edge:sunken;help:no;resizable:no;scroll:yes;status:yes;unadorned:yes");
		
}
function activateDebugMode ()
{
	window.showModalDialog (getVirtualPath() + "qs_report/wizards/setdebug.aspx",
		null, 
		"dialogHeight:100px;dialogWidth:200px;edge:sunken;help:no;resizable:no;scroll:yes;status:yes;unadorned:yes");

}
var registeredShortCutActions = {};	
function registerShortCutAction (letter, callback, cancelBubble)
{
	var regInfo = registeredShortCutActions [letter.toLowerCase()];
	if (!regInfo)
		regInfo = new Array ();
	regInfo.push ([callback, cancelBubble]);
	registeredShortCutActions [letter.toLowerCase()] = regInfo;
}
function executeRegisteredShortCutActions (letter)
{
	var regInfo = registeredShortCutActions [letter.toLowerCase()];
	if (!regInfo) return true;
	for (var i=0; i < regInfo.length; i++)
	{
		var shortCutSetting = regInfo [i];
		var method = shortCutSetting [0];
		var cancelBubble = shortCutSetting [1];
		if (method)
			method ();
		
		if (cancelBubble)
		{
			return false;
		}
	}
	
	return true;
}

var shortCutLetters = "";
var mouseTrackingMode = false;
var borderTrackingMode = false;
var keyTrackingMode = false;
/*
* Shortcuts overview:
*	Shift + Ctrl + "452217":		~=debugger;
*	Shift + Ctrl + "9452217":		internal debugger
*	Shift + Ctrl + "Q"/"T":				utilities window for developers

*	Shift + Ctrl + "S":				utilities window for customers
*	Shift + Ctrl + "R":				execute a reload action (ReloadActionOnShurtCut, has to be defined in another application)
*	Shift + Ctrl + "C":				system tests dialog
*	Shift + Ctrl + "D":				turning on/off the debug mode 
*	Shift + Ctrl + "E":				errors.xml 
*	Shift + Ctrl + "W":				showing window and document.body properties 
*	Shift + Ctrl + "X":				resizing the window - 1024x768 and fullscreen mode 
*	Shift + Ctrl + "L":				quick login dialog 
*	Shift + Ctrl + "M":				turning on/off the mouse tracking  
*	Shift + Ctrl + "K":				turning on/off the keycode tracking
*	Shift + Ctrl + "B":				turning on/off the element border tracking
*	Shift + Ctrl + "N":				reloading stylesheets 
*	Shift + Ctrl + "Z":				reloading stylesheets 
*	Shift + Ctrl + "O":				reloading javascripts
*	Shift + Ctrl + "J":				starting JS-Debugger
*	Shift + Ctrl + "6":				opens the debug file 

*/	

function checkShortCutAction (Event)
{
	try
	{
		
    	if (Event.shiftKey  && Event.ctrlKey)
		{
			//Check registered short cut actions (from within other scripts)
			var proceed = executeRegisteredShortCutActions (String.fromCharCode (Event.keyCode+96).toLowerCase());
			if (!proceed) return;
		}
	

		if(!(Event.shiftKey && Event.ctrlKey))
			shortCutLetters = "";
		else
			shortCutLetters += String(Event.keyCode);

		//Start debugger?	
		if(shortCutLetters.toLowerCase()=="452217")// "debug")
		{
			if(confirm("Do you want to start the debugger?"))
				debugger;
			shortCutLetters = "";
			return false;
		}
		else if(shortCutLetters.toLowerCase()=="9452217")//"idebug")
		{
			if(confirm("Do you want to start the internal debugger?"))
				startInternalDebugger();
			shortCutLetters = "";
			return false;
		}		
		
		//Shift+Strg+Q/T - Open utils window
		if ((Event.shiftKey && Event.ctrlKey && (Event.keyCode==17 || Event.keyCode==20)))
		{
			openUtilsSelectionWindow ();
			return false;
		}
		//Shift+Strg+S - Open utils window for customers 
		if ((Event.shiftKey && Event.ctrlKey && Event.keyCode==19))
		{
			openUtilsSelectionWindow2 ();
			return false;
		}
		
		//Shift+Strg+N/Z - Reloading the stylesheets 
		if ((Event.shiftKey && Event.ctrlKey && 
			(Event.keyCode==14 || Event.keyCode == 26)))
		{
			if (window.StylesheetsManager)
				window.StylesheetsManager.reload();
			return false;
		}
		//Shift+Strg+O - Reloading the javascripts 
		if ((Event.shiftKey && Event.ctrlKey && Event.keyCode==15))
		{
			if (window.ScriptsManager)
				window.ScriptsManager.reload();
			return false;
		}
		//Shift+Strg+R - execute a ReloadAction of the calling window 
		else if ((Event.shiftKey && Event.ctrlKey && Event.keyCode==18))
		{
			if( self.ReloadActionOnShurtCut)
				self.ReloadActionOnShurtCut();
			return false;
		}
		
		//Shift+Strg+C - Open the system test dialog 
		else if ( (Event.shiftKey && Event.ctrlKey && Event.keyCode==3))
		{
			openSystemTest ();
			return false;
		}
		//Shift+Strg+D - Turn on/off the debug mode
		else if ( (Event.shiftKey && Event.ctrlKey && Event.keyCode==4))
		{
			activateDebugMode ();
			return false;
		}
		
		//Shift+Strg+E/2 - Show errors.xml in a popup
		else if ( (Event.shiftKey && Event.ctrlKey && 
			(Event.keyCode==5 || Event.keyCode==0)))
		{
			showErrorsXml();
			return false;
		}
		//Shift+Strg+W - Show window properties
		else if ( (Event.shiftKey && Event.ctrlKey && Event.keyCode==23))
		{
			alert$(window);
			alert$(document.body);
			return false;
		}
		//Shift+Strg+X - Resize the window (between fullscreen and 1024x768)
		else if ( (Event.shiftKey && Event.ctrlKey && Event.keyCode==24))
		{
			var fullsize = !confirm("Windowsize 1024x768?");
			if(fullsize)
			{
				window.resizeTo(window.screen.availWidth,window.screen.availHeight);
				window.moveTo(0,0);
			}
			else
			{
				window.resizeTo(1024,768);				
			}
			return true;
		}
		//Shift+Strg+L - Quick login 
		else if ( (Event.shiftKey && Event.ctrlKey && Event.keyCode==12))
		{
			openQuickLogin();
			return false;
		}
		//Shift+Strg+M - Mouse tracking 
		else if ( (Event.shiftKey && Event.ctrlKey && Event.keyCode==13))
		{
			if(!document.body)return;
			if(mouseTrackingMode)
			{
				mouseTrackingMode = false;
				removeEvent(document.body,"mousemove",showMousePosition);
			}
			else
			{
				mouseTrackingMode = true; 
				addEvent(document.body,"mousemove",showMousePosition);
			}
			return false;
		}
		//Shift+Strg+K - Key tracking
		else if ( (Event.shiftKey && Event.ctrlKey && Event.keyCode==11))
		{
			if(!document.body)return;
			if(keyTrackingMode)
			{
				keyTrackingMode = false;
				removeEvent(document.body,"keypress",showKeyCode);
			}
			else
			{
				keyTrackingMode = true; 
				addEvent(document.body,"keypress",showKeyCode);
			}
			return false;
		}
		//Shift+Strg+B - Element border tracking
		else if ( (Event.shiftKey && Event.ctrlKey && Event.keyCode==2))
		{
			if(!document.body)return;
			if(borderTrackingMode)
			{
				borderTrackingMode = false;
				removeEvent(document.body,"onmouseover", highlightElementUnderFocus);
			}
			else
			{
				borderTrackingMode = true; 
				addEvent(document.body,"onmouseover",highlightElementUnderFocus);
			}
			return false;
		}
		//Shift+Strg+J - start a JavaScript-Debugger
		else if ( (Event.shiftKey && Event.ctrlKey && Event.keyCode==10))
		{
			debugger;
			return false;
		}
		//Shift+Strg+6 - opens the debug log file 
		else if ( (Event.shiftKey && Event.ctrlKey && Event.keyCode==30))
		{
			var win = window.open (getVirtualPath() + "/upload/tmp/debug.txt", "DebugLog",
	"width=800,height=600,resizable=yes,scrollbars=yes,menubar=yes");
			win.focus();	
			return false;
		}
	
		
		
		
	}catch (err)
	{		
	}
	return true;
}

var lastElementUnderFocusInBorderTrackingMode = null;
function highlightElementUnderFocus (e)
{
	if (!borderTrackingMode);
	var element = e.srcElement;
	//if (!element) element = e.srcElement;
	
	
	//Has border?
	var originalBorderStyle = getObjectBorderStyle (element, "Left") + ";"  + 
		getObjectBorderStyle (element, "Top") + ";"  + 
		getObjectBorderStyle (element, "Right") + ";"  + 
		getObjectBorderStyle (element, "Bottom");
	
	element.setAttribute ("originalBorderStyleForBorderTracking", originalBorderStyle);
	element.style.border = "1px solid blue";
	addEvent (element, "onmouseout", unhighlightElementUnderFocus);
	lastElementUnderFocusInBorderTrackingMode = element;
	
}
function unhighlightElementUnderFocus (e)
{
	if (!borderTrackingMode) return;
	
	var element = e.fromElement;
	
	//if (!element) 	element = e.srcElement;
	if (!element) return;
	element.style.borderStyle = "none";
	
	//Set the original border style 
	var originalBorderStyle = element.getAttribute ("originalBorderStyleForBorderTracking");
	
	if (originalBorderStyle)
	{
		var borderStyles = originalBorderStyle.split (";");
		try { 
			if (borderStyles [0])
				element.style.borderLeft = borderStyles [0];
			if (borderStyles [1])
				element.style.borderTop = borderStyles [1];
			if (borderStyles [2])
				element.style.borderRight = borderStyles [2];
			if (borderStyles [3])
				element.style.borderBottom = borderStyles [3];
		}catch (err) {}
	}
	
	removeEvent (element, "onmouseout", unhighlightElementUnderFocus);
}
function showKeyCode (e)
{
	showMsg (e.keyCode  + ", shift: " + e.shiftKey + ", ctrl: " + e.ctrlKey + ", alt:" + e.altKey);
}
function showMousePosition (e)
{
	showMsg(e.x + ", "+ e.y);
}
function startInternalDebugger()
{
	var div = $("div_debugger");
	if(div==null)
	{
		div = document.createElement("DIV");
		div.id = "div_debugger";
		var iframe = document.createElement("IFRAME");
		iframe.src = getVirtualPath() + "multimed/jsdebugger.htm";
		div.style.cssText = "border:1px solid royalblue;position:absolute;left:0px;top:0px;width:600px;height:400px;";
		iframe.style.cssText = "width:100%;height:100%";
		document.body.appendChild(div);
		//div.className = "moveme";
		var p = document.createElement("P");
		p.className = "handle";
		p.setAttribute("handlefor", "$('div_debugger')");
		p.innerHTML= "<span style=\"float:left;\">Debugger</span><span style='float:right;'><a href='javascript:void(0)' style='color:white;' onclick='$(\"div_debugger\").style.display=\"none\";'>Close</a></span>";
		p.style.cssText = "width:100%;height:30px;padding:5px;color:white;background-color:royalblue;border:1px solid black;margin:0px;";
		div.appendChild(p);
		div.appendChild (iframe);
		div.onmousemove = resizeElement;
	}
	div.style.display = "";
}
function resizeElement(d_ev)
{
	if(!dd.obj || !dd.obj.visible) return true;
	if(dd.wait) return false;
	dd.wait = 1;
	setTimeout('dd.wait = 0;', dd.tiv);
	dd.e = new dd.evt(d_ev);
	if(dd.ie && !dd.e.but)
	{
		DROP(d_ev);
		return true;
	}
	dd.msmoved = 1;
	var d_w = dd.limW(dd.inWndW(dd.ofx+dd.e.x)-dd.obj.x), d_h;
	if(!dd.whratio) d_h = dd.limH(dd.inWndH(dd.ofy+dd.e.y)-dd.obj.y);
	else
	{
		d_h = dd.limH(dd.inWndH(Math.round(d_w/dd.whratio)+dd.obj.y)-dd.obj.y);
		d_w = Math.round(d_h*dd.whratio);
	}
	dd.reszTo(d_w, d_h);
	if(window.my_ResizeFunc) my_ResizeFunc();
	if(dd.obj.resizeFunc) dd.obj.resizeFunc();
	if(dd.moveFunc) return dd.moveFunc(d_ev);
	return false;
}
function showErrorsXml()
{
	var winErrorsXml = window.open(getVirtualPath()+ "errors/errors.xml", "ErrorsXml");
	winErrorsXml.focus();
}
function openSystemTest()
{
	var winSystemTest = window.open(getVirtualPath()+ "system/systemtest.aspx", "SystemTest",
		"width=700,height=400,scrollbars=yes,resizable=yes");
	winSystemTest.focus();
}
/** Converting object to xml **/
function objectToXml(obj, withFormat, level)
{
	if(!obj) return null;
	if (!level) level = 0;
	var xml = "";
	
	var indentSpace = (withFormat ? space ("\t", int(level)) : "");
	var lineBreak = (withFormat ? "\n": "");
	
	var oVal = null;
	var type = null;
	var sVal = "";
	var first = true;
	var skip = false;
	try
	{
		for(var p in obj)
		{	
			if (p == undefined || p=="undefined") continue;
			if(first && p=="type") { first = false; continue; }
			skip= false;
			try { oVal = obj[p];} catch (err2) {
			//alert(err2.description); 
			}
			if(oVal==null)
				sVal = "";
			else
			{
				type = GetInstanceName(oVal);
				switch (type)
				{
					case "Boolean":
						sVal = (oVal==true?"true":"false");break;
					case "Number":
						sVal = oVal.toLocaleString();
						break;
					case "Date":
						sVal = oVal.toLocaleString ();
						break;
					case "String":
						sVal = HtmlEncodeForXml(oVal.toString());break;
					case "Array": //Skip for now
						skip=true;break;
					default:
						sVal = objectToXml(oVal, withFormat, level+1);
				}				
			}
			if(!skip) xml+= indentSpace + "<" + p + ">" + sVal + "</" +p + ">" + lineBreak;
		}
	}catch(err){
	//alert(err.description);
	}

	return xml;
}
/** 
 * Converting xml to an object (= reading object properties from an xml)
 * @param {} xml
 */
function xmlToObject (xml)
{
	var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
	xmlDoc.async=false;
	xmlDoc.loadXML(xml);
	var o = new Object();
	
	return populateObjectFromXml (o, xmlDoc.firstChild);
}
function populateObjectFromXml  (objectToPopulate, xmlObject)
{
	if (!objectToPopulate) objectToPopulate = new Object();
	if (!xmlObject) return;
	for (var i=0; i < xmlObject.childNodes.length; i++)
	{
		var r = xmlObject.childNodes [i];
		if (r && r.nodeType == 1 ) 
		{	
		
			var stringValue = new String(getNodeValue(r));
			var dateValue = null;
			var boolValue = null;
			var numericValue = null;
			try
			{
				if(stringValue!=null && stringValue!="")
				{
					//Boolean
					if (stringValue == "false" || stringValue == "true")
					{
						boolValue = (stringValue == "true");
						objectToPopulate [r.nodeName] = boolValue;
					}
					else 
					{
						//Date 
						dateValue = parseDate (stringValue);
						if (dateValue!=null)
						{
							objectToPopulate [r.nodeName] = dateValue;
						}
						else
						{
							//Numeric
							if (isNumeric (stringValue))
							{
								numericValue = parseNumber (stringValue);	
								objectToPopulate [r.nodeName] = numericValue;
							}
							else //Text 
							{
								objectToPopulate [r.nodeName] = stringValue;
							}
						}
					}
				}
				else 
				{
					objectToPopulate [r.nodeName] = stringValue;
				}	
			}
			catch (err)
			{
				//alert(t);
			}
		}
			
		
	}
	return objectToPopulate;
}

function firstLetterToUpper(name)
{
	if(name==null)return null;
	
	return String(name).charAt(0).toUpperCase() + name.substr(1);
}
function firstLetterToLower(name)
{
	if(name==null)return null;
	return String(name).charAt(0).toLowerCase() + name.substr(1);
}

function convertAttributesToCss(obj)
{
	var res = "";
	for (var a in obj)
	{
		
		var prop = convertJsPropertyToCssRule (a);
		var val = obj[a];
		if(isEmpty(val)) val = "";
		if(GetInstanceName (val).toLowerCase()!="object")
			res+=  (res!=""?"; ":"") + prop + ": " + (isEmpty(val)?"":val);
	}
	return res;
}
function convertCssToAttributes(obj, css)
{
	if(obj==null || css==null) return obj;
	var arr = String(css).split(";");
	for (var i=0; i < arr.length; i++)
	{
		var cssDef = String(arr[i]).split(":");
		cssRule = Trim(cssDef[0].toLowerCase());
		cssVal = Trim(cssDef[1]);
		var cssJsRule = convertCssRuleToJsProperty(cssRule);
		obj[cssJsRule] = cssVal;
	}
	return obj;
}

/** WAITING ANIMATION **/
var animWaitOptions = [{img:null,speed:100},{img:null,speed:1000}];
var animWaitCounter = new Array();
animWaitCounter[0] = animWaitCounter[1] = 0;
var animWaitingIconStopped = false;
var animWaitingImages = new Array();
//Animation with a sand clock
animWaitingImages [0] = new Array();
var animWaitingImagesPath = getVirtualPath() + "/images/animation/";


function preloadAnimationImages ()
{
	for(var i=1; i<=21; i++)
	{
		var img = document.createElement("IMG");
		img.src = animWaitingImagesPath + "sanduhr_" + i.toString() + ".gif";
		animWaitingImages [0].push(img);
	}
	//Animation with a clock
	animWaitingImages [1] = new Array();
	for(var i=0; i< 12; i++)
	{
		var img = document.createElement("IMG");
		img.src = animWaitingImagesPath + "clock_" + i.toString() + ".gif";
		animWaitingImages [1].push(img);
	}
}

function animateWaitingIcon (img, type)
{
	
	if(img==null)
		img = animWaitOptions[type].img;
	animWaitOptions[type].img = img;
	var imagesArray = animWaitingImages[type];
	if(animWaitingIconStopped){animWaitCounter[type]=0; return;}
	
	img.src = imagesArray [animWaitCounter[type]].src;
	animWaitCounter[type] ++;
	if(animWaitCounter[type] > (imagesArray.length-1)) animWaitCounter[type] = 0;
	
	window.setTimeout("animateWaitingIcon (null," + type + ")", animWaitOptions[type].speed);
}
function displayDummyElement(top,left,width,height,bgcolor)
{
	var dummy = document.createElement("DIV");
	dummy.style.cssText = "background-color:" + bgcolor + ";position:absolute;left:" + left + ";top:" + top + ";width:" + width + ";height:" + height + ";";
	document.body.appendChild(dummy);
}
//Returns the time in format "3 years 4 months 2 days 10 hours 3 minutes 40 seconds"
function formatTime (timeInSeconds)
{
	var years=0,months=0,days=0,hours=0,minutes=0,seconds=0;
	timeInSeconds = int (timeInSeconds);
	if(timeInSeconds==0) return "0 Sekunden";
	
	//Years
	years = timeInSeconds/(60*60*24*365);
	if(years>=1) { 
		years = Math.floor(years); 
		timeInSeconds -= years*(60*60*24*365);}
	else years=0;
	
	//Months
	months = timeInSeconds/(60*60*24*(365/12));//Average
	if(months>=1) { 
		months = Math.floor(months); 
		timeInSeconds -= months*(60*60*24*(365/12));
	}
	else months=0;
	
	//Days
	days = timeInSeconds/(60*60*24);
	if(days>=1) { 
		days = Math.floor(days); 
		timeInSeconds -= days*(60*60*24);
	}
	else days=0;
	
	//Hours
	hours = timeInSeconds/(60*60);
	if(hours>=1) { 
		hours = Math.floor(hours); 
		timeInSeconds -= hours*(60*60);
	}
	else hours=0;
	
	//Minutes
	minutes = timeInSeconds/(60);
	if(minutes>=1) { 
		minutes = Math.floor(minutes); 
		timeInSeconds -= minutes*(60);
	}
	else minutes=0;
	
	//Seconds
	seconds = timeInSeconds;
	
	var res = "";
	if(years>0)		res+=	" "	+ (years==1?	"1 Jahr":		years	+ " Jahre");
	if(months>0)	res+=	" "	+ (months==1?	"1 Monat":		months	+ " Monate");
	if(days>0)		res+=	" "	+ (days==1?		"1 Tag":		days	+ " Tage");
	if(hours>0)		res+=	" "	+ (hours==1?	"1 Stunde":		hours	+ " Stunden");
	if(minutes>0)	res+=	" "	+ (minutes==1?	"1 Minute":		minutes	+ " Minuten");
	if(seconds>0)	res+=	" "	+ (seconds==1?	"1 Sekunde":	seconds	+ " Sekunden");
	
	return Trim(res);
}

//Returns the time in format "3 years 4 months 2 days 10:03:40"
function formatTime2 (timeInSeconds)
{
	var years=0,months=0,days=0,hours=0,minutes=0,seconds=0;
	timeInSeconds = int (timeInSeconds);
	if(timeInSeconds==0) return "0 Sekunden";
	
	//Years
	years = timeInSeconds/(60*60*24*365);
	if(years>=1) { 
		years = Math.floor(years); 
		timeInSeconds -= years*(60*60*24*365);}
	else years=0;
	
	//Months
	months = timeInSeconds/(60*60*24*(365/12));//Average
	if(months>=1) { 
		months = Math.floor(months); 
		timeInSeconds -= months*(60*60*24*(365/12));
	}
	else months=0;
	
	//Days
	days = timeInSeconds/(60*60*24);
	if(days>=1) { 
		days = Math.floor(days); 
		timeInSeconds -= days*(60*60*24);
	}
	else days=0;
	
	//Hours
	hours = timeInSeconds/(60*60);
	
	if(hours>=1) { 
		hours = Math.floor(hours); 
		timeInSeconds -= hours*(60*60);
	}
	else hours=0;
	
	//Minutes
	minutes = timeInSeconds/(60);
	if(minutes>=1) { 
		minutes = Math.floor(minutes); 
		timeInSeconds -= minutes*(60);
	}
	else minutes=0;
	
	//Seconds
	seconds = timeInSeconds;
	
	var res = "";
	if(years>0)		res+=	" "	+ (years==1?	"1 Jahr":		years	+ " Jahre");
	if(months>0)	res+=	" "	+ (months==1?	"1 Monat":		months	+ " Monate");
	if(days>0)		res+=	" "	+ (days==1?		"1 Tag":		days	+ " Tage");
	//if(hours>0)		
					res+=	" "	+ (hours<10?"0":"")			+	hours	+ ":";
	//if(minutes>0)	
					res+=	""	+ (minutes<10?"0":"")		+	minutes	+ ":";
	//if(seconds>0)	
					res+=	""	+ (seconds<10?"0":"")		+	seconds;
	
	return Trim(res);
}
/* This is the code to format the object properties collection syntax below 
	var msg = "";
	var props = "";
	var errors="";
	for (var group in jsObjectProperties)
	{
		try
		{
			msg+="\t//" + group + "\n";
			msg+="\t" + (msg!=""?",":"") + "\"" + group + "\": [\n";
			props = "";
			var attributes = jsObjectProperties[group];
			attributes.sort();
			for (var p=0; p < attributes.length; p++)
			{
				props+="\t\t" + (props!=""?",":"") + "\"" + attributes[p] + "\"\n";
			}
			msg+=props+ "\t]\n\n"
		}catch (err)
		{
			errors+=err.description + "\n";
		}
	}*/
var jsObjectProperties = {
	//misc
	"misc": [
		"accessKey"
		,"canHaveChildren"
		,"canHaveHTML"
		,"contentEditable"
		,"dir"
		,"disabled"
		,"hideFocus"
		,"id"
		,"isContentEditable"
		,"isDisabled"
		,"isMultiLine"
		,"isTextEdit"
		,"lang"
		,"language"
		,"name"
		,"parentTextEdit"
		,"readOnly"
		,"readyState"
		,"recordNumber"
		,"scopeName"
		,"status"
		,"tabIndex"
		,"title"
		,"type"
	]

	//dimension
	,"dimension": [
		"clientHeight"
		,"clientWidth"
		,"offsetHeight"
		,"offsetWidth"
		,"scrollHeight"
		,"scrollWidth"
	]

	//collections
	,"collections": [
		"attributes"
		,"cols"
		,"rows"
	]

	//location
	,"location": [
		"clientLeft"
		,"clientTop"
		,"offsetLeft"
		,"offsetTop"
		,"scrollLeft"
		,"scrollTop"
	]

	//data
	,"data": [
		"dataFld"
		,"dataFormatAs"
		,"dataSrc"
	]

	//dom
	,"dom": [
		"all"
		,"childNodes"
		,"children"
		,"document"
		,"firstChild"
		,"form"
		,"innerHTML"
		,"innerText"
		,"lastChild"
		,"nextSibling"
		,"nodeName"
		,"nodeType"
		,"nodeValue"
		,"offsetParent"
		,"outerHTML"
		,"outerText"
		,"ownerDocument"
		,"parentElement"
		,"parentNode"
		,"previousSibling"
		,"sourceIndex"
		,"tagName"
		,"tagUrn"
		,"value"
	]

	//styles
	,"styles": [
		"behaviorUrns"
		,"className"
		,"currentStyle"
		,"filters"
		,"runtimeStyle"
		,"style"
		,"wrap"
	]

	//events
	,"events": [
		"onactivate"
		,"onafterupdate"
		,"onbeforeactivate"
		,"onbeforecopy"
		,"onbeforecut"
		,"onbeforedeactivate"
		,"onbeforeeditfocus"
		,"onbeforepaste"
		,"onbeforeupdate"
		,"onblur"
		,"oncellchange"
		,"onchange"
		,"onclick"
		,"oncontextmenu"
		,"oncontrolselect"
		,"oncopy"
		,"oncut"
		,"ondataavailable"
		,"ondatasetchanged"
		,"ondatasetcomplete"
		,"ondblclick"
		,"ondeactivate"
		,"ondrag"
		,"ondragend"
		,"ondragenter"
		,"ondragleave"
		,"ondragover"
		,"ondragstart"
		,"ondrop"
		,"onerrorupdate"
		,"onfilterchange"
		,"onfocus"
		,"onfocusin"
		,"onfocusout"
		,"onhelp"
		,"onkeydown"
		,"onkeypress"
		,"onkeyup"
		,"onlayoutcomplete"
		,"onlosecapture"
		,"onmousedown"
		,"onmouseenter"
		,"onmouseleave"
		,"onmousemove"
		,"onmouseout"
		,"onmouseover"
		,"onmouseup"
		,"onmousewheel"
		,"onmove"
		,"onmoveend"
		,"onmovestart"
		,"onpage"
		,"onpaste"
		,"onpropertychange"
		,"onreadystatechange"
		,"onresize"
		,"onresizeend"
		,"onresizestart"
		,"onrowenter"
		,"onrowexit"
		,"onrowsdelete"
		,"onrowsinserted"
		,"onscroll"
		,"onselect"
		,"onselectstart"
	]
};
//The same as above, but not grouped and serves to check if a given property is already "grouped"
/** This is the code to create the collection syntax below 
var msg = "";
	var props = [];
	var maxLength = 0;
	for (var a in document.body)
	{
		props[props.length] = a;
		try{
		if(String(a).length>maxLength ) maxLength = String(a).length;
		}catch (err) {}
	}
	props.sort();
	
	for (var p=0; p < props.length; p++)
	{
		//Add tabs
		var countSpaces = maxLength - String(props[p]).length;
		var spaces = "";
		for(var c=0; c < countSpaces; c++)spaces += " ";
		spaces+="\t";
		msg+="\t" + (msg!=""?",":"") + "\"" + props[p] + "\":" + spaces + "\"" + props[p] + "\"\n";
	}					
			
**/
var jsObjectPropertiesCollection = {
	"aLink":             	"aLink"
	,"accessKey":         	"accessKey"
	,"all":               	"all"
	,"attributes":        	"attributes"
	,"background":        	"background"
	,"behaviorUrns":      	"behaviorUrns"
	,"bgColor":           	"bgColor"
	,"bgProperties":      	"bgProperties"
	,"bottomMargin":      	"bottomMargin"
	,"canHaveChildren":   	"canHaveChildren"
	,"canHaveHTML":       	"canHaveHTML"
	,"childNodes":        	"childNodes"
	,"children":          	"children"
	,"className":         	"className"
	,"clientHeight":      	"clientHeight"
	,"clientLeft":        	"clientLeft"
	,"clientTop":         	"clientTop"
	,"clientWidth":       	"clientWidth"
	,"contentEditable":   	"contentEditable"
	,"currentStyle":      	"currentStyle"
	,"dir":               	"dir"
	,"disabled":          	"disabled"
	,"document":          	"document"
	,"filters":           	"filters"
	,"firstChild":        	"firstChild"
	,"hideFocus":         	"hideFocus"
	,"id":                	"id"
	,"innerHTML":         	"innerHTML"
	,"innerText":         	"innerText"
	,"isContentEditable": 	"isContentEditable"
	,"isDisabled":        	"isDisabled"
	,"isMultiLine":       	"isMultiLine"
	,"isTextEdit":        	"isTextEdit"
	,"lang":              	"lang"
	,"language":          	"language"
	,"lastChild":         	"lastChild"
	,"leftMargin":        	"leftMargin"
	,"link":              	"link"
	,"nextSibling":       	"nextSibling"
	,"noWrap":            	"noWrap"
	,"nodeName":          	"nodeName"
	,"nodeType":          	"nodeType"
	,"nodeValue":         	"nodeValue"
	,"offsetHeight":      	"offsetHeight"
	,"offsetLeft":        	"offsetLeft"
	,"offsetParent":      	"offsetParent"
	,"offsetTop":         	"offsetTop"
	,"offsetWidth":       	"offsetWidth"
	,"onactivate":        	"onactivate"
	,"onafterprint":      	"onafterprint"
	,"onafterupdate":     	"onafterupdate"
	,"onbeforeactivate":  	"onbeforeactivate"
	,"onbeforecopy":      	"onbeforecopy"
	,"onbeforecut":       	"onbeforecut"
	,"onbeforedeactivate":	"onbeforedeactivate"
	,"onbeforeeditfocus": 	"onbeforeeditfocus"
	,"onbeforepaste":     	"onbeforepaste"
	,"onbeforeprint":     	"onbeforeprint"
	,"onbeforeunload":    	"onbeforeunload"
	,"onbeforeupdate":    	"onbeforeupdate"
	,"onblur":            	"onblur"
	,"oncellchange":      	"oncellchange"
	,"onclick":           	"onclick"
	,"oncontextmenu":     	"oncontextmenu"
	,"oncontrolselect":   	"oncontrolselect"
	,"oncopy":            	"oncopy"
	,"oncut":             	"oncut"
	,"ondataavailable":   	"ondataavailable"
	,"ondatasetchanged":  	"ondatasetchanged"
	,"ondatasetcomplete": 	"ondatasetcomplete"
	,"ondblclick":        	"ondblclick"
	,"ondeactivate":      	"ondeactivate"
	,"ondrag":            	"ondrag"
	,"ondragend":         	"ondragend"
	,"ondragenter":       	"ondragenter"
	,"ondragleave":       	"ondragleave"
	,"ondragover":        	"ondragover"
	,"ondragstart":       	"ondragstart"
	,"ondrop":            	"ondrop"
	,"onerrorupdate":     	"onerrorupdate"
	,"onfilterchange":    	"onfilterchange"
	,"onfocus":           	"onfocus"
	,"onfocusin":         	"onfocusin"
	,"onfocusout":        	"onfocusout"
	,"onhelp":            	"onhelp"
	,"onkeydown":         	"onkeydown"
	,"onkeypress":        	"onkeypress"
	,"onkeyup":           	"onkeyup"
	,"onlayoutcomplete":  	"onlayoutcomplete"
	,"onload":            	"onload"
	,"onlosecapture":     	"onlosecapture"
	,"onmousedown":       	"onmousedown"
	,"onmouseenter":      	"onmouseenter"
	,"onmouseleave":      	"onmouseleave"
	,"onmousemove":       	"onmousemove"
	,"onmouseout":        	"onmouseout"
	,"onmouseover":       	"onmouseover"
	,"onmouseup":         	"onmouseup"
	,"onmousewheel":      	"onmousewheel"
	,"onmove":            	"onmove"
	,"onmoveend":         	"onmoveend"
	,"onmovestart":       	"onmovestart"
	,"onpage":            	"onpage"
	,"onpaste":           	"onpaste"
	,"onpropertychange":  	"onpropertychange"
	,"onreadystatechange":	"onreadystatechange"
	,"onresize":          	"onresize"
	,"onresizeend":       	"onresizeend"
	,"onresizestart":     	"onresizestart"
	,"onrowenter":        	"onrowenter"
	,"onrowexit":         	"onrowexit"
	,"onrowsdelete":      	"onrowsdelete"
	,"onrowsinserted":    	"onrowsinserted"
	,"onscroll":          	"onscroll"
	,"onselect":          	"onselect"
	,"onselectstart":     	"onselectstart"
	,"onunload":          	"onunload"
	,"outerHTML":         	"outerHTML"
	,"outerText":         	"outerText"
	,"ownerDocument":     	"ownerDocument"
	,"parentElement":     	"parentElement"
	,"parentNode":        	"parentNode"
	,"parentTextEdit":    	"parentTextEdit"
	,"previousSibling":   	"previousSibling"
	,"readyState":        	"readyState"
	,"recordNumber":      	"recordNumber"
	,"rightMargin":       	"rightMargin"
	,"runtimeStyle":      	"runtimeStyle"
	,"scopeName":         	"scopeName"
	,"scroll":            	"scroll"
	,"scrollHeight":      	"scrollHeight"
	,"scrollLeft":        	"scrollLeft"
	,"scrollTop":         	"scrollTop"
	,"scrollWidth":       	"scrollWidth"
	,"sourceIndex":       	"sourceIndex"
	,"style":             	"style"
	,"tabIndex":          	"tabIndex"
	,"tagName":           	"tagName"
	,"tagUrn":            	"tagUrn"
	,"text":              	"text"
	,"title":             	"title"
	,"topMargin":         	"topMargin"
	,"vLink":             	"vLink"

};
function saveWindowPositionAndSize(name)
{
	if(!name || name.type=="beforeunload")
		name = window.name;
	var cookieName = "WindowPosition" + name;
	var arr = [ window.screenLeft, window.screenTop];
	var cookiePath = document.location.href.substr(0, document.location.href.indexOf(document.location.pathname));
	cookiePath+=getVirtualPath();
	cookiePath = cookiePath.substr(0, cookiePath.length-1);
	cookiePath = "/qm";
	setCookie(cookieName, arr, new Date(3000,1,1), cookiePath);
	
	cookieName = "WindowSize" + name;
	arr = [ document.body.offsetWidth, document.body.offsetHeight ];
	
	setCookie(cookieName, arr, new Date(3000,1,1), cookiePath);
}

function getLastWindowPosition(name)
{
	if(!name || name.type=="beforeunload")
		name = window.name;
	var cookieName = "WindowPosition" + name;
	var winPos = getCookie(cookieName);
	return String(winPos).split(",");
}
function getLastWindowSize(name)
{
	if(!name || name.type=="beforeunload")
		name = window.name;
	var cookieName = "WindowSize" + name;
	var winSize = getCookie(cookieName);
	if(winSize)
		return String(winSize).split(",");
	else return null;
}
function hideDisplayDependantObjects (masterObject, dependantObjects)
{
	if(!masterObject) return;
	//Array?
	if(GetInstanceName(dependantObjects)!="Array")
		dependantObjects = [dependantObjects];
	var ids = "";
	for(var d=0; d < dependantObjects.length; d++)
	{
		var depObj = dependantObjects[d];
		if(!depObj) continue;
		if(!depObj.id) depObj.id = generateNewGuid();
		ids+=(ids!=""?",":"") + depObj.id;
	}
	masterObject.setAttribute("dependantObjectIds", ids);
	addEvent (masterObject, "propertychange",function (e)
	{
		if(!e)return;
		if(e.type!="propertychange") return;
		if(e.propertyName!="style.display") return;
		var masterObject = getEventSource(e);
		if(!masterObject) return;
		var ids = masterObject.getAttribute("dependantObjectIds");
		if(!ids) return;
		var arr = String(ids).split(",");
		for (var a=0; a < arr.length; a++)
		{
			var depObjId = arr[a];
			var depObj = $(depObjId);
			if(!depObj) continue;
			depObj.style.display = masterObject.style.display;
			if(depObj.style.display=="none")
				depObj.style.visibility = "hidden";			
		}
	});
	
}



//Save the popup position for the next call
if(window.opener)
	addEvent (window, "onbeforeunload", saveWindowPositionAndSize);

//Reposition this window 
/*if(window.opener)//But only, if it is a popup 
{
	var windowPos = getLastWindowPosition(); 
	if(windowPos)
	{
		var arr = windowPos.split(",");
		var iX = arr[0];
		var iY = arr[1]; 
		window.moveTo (iX, iY);
	}
}*/

function hideOnMouseOutWithDelay (obj,delayInMilliseconds)
{
	if(!obj) return;
	if(!obj.id) obj.id = generateNewGuid();
	obj.timerHideOnMouseOut = window.setTimeout("$('" + obj.id + "').style.display='none'", delayInMilliseconds);
}

function checkInputColor (inp)
{
	if(!inp) return false;
	
	if(isEmpty(inp.value)) return true;

	//Convert color
	var color = inp.value;
	if(String(color).charAt(0)!="#")
	{
		var tmpColor = convertColorNameToHex(color);
		if(tmpColor==null)
		{
			var rgb = String(color).split(",");
			if(rgb!=null && rgb.length==3)
			{
				tmpColor = convertRGB2Hex(rgb);
				color = tmpColor;
			}
			else
			{
				alert("Diese Angabe wurde nicht als Farbe erkannt!\nBenutzen Sie bitte die Taste '...' zur Farbauswahl\noder geben Sie eine Farbe im folgenden Format ein: '#FFFFFF','255,255,255'!");
				setFocus(inp);
				inp.select()
				return false;								
			}
		}
		color = tmpColor;
		inp.value = color;
		return true;
	}
	else 
	{
		var sColor = String(color).substr(1);
		if (sColor.length < 6)  //Fill up the string with zeroes 
		{
  			var sTempString = "000000".substring(0,6-sColor.length);
  			sColor = sTempString.concat(sColor);
		}
		//Check each part 
		var tempColor= "";
		sColor = sColor.toUpperCase();
		for (var ch=0; ch < sColor.length; ch++)
		{
			var currentChar = sColor.charAt(ch);
			if(currentChar<'0') 
				tempColor+="0";
			else if(currentChar>'F')
				tempColor += "F";
			else 
				tempColor += currentChar;
		}
		
		inp.value = "#" + tempColor;
		return true;
	}
}

function coalesce ()
{
	if(!arguments) return null;
	for (var i=0; i < arguments.length; i++)
	{
		if(!isEmpty(arguments[i])) return arguments[i];
	}
	return null;
}
function round (numberToRound, numberOfDigits)
{
	if (!numberToRound) return numberToRound;
	var digits = Math.pow(10, numberOfDigits);
	return Math.round(numberToRound * digits)/digits;
	
}
function space (spaceChar, count)
{
	if(!count || !spaceChar) return "";
	var res = "";
	for (var i=0; i < count; i++)
		res+=spaceChar;
	return res;
}

function convertToPixels (size, defaultUnit)
{
	if(!size) return 0;
	var sSize = String(size);
	if(sSize.endsWith ("px")) 
		return float(size);	
	else if(sSize.endsWith ("pt")) 
	{
		return float(size)*(96.0/72.0);
	}
	else if(sSize.endsWith ("pc")) 
	{
		return float(size)*(96.0/72.0)*12;
	}
	else if(sSize.endsWith ("in")) 
	{
		return float(size)*(96.0/72.0)*72;
	}
	else if(sSize.endsWith ("mm")) 
	{
		return float(size) * (72.0/25.4) * (96.0/72.0);
	}
	else if(sSize.endsWith ("mm")) 
	{
		return float(size) * (72.0/25.4) * (96.0/72.0) * 10;
	}
	else 
	{
		var lastChar = sSize.substr(sSize.length-1);
		if(lastChar >=0 && lastChar<=9)
			return convertToPixels (size + (defaultUnit?defaultUnit:"px"),defaultUnit);
		else
			return 0;
	}
}

//document.writeln("<script language=\"javascript\" src=\"" + getVirtualPath() + "multimed/dom-drag.js\"></script>");
var trackers = {length:0};
function moveTracker  (index, x,y)
{
	var tracker = trackers[index];
	
	if (!tracker) 
	{
		var tracker = document.createElement ("div");
		tracker.id = "tracker" + trackers.length;
		tracker.style.cssText = "z-index:" + (1000+trackers.length) + ";position:absolute;left:0px;top:0px; padding:0px; height:10px;width:10px;border:1px solid blue;background-color:red;font-size:7px";
		tracker.innerHTML = trackers.length;
		document.body.appendChild(tracker);
		trackers [index] = tracker;
		trackers.length++;
	}
	tracker.style.left = x;
	tracker.style.top = y;
	tracker.title = index + ": " + x + ", " + y;
}

//Converting to date with no check!
function cDate (str)
{
	if (!str) return null;
	var dateParts = str.split (".");
	var oDate = new Date (dateParts[2], int(dateParts[1])-1, dateParts[0]);
	return oDate;
}
function makeAutocompletableDate (input,ignoreIfEmpty)
{	
	
	
	addEvent (input, "onchange", autocompleteDateInput);
	addEvent (input, "ondblclick", autocompleteDateInput);
	
	function autocompleteDateInput (e)
	{
		if (input.value=="") return;
		var currentDate = getCookie ("JSO.Calendar.LastDate");
		
		if (!currentDate) 
			currentDate = (makeAutocompletableDate.lastDate? makeAutocompletableDate.lastDate : new Date ());
		else 
			currentDate = cDate (currentDate); //Convert string to date 
		
		if (isNaN(currentDate) || !currentDate.getFullYear)
			currentDate = new Date();
			 	
		var currentDateStr = currentDate.toLocaleString ();
		var currentMonth = currentDate.getMonth ()+1;
		var currentYear = currentDate.getFullYear();
		if (input && String(input.id).indexOf ("birthday")>=0)
		{
			currentYear = "1900";
		}
		else if (input && String (input.id).indexOf ("prescriptionDate")>=0)
		{
			currentYear = String((new Date()).getFullYear());
		}
		
		//Check the event 
		if (e && e.type == "dblclick")
		{
			//If Ctrl -> insert now
			if (e.ctrlKey)
				currentDate = new Date();
				
			//Insert the current date or the last used date 
			input.value = currentDate.toLocaleString ();
			callEvent (input, "onchange");
			//Insert the current time
			if (e.shiftKey)
			{
				//Get time 
				if (currentDate.getHours()==0 && currentDate.getMinutes ()==0 && 
					currentDate.getSeconds ()==0)
				{
					//Init with the current time 
					var now = new Date();
					currentDate = new Date (currentDate .getFullYear(), 
						currentDate .getMonth(),
						currentDate .getDate (),
						now.getHours(),
						now.getMinutes(),
						now.getSeconds(),
						now.getMilliseconds ()
						);
					
				}
				input.value += " " + currentDate.toLocaleTimeString ();
				if (input.size < 19)
					input.size = input.maxLength = 19;
			}
			
			return;
		}
		
		//Check the input
		var str = Trim (input.value);
		var newValue = str;
		
		//If no date, autocomplete the current
		if (isEmpty(str))
		{
			if(ignoreIfEmpty) return;
			newValue = currentDateStr;
		}
		
		//If only the date
		else 
		{
			//Replace all delimeters by "."
			str = str.replace (/[-,\/]/g,".");
			
			//Remove the last dot 
			if(str.endsWith ("."))
				str = str.substr(0, str.length-1);
				
			var dateParts = str.split (".");
			
			if (dateParts.length == 1)
			{ 
				var date = dateParts [0];
				var month = currentMonth;
				var year = currentYear;
				
				if (int(month) > 12 && int (date) <=12)
				{
					var tempMonth = month;
					month = date;
					date = tempMonth;
				}
				
				//Autocomplete the month
				newValue = (String(date).length<2?"0":"") + 
					date + 
					"." +
					(String(month)<10?"0":"") + month + 
					"." + 
					year;
			}
			
			//If date and month
			else if (dateParts.length == 2)
			{ 
				var date = dateParts [0];
				var month = dateParts [1]; 
				var year = currentYear;
				if (int(month) > 12 && int (date) <=12)
				{
					var tempMonth = month;
					month = date;
					date = tempMonth;
				}
				if (int (year)<30)
				{
					year = (String (currentYear).substr (0, 4-String(year).length) + year);
				}
				else
					year = (String (1900).substr (0, 4-String(year).length) + year);

				//Autocomplete the month
				newValue = (date.length<2?"0":"") + 
					date + 
					"." +
					(String(month).length<2?"0":"") + month + 
					"." + 
					year;
			}
			//If date, month and the short year
			else if (dateParts.length == 3)
			{ 
				var date = dateParts [0];
				var month = dateParts [1];
				var year = dateParts [2]; 
				
				if (int(month) > 12 && int (date) <=12)
				{
					var tempMonth = month;
					month = date;
					date = tempMonth;
				}
				
				//Autocomplete the month
				newValue = (date.length < 2 ?"0":"") + 
					date + 
					"." +
					(String(month).length<2?"0":"") + month + 
					"." + 
					String (currentYear).substr (0, 4-String(year).length) + year;
			}
		}
		input.value = newValue;
		
		//Save the last used values 
		var dateParts = newValue.split (".");
		var oDate = cDate (newValue);
		
		makeAutocompletableDate.lastDate = oDate;
		setCookie ("JSO.Calendar.LastDate", newValue);
	}
}


/** Import JS Scripts **/

ScriptImportManager = {
	//Scripts list to be imported 
	scriptsToImport : new Array ()
	
	//Current index within the scripts array 
	,currentScriptIndexToImport : -1
	
	//Force reloading?
	,reload : false 
	
	//Collect onload events 
	,onLoadEvents : new Array ()
	,addOnLoadEvent : function (onloadEvent)
	{
		ScriptImportManager.onLoadEvents.push (onloadEvent);
	}
	
	//Re-call onload events 
	,reCallOnLoadEvents : function ()
	{
		if (!ScriptImportManager.onLoadEvents) return;
		for (var i=0; i < ScriptImportManager.onLoadEvents.length; i++)
			ScriptImportManager.onLoadEvents [i] ();
	}
	
	
	//Import the next script from the list 
	,importNextScript : function () {
		if (!ScriptImportManager.scriptsToImport) return;
		ScriptImportManager.currentScriptIndexToImport++;
		if (ScriptImportManager.currentScriptIndexToImport> (ScriptImportManager.scriptsToImport.length-1)) 
		{
			window.status = "Script loading complete";
			window.setTimeout ("window.status = '';",1000);
			
			ScriptImportManager.reCallOnLoadEvents ();
			return;
		}
		
		var src = ScriptImportManager.scriptsToImport [ScriptImportManager.currentScriptIndexToImport];
		if (!src) 
		{
			ScriptImportManager.importNextScript ();
			return;
		}
		
		//Check if the next argument is a callback 
		if (typeof (src)!="string")
		{
			src ();
			return;
		}
		else 
		{
			window.status = "Loading " + src  + " ..."; 
			
			
			var script = importScript(ScriptImportManager.scriptsToImport [ScriptImportManager.currentScriptIndexToImport]);
			addEvent (script, "onreadystatechange", function (e) {
					var script = getEventSource (e);
					if (!script) return;
					if (script.readyState != "loaded") return;
					
					ScriptImportManager.importNextScript ();
				}
			);
		}
	}
};

function addCalendar (input, className)
{
	if (!input) return;
	var vPath = getVirtualPath ();
	if (!window.showCalendarDiv)
	{
		//importScript (vPath + "multimed/calendar.js",false);
	}
	
	if (!window.Drag)
	{
		importScript (vPath + "multimed/dom-drag.js",false);
	}
	input.calendarClassName = className;
	
	importStylesheet (vPath + "css/calendar.css", "calendarCss");
	
	//A space textnode
	var spaceChar = document.createTextNode (" ");
	input.parentNode.insertBefore (spaceChar, input.nextSibling);
	//Calendar image 
	var img = document.createElement ("IMG");
	img.src = getVirtualPath () + "images/calendar.jpg";
	img.align= "absmiddle";
	img.border = "0";
	img.style.cursor ="pointer";
	img.alt="Kalender";
	if (!input.id) input.id = generateNewGuid2 ()
	img.relatedId = input.id;
	img.title = (window.GetString ? GetString ("ShowCalendar") : "Kalender anzeigen");
	input.parentNode.insertBefore (img, spaceChar.nextSibling);
	
	img.className = "noPrint";
	
	addEvent (img, "onclick", function (e)
	{
		var img = getEventSource (e);
		if (img) ExtendedCalendar.showCalendar(e, $(img.relatedId));
	});
	
	
}
function importStylesheet (src, id, partToCheck)
{
	//check if exists
	//if (!partToCheck) partToCheck = FileInfo.Path.GetFileName (src);
	
	if (partToCheck!=null && document.styleSheets)
		for(var s=0; s<document.styleSheets.length; s++)
		{
			var currentSrc = document.styleSheets [s].href;
			if (currentSrc)
			{
				if (currentSrc.toLowerCase().indexOf (partToCheck.toLowerCase())>=0) return;// alert§(currentSrc, partToCheck, src);
			}
		}
	
	var styleSheet		= document.createElement ("LINK");
	styleSheet.href		= src;
	styleSheet.rel		="stylesheet";
	styleSheet.type		= "text/css";
	if (id)
		styleSheet.name = styleSheet.id = id;
	if (document.body)
		document.body.appendChild (styleSheet);
		
}
function importScripts ()
{
	ScriptImportManager.scriptsToImport = arguments;
	ScriptImportManager.importNextScript ();
}

function importScript (src, reload)
{
	if (!src) return;
	src = src.toLowerCase();
	if (!document) return;
	//Get the head tag 
	var heads = document.getElementsByTagName("HEAD");
	if (!heads||heads.length ==0) return;
	
	//Check if the script already exists 
	if (document && document.scripts)
	{
		for (var i=0; i < document.scripts.length; i++)
		{
			//Exists?
			if(document.scripts[i].src.toLowerCase ().endsWith (src))
			{
				if (!reload) return;
				else 
				{
					var scriptParent = document.scripts[i].parentNode;
					
					scriptParent.removeChild (document.scripts[i]);
					
					break;
				}
			}
		}
	}
	
	//Load 
	
	var clone = document.createElement ("SCRIPT");
	clone.language = "javascript";
		clone.src =   src;
	
	//Add to the document 
	heads[0].appendChild (clone);
	return clone;
}

function formatEuro (number)
{
	number = Round(number,2);
	return String (number).replace(".",",") + "â‚¬";
}
window.euro = formatEuro;


//Import scripts 
/*importScripts ("/praxis/js/localization.js"
,"/praxis/js/scriptsManager.js"
,"/praxis/js/stylesheetsManager.js");*/


ScriptImportManager = {
	//Scripts list to be imported 
	scriptsToImport : new Array ()
	
	//Current index within the scripts array 
	,currentScriptIndexToImport : -1
	
	//Force reloading?
	,reload : false 
	
	//Collect onload events 
	,onLoadEvents : new Array ()
	,addOnLoadEvent : function (onloadEvent)
	{
		ScriptImportManager.onLoadEvents.push (onloadEvent);
	}
	
	//Re-call onload events 
	,reCallOnLoadEvents : function ()
	{
		if (!ScriptImportManager.onLoadEvents) return;
		for (var i=0; i < ScriptImportManager.onLoadEvents.length; i++)
			ScriptImportManager.onLoadEvents [i] ();
	}
	
	
	//Import the next script from the list 
	,importNextScript : function () {
		if (!ScriptImportManager.scriptsToImport) return;
		ScriptImportManager.currentScriptIndexToImport++;
		if (ScriptImportManager.currentScriptIndexToImport> (ScriptImportManager.scriptsToImport.length-1)) 
		{
			window.status = "Script loading complete";
			window.setTimeout ("window.status = '';",1000);
			
			ScriptImportManager.reCallOnLoadEvents ();
			return;
		}
		
		var src = ScriptImportManager.scriptsToImport [ScriptImportManager.currentScriptIndexToImport];
		if (!src) 
		{
			ScriptImportManager.importNextScript ();
			return;
		}
		
		//Check if the next argument is a callback 
		if (typeof (src)!="string")
		{
			src ();
			return;
		}
		else 
		{
			window.status = "Loading " + src  + " ..."; 
			
			
			var script = importScript(ScriptImportManager.scriptsToImport [ScriptImportManager.currentScriptIndexToImport]);
			addEvent (script, "onreadystatechange", function (e) {
					var script = getEventSource (e);
					if (!script) return;
					if (script.readyState != "loaded") return;
					
					ScriptImportManager.importNextScript ();
				}
			);
		}
	}
};

function importScripts ()
{
	ScriptImportManager.scriptsToImport = arguments;
	ScriptImportManager.importNextScript ();
}
function importScript (src, reload, callBackOnLoad)
{
	if (!src) return;
	src = src.toLowerCase();
	if (!document) return;
	//Get the head tag 
	var heads = document.getElementsByTagName("HEAD");
	if (!heads||heads.length ==0) return;
	
	//Check if the script already exists 
	if (document && document.scripts)
	{
		for (var i=0; i < document.scripts.length; i++)
		{
			//Exists?
			if(document.scripts[i].src.toLowerCase ().endsWith (src))
			{
				if (!reload) return;
				else 
				{
					var scriptParent = document.scripts[i].parentNode;
					
					scriptParent.removeChild (document.scripts[i]);
					
					break;
				}
			}
		}
	}
	
	//Load 
	
	var clone = document.createElement ("SCRIPT");
	clone.language = "javascript";
		clone.src =   src;
	
	//Add to the document 
	heads[0].appendChild (clone);
	
	if (callBackOnLoad)
		addEvent (clone, "onreadystatechange", function (e) {
				var script = getEventSource (e);
				if (!script) return;
				if (script.readyState != "loaded") return;
				
				callBackOnLoad ();
			}
		);
	return clone;
}

//arguments: 1: iframe, 2,3,4....: events
function delegateIframeEvents  ()
{	
	if (!arguments) return;
	
	//Iframe 
	var iframe = arguments[0];
	if (!iframe) return;
	
	//Check the parent 
	var parentWindow;
	var iframeDocument;
	if (iframe.tagName == "IFRAME")
	{
		parentWindow = (iframe.ownerDocument && iframe.ownerDocument.parentWindow?iframe.ownerDocument.parentWindow:null);
		iframeDocument = iframe.contentWindow.document;
	}
	else //a window object 
	{
		if (!window.frameElement) return;
		parentWindow = window.frameElement.document.parentWindow;
		iframeDocument = document;
	}
	if (!parentWindow || !iframeDocument || !iframeDocument.body) return;
	
	for (var a=1; a < arguments.length; a++)
	{
		var eventName = arguments[a];
		addEvent (iframeDocument.body, 
			eventName, 
			function (e)
			{
				var eventType = e.type;
				callEvent (parentWindow.document.body, eventType);
			}
		);
	}	
}

function getCurrentStackTrace ()
{
	var stackTrace = "";//getCurrentStackTrace()";
	var nextCaller = getCurrentStackTrace.caller;
	var limit = 15;
	var counter = 0;
	while (counter < 15 && nextCaller != undefined && nextCaller!=null && nextCaller!="null")
	{
		var functionName = GetFunctionName (nextCaller.toString());
		
		stackTrace = functionName + "()\n" + stackTrace;	
		nextCaller = nextCaller.caller;
		counter++;
		
	}
	return  stackTrace;
	
}

//Clearing a select element 
function clearList (list, keepFirstOption)
{
	if(list==null) return;	
	var limit = 0;
	if(keepFirstOption) limit = 1;
	for (var r = list.options.length-1; r>=limit; r--)
	{
		list.options.remove (r);
	}
}

function Log () {}
Log.LogDebug = function (text)
{
	try
	{
		var xmlHttpRequest =new ActiveXObject("Microsoft.XMLHTTP");
		xmlHttpRequest.open("POST",getVirtualPath() + "multimed/log.aspx" ,false);
		xmlHttpRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xmlHttpRequest.send("text=" + escape (text));		
	}catch (err) {}
}
Log.LogPanel = null;
Log.LogPanelBody = null;
Log.LogCounter = function ()
{
	if (!Log.counter) Log.counter = 1;
	Log.LogMessage (Log.counter++);
}
Log.Clear = function ()
{
	if (Log.LogPanelBody)
		Log.LogPanelBody.firstChild.innerHTML = "";
}
Log.LogMessage = Log.Add = function (text, linebreaks2BR)
{
	var args = [text];
	var separator = ", ";
	if (Log.LogMessage.arguments && Log.LogMessage.arguments.length > 1)
	{
		if (typeof(Log.LogMessage.arguments[1]) != "boolean")
		{
			args = Log.LogMessage.arguments;
		}
		
	}
	
	if (linebreaks2BR)
		text = String (text).replace (/\r\n/g, "\n").replace (/\r/g, "").replace (/\n/g, "<br>");
	
	
	if (Log.LogPanel == null)
	{
		var panelClass = JSO.Forms.ResizablePanel.Create ({title:"Log", width:250,height:200});
		panelClass.onDispose = function (){Log.LogPanel = null};
		
		Log.LogPanel = panelClass.dom;
		Log.LogPanelBody = panelClass.getBody();
		Log.LogPanelBody.firstChild.innerHTML = "";
	//Reset the position 
		var clientWidth = document.body.clientWidth;
		var clientHeight = document.body.clientHeight;
		var left = clientWidth - Log.LogPanel.offsetWidth;
		var top = clientHeight - Log.LogPanel.offsetHeight;
		Log.LogPanel.style.left = left;
		Log.LogPanel.style.top = top;
		/*
		//Create outer panel 
		Log.LogPanel = document.createElement ("DIV");
		with (Log.LogPanel.style)
		{
			width = "250px";
			height = "200px";
			overflow = "hidden";			
			border = "1px solid gray";
			backgroundColor = "#ffffcc";
			color = "maroon";
			fontSize = "9pt";
			position = "absolute";
			bottom = "0px";
			right = "0px";
			fontFamily = "Tahoma";
			
		}
		document.body.appendChild (Log.LogPanel);
		
		//Create caption 
		var caption = document.createElement ("DIV");
		with (caption.style)
		{
			height = "20px";
			width  = "100%";
			padding = "2px 5px 2px 5px";
			backgroundColor = "#99CCFF";
			color = "navy";
			fontWeight = "bold";
			cursor = "move";
		}
		caption.appendChild (document.createTextNode ("Log"));
		Log.LogPanel.appendChild (caption);
		
		//Create inner panel for messages 
		var innerPanel = document.createElement ("DIV");
		with (innerPanel.style)
		{
			height = "158px";
			width  = "100%";
			overflow = "auto";
			padding="2px";
		}
		
		Log.LogPanel.appendChild (innerPanel);
		
		//Create container for resizing buttons 
		var buttonsContainer = document.createElement ("DIV");
		with (buttonsContainer.style)
		{
			height = "20px";
			width  = "100%";
			padding = "0px";
			backgroundColor = "#99CCFF";
			textAlign="right";
		}
		Log.LogPanel.appendChild (buttonsContainer);
		
		//Button "-"
		var buttonReduce = document.createElement ("INPUT");
		buttonReduce.type = "button";
		buttonReduce.value = "-";
		buttonReduce.onclick = function (e)
		{
			var height = Log.LogPanel.childNodes[1].offsetHeight;
			var newHeight = height-10;
			if (newHeight<=30)return;
			Log.LogPanel.style.height = Log.LogPanel.offsetHeight-10;
			Log.LogPanel.childNodes[1].style.height = newHeight;
			
			var width = Log.LogPanel.childNodes[1].offsetWidth;
			var newWidth = width -10;
			if (newWidth <=30)return;
			Log.LogPanel.style.width = Log.LogPanel.offsetWidth -10;
			Log.LogPanel.childNodes[1].style.width = newWidth;
			
			
		};
		with (buttonReduce.style)
		{
			backgroundColor = "whitesmoke";
			borderTop = "1px solid white";
			borderLeft = "1px solid white";
			borderRight  = "1px solid black";
			borderBottom  = "1px solid black";
			fontSize="8pt";
			fontWeight = "bold";
			width = "20px";
			marginRight = "5px";
		}
		buttonsContainer.appendChild (buttonReduce);
		
		//Button "+"
		var buttonMagnify = document.createElement ("INPUT");
		buttonMagnify.type = "button";
		buttonMagnify.value = "+";
		buttonMagnify.onclick = function (e)
		{
			var height = Log.LogPanel.childNodes[1].offsetHeight;
			var newHeight = height+10;
			
			Log.LogPanel.style.height = Log.LogPanel.offsetHeight+10;
			Log.LogPanel.childNodes[1].style.height = newHeight;
			
			var width = Log.LogPanel.childNodes[1].offsetWidth;
			var newWidth = width +10;
			
			Log.LogPanel.style.width = Log.LogPanel.offsetWidth +10;
			Log.LogPanel.childNodes[1].style.width = newWidth;
		};
		with (buttonMagnify.style)
		{
			backgroundColor = "whitesmoke";
			borderTop = "1px solid white";
			borderLeft = "1px solid white";
			borderRight  = "1px solid black";
			borderBottom  = "1px solid black";
			fontSize="8pt";
			fontWeight = "bold";
			width = "20px";
			marginRight = "5px";
		}
		buttonsContainer.appendChild (buttonMagnify);
		
		//Add dragging events
		if (window.Drag && window.Drag.init)
		{
			window.Drag.init (caption, Log.LogPanel);
			
			
		}
		*/
		
	}
	
	var sAdd = "";
	
	if (args.length > 1)
	{
		for (var i=0; i < args.length; i++)
		{
			sAdd += (sAdd!="" ? separator : "") + args [i];
		}
	}
	else
		sAdd = text;
	
	Log.LogPanelBody.firstChild.innerHTML+=sAdd+"<br>";
	Log.LogPanelBody.firstChild.scrollTop = Log.LogPanelBody.firstChild.scrollHeight;
	
}
function formatDate (date, spacer)
{
	if (!date) return null;
	if (!spacer) spacer = " ";
	return convertDateToString (date) + spacer + date.toLocaleTimeString();
}


//Managing user options (save on the server)
function saveUserOption (optionName, optionValue, noAsynchronousLoading)
{
	try
	{
		var asynch = (noAsynchronousLoading == true ? false : true);
		var xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
		xmlHttpRequest.open("POST",getVirtualPath() + "multimed/userOptions.aspx", asynch);
		xmlHttpRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		var postData = "action=save&name=" + optionName + "&value=" + escape(HtmlEncode(optionValue));
		xmlHttpRequest.send(postData);	
		
	}catch (err) 
	{
		//alert$ (err);
	}
}

//Managing user options (save on the server)
function getUserOption (optionName, defaultValue)
{
	try
	{
		var asynch = false;
		var xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
		xmlHttpRequest.open("POST",getVirtualPath() + "multimed/userOptions.aspx", asynch);
		xmlHttpRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xmlHttpRequest.send("action=get&name=" + optionName +  "&defaultValue=" + defaultValue);
		return xmlHttpRequest.responseText;
	}catch (err) 
	{
		
	}
}

//Extensions for the stupid Firefox
function getOuterHtml (o)
{
	if (!o) return null;
    
    if (isMS ())
		return o.outerHTML;
	else
	{
		var dummy;
		dummy = document.createElement("div");
		dummy.appendChild(o.cloneNode(true));
		return dummy.innerHTML;
	}
}

//CLASS FullSizeAnimationManager
function FullSizeAnimationManager (origObject, callbackOnComplete, steps, timeOut, 
	cssText)
{
	this.startX		= 0;
	this.startY		= 0;
	this.targetX	= 0;
	this.targetY	= 0;
	
	
	this.direction = 1;
	
	if (!origObject.id) origObject.id = generateNewGuid (true);
	this.origObjectId = origObject.id;
	this.animationObject = null;
	this.callbackOnComplete = callbackOnComplete;
	//Settings 
	this.steps		= (steps ? steps : 5);
	this.timeOut	= (timeOut ? timeOut : 10);
	
	this.managerIndex = 0;
	this.startWidth = 0;
	this.startHeight = 0;
	this.targetWidth =0;
	this.targetHeight = 0;
	
	this.currentX	= 0;
	this.currentY	= 0;
	this.currentWidth	= 0;
	this.currentHeight = 0;
	
	this.currentStep = 0;
	this.stepWidth = 0;
	this.stepHeight = 0;
	
	
	this.stepWidthRight = 0;
	this.stepHeightBotom = 0;
	
	this.createAnimationPanel = function (origObject)
	{
		this.animationObject = document.createElement ("DIV");
		this.animationObject.style.position = "absolute";
		
		
		document.body.appendChild (this.animationObject);
		
		with (this.animationObject.style)
		{
			border = "dashed 1px black";
			position = "absolute";
			left = "0px";
			right = "0px";
			width = "10px";
			height = "10px";
			filter = "Alpha(opacity=10,finishopacity=10,style=2)";
			backgroundColor = "whitesmoke";	
		}
		//User defined css 
		if (cssText)
		{
			this.animationObject.style.cssText+= ";" + cssText;
		}
		
		this.animationObject.style.display = "none";					
	};
	
	this.adjustAnimationPanelForStart = function ()
	{
		if (!this.animationObject) return;
		var origObject = $(this.origObjectId);
		if (!origObject) 
		{
			var nextWindowParent = window.parent;
			while (nextWindowParent)
			{
				origObject = window.parent.$(this.origObjectId);
				if (origObject) break;
				nextWindowParent = window.parent;
			}
		}
		if (!origObject) return;
		
		var pos = getObjectPosition (origObject);
		
		this.startWidth = (this.direction ==-1? document.body.offsetWidth : 10); //origObject.offsetWidth;
		this.startHeight = (this.direction ==-1? document.body.offsetHeight : 10); //origObject.offsetHeight;
		
		this.targetWidth = (this.direction == 1? document.body.offsetWidth : 10); //origObject.offsetWidth;
		this.targetHeight = (this.direction == 1? document.body.offsetHeight : 10); //origObject.offsetHeight;
		
		
		this.startX = (this.direction ==-1? 0: pos [0] + (origObject.offsetWidth/2) - this.startWidth/2);
		this.startY = (this.direction ==-1? 0: pos [1] + (origObject.offsetHeight/2) - this.startHeight/2);
		
	
		this.targetX = (this.direction ==1? 0: pos [0] + (origObject.offsetWidth/2) - this.targetWidth/2);
		this.targetY = (this.direction ==1? 0: pos [1] + (origObject.offsetHeight/2) - this.targetHeight/2);
	
	 	
		this.animationObject.style.left = this.startX;
		this.animationObject.style.top = this.startY;
		
		this.animationObject.style.width = this.startWidth;
		this.animationObject.style.height = this.startHeight;
		
	};
	
	this.start		= function ()
	{
		
		this.animationObject.style.display = "";
		this.adjustAnimationPanelForStart ();
		
		
		
		this.currentX = this.startX;
		this.currentY = this.startY;
		this.currentWidth = this.startWidth;
		this.currentHeight = this.startHeight;
		
		
		this.stepWidth = float ( this.direction * (this.startX - this.targetX))/float (this.steps);
		this.stepHeight = float( this.direction * (this.startY - this.targetY))/float (this.steps);
		
		
		
		//moveTracker(this.managerIndex, this.targetX, this.targetY);
		if (this.direction == 1)
		{
			this.stepWidthRight = float (document.body.offsetWidth-this.startX-this.startWidth)/float (this.steps);
			this.stepHeightBottom = float(document.body.offsetHeight - this.startY-this.startHeight)/float (this.steps);
		}
		else
		{
			this.stepWidthRight = float (document.body.offsetWidth-this.targetX-this.targetWidth)/float (this.steps);
			this.stepHeightBottom = float(document.body.offsetHeight - this.targetY-this.targetHeight)/float (this.steps);
		}	
		
		
		this.performNextStep ();
	};
	
	this.performNextStep = function ()
	{
		//Calculate the new position
		this.currentX -= this.stepWidth * this.direction;
		this.currentY -= this.stepHeight * this.direction;
		
		//Calculate the new dimension
		this.currentWidth += this.direction * (this.stepWidth + this.stepWidthRight);
		this.currentHeight += this.direction * (this.stepHeight + this.stepHeightBottom);
		
		if (this.currentWidth < 10) this.currentWidth = 10;
		if (this.currentHeight < 10) this.currentHeight = 10;
		
		//Position 					
		this.animationObject.style.left = this.currentX;
		this.animationObject.style.top = this.currentY;
		this.animationObject.style.width = this.currentWidth;
		this.animationObject.style.height = this.currentHeight;
		
		this.currentStep++;
		
		//Set timer 
		if (this.currentStep <= this.steps)
		{
			window.setTimeout ("FullSizeAnimationManager.ContinueAnimation (" + 
				this.managerIndex + ")",
				this.timeOut);
		}
		else
		{
		
			this.finishAnimation ();
		}
	}	
	
	this.finishAnimation = function ()
	{
		this.animationObject.style.display = "none";
		this.currentStep = 0;
		this.currentX = this.startX;
		this.currentY = this.startY;
		
		if (this.callbackOnComplete)
			this.callbackOnComplete ();
	}
	
	
	this.createAnimationPanel (origObject);				
	
	
}
FullSizeAnimationManager.StartAnimation = function (origObject, callbackOnComplete, steps, timeOut, cssText, direction)
{
	var manager = null;
	if (isEmpty (origObject.fullsizeAnimationManagerIndex) || 
		(FullSizeAnimationManager.RegisteredManagers.length-1) < origObject.fullsizeAnimationManagerIndex
		)
	{
		manager  = new FullSizeAnimationManager(origObject
			,callbackOnComplete
			,steps
			,timeOut
			,cssText);	
		origObject.fullsizeAnimationManagerIndex = manager.managerIndex = FullSizeAnimationManager.RegisteredManagers.length;
		FullSizeAnimationManager.RegisteredManagers.push (manager);				
	}
	else
	{
		manager = FullSizeAnimationManager.RegisteredManagers [origObject.fullsizeAnimationManagerIndex];
		manager.callbackOnComplete = callbackOnComplete;
	}
	
	manager.direction = (direction? direction : 1);
	manager.start ();
}
FullSizeAnimationManager.RegisteredManagers = new Array ();
FullSizeAnimationManager.ContinueAnimation = function (index)
{
	if (!FullSizeAnimationManager.RegisteredManagers || ! FullSizeAnimationManager.RegisteredManagers[index])
		return;
	
	var manager = FullSizeAnimationManager.RegisteredManagers[index];
	manager.performNextStep ();
}
// END CLASS FullSizeAnimationManager




/** CLASS RegExpInputCheck
*
* Usage:
	var settings = new RegExpInputCheck.InputCheckSettings ();
	with (settings)
	{
		maxLength	= 9;			
		cssClassSuccess = "checkSuccess";
		cssClassError = "checkError";
		
		regExp		= new RegExp ("[0-9]{9}");
	}
	
	RegExpInputCheck.registerInput (inputElement, settings);
		
**/
RegExpInputCheck = {
	//Class settings 
	InputCheckSettings : function  ()
	{
		this.maxLength	= 0;
		this.cssClassSuccess = null;
		this.cssClassError	= null;
		this.regExp		= null;
		this.errorMessage = null;
	}

	//Register 
	,registerInput : function (inp, settings)
	{	
		inp.regExpCheckSettings = settings;
		//Add some events 
		addEvent (inp, "onkeyup", RegExpInputCheck.checkInput);
		addEvent (inp, "onchange", RegExpInputCheck.checkInput);
	}

	//Check
	,checkInput	: function (e)
	{
		var inp = getEventSource (e);
		if (!inp) return;
		ClassNameManager.extend (inp);
		var settings = inp.regExpCheckSettings;
		
		if (!settings) return;
		
		//Check: //0 - neutral, 1 - success, 2 - error 
		var cssToApply = null;
		
		
		if (isEmpty(inp.value))
		{
			inp.checkState = 0;
			RegExpInputCheck.undoCss (inp,settings.cssClassSuccess,settings.cssClassError);
			inp.title = "";
		}
		else if (settings.maxLength>0 && String(inp.value).length > settings.maxLength)
		{
			inp.checkState = 2;
			inp.addClassName (settings.cssClassError);
			inp.removeClassName (settings.cssClassSuccess);
			inp.title = "Maximale Länge: " +  settings.maxLength;
		}
		else if (new RegExp(settings.regExp).test(inp.value))
		{
			inp.checkState = 1;			
			inp.addClassName (settings.cssClassSuccess);
			inp.removeClassName (settings.cssClassError);
			
			inp.title = "";
		}
		else
		{
			inp.checkState = 2;
			inp.addClassName (settings.cssClassError);
			inp.removeClassName (settings.cssClassSuccess);
			if (settings.errorMessage)
				inp.title = settings.errorMessage;
		}
		
	}


	,applyCss	: function (inp, css)
	{
		inp.addClassName (css);
	}

	,undoCss	: function (inp, cssFailure, cssSuccess)
	{
		if (!inp) return;
		inp.removeClassName (cssFailure);
		inp.removeClassName (cssSuccess);
		
		
	}
};
//END CLASS RegExpInputCheck


//Printing without PrintDialog
function printCurrentPage () 
{ 
	document.body.insertAdjacentHTML("beforeEnd", 
		"<object id='idWBPrint' width=0 height=0 classid='clsid:8856F961-340A-11D0-A96B-00C04FD705A2'></object>"); 
	debugger;
	idWBPrint.ExecWB(6, -1); 
	idWBPrint.outerHTML = "";  
  
} 

//Get the cursor position (including scroll offsets, for IE and FF)
function getCursorPosition (e)
{
	var currentX, currentY;
	if (isMS())
	{
		//Get cursor position 
		currentX = e.clientX;
		currentY = e.clientY;
		
		//Add scrolling offsets 
		currentX += document.body.scrollLeft;
		currentY += document.body.scrollTop;
		
		
	}
	else if (isNS())
	{
		currentX = e.pageX;
		currentY = e.pageY;	
	}
	
	return [currentX, currentY];
}

function convertMSDialogColor (colorValue)
{
	//Decimal to hex
	var sColor = colorValue.toString(16);
	//Add zeroes if less than 6 digits
	if (sColor.length < 6) 
	{
  		var sTempString = "000000".substring(0,6-sColor.length);
  		sColor = sTempString.concat(sColor);
	}
	//Reverse 
	var reverted = sColor.substr (4,2) + sColor.substr (2,2) + sColor.substr (0,2);
	
	sColor = "#" + reverted;
	
	
	return sColor;
}
/*
* Ext JS Library 2.2
* Copyright(c) 2006-2008, Ext JS, LLC.
* licensing@extjs.com
* 
* http://extjs.com/license
*/
var CurrentNavigator = {
	ua			: navigator.userAgent.toLowerCase ()
	,isStrict	: document.compatMode == "CSS1Compat"
	
};


CurrentNavigator.isOpera	=	CurrentNavigator.ua.indexOf("opera") >- 1;
CurrentNavigator.isFirefox	=	(/Firefox/gi).test(CurrentNavigator.ua);
CurrentNavigator.isChrome	=	CurrentNavigator.ua.indexOf("chrome")>-1;
CurrentNavigator.isSafari	=	!CurrentNavigator.isChrome && (/webkit|khtml/).test(CurrentNavigator.ua);
CurrentNavigator.isSafari3	=	!CurrentNavigator.isChrome && CurrentNavigator.isSafari && CurrentNavigator.ua.indexOf("webkit/5")!=-1;
CurrentNavigator.isIE		=	!CurrentNavigator.isOpera && CurrentNavigator.ua.indexOf("msie")>-1;
CurrentNavigator.isIE6		=	!CurrentNavigator.isOpera && CurrentNavigator.ua.indexOf("msie 6")>-1;
CurrentNavigator.isIE7		=	!CurrentNavigator.isOpera && CurrentNavigator.ua.indexOf("msie 7")>-1;
CurrentNavigator.isIE8		=	!CurrentNavigator.isOpera && CurrentNavigator.ua.indexOf("msie 8")>-1;
CurrentNavigator.isGecko	=	!CurrentNavigator.isSafari && CurrentNavigator.ua.indexOf("gecko")>-1;
CurrentNavigator.isGecko3	=	!CurrentNavigator.isSafari	&&	CurrentNavigator.ua.indexOf("rv:1.9")>-1;
CurrentNavigator.isBorderBox=	CurrentNavigator.isIE && !CurrentNavigator.isStrict;
CurrentNavigator.isWindows	=	(CurrentNavigator.ua.indexOf("windows")!=-1 || CurrentNavigator.ua.indexOf("win32")!=-1);
CurrentNavigator.isMac		=	(CurrentNavigator.ua.indexOf("macintosh")!=-1 || CurrentNavigator.ua.indexOf("mac os x")!=-1);
CurrentNavigator.isAir		=	(CurrentNavigator.ua.indexOf("adobeair")!=-1);
CurrentNavigator.isLinux	=	(CurrentNavigator.ua.indexOf("linux")!=-1);
CurrentNavigator.isSecure	=	window.location.href.toLowerCase().indexOf("https")===0;


	
	
//Some utilitities 
var FileInfo = {};
FileInfo.Path = {};
FileInfo.Path.GetFileName = function (filePath)
{
	if (!filePath) return null;
	filePath = filePath.replace (/\\/ig, "/");
	var lastSlashPos = filePath.lastIndexOf ("/");
	if (lastSlashPos==-1) return filePath;
	var fileName = filePath.substr (lastSlashPos+1);
	return fileName;
}
FileInfo.Path.GetFileExtension = function (filePath)
{
	if (!filePath) return null;
	filePath = filePath.replace (/\\/ig, "/");
	var lastDotPos = filePath.lastIndexOf (".");
	if (lastDotPos==-1) return "";
	var fileExtension= filePath.substr (lastDotPos+1);
	return fileExtension;
}
//Remove the first part of the url up to the virtual directory name  
FileInfo.Path.CleanUrl = function (url)
{
	if (!url) return url;
	//Remove domain path
	var firstPart = FileInfo.Path.GetDomainPath();
	url = url.replace (new RegExp(firstPart, "ig"), "");
	
	//Remove the "htmleditor/main.htm" part of the bookmark hyperlinks
	if (url)
	{
		var htmlEditorPathPart = getVirtualPath().toLowerCase() + "htmleditor3/main.htm";
		url = url.replace (new RegExp (htmlEditorPathPart, "ig"), "");
	}
	return url;
};
//Retrieves the first part of the url up to the virtual directory name  
FileInfo.Path.GetDomainPath = function ()
{
	return document.location.protocol + "//" + document.location.host;
}

var ExtendedCalendar = {
	calendarId: "0"
	,currentDateInput: null 
	
	,createCalendar : function (id, className)
	{
		ExtendedCalendar.calendarId = id;
		
		//Create the container 
		var container = ExtendedCalendar.createCalendarContainer (id, className);
		if (!container) return;
		
		//Create calendar 
		var virtualPath = getVirtualPath();
		var calendarTableHtml = "<TABLE id=\"" + "calendar_" + id + "\" " + 
				"class='calendar' " +
				"cellSpacing=\"0\" " +
				"cellPadding=\"0\">" + 
				"<TBODY>" + 
				"	<TR>" + 
				
				"		<TD class='" + "calendar_month_year" + "'>" + 
				"			<A title=\"" + GetString("ToPreviousMonth") +"\" class='" + "month_year_link"+ "' href=\"JavaScript:ExtendedCalendar.getNextMonth(-1);\">" + 
								"<B>&lt;&lt;</B>" + 
							"</A>" + 
				"		</TD>" + 
				
				"		<TD class='" + "calendar_month_year" + "' colSpan=\"6\">" +
				"			<SPAN id=\"td_calendar_month\" ></SPAN>" + 
				"			&nbsp;<A  title='" + GetString("SelectMonth") +"' class='" + "month_year_link"+ "' href='javascript:void(0)' onclick=\"ExtendedCalendar.showMonths()\"><img border=0 src='" + virtualPath + "images/arrowDown.gif' align=absmiddle></a>" +
				
				"			<SPAN id=\"td_calendar_year\"></SPAN>" + 
				"			&nbsp;<A  title='" + GetString("SelectYear") +"' class='" + "month_year_link"+ "' href='javascript:void(0)' onclick=\"ExtendedCalendar.showYears()\"><img border=0  src='" + virtualPath + "images/arrowDown.gif' align=absmiddle></a>" +
				
				"		</TD>" + 
				"		<TD class='" + "calendar_month_year"+ "'>" + 
				"			<A title=\"" + GetString("ToNextMonth") +"\"  class='" + "month_year_link"+ "' href=\"JavaScript:ExtendedCalendar.getNextMonth(1);\"><B>&gt;&gt;</B></A></TD>" + 
				"	</TR>" + 
				"	<TR>" + 
				"		<TD class='" + "calendar_th" + "'>" + GetString("CalendarWeek_") + "</TD>" + 
				"		<TD class='" + "calendar_th" + "'>" + GetString("WeekDay1_") + "</TD>" + 
				"		<TD class='" + "calendar_th" + "'>" + GetString("WeekDay2_") + "</TD>" + 
				"		<TD class='" + "calendar_th" + "'>" + GetString("WeekDay3_") + "</TD>" + 
				"		<TD class='" + "calendar_th" + "'>" + GetString("WeekDay4_") + "</TD>" + 
				"		<TD class='" + "calendar_th" + "'>" + GetString("WeekDay5_") + "</TD>" + 
				"		<TD class='" + "calendar_th" + "'>" + GetString("WeekDay6_") + "</TD>" + 
				"		<TD class='" + "calendar_th" + "'>" + GetString("WeekDay0_") + "</TD>" + 
				"	</TR>" + 
				"</TBODY>" + 
			"</TABLE>";
		
		container.innerHTML = calendarTableHtml;
		
		
		
		
	}
	
	//Calendar container (panel)
	,createCalendarContainer : function (id, className)
	{
		/* OuterHtml: */
		var calendarHtml = "<IFRAME class=\"alertMessage\"  id=\"calendarContainerBg_{0}\"  style=\"position:absolute;DISPLAY: block; Z-INDEX: 19998; LEFT: 238px; VISIBILITY: visible; OVERFLOW: hidden; WIDTH: 280px; TOP: 163px; HEIGHT: 50px;margin:0px;\" ></IFRAME><DIV class=\"alertMessageShadow\"  id=\"calendarContainerShadow_{0}\" style=\"DISPLAY: block; Z-INDEX: 19999; FILTER: progid:DXImageTransform.Microsoft.alpha(opacity=50) progid:DXImageTransform.Microsoft.Blur(pixelradius=4); LEFT: 238px; WIDTH: 250px; TOP: 163px; HEIGHT: 50px\" ></DIV><DIV class=\"alertMessageTip _error\"  id=\"calendarContainerTip_{0}\" style=\"Z-INDEX: 20000; LEFT: 240px; VISIBILITY: visible; WIDTH: 282px; POSITION: absolute; TOP: 165px\" ><DIV class=\"am_TipLeft\" ><DIV class=\"am_TipRight\" ><DIV class=\"am_TipCenter\" ><DIV class=\"alertMessageTipHeader _error\"  id=\"calendarContainerTipHeader_{0}\" unselectable=\"on\" ><DIV class=\"alertMessageButton am_ButtonClose\"  onmouseover=\"this.style.backgroundPosition='-15px 0px'\"  onclick=\"ExtendedCalendar.hideCalendar ()\"  onmouseout=\"this.style.backgroundPosition='0px 0px'\" ></DIV><SPAN class=\"alertMessageTipHeaderText\" >Kalender</SPAN></DIV></DIV></DIV></DIV><DIV class=\"alertMessageBodyWrap _error\"  id=\"calendarContainerBody_{0}\" style=\"WIDTH: auto; HEIGHT: 50px\" ><DIV class=\"am_BodyLeft\" ><DIV class=\"am_BodyRight\" ><DIV class=\"am_BodyCenter\" ><DIV class=\"am_Body" + (className? " " + className : "") + "\"  style=\"WIDTH: auto; HEIGHT: auto\"  id=\"calendarContainerDiv_{0}\" ></DIV></DIV></DIV></DIV><DIV class=\"am_BottomLeft\"  id=\"calendarContainerBottom_{0}\" ><DIV class=\"am_BottomRight\" ><DIV class=\"am_BottomCenter\" ></DIV></DIV></DIV></DIV></DIV>";
		var div = document.createElement ("DIV");
		
		div.style.cssText = "position:absolute;left:0px;top:0px";
		div.innerHTML = calendarHtml.replace (/\{0\}/g, id);
		document.body.appendChild (div);
		div.style.zIndex = 200000;
		
		return $("calendarContainerDiv_" + id);
	}
	,getInputPosition : function (input)
	{
		
		var inputPos = getObjectPosition4(input);
		var res = [0,0];
		if (!input) return res;
		res [0] = inputPos [0];//input.offsetLeft;
		
		if (getStyleValue (input, "borderLeftStyle")!="none")
			res [0] += int (getStyleValue (input, "borderLeftWidth"));
		res [1] =  inputPos [1];//input.offsetTop;
		if (getStyleValue (input, "borderTopStyle")!="none")
			res [1] += int (getStyleValue (input, "borderTopWidth"));
		
		return res;
		
		if (input.parentNode && input.parentNode.currentStyle && 
			input.parentNode!=document.body)
		{	
			//res [0] += int(input.parentNode.currentStyle.paddingLeft);
			//res [1] += int(input.parentNode.currentStyle.paddingTop);
			var nextParent = input.parentNode;
			if (nextParent.tagName == "TR") nextParent = nextParent.parentNode;
			if (nextParent.tagName == "TBODY") nextParent = nextParent.parentNode;
			if (nextParent.tagName == "THEAD") nextParent = nextParent.parentNode;
			
			var parentRes = ExtendedCalendar.getInputPosition (nextParent);
			
			res [0]+= parentRes [0];
			res [1]+= parentRes [1];
		}
		else
		{
			//res [0] += int (getStyleValue (document.body, "borderLeftWidth"));
			//res [1] += int (getStyleValue (document.body, "borderTopWidth"));
		}
		
		return res;
		
	}
	//Adjust the size of the container 
	,positionContainer: function (e)
	{
		var calendarContainer = document.getElementById ("calendarContainerTip_" + ExtendedCalendar.calendarId);
		var calendarContainerShadow = document.getElementById("calendarContainerShadow_" + ExtendedCalendar.calendarId);
		var calendarContainerBG = document.getElementById("calendarContainerBg_" + ExtendedCalendar.calendarId);
		
		var cursorPos = getCursorPosition (e);
		if (!cursorPos) return;
		calendarContainer.style.position = "absolute";
		
		var calendarLeft = cursorPos[0]+10;
		var calendarTop = cursorPos[1]-10;
		
		if (ExtendedCalendar.currentDateInput)
		{
			relatedElementPosition = ExtendedCalendar.getInputPosition (ExtendedCalendar.currentDateInput);
			if (!relatedElementPosition || 
				(relatedElementPosition[0] == 0 && relatedElementPosition [1] == 0))	
				relatedElementPosition = [calendarLeft, calendarTop];
				
			if (relatedElementPosition)
			{
				var positionRight = ExtendedCalendar.currentDateInput.getAttribute("calendarPosition") == "right";
				
				var calendarWidth = calendarContainer.offsetWidth;
				var inputWidth = ExtendedCalendar.currentDateInput.offsetWidth;
				var calendarHeight = ExtendedCalendar.currentDateInput.offsetHeight;
				if (positionRight)
					calendarLeft = relatedElementPosition [0]  + inputWidth + 20;
				else
					calendarLeft = relatedElementPosition [0] - calendarWidth + inputWidth;
				calendarTop = relatedElementPosition [1] + 8;
			}
		}
 
		if (window.calendarAdjustmentCallback)
		{
			var pos = window.calendarAdjustmentCallback([calendarLeft, calendarTop], ExtendedCalendar.currentDateInput);
			calendarLeft = pos[0];
			calendarTop = pos[1];
		}
		
		
		calendarContainer.style.left = String (calendarLeft) + "px";
		calendarContainer.style.top = String (calendarTop) + "px";
		
		ExtendedCalendar.adjustContainerPosition ()
		
	}
	//Adjust the position of the background iframe and shadow 
	,adjustContainerPosition : function ()
	{
		var calendarContainer = document.getElementById ("calendarContainerTip_" + ExtendedCalendar.calendarId);
		var calendarContainerShadow = document.getElementById("calendarContainerShadow_" + ExtendedCalendar.calendarId);
		var calendarContainerBG = document.getElementById("calendarContainerBg_" + ExtendedCalendar.calendarId);
		var pos = getObjectPosition4 (calendarContainer);
		
		calendarContainerShadow.style.left = pos [0]+1;
		calendarContainerShadow.style.top  = pos [1]+1;
		
		calendarContainerBG.style.left = pos [0];
		calendarContainerBG.style.top  = pos [1]+1;
		
		
	}
	
	//Adjust the size of the container 
	,adjustContainerSize : function (id, width)
	{
		var calendarContainer = document.getElementById ("calendarContainerTip_" + id);
		var calendarContainerHeader = document.getElementById("calendarContainerTipHeader_" + id);
		var calendarContainerShadow = document.getElementById("calendarContainerShadow_" + id);
		var calendarContainerBG = document.getElementById("calendarContainerBg_" + id);
		var calendarContainerBottom = document.getElementById("calendarContainerBottom_" + id);
		var calendarContainerBody = document.getElementById("calendarContainerBody_" + id);
		
		
		//Init size 
		/* Container body */
		calendarContainerBody.style.width = String (width) + "px";
		
		/* The whole container */
		calendarContainer.style.width = calendarContainerBody.offsetWidth;
		
		
		/* The bottom */
		calendarContainerBottom.style.width = calendarContainer.offsetWidth-6;
		
		/* Shadow */
		calendarContainerShadow.style.height = calendarContainer.offsetHeight-2;
		calendarContainerShadow.style.width = calendarContainer.offsetWidth-4;
		
		/* Background iframe */
		calendarContainerBG.style.height  = calendarContainer.offsetHeight-1;
		calendarContainerBG.style.width  = calendarContainer.offsetWidth+1;
		
		//calendarContainerBody.firstChild.firstChild.firstChild.firstChild.style.width = calendarContainerShadow.offsetWidth -12;
		Drag.init (calendarContainerHeader, calendarContainer );
		
		calendarContainer.objShadow = calendarContainerShadow;
		calendarContainer.objBg = calendarContainerBG;
		calendarContainer.onDrag = function (x, y)
		{
			ExtendedCalendar.adjustContainerPosition ();
			
		};
	}
	
	//Show calendar 
	,showCalendar : function (event, input)
	{
		if (ExtendedCalendar.currentDateInput)
			ExtendedCalendar.hideCalendar ();
		
		ExtendedCalendar.createCalendar (input.id, input.calendarClassName);
			
		ExtendedCalendar.currentDateInput = input;
		
		ExtendedCalendar.currentDate = new Date();

		if(ExtendedCalendar.currentDateInput!=null)
		{
			
			try {
				if(ExtendedCalendar.currentDateInput.value!=null && ExtendedCalendar.currentDateInput.value!="")
				{
					ExtendedCalendar.currentDate = convertStringToDate(ExtendedCalendar.currentDateInput.value);
					if(isEmpty(ExtendedCalendar.currentDate)) 
						ExtendedCalendar.currentDate = new Date();
				}
			}catch (err)
			{
				ExtendedCalendar.currentDate= new Date();
			}
		}		
		ExtendedCalendar.currentMonth = ExtendedCalendar.currentDate.getMonth();
		ExtendedCalendar.currentYear = ExtendedCalendar.currentDate.getFullYear();
		
		ExtendedCalendar.displayDate (ExtendedCalendar.currentDate);
		ExtendedCalendar.positionContainer (event);
	}
	
	
	//Displaying a given date 
	,displayDate : function (date)
	{
		var virtualPath = getVirtualPath ();
		//Set 00:00 as time 
		var today = new Date(date.getFullYear(), date.getMonth(), date.getDate(),0,0,1);
		//Get the first day
		var firstDay = new Date (today.getMonth()+1 + "/01/" + today.getFullYear());				
		var rowsCount=2;
		var table = $( "calendar_" + ExtendedCalendar.calendarId);
		if (!table) return;
		//Empty the table 
		if (table.rows.length>2)
		{
			var i;
			for (i=table.rows.length-1;i>1;i--)
			{
				table.deleteRow(i);
			}
		}
		//Title
		$("td_calendar_month").innerHTML =  GetString("Month" + (today.getMonth()+1));
		$("td_calendar_year").innerHTML =   today.getFullYear();
	
	
		//Dates 
		var dayOfWeek = firstDay.getDay();
		if (dayOfWeek==0) dayOfWeek=7;
		var startDate = new Date (firstDay - 24*60*60*1000*(dayOfWeek-1));
		var startDate =new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate(),0,0,1);
		var cw = ExtendedCalendar.getCalendarWeek(startDate);
		if (cw>=52 && (firstDay.getMonth()==0)) cw = 1;
		var actKW = ExtendedCalendar.getCalendarWeek();
	
		var curDate=startDate;
		var last=false
		var j=0;
		
	
		var stopLimit=0;
		while(last!=true)
		{
		
			tr = table.insertRow(rowsCount++);
		
			//Calendar week 
			var cw = ExtendedCalendar.getCalendarWeek(curDate);
			td = document.createElement("td");
			td.className = "calendar_kw_cell";
			
			td.innerHTML = cw;
			tr.appendChild(td);
		
			var wert;
			var actFontColor;
			for (var i=0;i<7;i++)
			{
				td = document.createElement("td");
				
				if (actKW == cw)
					td.className = "calendar_actual_week_day_cell";
				else
					td.className = "calendar_day_cell";
				
				if (curDate.getMonth() != firstDay.getMonth())
				{
					td.className = "calendar_not_actual_month_day_cell";
				}
				
				
				
				if (curDate.getDate() == today.getDate()
					&& curDate.getMonth() == today.getMonth()
					&& curDate.getFullYear() == today.getFullYear())
					{
					var linkDate = "<a class='" + "calendar_actual_date_link" + "' href='javascript:void(0)' onclick='ExtendedCalendar.applyDate(" + curDate.getDate() + "," + (curDate.getMonth()+1) + "," + curDate.getFullYear() + ")'>" + 
					curDate.getDate()+"</a>";
					wert = linkDate;
					td.className = "calendar_actual_date";
					}
				else
				{
					var linkDate = "<a class='" + "calendar_day_link" + "' href='javascript:void(0)' onclick='ExtendedCalendar.applyDate(" + curDate.getDate() + "," + (curDate.getMonth()+1) + "," + curDate.getFullYear() + ")'>" + 
						curDate.getDate()+"</a>";
						wert = linkDate;
				}
			
				td.innerHTML = wert;
				tr.appendChild(td);
			
				var summerTime =(curDate.getUTCHours() > curDate.getHours()) ? 3600000 : 0;			
				curDate.setTime(Number(curDate) + summerTime + 24*60*60*1000);
			
			
				
			}
		
			if ((curDate.getMonth()-firstDay.getMonth())==1 || (curDate.getMonth()-firstDay.getMonth())<0 ) //Next month
				last=true;
			//cw++;
			stopLimit++;
			if (stopLimit>6) return;
		}
	
	
		//Today
		tr = table.insertRow(rowsCount++);
		td = document.createElement("td");
		td.colSpan = 8;
		td.className = "calendar_day_cell";
		td.align = "left";
		var today = new Date();
		td.innerHTML = GetString("Today") + ": <a href=\"javascript: ExtendedCalendar.goToDate("+ today.getFullYear() + "," + today.getMonth() + "," + today.getDate() + ");\">" + today.toLocaleLongDateString() + "</a>";
		tr.appendChild(td);
		
		ExtendedCalendar.adjustContainerSize (ExtendedCalendar.calendarId, 242);
		
	}
	//Apply the date to the input element 
	, applyDate : function (day, mm, yyyy)
	{
		
		var ddd = new Date(yyyy, mm-1, day,0,0,1);
		if (!ExtendedCalendar.currentDateInput) return;
		
		ExtendedCalendar.currentDateInput.value = ddd.toLocaleShortDateString (); //tag + "." + mm + "." + yyyy;
		ExtendedCalendar.currentDateInput.title = ddd.toLocaleLongDateString(); //ddd.toLocaleDateString();
		callEvent (ExtendedCalendar.currentDateInput, "onchange");
		ExtendedCalendar.hideCalendar();
	}
	//Hide the calendar 
	,hideCalendar : function ()
	{
		$('calendarContainerBg_' + ExtendedCalendar.calendarId).parentNode.removeChild ($('calendarContainerBg_' + ExtendedCalendar.calendarId));
		$('calendarContainerShadow_' + ExtendedCalendar.calendarId).parentNode.removeChild ($('calendarContainerShadow_' + ExtendedCalendar.calendarId));
		$('calendarContainerTip_' + ExtendedCalendar.calendarId).parentNode.removeChild ($('calendarContainerTip_' + ExtendedCalendar.calendarId));
		ExtendedCalendar.currentDateInput = null;
	}
	//Move to the next month 
	,getNextMonth : function (add)
	{
		ExtendedCalendar.currentMonth+=add;
	
		if (ExtendedCalendar.currentMonth<0)
		{
			ExtendedCalendar.currentYear = ExtendedCalendar.currentYear-1;
			ExtendedCalendar.currentDate = new Date(ExtendedCalendar.currentYear,11,ExtendedCalendar.currentDate.getDate());				
			ExtendedCalendar.currentMonth =11;
		}
		else if(ExtendedCalendar.currentMonth>11)
		{
		
			ExtendedCalendar.currentYear = ExtendedCalendar.currentYear+ 1;
			ExtendedCalendar.currentDate = new Date(ExtendedCalendar.currentYear,0,ExtendedCalendar.currentDate.getDate());
			ExtendedCalendar.currentMonth =0;
		}
		else
			ExtendedCalendar.currentDate = new Date(ExtendedCalendar.currentYear,ExtendedCalendar.currentMonth,ExtendedCalendar.currentDate.getDate());
	
		
		ExtendedCalendar.displayDate (ExtendedCalendar.currentDate);
	}
	,goToDate : function (y,m,d)
	{
		ExtendedCalendar.currentYear = parseInt(y);
		ExtendedCalendar.currentMonth = parseInt(m);
		ExtendedCalendar.currentDate = new Date(ExtendedCalendar.currentYear,ExtendedCalendar.currentMonth,parseInt(d));
		ExtendedCalendar.displayDate (ExtendedCalendar.currentDate);
	}
	,showMonths : function ()
	{
		var div = $("div_months");
		var monthlist="";
		for (var m=0; m< 12;m++)
		{
			monthlist += "<option value='" + m + "'>" + GetString("Month" + (m+1)) + "</option>";			
		}
		monthlist = "<select onchange='javascript:ExtendedCalendar.goToMonth(this.value)' class='" + "calendar_month_list" + "' id='select_month'>" + monthlist + "</select>";
		
		$("td_calendar_month").innerHTML = monthlist;
		$("select_month").selectedIndex = ExtendedCalendar.currentMonth;
	
		ExtendedCalendar.adjustContainerSize (ExtendedCalendar.calendarId, 242);
	}
	,showYears : function ()
	{
		var div = $("div_years");
		var monthlist="";
		for (var m=-50; m< 50;m++)
		{
			var year = ExtendedCalendar.currentYear + m;
			monthlist += "<option value='" + year + "'>" + year + "</option>";
			
		}
		monthlist = "<select onchange='javascript:ExtendedCalendar.goToYear(this.value)' class='" + "calendar_year_list" + "' id='select_year'>" + monthlist + "</select>";
		
	
		$ ("td_calendar_year").innerHTML = monthlist;
		$("select_year").selectedIndex = 50;
	
		ExtendedCalendar.adjustContainerSize (ExtendedCalendar.calendarId, 242);
	}
	,goToYear : function (y)
	{
		ExtendedCalendar.currentYear = parseInt (y);
		ExtendedCalendar.currentDate = new Date(ExtendedCalendar.currentYear,ExtendedCalendar.currentMonth,ExtendedCalendar.currentDate.getDate());
		ExtendedCalendar.displayDate (ExtendedCalendar.currentDate);
		
	}
	,goToMonth : function (m)
	{
		ExtendedCalendar.currentMonth = parseInt (m);
		ExtendedCalendar.currentDate = new Date(ExtendedCalendar.currentYear,ExtendedCalendar.currentMonth,ExtendedCalendar.currentDate.getDate());
		ExtendedCalendar.displayDate (ExtendedCalendar.currentDate);
		
	}
	//Some utils
	,getCalendarWeek : function (date)
	{
		if (!date) date = new Date();
		date = new Date(date);			
		var day = date.getDay(); if (day == 0) day = 7;
		var summerTime  =(date.getUTCHours() > date.getHours()) ? 3600000 : 0;
		date.setTime(Number(date)+summerTime-(day-1)*86400000);
		var year = date.getFullYear(); if (1900 > year) year +=1900;
		var cw = 1;
		if (new Date(year,11,29) > date) {
			var Start = new Date(year,0,1);
			Start = new Date(Number(Start)+86400000*(8-Start.getDay()));
			if(Start.getDate() > 4) Start.setTime(Number(Start)-604800000);
			cw = Math.ceil((date.getTime()-Start)/604800000);
		}
		return cw;
	}
	
};

///<Summary>
///Managing various manipulations of the className attribute
///</Summary>
var ClassNameManager = 
{
	cache : null
	,flyWeight: function (obj)
	{
		this.dom = $(obj);
		this.isFly = true;
		for (var m in ClassNameManager.extendedMethods)
		{
			this [m] = ClassNameManager.extendedMethods [m];
		}
	}
	,fly : function (obj)
	{
		obj = $(obj);
		if (ClassNameManager.cache!=null)
		{
			ClassNameManager.cache.dom = obj;
			
		}
		else
			ClassNameManager.cache = new ClassNameManager.flyWeight(obj);
		return ClassNameManager.cache;
	}
	
	//Adding the ClassName methods
	,extend : function (obj)
	{
		if (!obj) return null;
		if (obj.extendedClassNameManager) return obj;
		obj.dom = {};
		for (var m in ClassNameManager.extendedMethods)
		{
			obj [m] = ClassNameManager.extendedMethods [m];
		}
		obj.extendedClassNameManager = true;
		return obj;
	}
	,extendedMethods : 
	{
		classNames : function ()
		{
			var strClassNames = this.className || this.dom.className;
			if (strClassNames)
			{
				return strClassNames.split (" ");
			}
			return [];
		}
		,hasClassName : function (className)
		{
			var elementClassName = this.className || this.dom.className;
			
			if (!elementClassName || elementClassName.length == 0) return false;
			if (elementClassName == className ||
				elementClassName.match(new RegExp("(^|\\s)" + className + "(\\s|$)")))
				return true;
			return false;
		}
		,addClassName : function (className)
		{
			if (!this.hasClassName (className))
			{
				var obj = (this.isFly ? this.dom : this);
				
				obj.className = this.classNames().join (" ") + " " + className;
				
			}
		}
		,removeClassName : function (className)
		{
			if (this.hasClassName (className))
			{
				var classNames = this.classNames(); 
				var obj = (this.isFly ? this.dom : this);
				
				for (var i= classNames.length; i>=0; i--)
				{
					if (classNames[i] == className)
					{
						classNames.splice (i, 1);
						obj.className = classNames.join (" ");
						
						return;
					}
				}
				
			}
		}
		,removeAllClassNames : function ()
		{
			var obj = (this.isFly ? this.dom : this);
			obj.className = "";
			obj.removeAttribute ("className");
			return;
		}
		,toggleClassName: function(className) {
			
			if (this.hasClassName (className))
				this.removeClassName (className);
			else	
				this.addClassName (className);
			//(this.isFly ? this.dom : this).className = this.classNames().join (" ") + className;
		}
		,changeClassName: function(oldClassName,newClassName) {
			if (this.hasClassName (oldClassName))
				this.removeClassName (oldClassName);
			
			this.addClassName (newClassName);
			
			(this.isFly ? this.dom : this).className = this.classNames().join (" ");
		}
	}
}


function addToListWithSort (select, optionToAdd)
{
	//Keep the sort order
	var tt;
	var option;
	var optionText;
	for ( tt=0; tt<select.length;tt++)
	{
		option = select.options[tt];				
		if (option!=null)
		{
			optionText = option.text;					
			if ( optionText !=null && optionText.length>0)
			{	
				
				if (optionToAdd.text <= optionText)
					{ break;}
			}
		}
	}
	var newOption = new Option (optionToAdd.text, optionToAdd.value);
	if (optionToAdd.className)
		newOption.className = optionToAdd.className;
	
	//Clone details 
	newOption.guid = optionToAdd.guid ;
	newOption.userTitle = optionToAdd.userTitle;
	newOption.description = optionToAdd.description;
	newOption.isGroup = optionToAdd.isGroup;
	newOption.firstName = optionToAdd.firstName;
	newOption.lastName = optionToAdd.lastName;
	newOption.hospitalName = optionToAdd.hospitalName;
	newOption.userRolesInfo = optionToAdd.userRolesInfo;
	newOption.userGroupsInfo = optionToAdd.userGroupsInfo;
	
	if(isMS())
		select.add (newOption, tt);
	else
		select.add (newOption, null);
	
	return tt;
}


//Class MultipleSelectionManager
var MultipleSelectionManager = 
{
	createNew : function (id)
	{
		return new 	MultipleSelectionManager.object (id);
	}
	,object : function (id)
	{
		this.listAvailable = $(id + "_available");
		this.listSelected  = $(id + "_selected");
		
		//Add all 
		this.addAllItems = function ()
		{
			if (!this.listAvailable || !this.listSelected) return;
			
			var i;
			var itemCount1,itemCount2;
			itemCount2 =0;
			itemCount1 = this.listAvailable.length ;
			for (i=itemCount1-1;i>=0;i--)
			{
				addToListWithSort (this.listSelected,this.listAvailable.options[i]);
				this.listAvailable.remove(i);			
			}
		};
		
		//Add 1 item 
		this.addItem = function ()
		{
			if (this.listAvailable==null || this.listSelected==null) return;
			
			var i;
			var itemCount1,itemCount2;
			itemCount2 =0;
			itemCount1 =this.listAvailable.length ;
			for (i=itemCount1-1;i>=0;i--)
				if (this.listAvailable.options[i].selected == true)				
				{
					addToListWithSort (this.listSelected,this.listAvailable.options[i]);
					this.listAvailable.remove(i);
				}
		};
		
		//Remove all 
		this.removeAllItems = function ()
		{
			var i;
			var itemCount1,itemCount2;
			itemCount2 =0;
			itemCount1 =this.listSelected.length;
			
			for (i=itemCount1-1;i>=0;i--)
			{
				addToListWithSort (this.listAvailable,this.listSelected.options[i]);
				this.listSelected.remove(i);
			}
		};
		
		//Remove 1 item 
		this.removeItem = function ()
		{
			var i;
			var itemCount1,itemCount2;
			itemCount2 =0;
			itemCount1 =this.listSelected.length ;
			
			for (i=itemCount1-1;i>=0;i--)
				if (this.listSelected.options[i].selected == true)				
				{
					addToListWithSort (this.listAvailable,this.listSelected.options[i]);
					this.listSelected.remove(i);
				}
		}
	}	
}

//Some useful casting/type methods 
var JsType = {};
JsType.IsArray = function(o){
	return o && o!=window && 
		( o instanceof Array ||
			(typeof o.length == "number" && typeof o.item=="function")
		);
};


/// <summary>
/// Getting elements by class name and executing the given action 
/// </summary>
/// <param name="className">the class name to search for</param>
/// <param name="parentElement">"document" by default</param>
/// <param name="callBackAction">an action (callback) to execute</param>
document.getElementsByClassName = function (className, parentElement, callBackAction, tagName)
{
	if(!parentElement) parentElement = document.body;
	var children = parentElement.getElementsByTagName ("*");
	if (!children) return null;
	var elements = new Array ();
	var child = null;
	for (var i=0, length=children.length; i < length; i++)
	{
		child = children [i];
		if (ClassNameManager.fly(child).hasClassName (className))
		{
			if (tagName && child.tagName!=tagName) continue;
			elements.push (child);
			if (callBackAction) callBackAction (child);
		}

	}
	return elements;
}

function cloneObject(obj)
{
	var clone;
	
    if (obj == null)
    {
        clone = null;
    }
    else
    {
        var type = GetInstanceName(obj);
        switch (type)
        {
            case "Boolean":
                clone = obj == true ? true : false;
                break;
            case "Number":
                clone = new Number(obj);
                break;
            case "Date":
                clone = new Date(obj);
                break;
            case "String":
                clone = new String(obj);
                break;
            case "Array":
                clone = new Array();
                for (var p in obj)
                {
                    clone[p] = cloneObject(obj[p]);
                }
                break;
            case "Object":
                clone = new Object();
                for (var p in obj)
                {
                    clone[p] = cloneObject(obj[p]);
                }
                break;
            default:
                clone = obj;
                break;
        }
    }
    
	return clone;
}

/** 
 * Some useful javascript extensions
 */
var JSO = {}
/** 
 * Iterating the given collection and applying the passed "method" on each item of the collection 

* <param name="collection">the collection to iterate</param>
* <param name="method">method to apply to the items of the given collection
 if "method (item)" returns "false", the iteration will be stopped
</param>
* <param name="throwException">if true, the iteration will be stopped on error and an alert will be displayed</param>
*/
JSO.ForEach = function (collection, method, throwException)
{
	if (!method) return;
	if (!collection) return;
	try
	{
		if (collection.length && collection.length > 0)
		{
			for (var i=0; i < collection.length; i++)
			{
				var bContinue = method (collection[i]);
				if (!bContinue) return;
			}
		}
		else
		{
			for (var i in collection.length)
			{
				var bContinue = method (collection[i]);
				if (!bContinue) return;
			}
		}
	} 
	catch (err)
	{	
		if (throwException)
			alert (err.message || err.description || err);
	}
}

/// <summary>
/// All kinds of event managing methods
/// </summary>
JSO.EventManager = {};
JSO.EventManager.KeyCodes = { up:38, down: 40, left:37, right:39, tab:9, enter: 13, escape:27 };


JSO.Utils = {}
JSO.Utils.Captcha = {
	Create : function ()
	{
		var number1 = int(Math.random()*10)+1;
		var number2 = int(Math.random()*10)+1;
		while (number2 > number1)
		{
			number2 = int(Math.random()*10)+1;
		}
		var operators = ["+","*","-"];
		var operatorIndex = int (Math.random()*3);
		
		var formula = String (number1) + " " + operators [operatorIndex] + " " + String (number2);
		return formula;
	}
}

/// <summary>
/// All kinds of measuring/positioning methods
/// </summary> 
JSO.Ruler = {};
JSO.Ruler.GetElementTextWidth = function (el)
{
	var clone = cloneHtmlElement (el);
	
	with (clone.style)
	{
		visibility = "hidden";
		position = "absolute";
		left = "0px";
		top = "0px";
		fontFamily = el.currentStyle.fontFamily;
		fontSize = el.currentStyle.fontSize;
		fontWeight = el.currentStyle.fontWeight;
		fontVariant = el.currentStyle.fontVariant;
		fontStyle = el.currentStyle.fontStyle;
	}
	
	document.body.appendChild(clone);
	
	var w = clone.offsetWidth;
	
	document.body.removeChild (clone);
	
	return w;
}


/// <summary>
/// Message box functionality 
/* 
	Syntax:
	
	JSO.MessageBox.Show (
		"Message to be be displayed" 
		[, "Caption to be displayed"
		, ButtonsType < JSO.MessageBox.Buttons.{<default>OK</default>,OKCancel,YesNo,YesNoCancel} >
		, IconType < JSO.MessageBox.Icons.{<default>Info</default>,Question,Warning,Error}>
		, DialogWidth <int>
	]);
	
	//To handle the dialog result (= user selection), pass the Callback function as follows:
	
	JSO.MessageBox.Show (....).CallBack = MyCallBackFunction;
	
	//The call back function gets one of the DialogResult enum values 
	function MyCallBackFunction (result)
	{
		if (result == DialogResult.OK) 
			// ... handle "OK"
		else if (result == DialogResult.Cancel) 
			// ... handle "Cancel"
		else if (result == DialogResult.Yes) 
			// ... handle "Yes"
		else if (result == DialogResult.No) 
			// ... handle "No"
	}
*/
/// </summary>
JSO.MessageBox = {
	ID : "MessageBox-#1"
	,Dialog : null
	,DialogWidth : 350
	,Caption : null 
	,Text : null 
	//,CallBack : null 
	
	,DialogResult : {
		OK: "ok"
		,Cancel: "cancel"
		,Yes: "yes"
		,No: "no"
	}
	
	
	
	,Buttons : {
		OK : "ok"
		,OKCancel: "ok-cancel"
		,YesNo: "yes-no"
		,YesNoCancel: "yes-no-cancel"
	}
	,Icons : {
		Info		: "info"
		,Question	: "question"
		,Warning	: "warning"
		,Error		: "error"
	}
	,Show : function (text, caption, buttons, icon, dialogWidth)
	{
		if (!isNull(dialogWidth)) JSO.MessageBox.DialogWidth = dialogWidth;		
		else JSO.MessageBox.DialogWidth  = 350;
		
		if (JSO.MessageBox.Dialog==null) JSO.MessageBox.CreateDialog ();
		else
			JSO.MessageBox.Dialog.style.width = String (JSO.MessageBox.DialogWidth) + "px";
		JSO.MessageBox.Dialog.style.visibility = "hidden";
		JSO.MessageBox.Dialog.style.display = "";
		
		if (isNull(caption)) caption = "Info";
		if (isNull(buttons)) buttons = JSO.MessageBox.Buttons.OK;
		if (isNull(icon)) icon= JSO.MessageBox.Icons.Info;
		
		
		//Prepare 
		JSO.MessageBox.Dialog.removeAllClassNames();
		JSO.MessageBox.Dialog.addClassName ("jso-message-box");
		
		//Dialog type 
		JSO.MessageBox.Dialog.addClassName ("type-" + buttons);
		
		//Icon type 
		JSO.MessageBox.Dialog.addClassName ("icon-" + icon);
		
		//Caption
		JSO.MessageBox.Caption.innerHTML = caption;
		
		//Text  
		JSO.MessageBox.Text.innerHTML = String(text).replace (/\n/gi, "<br />");
		
		
		//Position
		JSO.MessageBox.SetPosition ();
	
		JSO.MessageBox.Dialog.style.visibility = "visible";
		JSO.MessageBox.Background.style.display = "block";
		JSO.MessageBox.IframeBackground.style.display = "block";
		
		
		
		//Add onresize event 
		addEvent (window, "onresize", JSO.MessageBox.SetPosition);
		 
				//Observe enter/cancel keys
		addEvent (document.body, "onkeyup", JSO.MessageBox.CheckFormKeyEvent);
		
		return JSO.MessageBox.Dialog;
	}
	,CheckFormKeyEvent : function (e)
	{
		if (e.keyCode == JSO.EventManager.KeyCodes.escape || e.keyCode == JSO.EventManager.KeyCodes.enter)
		{
			if (isMS()) e.cancelBubble = true;
			else e.stopPropagation ();
			JSO.MessageBox.Hide();
		}
	}
	,Hide : function ()
	{
		JSO.MessageBox.Dialog.style.display = "none";
		JSO.MessageBox.Background.style.display = "none";
		JSO.MessageBox.IframeBackground.style.display = "none";
		
		document.body.style.overflow = (document.body.styleOverflow || "auto");
		
		//Remove onresize event 
		removeEvent (window, "onresize", JSO.MessageBox.SetPosition);
		
		//Remove enter/cancel key event
		removeEvent (document.body, "onkeyup", JSO.MessageBox.CheckFormKeyEvent);
		
	}
	,SetPosition : function ()
	{
		if (JSO.MessageBox.Dialog == null) return;
		if (JSO.MessageBox.Dialog.style.display == "none") return;
		
		var pageSize = getClientSize ();
		var clientWidth = (document.documentElement && document.documentElement.clientWidth  ?
			document.documentElement.clientWidth : pageSize [0]);
		var clientHeight = (document.documentElement && document.documentElement.clientHeight  ?
			document.documentElement.clientHeight : pageSize [1]);
				
		
		
		
		
		var dlgSize = getObjectSize (JSO.MessageBox.Dialog);
		
		var scroll = JSO.Layout.GetScroll (document);
		
			
		var left = (clientWidth - dlgSize [0])/2 + scroll.left;
		var top = (clientHeight - dlgSize [1] )/2 + scroll.top;
		
		JSO.MessageBox.Dialog.style.left = left;
		JSO.MessageBox.Dialog.style.top = top;
		
		if (document.body.scrollWidth>pageSize[0]) pageSize[0] = document.body.scrollWidth;
		if (document.body.scrollHeight>pageSize[1]) pageSize[1] = document.body.scrollHeight;
		
		JSO.MessageBox.Background.style.width = JSO.MessageBox.IframeBackground.style.width = pageSize[0];
		JSO.MessageBox.Background.style.height = JSO.MessageBox.IframeBackground.style.height = pageSize[1];
		
		//Change the scroll value
		
		document.body.style.overflow = "hidden";
	}
	
	,CreateDialog : function ()
	{
		importStylesheet (getVirtualPath () + "multimed/message-box/main.css", "messageBoxCss");
		
		//Create iframe background 
		var iframeBgHtml = "<iframe scrolling=no frameborder=0 id=\"MessageBox-#1-IframeBackground\" class=\"jso-message-box-page-background\"></iframe>";
		document.body.insertAdjacentHTML ("beforeEnd", iframeBgHtml);
		JSO.MessageBox.IframeBackground = $(JSO.MessageBox.ID + "-IframeBackground");
		
		
		//Create background 
		var bgHtml = "<div id=\"MessageBox-#1-Background\" class=\"jso-message-box-page-background\"></div>";
		document.body.insertAdjacentHTML ("beforeEnd", bgHtml);
		JSO.MessageBox.Background = $(JSO.MessageBox.ID + "-Background");
			
		//DIALOG HTML TEXT BEGIN -----------------------------------------------
		var dlgHtml = "<div id=\"MessageBox-#1\" class=\"jso-message-box type-ok-cancel\" style=\"height: auto\" onclick=\"JSO.MessageBox.EvalClickEvent(event)\">	<div class=\"message-box-shadow\">		<!-- Header -->		<div class=\"message-box-title-left\">			<div class=\"message-box-title-right\">				<div class=\"message-box-title-center\">					<div class=\"message-box-title\">						<div dlgButtonType=\"cancel\" title=\"Schließen\" style=\"display: block; position: relative\" class=\"message-box-toolbutton toolbutton-close\"						 onmouseover=\"this.className+=' highlight'\"						 onmouseout=\"this.className ='message-box-toolbutton toolbutton-close'\">						</div>						<span class=\"message-box-title-text\"  id=\"MessageBox-#1-Caption\"></span>					</div>				</div>			</div>		</div>		<!-- Body -->		<div class=\"message-box-body\">			<div class=\"message-box-text-left\">				<div class=\"message-box-text-right\">					<div class=\"message-box-text-center\">						<div class=\"message-box-text-body\">							<div >								<div class=\"jso-message-box-icon\"></div>								<div class=\"message-box-content\">									<span class=\"message-box-content-text\" id=\"MessageBox-#1-Text\"></span></div>							</div>						</div>					</div>				</div>			</div>			<div class=\"message-box-buttons-left\">				<div class=\"message-box-buttons-right\">					<div class=\"message-box-buttons-center\">					<div class=\"message-box-buttons-body\">						<div class=\"message-box-buttons-container\">							<div class=\"message-box-buttons-content\">								<div class=\"jso-mb-buttons-set\">									<div dlgButtonType=\"ok\" class=\"jso-mb-button btn-ok\" onmouseover=\"this.className+=' highlight'\"										onmouseout=\"this.className='jso-mb-button btn-ok'\">OK</div>									<div dlgButtonType=\"yes\" class=\"jso-mb-button btn-yes\" onmouseover=\"this.className+=' highlight'\"										onmouseout=\"this.className='jso-mb-button btn-yes'\">Ja</div>									<div dlgButtonType=\"no\" class=\"jso-mb-button btn-no\" onmouseover=\"this.className+=' highlight'\"										onmouseout=\"this.className='jso-mb-button btn-no'\">Nein</div>									<div dlgButtonType=\"cancel\" class=\"jso-mb-button btn-cancel\" onmouseover=\"this.className+=' highlight'\"										onmouseout=\"this.className='jso-mb-button btn-cancel'\">Abbrechen</div>								</div>															</div>						</div>								</div>				</div>				</div>			</div>		</div>	</div></div>";
			//DIALOG HTML TEXT END -----------------------------------------------
			document.body.insertAdjacentHTML ("beforeEnd", dlgHtml);
			
			JSO.MessageBox.Dialog = $(JSO.MessageBox.ID);
			JSO.MessageBox.Dialog.style.width = String (JSO.MessageBox.DialogWidth) + "px";
			JSO.MessageBox.Caption = $(JSO.MessageBox.ID + "-Caption");
			JSO.MessageBox.Text = $(JSO.MessageBox.ID + "-Text");
			
			ClassNameManager.extend (JSO.MessageBox.Dialog);
			
			if (window.Drag)
				window.Drag.init (JSO.MessageBox.Caption.parentNode.parentNode.parentNode.parentNode, JSO.MessageBox.Dialog);
	}
	
	,EvalClickEvent: function (e)
	{
		var src = getEventSource (e);
		if (!src) return;
		if (!src.dlgButtonType) return;
		
		var btnType = src.dlgButtonType;
		
		JSO.MessageBox.ExecuteAction (btnType);
	}	
	
	,ExecuteAction: function (dialogResult)
	{
		if (JSO.MessageBox.Dialog.CallBack)
			JSO.MessageBox.Dialog.CallBack (dialogResult);
		
		JSO.MessageBox.Hide();
	}

};

/// <summary>
/// Collection of all kind of form utilitiess 
/// <summary>
JSO.Forms = {};
/// <summary>
/// Form tooltips (for the input fields)
/// <summary>
JSO.Forms.Tooltips = {
	ID : "JSO-Forms-Tooltip-#1"
	,Popup : null
	,Text : null 
	
	
	,CreatePopup : function ()
	{
		importStylesheet (getVirtualPath () + "multimed/tooltips/main.css", "tooltipsCss");
		
		//Create iframe background 
		/*var iframeBgHtml = "<iframe scrolling=no frameborder=0 id=\"MessageBox-#1-IframeBackground\" class=\"jso-message-box-page-background\"></iframe>";
		document.body.insertAdjacentHTML ("beforeEnd", iframeBgHtml);
		JSO.MessageBox.IframeBackground = $(JSO.MessageBox.ID + "-IframeBackground");
		*/
		
		//Create background 
		/*var bgHtml = "<div id=\"MessageBox-#1-Background\" class=\"jso-message-box-page-background\"></div>";
		document.body.insertAdjacentHTML ("beforeEnd", bgHtml);
		JSO.MessageBox.Background = $(JSO.MessageBox.ID + "-Background");
		*/
			
		//DIALOG HTML TEXT BEGIN -----------------------------------------------
		var dlgHtml = "<div id=\"" + JSO.Forms.Tooltips.ID + "\" class=\"jso-tooltip-container\"><div class=\"tooltip-center\" id=\"" + JSO.Forms.Tooltips.ID + "-Text\"></div></div>";
		
		//DIALOG HTML TEXT END -----------------------------------------------
		document.body.insertAdjacentHTML ("beforeEnd", dlgHtml);
		
		JSO.Forms.Tooltips.Popup = $(JSO.Forms.Tooltips.ID);
		JSO.Forms.Tooltips.Text = $(JSO.Forms.Tooltips.ID + "-Text");
		
		ClassNameManager.extend (JSO.Forms.Tooltips.Popup);
		
	}
	
	,Show : function  (inputElement, text)
	{
		if (JSO.Forms.Tooltips.Popup ==null) JSO.Forms.Tooltips.CreatePopup ();
		JSO.Forms.Tooltips.Trigger = inputElement;
		JSO.Forms.Tooltips.Popup.style.visibility = "hidden";
		JSO.Forms.Tooltips.Popup.style.display = "";
		
		//Text  
		JSO.Forms.Tooltips.Text.innerHTML = "<p>" + String(text).replace (/\n/gi, "</p><p>") + "</p>";
		
		//Position
		JSO.Forms.Tooltips.SetPosition ();
	
		JSO.Forms.Tooltips.Popup.style.visibility = "visible";
		//JSO.Forms.Tooltips.Popup.Background.style.display = "block";
		//JSO.Forms.Tooltips.Popup.MessageBox.IframeBackground.style.display = "block";
		
		//Add onresize event 
		addEvent (window, "onresize", JSO.Forms.Tooltips.SetPosition);
	}
	,Hide : function ()
	{
		JSO.Forms.Tooltips.Popup.style.display = "none";
		//JSO.Forms.Tooltips.Background.style.display = "none";
		//JSO.Forms.Tooltips.IframeBackground.style.display = "none"; 
		
		//Remove onresize event 
		removeEvent (window, "onresize", JSO.Forms.Tooltips.SetPosition);
		
	}
	,SetPosition : function ()
	{
		if (JSO.Forms.Tooltips.Popup == null) return;
		if (JSO.Forms.Tooltips.Popup.style.display == "none") return;
		
		var pageSize = getClientSize ();
		var dlgSize = getObjectSize (JSO.Forms.Tooltips.Popup);
		var triggerSize = getObjectSize (JSO.Forms.Tooltips.Trigger);
		var triggerPos = getObjectPosition3 (JSO.Forms.Tooltips.Trigger);
		
		var left = triggerPos [0] + triggerSize [0] + 5;
		var top = triggerPos [1] - 14;
		
		JSO.Forms.Tooltips.Popup.style.left = left;
		JSO.Forms.Tooltips.Popup.style.top = top;
	}
};
/// <summary>
/// Simple (prompt) dialogs
/* 
	Syntax:
	
	JSO.Forms.SimpleDialog.Show (
		"Caption to be displayed"
		, FormElements <Array [ 
			{
				type: "Text(...Memo,List,Radio,Checkbox,DateTime)" | "Newline"| "AddOn"
				,name: "some unique name for the input element"
				,title: "Last name"			
				,defaultValue : "some default value"
				,style: "some css declarations"
				,group: "groupName (only for radio elements)"
				,position: "left|right"
				,labelOnNewLine: false|true (default = false)
				,fullLine : false | true				
				,values: [ { id: 0, val : "First option"}, {id: 1, val: "Second option"}, ...]
			}
			,...
		]>
		[, DialogWidth <int>
	]);
	
	//To handle the dialog result (= user selection), pass the Callback function as follows:
	
	JSO.MessageBox.Show (....).CallBack = MyCallBackFunction;
	
	//The call back function gets one of the DialogResult enum values 
	//inputData is an array of type:
	// [{ "some unique name for the input element" : "user input" }, ...] 
	function MyCallBackFunction (result, inputData)
	{
		
		if (result == DialogResult.OK) 
			// ... handle "OK"
		else if (result == DialogResult.Cancel) 
			// ... handle "Cancel"
		else if (result == DialogResult.Yes) 
			// ... handle "Yes"
		else if (result == DialogResult.No) 
			// ... handle "No"
		
		
	}
*/
/// </summary>
JSO.Forms.SimpleDialog = {
	ID : "Dialog-#1"
	,Dialog : null
	,DialogWidth : 350
	,Caption : null 
	,Text : null
	,FormElements : null
	,RelatedElement : null 
	//,CallBack : null 
	
	,DialogResult : {
		OK: "ok"
		,Cancel: "cancel"
	}
	,Show : function (caption, formElements, dialogWidth, relatedElement, keepOpened)
	{
		
		JSO.Forms.SimpleDialog.PostBuildEvents = new Array();
		JSO.Forms.SimpleDialog.KeepOpened = keepOpened == true;
		
		if (!isNull(dialogWidth)) JSO.Forms.SimpleDialog.DialogWidth = dialogWidth;		
		else JSO.Forms.SimpleDialog.DialogWidth  = 350;
		
		if (JSO.Forms.SimpleDialog.Dialog==null) JSO.Forms.SimpleDialog.CreateDialog ();
		else
			JSO.Forms.SimpleDialog.Dialog.style.width = String (JSO.Forms.SimpleDialog.DialogWidth) + "px";
		
		JSO.Forms.SimpleDialog.RelatedElement = relatedElement;
		JSO.Forms.SimpleDialog.Dialog.style.visibility = "hidden";
		JSO.Forms.SimpleDialog.Dialog.style.display = "";
		
		if (isNull(caption)) caption = "Eingabeaufforderung";
		buttons = JSO.MessageBox.Buttons.OKCancel;
		
		
		//Prepare 
		JSO.Forms.SimpleDialog.Dialog.removeAllClassNames();
		JSO.Forms.SimpleDialog.Dialog.addClassName ("simple-dialog jso-message-box");
		
		//Dialog type 
		JSO.Forms.SimpleDialog.Dialog.addClassName ("type-" + buttons);
		
		//Icon type 
		JSO.Forms.SimpleDialog.Dialog.addClassName ("icon-info");
		
		//Caption
		JSO.Forms.SimpleDialog.Caption.innerHTML = caption;
		
		//Form elements
		JSO.Forms.SimpleDialog.FormElements = formElements;
		JSO.Forms.SimpleDialog.BuildForm (formElements);
		
		
		
		//Position
		JSO.Forms.SimpleDialog.SetPosition ();
	
		JSO.Forms.SimpleDialog.Dialog.style.visibility = "visible";
		JSO.Forms.SimpleDialog.Background.style.display = "block";
		JSO.Forms.SimpleDialog.IframeBackground.style.display = "block";
		
		//Add onresize event 
		addEvent (window, "onresize", JSO.Forms.SimpleDialog.SetPosition);
			
		//Observe enter/cancel keys
		addEvent (document.body, "onkeyup", JSO.Forms.SimpleDialog.CheckFormKeyEvent);
		
	
		return JSO.Forms.SimpleDialog.Dialog;
	}
	,CheckFormKeyEvent : function (e)
	{
		if (e.keyCode == JSO.EventManager.KeyCodes.escape)			
			JSO.Forms.SimpleDialog.Hide();
		else if (e.keyCode == JSO.EventManager.KeyCodes.enter)
		{
			if (isMS()) e.cancelBubble = true;
			else e.stopPropagation ();
			
			var okButton = $("Dialog-Button-OK-#1");
			var yesButton = $("Dialog-Button-YES-#1");
			if (JSO.Layout.GetCssValue (okButton, "display") != "none")
			{
				callEvent (okButton, "onclick");
			}
			else if (JSO.Layout.GetCssValue (yesButton, "display") != "none")
			{
				callEvent (yesButton, "onclick");
			}
		}
			
			
	}

	,PostBuildEvents: new Array ()
	,Elements : 
	{
		GetId : function (elementInfo)
		{
			return "jso.forms.simpleForm.elements." + elementInfo.name;
		}
		,AddOn : {
			Add : function (elementInfo)
			{
				if (!elementInfo.callBack) return "";
				return elementInfo.callBack ();
			}
			,GetInputValue : function (elementInfo)
			{
				if (!elementInfo.callBackGetInputData) return "";
				return (elementInfo.callBackGetInputData ());
			}
		}
		,Newline : {
			Add : function (elementInfo)
			{
				return "<div class=clear></div>";
			}
			
		}
		,Text : {
			Add : function (elementInfo)
			{
				var id = JSO.Forms.SimpleDialog.Elements.GetId (elementInfo);
				return "<div " + (elementInfo.position ? "style=\"float:" + elementInfo.position + "\"" : "") + 
				
				" class=\"element type-text " + (elementInfo.fullLine ? " full-line":"") + "\"><label for=\"" + id + "\">" + elementInfo.title + "</label>" + (elementInfo.labelOnNewLine ? "<div class=clear></div>" : "") + 
				"<input onfocus=\"ClassNameManager.extend(this);this.addClassName ('onfocus')\" onblur=\"this.removeClassName('onfocus')\"  value=\""  + HtmlEncode(elementInfo.defaultValue || "") + "\" style=\""+(elementInfo.style || "") + "\" type=text id=\""  + id + "\"></div>";
			}
			,GetInputValue : function (elementInfo)
			{
				var id = JSO.Forms.SimpleDialog.Elements.GetId (elementInfo);
				var inputElement = $(id);
				if (!inputElement) return null;
				return inputElement.value;
			}
		}
		,Label : {
			Add : function (elementInfo)
			{
				var id = JSO.Forms.SimpleDialog.Elements.GetId (elementInfo);
				return "<div " + (elementInfo.position ? "style=\"float:" + elementInfo.position + "\"" : "") + 
				" style=\""+(elementInfo.style || "") + "\" " + 
				" class=\"element type-label full-line" + "\">" + elementInfo.title + "<div class=clear></div>" + 
				"</div>";
			}
			
		}

		,Number : {
			Add : function (elementInfo)
			{
				var id = JSO.Forms.SimpleDialog.Elements.GetId (elementInfo);
				
				JSO.Forms.SimpleDialog.PostBuildEvents.push( function(){
					RegExpInputCheck.registerInput($(id),
						{
							maxLength			: 3
							,cssClassSuccess	: null
							,cssClassError		: "input-failure"
							,regExp				: /^[0-9]*$/gi
							,errorMessage		: "Es sind nur Zahlen erlaubt"
						}
					);
					}
				);
				
				return "<div " + (elementInfo.position ? "style=\"float:" + elementInfo.position + "\"" : "") + 
				
				" class=\"element type-text " + (elementInfo.fullLine ? " full-line":"") + "\"><label for=\"" + id + "\">" + elementInfo.title + "</label>" + (elementInfo.labelOnNewLine ? "<div class=clear></div>" : "") + 
				"<input  onfocus=\"ClassNameManager.extend(this);this.addClassName ('onfocus')\" onblur=\"this.removeClassName('onfocus')\"  value=\""  + HtmlEncode(elementInfo.defaultValue || "") + "\" style=\""+(elementInfo.style || "") + "\" type=text id=\""  + id + "\"></div>";
			}
			,GetInputValue : function (elementInfo)
			{
				var id = JSO.Forms.SimpleDialog.Elements.GetId (elementInfo);
				var inputElement = $(id);
				if (!inputElement) return null;
				return inputElement.value;
			}
		}
		,Email : {
			Add : function (elementInfo)
			{
				var id = JSO.Forms.SimpleDialog.Elements.GetId (elementInfo);
				
				JSO.Forms.SimpleDialog.PostBuildEvents.push( function(){
					RegExpInputCheck.registerInput($(id),
						{
							maxLength			: 0
							,cssClassSuccess	: null
							,cssClassError		: "input-failure"
							,regExp				: /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})$/gi
							,errorMessage		: "Die Eingabe ist keine gültige Email-Adresse"
						}
					);
					}
				);
				
				return "<div " + (elementInfo.position ? "style=\"float:" + elementInfo.position + "\"" : "") + 
				
				" class=\"element type-text " + (elementInfo.fullLine ? " full-line":"") + "\"><label for=\"" + id + "\">" + elementInfo.title + "</label>" + (elementInfo.labelOnNewLine ? "<div class=clear></div>" : "") + 
				"<input  onfocus=\"ClassNameManager.extend(this);this.addClassName ('onfocus')\" onblur=\"this.removeClassName('onfocus')\"  value=\""  + HtmlEncode(elementInfo.defaultValue || "") + "\" style=\""+(elementInfo.style || "") + "\" type=text id=\""  + id + "\"></div>";
			}
			,GetInputValue : function (elementInfo)
			{
				var id = JSO.Forms.SimpleDialog.Elements.GetId (elementInfo);
				var inputElement = $(id);
				if (!inputElement) return null;
				return inputElement.value;
			}
		}
		,DateTime : {
			Add : function (elementInfo)
			{
				var id = JSO.Forms.SimpleDialog.Elements.GetId (elementInfo);
				JSO.Forms.SimpleDialog.PostBuildEvents.push( function(){addCalendar($(id), "blue");});
				
				return "<div " + (elementInfo.position ? "style=\"float:" + elementInfo.position + "\"" : "") +
					" class=\"element type-text " + (elementInfo.fullLine ? " full-line":"") + "\"><label for=\"" + id + "\">" + elementInfo.title + "</label>" + (elementInfo.labelOnNewLine ? "<div class=clear></div>" : "") + 
					"<input  onfocus=\"ClassNameManager.extend(this);this.addClassName ('onfocus')\" onblur=\"this.removeClassName('onfocus')\"  value=\""  + HtmlEncode(elementInfo.defaultValue || "") + "\" size=19 maxlength=19 type=text id=\""  + id + "\"></div>";
				
			}
			,GetInputValue : function (elementInfo)
			{
				var id = JSO.Forms.SimpleDialog.Elements.GetId (elementInfo);
				var inputElement = $(id);
				if (!inputElement) return null;
				return inputElement.value;
			}
		}
		,Memo : {
			Add : function (elementInfo)
			{
				var id = JSO.Forms.SimpleDialog.Elements.GetId (elementInfo);
				return "<div " + (elementInfo.position ? "style=\"float:" + elementInfo.position + "\"" : "") + 
				" class=\"element type-memo " + (elementInfo.fullLine ? " full-line":"") + "\"><label for=\"" + id + "\">" + elementInfo.title + "</label>" + (elementInfo.labelOnNewLine ? "<div class=clear></div>" : "") + "<textarea   onfocus=\"ClassNameManager.extend(this);this.addClassName ('onfocus')\" onblur=\"this.removeClassName('onfocus')\"  style=\""+(elementInfo.style || "") + "\" id=\""  + id + "\">" + (elementInfo.defaultValue || "") + "</textarea></div>";
			}
			,GetInputValue : function (elementInfo)
			{
				var id = JSO.Forms.SimpleDialog.Elements.GetId (elementInfo);
				var inputElement = $(id);
				if (!inputElement) return null;
				return inputElement.value;
			}
		}
		,List : {
			Add : function (elementInfo)
			{
				var id = JSO.Forms.SimpleDialog.Elements.GetId (elementInfo);
				var html = "<div " + (elementInfo.position ? "style=\"float:" + elementInfo.position + "\"" : "") + 
				 
				" class=\"element type-list " + (elementInfo.fullLine ? " full-line":"") + "\"><label for=\"" + id + "\">" + elementInfo.title + "</label>" + (elementInfo.labelOnNewLine ? "<div class=clear></div>" : "") + "<select style=\"" + (elementInfo.style || "") + "\" id=\""  + id + "\"><option value=\"\">-Bitte w&auml;hlen-</option>";
				for (var i=0; i < elementInfo.values.length; i++)
				{
					var valueOption = elementInfo.values [i];
					html+="<option value=\"" + valueOption.id + "\" " + 
						(valueOption.id == elementInfo.defaultValue ? " selected ": "") + 
						">" + valueOption.val + "</option>";
				}
				return html + "</select></div>";
			}
			,GetInputValue : function (elementInfo)
			{
				var id = JSO.Forms.SimpleDialog.Elements.GetId (elementInfo);
				var inputElement = $(id);
				if (!inputElement) return null;
				if (inputElement.selectedIndex <= 0) return null;
				return inputElement.value;
			}
		}
		,Radio : {
			Add : function (elementInfo)
			{
				var id = JSO.Forms.SimpleDialog.Elements.GetId (elementInfo);
				return "<div " + (elementInfo.position ? "style=\"float:" + elementInfo.position + "\"" : "") + 
				" class=\"element type-radio " + (elementInfo.fullLine ? " full-line":"") + "\"><input  type=radio " + 
				 (elementInfo.defaultValue == true ? " checked ": "") + 
				 (elementInfo.group ? " name=\"" + elementInfo.group + "\"" : "") + 
				" style=\"" + (elementInfo.style || "") + "\" id=\""  + id + "\"><label for=\"" + id + "\">" + elementInfo.title + "</label></div>";
			}
			,GetInputValue : function (elementInfo)
			{
				var id = JSO.Forms.SimpleDialog.Elements.GetId (elementInfo);
				var inputElement = $(id);
				if (!inputElement) return false;
				return inputElement.checked;
			}
		}
		,Checkbox : {
			Add : function (elementInfo)
			{
				var id = JSO.Forms.SimpleDialog.Elements.GetId (elementInfo);
				return "<div " + (elementInfo.position ? "style=\"float:" + elementInfo.position + "\"" : "") + 
				 
				" class=\"element type-checkbox " + (elementInfo.fullLine ? " full-line":"") + "\"><input   type=checkbox " + 
				 (elementInfo.defaultValue == true ? " checked ": "") + 				 
				" style=\"float:left;" + (elementInfo.style || "") + "\" id=\""  + id + "\"><label style=\"float:left\" for=\"" + id + "\">" + elementInfo.title + "</label></div>";
			}
			,GetInputValue : function (elementInfo)
			{
				var id = JSO.Forms.SimpleDialog.Elements.GetId (elementInfo);
				var inputElement = $(id);
				if (!inputElement) return false;
				return inputElement.checked;
			}
		}
	}
	,BuildForm : function (formElements)
	{
		if (!formElements) return;
		var formHtml = "";
		for (var i=0; i < formElements.length; i++)
		{
			var elementInfo = formElements [i];
			var formElementInfo = JSO.Forms.SimpleDialog.Elements [elementInfo.type];
			if (!formElementInfo)
			{
				alert ("JSO.Forms.SimpleDialog.Elements." + elementInfo.type + " not supported!");
				continue;
			}
			formHtml += JSO.Forms.SimpleDialog.Elements [elementInfo.type].Add (elementInfo);
		}
		
		JSO.Forms.SimpleDialog.Text.innerHTML = formHtml;
		
		//Check post build events
		if (JSO.Forms.SimpleDialog.PostBuildEvents!=null)
			for (var e=0; e < JSO.Forms.SimpleDialog.PostBuildEvents.length; e++)
			{
				JSO.Forms.SimpleDialog.PostBuildEvents [e] ();
			}
	}
	
	,Hide : function ()
	{
		JSO.Forms.SimpleDialog.Dialog.style.display = "none";
		JSO.Forms.SimpleDialog.Background.style.display = "none";
		JSO.Forms.SimpleDialog.IframeBackground.style.display = "none"; 
		
		//Remove onresize event 
		removeEvent (window, "onresize", JSO.Forms.SimpleDialog.SetPosition);

		//Remove enter/cancel key event
		removeEvent (document.body, "onkeyup", JSO.Forms.SimpleDialog.CheckFormKeyEvent);

	}
	,SetPosition : function ()
	{
		if (JSO.Forms.SimpleDialog.Dialog == null) return;
		if (JSO.Forms.SimpleDialog.Dialog.style.display == "none") return;
		
		var pageSize = getClientSize (true);
			var clientWidth = (document.documentElement && document.documentElement.clientWidth  ?
			document.documentElement.clientWidth : pageSize [0]);
		var clientHeight = (document.documentElement && document.documentElement.clientHeight  ?
			document.documentElement.clientHeight : pageSize [1]);
				
		var dlgSize = getObjectSize (JSO.Forms.SimpleDialog.Dialog);
		
		var scroll = JSO.Layout.GetScroll (document);
		
		var left = (clientWidth - dlgSize [0])/2 + scroll.left;
		var top = (clientHeight - dlgSize [1] )/2 + scroll.top;


		if(document.body.scrollTop)
			top += document.body.scrollTop;

		JSO.Forms.SimpleDialog.Dialog.style.left = left;
		JSO.Forms.SimpleDialog.Dialog.style.top = top;
		var backgroundHeight = pageSize [1];
		//Check scroll height
		if (document.body.scrollHeight > backgroundHeight)
			backgroundHeight = document.body.scrollHeight;
		
		JSO.Forms.SimpleDialog.Background.style.width = JSO.Forms.SimpleDialog.IframeBackground.style.width = pageSize[0];
		JSO.Forms.SimpleDialog.Background.style.height = JSO.Forms.SimpleDialog.IframeBackground.style.height = backgroundHeight;

	}
	
	,CreateDialog : function ()
	{
		importStylesheet (getVirtualPath () + "multimed/message-box/main.css", "messageBoxCss");
		
		//Create iframe background 
		var iframeBgHtml = "<iframe scrolling=no frameborder=0 id=\"Dialog-#1-IframeBackground\" class=\"jso-message-box-page-background\"></iframe>";
		document.body.insertAdjacentHTML ("beforeEnd", iframeBgHtml);
		JSO.Forms.SimpleDialog.IframeBackground = $(JSO.Forms.SimpleDialog.ID + "-IframeBackground");
		
		
		//Create background 
		var bgHtml = "<div id=\"Dialog-#1-Background\" class=\"jso-message-box-page-background\"></div>";
		document.body.insertAdjacentHTML ("beforeEnd", bgHtml);
		JSO.Forms.SimpleDialog.Background = $(JSO.Forms.SimpleDialog.ID + "-Background");
			
		//DIALOG HTML TEXT BEGIN -----------------------------------------------
		var dlgHtml = "<div id=\"Dialog-#1\" class=\"simple-dialog jso-message-box type-ok-cancel\" style=\"height: auto\" onclick=\"JSO.Forms.SimpleDialog.EvalClickEvent(event)\"><div class=\"message-box-shadow\"><!-- Header --><div class=\"message-box-title-left\"><div class=\"message-box-title-right\"><div class=\"message-box-title-center\"><div class=\"message-box-title\"><div dlgButtonType=\"cancel\" title=\"SchlieÃŸen\" style=\"display: block; position: relative\" class=\"message-box-toolbutton toolbutton-close\"	 onmouseover=\"this.className+=' highlight'\"	 onmouseout=\"this.className ='message-box-toolbutton toolbutton-close'\"></div><span class=\"message-box-title-text\"  id=\"Dialog-#1-Caption\"></span></div></div></div></div><!-- Body --><div class=\"message-box-body\"><div class=\"message-box-text-left\"><div class=\"message-box-text-right\"><div class=\"message-box-text-center\"><div class=\"message-box-text-body\"><div ><div class=\"jso-message-box-icon\"></div><div class=\"message-box-content\"><div class=\"message-box-content-text\" id=\"Dialog-#1-Text\"></div></div></div></div></div></div></div><div class=\"message-box-buttons-left\"><div class=\"message-box-buttons-right\"><div class=\"message-box-buttons-center\"><div class=\"message-box-buttons-body\"><div class=\"message-box-buttons-container\"><div class=\"message-box-buttons-content\"><div class=\"jso-mb-buttons-set\"><div id=\"Dialog-Button-OK-#1\"  dlgButtonType=\"ok\" class=\"jso-mb-button btn-ok\" onmouseover=\"this.className+=' highlight'\"     onmouseout=\"this.className='jso-mb-button btn-ok'\">OK</div><div id=\"Dialog-Button-YES-#1\" dlgButtonType=\"yes\" class=\"jso-mb-button btn-yes\" onmouseover=\"this.className+=' highlight'\"     onmouseout=\"this.className='jso-mb-button btn-yes'\">Ja</div><div id=\"Dialog-Button-NO-#1\" dlgButtonType=\"no\" class=\"jso-mb-button btn-no\" onmouseover=\"this.className+=' highlight'\"     onmouseout=\"this.className='jso-mb-button btn-no'\">Nein</div><div id=\"Dialog-Button-CANCEL-#1\" dlgButtonType=\"cancel\" class=\"jso-mb-button btn-cancel\" onmouseover=\"this.className+=' highlight'\"     onmouseout=\"this.className='jso-mb-button btn-cancel'\">Abbrechen</div></div></div></div></div></div></div></div></div></div></div>";

		
			//DIALOG HTML TEXT END -----------------------------------------------
			document.body.insertAdjacentHTML ("beforeEnd", dlgHtml);
			
			JSO.Forms.SimpleDialog.Dialog = $(JSO.Forms.SimpleDialog.ID);
			JSO.Forms.SimpleDialog.Dialog.style.width = String (JSO.Forms.SimpleDialog.DialogWidth) + "px";
			JSO.Forms.SimpleDialog.Caption = $(JSO.Forms.SimpleDialog.ID + "-Caption");
			JSO.Forms.SimpleDialog.Text = $(JSO.Forms.SimpleDialog.ID + "-Text");
			
			ClassNameManager.extend (JSO.Forms.SimpleDialog.Dialog);
			
			if (window.Drag)
				window.Drag.init (JSO.Forms.SimpleDialog.Caption.parentNode.parentNode.parentNode.parentNode, JSO.Forms.SimpleDialog.Dialog);
	}
	
	,EvalClickEvent: function (e)
	{
		var src = getEventSource (e);
		if (!src) return;
		if (!src.dlgButtonType) return;
		
		var btnType = src.dlgButtonType;
		var inputData = JSO.Forms.SimpleDialog.GetInputData ();
		
		JSO.Forms.SimpleDialog.ExecuteAction (btnType, inputData);
	}	
	,GetInputData : function ()
	{
		if (!JSO.Forms.SimpleDialog.FormElements) return;
		var inputData = {};
		
		for (var i=0; i < JSO.Forms.SimpleDialog.FormElements.length; i++)
		{
			var elementInfo = JSO.Forms.SimpleDialog.FormElements [i];
			var formElementInfo = JSO.Forms.SimpleDialog.Elements [elementInfo.type];
			if (!formElementInfo)
			{
				continue;
			}
			if (!formElementInfo.GetInputValue) continue;
			
			var currentValue = formElementInfo.GetInputValue (elementInfo);
			inputData [elementInfo.name] = currentValue;
		}
		
		return inputData;
	}
	,ExecuteAction: function (dialogResult, inputData)
	{
		if (JSO.Forms.SimpleDialog.Dialog.CallBack)
			JSO.Forms.SimpleDialog.Dialog.CallBack (dialogResult, inputData);
		
		if (dialogResult == JSO.MessageBox.DialogResult.OK && JSO.Forms.SimpleDialog.KeepOpened) return;

		JSO.Forms.SimpleDialog.Hide();
	}

};
JSO.Forms.DropdownList = {
	//Variables	
	_ClassId : "JSO-DropdownList"
	,_Instances: new Array ()
	,_Items: new Array()
	
	//Objects
	
	//HTML codes
	,_Html : {
		List: "<div class=\"jdl-left\"><div class=\"jdl-right\"><div class=\"jdl-middle\"><div class=\"jdl-text\" id=\"_TITLE_ID_\"></div></div></div>"
		,ItemsPanel: "<div class=\"jdl-ip-top\"><div class=\"jdl-ip-left\"><div class=\"jdl-ip-right\"><div class=\"jdl-ip-middle\">&nbsp;</div></div></div></div><div class=\"jdl-ip-body\" ><div class=\"jdl-ip-left\"><div class=\"jdl-ip-right\"><div class=\"jdl-ip-middle\" id=\"_BODY_ID_\"></div></div></div></div><div class=\"jdl-ip-bottom\"><div class=\"jdl-ip-left\"><div class=\"jdl-ip-right\"><div class=\"jdl-ip-middle\">&nbsp;</div></div></div></div>"
		,Item: "<div class=\"jdl-item-left\"><div class=\"jdl-item-right\"><div class=\"jdl-item-middle\" id=\"_TITLE_ID_\"><SPAN class=\"filter_state\">&nbsp;</SPAN><SPAN class=\"title-text\">_TITLE_</SPAN></div></div></div>"
	}
	//Classes
	,List : function (id)
	{
		this._items = [];
		this.offset = [0,0];
		this.id = JSO.Forms.DropdownList._ClassId  + id;
		this.fixWidth = 0;
		this.selectedIndex = -1;
		this.multipleSelection = false;
		
		this.GetObject = function ()
		{
			return $(this.id);
		};
		this.GetListObject = function ()
		{
			return $(this.id);
		};
		this.GetTitleObject = function ()
		{
			return $(this.id + "Title");
		};
		this.GetPanelObject = function ()
		{
			return $(this.id + "ItemsPanel");
		};
		this.GetPanelBodyObject = function ()
		{
			return $(this.id + "ItemsPanelBody");
		};
		this.Create = function (parent) {
			
			//Create the title object
			var div = JSO.Forms.DropdownList.Factory.List(this);
			if (!parent)
			{
				parent = document.body;
				div.style.position = "absolute";
				
			}
			//Add events
			var listId = this.id;
			var list = this;
			addEvent(div, "onclick", function (e){list.DisplayList (listId,e);});
			addEvent(document,"click", function(e){list.Hide(e)});

			parent.appendChild (div);
			
			
			//Create the items panel
			var panel = JSO.Forms.DropdownList.Factory.Panel(this);			
			parent.appendChild (panel);
			
		};
		this.AddItem = function (itemInfo)
		{
			this._items.push (itemInfo);
			itemInfo.index = this._items.length-1;
			JSO.Forms.DropdownList.AddItem (this, itemInfo);
		};
		
		this.AddItems = function (collection)
		{
			if (!collection) return;
			for (var i=0; i < collection.length; i++)
			{
				this.AddItem(collection[i]);
			}
			
		};
			
		
		this.SetTitle = function (title)
		{
			var div = this.GetTitleObject();
			
			if (div) div.innerHTML = title;
			
		}
		this.Display = function ()
		{
			var div = this.GetListObject();
			if (div) div.style.visibility = "visible";
			
		}
		this.DisplayList = function(id,e)
		{
			if (e) if (e.stopPropagation) e.stopPropagation(); else e.cancelBubble = true;
				
			var div = (id ? $(id + "ItemsPanel") : this.GetPanelObject());
			if (!div) return;
			var list = (id ? $(id) : this.GetListObject());
			if (!list) return;
			this.SetPanelPosition (list, div);
			div.style.visibility = "visible";
		}
		this.SetPanelPosition = function (list, panel)
		{
			var pos = JSO.Layout.GetPosition(list);
			var size = JSO.Layout.GetSize (list);
			
			var x = pos[0]-2 + this.offset[0];
			var y = pos[1] + size[1]-2 + this.offset[1];
			
			//Adjust x, y 
			var totalSize = getObjectSize (panel);
			var clientSize = getClientSize ();
		
			if ((y + totalSize [1]) > clientSize [1])
				y = clientSize [1] - totalSize [1] + this.offset[1];
			if (y < 0) y = 0;
			
			if ((x + totalSize [0]) > clientSize [0])
			{
				//Doc to the right of the list				
				x = pos[0]+ size[0] - totalSize [0] + this.offset[0];
			}
			
			if (x < 0) x = 0;
			
			panel.style.left = String(x) + "px";
			panel.style.top = String(y) + "px"; 
			
		}
		this.Hide = function (e	)
		{
			var div = this.GetPanelObject();
			
			if (div) div.style.visibility = "hidden";
			
		}
		this.ClearList = function ()
		{
			this._items = new Array();
			var panel = this.GetPanelBodyObject();
			if (panel) panel.innerHTML = "";
		}
	}
	,ItemInfo: function (title, action, icon, selected, id, toggelable)
	{
		this.id = id;
		this.title = title;
		this.selected = (selected == true);
		this.action = action;
		this.icon = icon;
		this.toggelable = toggelable == true; 
		this.active = true;
		
		
	}
	//Methods
	,Create : function (id, parent, fixWidth)
	{
		var listInfo = new JSO.Forms.DropdownList.List(id);
		listInfo.fixWidth = fixWidth;
		listInfo.Create(parent);
		
		JSO.Forms.DropdownList._Instances [id] = listInfo;
		
		return listInfo;
	}
	,AddItem : function (listInfo, itemInfo)
	{
		itemInfo.listId = listInfo.id;
		if(!itemInfo.id) itemInfo.id = listInfo.id + "-Item-" + listInfo._items.length;
		JSO.Forms.DropdownList._Items[itemInfo.id] = itemInfo;
		
		itemInfo.active = !(itemInfo.active == false);
		if (itemInfo.active)
			listInfo.selectedIndex = listInfo._items.length-1;
			
		var div = JSO.Forms.DropdownList.Factory.Item (itemInfo, listInfo);
		
		
		//Events
		addEvent (div, ["onmouseover", "onmouseout"], JSO.Forms.DropdownList.Events.Items.Mouse);
		if (itemInfo.action)
		{
			addEvent (div, "onclick", JSO.Forms.DropdownList.Events.Items.Click);
		}
		
		var itemsPanelBody = listInfo.GetPanelBodyObject();
		if (!itemsPanelBody) return;
		itemsPanelBody.appendChild (div);
		
		//Need resizing?
		var itemsPanel = listInfo.GetPanelObject();
		if (!itemsPanel) return;
		var itemWidth = div.offsetWidth + 11;
		if (itemWidth > itemsPanel.firstChild.offsetWidth)
		{
			//Set max
			if (itemWidth > 400)
			{
				itemWidth = 400;
				div.firstChild.firstChild.firstChild.style.width = String(400-19) + "px";
			}
			itemsPanel.style.width = itemsPanel.firstChild.style.width = itemsPanel.lastChild.style.width = itemWidth;//Panel top
			
		}
	}
	//DOM factory
	,Factory : {
		List : function (listInfo)
		{
			var div = document.createElement("DIV");
			div.style.visibility = "hidden";
			div.innerHTML = JSO.Forms.DropdownList._Html.List.replace("_TITLE_ID_", 
				listInfo.id + "Title");
			div.className = "jso-dropdownlist";
			if(listInfo.fixWidth) div.firstChild.firstChild.firstChild.firstChild.
				style.width = String(listInfo.fixWidth-14) + "px";
			div.id= listInfo.id;
			JSO.GarbageCollector.Collect (div.id);
			return div;
		}
		,Panel : function (listInfo)
		{
			var div = document.createElement("DIV");
			div.style.visibility = "hidden";
			div.style.position = "absolute";//Always!
			div.style.left = "0px";
			div.style.top = "0px";
			div.innerHTML =  JSO.Forms.DropdownList._Html.ItemsPanel.replace("_BODY_ID_", 
				listInfo.id + "ItemsPanelBody");
				
			div.className = "jso-dropdownlist-items-panel";
			div.id= listInfo.id + "ItemsPanel";
			JSO.GarbageCollector.Collect (div.id);
			return div;
		}
		,Item : function (itemInfo, listInfo)
		{
			var div = document.createElement("DIV");
			div.innerHTML =  JSO.Forms.DropdownList._Html.Item.replace("_TITLE_ID_", 
				itemInfo.id+"Title").replace("_TITLE_",
				(itemInfo.icon ? "<img border=0 align=absmiddle src=\"" + itemInfo.icon + "\"> " : "")+ 
				itemInfo.title);
			div.className = "jdl-item no-background";
			
			if (!itemInfo.toggelable && itemInfo.noState!=true) 
			{
				if (itemInfo.active)	
				{
					ClassNameManager.fly(div).addClassName ("no-state-change"); 
					ClassNameManager.fly(div).addClassName ("no-toggle-active"); 
					
				}	
				else
				{
					ClassNameManager.fly(div).addClassName ("no-state-change"); 
					ClassNameManager.fly(div).addClassName ("no-toggle-inactive"); 
					
				}
			}
			else if (!itemInfo.toggelable)
				ClassNameManager.fly(div).addClassName ("no-state-change");	
				
			
			div.id= itemInfo.id;
			div.isItem = true;
			
			
			JSO.GarbageCollector.Collect (div.id);
			return div;
		}
		
	}
	//Events
	,Events : {
		Items: {
			Mouse: function (e)
			{
				var div = JSO.DOM.GetParent.ByProperty (getEventSource(e), "isItem", true);
				if (!div) return;
				
				if (e.type == "mouseover")
				{
					ClassNameManager.fly(div).removeClassName("no-background");
				}
				else
					ClassNameManager.fly(div).addClassName("no-background");
			}
			,Click : function(e)
			{
				//if (e) if (e.stopPropagation) e.stopPropagation(); else e.cancelBubble = true;
				var div = JSO.DOM.GetParent.ByProperty (getEventSource(e), "isItem", true);
				if (!div) return;
				
				var itemInfo = JSO.Forms.DropdownList._Items [div.id];
				if (!itemInfo) return;
				
				var listInfo = JSO.Forms.DropdownList._Instances [itemInfo.listId.substr(JSO.Forms.DropdownList._ClassId.length)];
				
				//Change the state of the current active item
				var currentItem =  listInfo._items [listInfo.selectedIndex];
				if (currentItem && currentItem!=itemInfo)
				{
					if (!currentItem.toggelable && currentItem.noState!=true)
					{
						currentItem.active = false;
						var itemDiv = $(currentItem.id);
						if (currentItem.active)
						{
							ClassNameManager.fly(itemDiv).addClassName ("no-toggle-active");
							ClassNameManager.fly(itemDiv).removeClassName ("no-toggle-inactive");	
						}
						else
						{
							ClassNameManager.fly(itemDiv).addClassName ("no-toggle-inactive");
							ClassNameManager.fly(itemDiv).removeClassName ("no-toggle-active");	
						}
						
					}
				}
				
				//Change toggle state
							
				if (itemInfo.toggelable)
				{
					itemInfo.active = !itemInfo.active;		
					ClassNameManager.fly(div).toggleClassName ("inactive");
				}
				else if (itemInfo.noState!=true)
				{
					itemInfo.active = true;
					var fly = ClassNameManager.fly(div);
					
					
					if (itemInfo.active)
					{
						fly.addClassName ("no-toggle-active");
						fly.removeClassName ("no-toggle-inactive");	
					}
					else
					{
						fly.addClassName ("no-toggle-inactive");
						fly.removeClassName ("no-toggle-active");	
					}
					
					
				}
				
				listInfo.selectedIndex = itemInfo.index;
				if(itemInfo.action)
					itemInfo.action (itemInfo);
			}
		}
	}
	
}
/************************************************************************
*																		*
*	Class ResizablePanel v1.0 											*
*																		*
*************************************************************************/
JSO.Forms.ResizablePanel = {
	_instances : []
	,_borderParts : ["top", "bottom", "right", "left", "topright", "topleft", "bottomright", "bottomleft"]
	
	,ClassId : "JSO-ResizablePanel"
	,Proxy : null
	
	,GetInstance : function (id, withIndex)
	{
		for (var i=0; i < JSO.Forms.ResizablePanel._instances.length; i++)
		{
			if (JSO.Forms.ResizablePanel._instances[i].id == id) 
			{
				var instance = JSO.Forms.ResizablePanel._instances[i];
				if (withIndex == true)
					return [instance, i];
				else
					return instance;
			}
		}
	}
	/** Class ResizablePanel **/
	,PanelClass : function (id, container)
	{
		this.id = id;
		this.dom = container;
		this.getBody = function ()
		{
			return $(JSO.Forms.ResizablePanel.ClassId + "-BodyContent-" + this.id)
		}
		this.getObject = function (objectPart)
		{
			return $(JSO.Forms.ResizablePanel.ClassId + "-" + objectPart + "-" + this.id)
		}
		this.createBorders = function ()
		{
			for (var i=0, d=JSO.Forms.ResizablePanel._borderParts.length; i < d; i++)	
				this.dom.appendChild (JSO.DOM.Node ("DIV", 
						{ className : "resizable-border border-" + JSO.Forms.ResizablePanel._borderParts[i]
							,direction : JSO.Forms.ResizablePanel._borderParts[i]
							,panelId : id
						}
					,[JSO.DOM.TextNode ("")]));
		}
		this.initEvents = function ()
		{
			addEvent (container, "mousedown", JSO.Forms.ResizablePanel.Events.Borders.Mouse);
			addEvent ([document], "mouseup", JSO.Forms.ResizablePanel.Events.Borders.Mouse);
			
			addEvent([this.getObject("ButtonMaximize"), this.getObject("ButtonMinimize"), this.getObject("ButtonClose")],
				["mouseover", "mouseout"], JSO.Forms.ResizablePanel.Events.Buttons.Mouse);
			
			addEvent(this.getObject("ButtonClose"),
				"click", JSO.Forms.ResizablePanel.Close);
			
			addEvent(this.getObject("ButtonMaximize"),
				"click", JSO.Forms.ResizablePanel.Maximize);
				
			addEvent(this.getObject("ButtonMinimize"),
				"click", JSO.Forms.ResizablePanel.Minimize);
				
				
		}
		this.createBorders();
		this.initEvents ();
		this.setTitle = function (title)
		{
			var headerText = $(JSO.Forms.ResizablePanel.ClassId + "-PanelHeaderText-" + this.id);
			if (headerText) headerText.innerHTML = title;
		}
		var curPos = $obj(container).pos();
		Drag.init ($(JSO.Forms.ResizablePanel.ClassId + "-TitleContainer-" + this.id),container);
		container.style.left = curPos[0];
		container.style.top = curPos[1];
	}
	
	/** Converting an existing panel **/
	,Convert: function (el, title)
	{
		if (!el) return;
		ClassNameManager.fly( el ).addClassName ("resizable-contents");
		
		var id = generateNewGuid(true);	
		
		var container = JSO.Forms.ResizablePanel.Factory.Container(id);
		el.parentNode.insertBefore (container, el);
		
		var elementPos = $obj(el).pos();
		
		container.style.left = elementPos[0];
		container.style.top = elementPos[1];
		el.style.position = "relative";
		el.style.left = "0px";
		el.style.top = "0px";
		
		
		var contentBody = $(JSO.Forms.ResizablePanel.ClassId + "-BodyContent-" + id);
		contentBody.appendChild (el);
		
		var cls = new JSO.Forms.ResizablePanel.PanelClass(id, container);
		
		if (JSO.Forms.ResizablePanel.Proxy == null)
			JSO.Forms.ResizablePanel.Proxy = JSO.Forms.ResizablePanel.Factory.Proxy (id);
		
		JSO.Forms.ResizablePanel._instances.push(cls);
		cls.setTitle (title);
		
		JSO.Forms.ResizablePanel.ResizeInnerElements(id);
		
		return cls;
	}
	
	/**
	 * Creating a new panel
	 * @param {} options: { title: "Some title", text:  "Some text", width: 300, height:200, left:300, top: 100}
	 * 
	 */
	,Create: function (options)
	{
		var id = generateNewGuid(true);	
		if (!options) options = { title: "&nbsp;", text:  "&nbsp;", width: 300, height:300, left:0, top: 0};
		var container = JSO.Forms.ResizablePanel.Factory.Container(id);
		document.body.appendChild(container);
		
		if (options)
		{
			 
			container.style.left = int (options.left).toString() + "px";
			container.style.top = int (options.top).toString() + "px";
			
			if (!isEmpty(options.width)) container.style.width = int (options.width).toString() + "px";
			if (!isEmpty(options.height)) container.style.height = int (options.height).toString() + "px";
		}
		
		
		
		var contentBody = $(JSO.Forms.ResizablePanel.ClassId + "-BodyContent-" + id);
		contentBody.innerHTML = "<div class=\"resizable-contents\">" + (options.text || "&nbsp;") + "</div>";
		
		var cls = new JSO.Forms.ResizablePanel.PanelClass(id, container);
		
		if (JSO.Forms.ResizablePanel.Proxy == null)
			JSO.Forms.ResizablePanel.Proxy = JSO.Forms.ResizablePanel.Factory.Proxy (id);
		
		JSO.Forms.ResizablePanel._instances.push(cls);
		cls.setTitle (options.title || "&nbsp;");
		
		JSO.Forms.ResizablePanel.ResizeInnerElements(id, options.width, options.height);
		
		
		return cls;
	}
	,Close : function (e)
	{
		if (!e) return;
		var button = $e(e).src;
		
		//Disposing
		var def = JSO.Forms.ResizablePanel.GetInstance(button.panelId,true);
		if (!def) return;
		
		var panelCls =def [0];
		var index = def [1];
		JSO.Forms.ResizablePanel._instances.slice(index,1);
		
		var panel = panelCls.dom;
		if (!panel) return;
		if (panelCls.onDispose) panelCls.onDispose();
		delete panelCls;
		panel.parentNode.removeChild(panel);		
	}
	,Maximize : function (e)
	{
		if (!e) return;
		var button = $e(e).src;
		
		//Disposing
		var panelCls = JSO.Forms.ResizablePanel.GetInstance(button.panelId);
		
		var panel = panelCls.dom;
		
		//Save primer values
		panelCls.zIndex = panel.style.zIndex;
		panelCls.startWidth = $obj(panel).width();
		panelCls.startHeight = $obj(panel).height();
		panelCls.startLeft = int(panel.style.left);
		panelCls.startTop = int(panel.style.top);
		
		document.body.origOverflow = JSO.Layout.GetCssValue(document.body, "overflow");
		document.body.style.overflow = "hidden";
		(document.documentElement || document.body).scrollTop = 0;
		(document.documentElement || document.body).scrollLeft = 0;
		
		var clientSize = getClientSize();
		panel.style.width =  clientSize [0] + int(JSO.Layout.GetCssValue(document.body,"padding-left")) -
			int(JSO.Layout.GetCssValue(document.body,"padding-right"));
		panel.style.height =  clientSize [1] + int(JSO.Layout.GetCssValue(document.body,"padding-top")) -
			int(JSO.Layout.GetCssValue(document.body,"padding-bottom"));
		panel.style.left = "0px";
		panel.style.top = "0px";
		
		
		panel.style.zIndex = 100 + JSO.Forms.ResizablePanel._instances.length + 1;
		
		ClassNameManager.fly(panel).changeClassName ("normal-size", "maximized-size");
		
		JSO.Forms.ResizablePanel.ResizeInnerElements(panelCls.id, int(panel.style.width), int(panel.style.height));
	}
	,Minimize : function (e)
	{
		if (!e) return;
		var button = $e(e).src;
		
		//Disposing
		var panelCls = JSO.Forms.ResizablePanel.GetInstance(button.panelId);
		
		var panel = panelCls.dom;
		
		if (document.body.origOverflow)
			document.body.style.overflow = document.body.origOverflow;
		else
		{
			if(document.body.style.removeAttribute)
				document.body.style.removeAttribute("overflow");
			else
				document.body.style.overflow = "";
		}
		//Restore primer values
		panel.style.zIndex = panelCls.zIndex;
		panel.style.width = panelCls.startWidth.toString() + "px";
		panel.style.height = panelCls.startHeight.toString() + "px";
		panel.style.left = panelCls.startLeft.toString() + "px";
		panel.style.top = panelCls.startTop.toString() + "px";
		
		
		ClassNameManager.fly(panel).changeClassName ("maximized-size", "normal-size");
		
		JSO.Forms.ResizablePanel.ResizeInnerElements(panelCls.id,  panelCls.startWidth, panelCls.startHeight);
	}
	,Resizing : 
	{
		InProcess : false
		,Start : function (e,trigger)
		{
			var p = JSO.Forms.ResizablePanel.Proxy;
			p._direction = trigger.direction;
			e = $(e);
			var triggerPos = $obj(trigger).pos();
			
			p.offsetX = e.offsetX || (e.currentX - triggerPos[0]);
			p.offsetY = e.offsetY || (e.currentY - triggerPos[1]);
			
			p.startX = e.currentX;
			p.startY = e.currentY;
			
			p.lastX = p.offsetLeft;
			p.lastY = p.offsetTop;
			p.lastWidth  = p.startWidth = $obj(p).width();
			p.lastHeight = p.startHeight = $obj(p).height ();
			
			JSO.Forms.ResizablePanel.Resizing.InProcess = true;	
			
		}
		,Continue : function (e)
		{
			if(!JSO.Forms.ResizablePanel.Resizing.InProcess) return;
			if (!e) return;
			e = $e(e);
			e.stopDefault ();
			e.clearSelection();
			
			
			var p = JSO.Forms.ResizablePanel.Proxy;
			
			var leftPos = e.currentX;
			var topPos = e.currentY;
			var proxyPos = $obj(p).pos();
			var w = p.startWidth, h = p.startHeight, l = p.lastX, t = p.lastY;
			var x = proxyPos[0], y = proxyPos[1];
			
			switch (p._direction)
			{
				case "right":
					w = w + (leftPos - p.startX);
					if (w < 150) w = 150;
					
					break;	
				case "left":
				
					w = w + (p.startX - leftPos) - p.offsetX;
					if (w < 150) { w = 150; l = x; 0}
					else
						l = l + (leftPos - p.startX) + p.offsetX;
					break;	
				case "top":
				
					
					h = h + (p.startY - topPos) - p.offsetY;
					if (h < 100) { h = 100; t = y; }
					else t = t + (topPos - p.startY) + p.offsetY;
					break;
				case "bottom":
					h = h + (topPos - p.startY);
					if (h < 100) h = 100;
					break;	
				case "bottomright":
					w = w + (leftPos - p.startX);
					if (w < 150) w = 150;
					h = h + (topPos - p.startY);
					if (h < 100) h = 100;
					 
					break;	
				case "topright":
					h = h + (p.startY - topPos);
					if (h < 100)  { h = 100; t = y; }
					else t = t + (topPos - p.startY);
					w = w + (leftPos - p.startX);
					if (w < 150) w = 150;
					break;
				case "topleft":
					w = w + (p.startX - leftPos);
					if (w < 150){ w = 150; l = x; 0}
					else l = l + (leftPos - p.startX);
					h = h + (p.startY - topPos);
					if (h < 100)  { h = 100; t = y; }
					else t = t + (topPos - p.startY);
					break;
				case "bottomleft":
					h = h + (topPos - p.startY);
					if (h < 100) h = 100;
			
					w = w + (p.startX - leftPos);
					if (w < 150) { w = 150; l = x; 0}
					else l = l + (leftPos - p.startX);
					break;
			}
			
			//Check min size
			
			p.style.width = w.toString()+ "px";
			p.style.height = h.toString()+ "px";
			p.style.left = l.toString()+ "px";
			p.style.top = t.toString()+ "px";
			
			
		}
		,Stop : function (e)
		{
			JSO.Forms.ResizablePanel.Resizing.InProcess = false;
			JSO.Forms.ResizablePanel.ResizePanel();
			
		}
	}
	,Events :
	{
		Ignore : function (e)
		{
			return false;
		}
		,Buttons : 
		{
			Mouse : function (e)
			{
				if (!e) return;
				var button = $e(e).src;
				button.style.backgroundPositionX = (e.type =="mouseover" ? "-15px" : "0px");
			}
		}
		
		,Borders : 
		{
			Mouse: function (e)
			{
				var eventType = e.type;
				var trigger = $e(e).src;
				
				if (eventType == "mouseup")
				{
					if (JSO.Forms.ResizablePanel.Resizing.InProcess)
						JSO.Forms.ResizablePanel.Resizing.Stop(e,trigger);
					JSO.Forms.ResizablePanel.Proxy.style.display = "none";
					removeEvent ([document,document.body,trigger], "onmousemove", JSO.Forms.ResizablePanel.Resizing.Continue);
					removeEvent([document.body], "onselectstart", JSO.Forms.ResizablePanel.Events.Ignore);
					return true;
					
				}
				if (!ClassNameManager.fly(trigger).hasClassName ("resizable-border"))
					return true;
				
					
					
				var dir = trigger.direction;
				var panelId = trigger.panelId;
				
				
				var panel = $(JSO.Forms.ResizablePanel.ClassId + "-Container-" + panelId);
				
				
				if (!panel) return true;
				addEvent ([document,document.body,trigger], "onmousemove", JSO.Forms.ResizablePanel.Resizing.Continue);
				addEvent ([document.body], "onselectstart", JSO.Forms.ResizablePanel.Events.Ignore);
				
				JSO.Forms.ResizablePanel.ResizeProxy (panel);
				JSO.Forms.ResizablePanel.PositionProxy (panel);
				JSO.Forms.ResizablePanel.Proxy.style.display = "block";
				
				JSO.Forms.ResizablePanel.Resizing.Start(e,trigger);
				
				JSO.Forms.ResizablePanel.Resizing.CurrentId = panelId;
			
				
				
				return false;
			}
		}
	}
	,ResizeProxy : function (container)
	{
		var p = JSO.Forms.ResizablePanel.Proxy;
		
		p.style.width = $obj(container).width().toString() + "px";
		p.style.height = $obj(container).height().toString() + "px";
		
	}
	,ResizeInnerElements: function(panelId, panelWidth, panelHeight)
	{
		var container = $(JSO.Forms.ResizablePanel.ClassId + "-Container-" + panelId);
		if (!container) return;
		
		
		var w = panelWidth || $obj(container).width ();
		var h = panelHeight || $obj(container).height ();
		
		var contentBody = $(JSO.Forms.ResizablePanel.ClassId + "-BodyContent-" + panelId);
		if (!contentBody) return;
		
		contentBody.style.width = (w-14).toString() + "px";
		contentBody.style.height = (h-38).toString()+ "px";
		
		var headerText = $(JSO.Forms.ResizablePanel.ClassId + "-PanelHeaderText-" + panelId);
		if (!headerText) return;
		headerText.style.width = (w-50).toString() + "px";
	}
	,ResizePanel : function ()
	{
		var p = JSO.Forms.ResizablePanel.Proxy;
		var container = $(JSO.Forms.ResizablePanel.ClassId + "-Container-" + JSO.Forms.ResizablePanel.Resizing.CurrentId);
		if (!container) return;
		
		var w = $obj(p).width ();
		var h = $obj(p).height ();
		
		container.style.width = w.toString() + "px";
		container.style.height = h.toString() + "px";
		
		var pos = $obj(p).pos();
		
		container.style.left = pos [0].toString() + "px";
		container.style.top  = pos [1].toString() + "px";
		
		JSO.Forms.ResizablePanel.ResizeInnerElements(JSO.Forms.ResizablePanel.Resizing.CurrentId, w, h);
		
		
	}
	,PositionProxy : function (container)
	{
		var p = JSO.Forms.ResizablePanel.Proxy;
		var pos = $obj(container).pos();
		
		p.style.left = (pos [0]).toString() + "px";
		p.style.top = (pos [1]).toString() + "px";
	}
	,Factory : {
		Container : function (id)
		{
			//Container
			var container = JSO.DOM.Node ("DIV", { id: JSO.Forms.ResizablePanel.ClassId + "-Container-" + id, className : "resizable-panel-container normal-size"});
			
			//Title 
			container.appendChild (JSO.Forms.ResizablePanel.Factory.TitleContainer (id))
			
			//Body
			container.appendChild (JSO.Forms.ResizablePanel.Factory.BodyWrap (id))
			
			return container;
		}
		
		,Proxy : function ()
		{
			var proxy = JSO.DOM.Node ("DIV", {id: JSO.Forms.ResizablePanel.ClassId + "-Proxy" , className : "resizable-panel-proxy"},[JSO.DOM.TextNode (" ")] );
			document.body.appendChild(proxy);
			return proxy;
		}
		,TitleContainer : function (id)
		{
			var title  = JSO.DOM.Node ("DIV", 
					{ id: JSO.Forms.ResizablePanel.ClassId + "-TitleContainer-" + id, className : "title-container"}
				,
				[
					JSO.DOM.Node ("DIV", 
						{ className : "title-right"}
						,
						[
							JSO.DOM.Node ("DIV", { className : "title-center"}
								,[
									JSO.DOM.Node ("DIV", { className : "panel-header"}
									,[
										JSO.DOM.Node ("DIV", { className : "panel-toolbar"}, 
										[
											JSO.DOM.Node ("DIV", { panelId : id, id: JSO.Forms.ResizablePanel.ClassId + "-ButtonMaximize-" + id, className: "jso-rp-button button-maximize", title: "Maximieren"}
												,[JSO.DOM.TextNode(" ")])
											,JSO.DOM.Node ("DIV", { panelId : id,id: JSO.Forms.ResizablePanel.ClassId + "-ButtonMinimize-" + id, className: "jso-rp-button button-minimize", title: "Verkleinern"}
												,[JSO.DOM.TextNode(" ")])
											,JSO.DOM.Node ("DIV", { panelId : id, id: JSO.Forms.ResizablePanel.ClassId + "-ButtonClose-" + id, className: "jso-rp-button button-close", title: "Schließen"}
												,[JSO.DOM.TextNode(" ")])
										])
										,JSO.DOM.Node ("SPAN", { id: JSO.Forms.ResizablePanel.ClassId + "-PanelHeaderText-" + id, className : "panel-header-text"}, [JSO.DOM.TextNode ("Panel header text")])
									])
									
								]
							)
						]
					)
				]
			);
			
			return title;
			
		}
		
		,BodyWrap : function (id)
		{
			var bodyWrap  = JSO.DOM.Node ("DIV", 
				{ id: JSO.Forms.ResizablePanel.ClassId + "-BodyWrap-" + id, className : "body-wrap"}
				,[
					JSO.DOM.Node ("DIV", { className : "body-content-left"}
					,[
						JSO.DOM.Node ("DIV", { className : "body-content-right"}
						,[
							JSO.DOM.Node ("DIV", { className : "body-content-center"}
								,[
									JSO.DOM.Node ("DIV", { id: JSO.Forms.ResizablePanel.ClassId + "-BodyContent-" + id,  className : "body-content"})
								]
							)
						])
					])
					,JSO.DOM.Node ("DIV", { className : "body-footer-left"}
					,[
						JSO.DOM.Node ("DIV", { className : "body-footer-right"}
						,[
							JSO.DOM.Node ("DIV", { className : "body-footer-center"}
								,[
									JSO.DOM.Node ("DIV", { className : "body-footer"})
								]
							)
						])
					])
				]
			);
			
			return bodyWrap;
			
		}
	}
}
JSO.GarbageCollector = {
	Collection : {}
	
	,Collect: function (objId)
	{
		JSO.GarbageCollector.Collection [objId] = objId;
	}
	,Dispose : function (objId)
	{
		if (objId)
		{
			if (JSO.GarbageCollector.Collection [objId]);
			{
				$(objId).parentNode.removeChild ($(objId));
				JSO.GarbageCollector.Collection [objId] = null;
			}
		}
		else	 //Remove all
		{
			for (var objId in JSO.GarbageCollector.Collection)
				if ($(objId)) $(objId).parentNode.removeChild ($(objId));
		
		}
	}
}
JSO.Types = {};
JSO.Types.Array = function (origArray)
{
	this.array = origArray || new Array();
	
	this.concat = this.array.concat;
	this.join 	= this.array.join;
	this.pop 	= this.array.pop;
	this.push	= this.array.push;
	this.reverse= this.array.reverse;
	this.shift	= this.array.shift;
	this.slice	= this.array.slice;
	this.sort	= this.array.sort;
	this.slice	= this.array.splice;
	this.toString= this.array.toString;
	this.unshift = this.array.unshift;
	this.length = this.array.length;
	
	this.removeItemByValue = function (item)
	{
		if (!this.array || this.array.length == 0) return;
		for (var i=0; i < this.array.length; i++)
		{
			if (this.array[i] == item)
			{
				this.array.splice (i, 1);
				return;
			}
		}
	}
}

JSO.Texts = {};
JSO.Texts.Compare = function (oldText, newText)
{
	try
	{
		var result = SoapClient.GetPlainText ("POST", getVirtualPath() + "wizards/merging/htmlCompare.aspx", 
		"html_1=" + 
		escape(oldText) + "&" +  
		"html_2=" + escape(newText));
		
		var popup = window.open ("about:blank");
		popup.document.writeln (result);
	}catch (err){ alert$(err)}
}


 
/** 
 * Context menu functionality	
 * 
 * @syntax: Syntax for creating a menu:
 * 
 *  
 *   //Create menu
 *	var menu = JSO.ContextMenu.Add ("Test1", "Options", 255, "default", document);
 *	
 *	//Add items
 *	menu.AddCollection (
 *		[
 *			{
 *				icon: getVirtualPath()+"htmlEditor3/images/contextmenu/delete-row.gif"
 *				,title:"Delete row"
 *				,action: Action
 *				,tooltip: "Delete this row"
 *			}
 *			,{
 *				icon: getVirtualPath()+"htmlEditor3/images/contextmenu/copy-row-before.gif"
 *				,title:"Einfügen"
 *				,action: Action
 *				,submenu: JSO.ContextMenu.Add ("Test33", null, 255, "default", document, true, 
 *					[
 *						{
 *							icon: getVirtualPath()+"htmlEditor3/images/contextmenu/delete-cell.gif"
 *							,title:"Delete cell"
 *							,action: Action
 *							,tooltip: "Delete this cell"
 *						}
 *						,{
 *							icon: getVirtualPath()+"htmlEditor3/images/contextmenu/delete-column.gif"
 *							,title:"Delete column"
 *							,action: Action
 *							,tooltip: "Delete this column"
 *						}
 *					]
 *					
 *				)
 *			}
 *			
 *		]
 *	);
 *	
 *	//Syntax for displaying a menu:
 *	JSO.ContextMenu.Show ("Test1", e);
 *	
 *	//Syntax for hiding the displayed menu
 *	JSO.ContextMenu.Hide();
 ***/
JSO.ContextMenu = {
	//Collection of existing menus
	Menus: {}
	, ClassId: "JSO-ContextMenu"
	, ResourcesPath: "multimed/contextMenu/"
	, CssInitialized: false //Import of the css
	, CurrentMenu: null //the menu currently displayed
	
	//Menu class
	, MenuClass: function(id, title, width, doc, designName, isSubmenu) {
		this.id = id;
		this.title = title;
		this.doc = doc || document;
		this.width = (width || 200);
		this.designName = designName || "default";

		this.items = [];
		this.itemsDic = {};


		this.isSubmenu = isSubmenu;
		this.CurrentSubmenu = null;
		
		//Timers
		this.showTimer = null; //The timer for this.Show
		this.menuTimer = null; //The timer for this.Hide

		//Callback on hide
		this.callbackOnHide = null;

		/* Methods */
		this.$ = function(id) {
			return this.doc.getElementById(id);
		};

		this.GetItemInfo = function(itemId) {

			return this.itemsDic[itemId];

		}
		//Showing the menu
		this.Show = function(e, offsetLeft, offsetTop, trigger) {
			if (this.menuTimer) this.doc.parentWindow.clearTimeout(this.menuTimer);
			if (this.showTimer) this.doc.parentWindow.clearTimeout(this.showTimer);
			this.trigger = trigger;
			
			//Update item states
			this.UpdateItems ();
			
			var panel = this.$(JSO.ContextMenu.ClassId + this.id);
			if (panel) 
			{
				//this.showTimer = window.setTimeout(function() { 
					panel.style.display = ""; 
				//}, 50);
			}
			this.offsetLeft = int(offsetLeft);
			this.offsetTop = int(offsetTop);

			JSO.ContextMenu.PositionMenu(this, panel, e, offsetLeft, offsetTop);

			if (!this.isSubmenu)
				JSO.ContextMenu.CurrentMenu = this;
		}
		
		//Updating the item states
		this.UpdateItems = function ()
		{
			for (var i =0 ; i < this.items.length; i++)
			{
				var itemDef = this.items[i];
				if (itemDef.updateState)
					itemDef.updateState (itemDef, this.trigger);
			}
		}
		
		//Hiding the menu and all its submenus
		this.Hide = function() {
			//Clear display timer
			if (this.showTimer) this.doc.parentWindow.clearTimeout(this.showTimer);
			
			//Hide submenu
			if (this.CurrentSubmenu)
				this.CurrentSubmenu.Hide();

			var panel = this.$(JSO.ContextMenu.ClassId + this.id);


			if (panel) panel.style.display = "none";


			if (this.callbackOnHide) this.callbackOnHide();
		}
		//Starts the hiding timer
		this.StartHiding = function() {
			if (this.menuTimer) this.doc.parentWindow.clearTimeout(this.menuTimer);

			var menuInfo = this;

			this.menuTimer = this.doc.parentWindow.setTimeout(function() {
				menuInfo.Hide();
				if (!menuInfo.isSubmenu)
					JSO.ContextMenu.CurrentMenu = null;
			}, 500);
		}
		//Stopping the hiding timer of the parent
		this.StopParentTimer = function() {
			var parentMenuInfo = JSO.ContextMenu.GetMenuInfo(this.parentMenuId);
			var itemInfo = parentMenuInfo.GetItemInfo(this.parentItemId);

			if (itemInfo.submenuTimer) parentMenuInfo.doc.parentWindow.clearTimeout(itemInfo.submenuTimer);

		}
		//Get the panel object
		this.GetPanel = function() {
			return this.$(JSO.ContextMenu.ClassId + this.id);
		}
		//Adding a collection of item classes
		this.AddCollection = function(items) {
			if (!items) return;
			for (var i = 0; i < items.length; i++) {
				if (items[i].type == "separator")
					this.AddSeparator();
				else
					this.Add(items[i].icon, items[i].title, items[i].action, items[i].submenu, items[i].tooltip, items[i]);
			}
		}


		//Adding a new item class
		this.Add = function(icon, title, action, submenu, tooltip, itemDef) {
			var id = this.id + "Item" + this.items.length;
			//Check if exists
			if (this.itemsDic[id]) return this.itemsDic[id];

			var itemInfo = new JSO.ContextMenu.ItemClass(id, icon, title, action, submenu);
			itemInfo.itemDef = itemDef;
			itemInfo.tooltip = tooltip;
			itemInfo.updateState = itemDef.updateState;
			
			if (submenu) {
				submenu.parentMenuId = this.id;
				submenu.parentItemId = itemInfo.id;
			}
			itemInfo.menuId = this.id;

			//Creating
			//Panel
			var itemPanel = JSO.ContextMenu.Factory.Item(itemInfo, this);

			//Container
			var container = this.$(JSO.ContextMenu.ClassId + "ItemsContainer" + this.id);
			if (container) container.appendChild(itemPanel);

			this.itemsDic[id] = itemInfo;
			this.items.push(itemInfo);
			return itemInfo;
		}

		//Adding a separator
		this.AddSeparator = function() {
			//Creating
			//Separator
			var separatorPanel = JSO.ContextMenu.Factory.Separator(this);

			//Container
			var container = this.$(JSO.ContextMenu.ClassId + "ItemsContainer" + this.id);
			if (container) container.appendChild(separatorPanel);
			return;
		}
	}

	//Item class
	, ItemClass: function(id, icon, itemText, itemAction, submenu) {
		this.id = id;
		this.iconPath = icon;
		this.title = itemText;
		this.action = itemAction;
		this.submenu = submenu;

		this.doc = null;

		this.tooltip = null;

		this.menuId = null;
		this.submenuTimer = null;
		this.SetTitle = function (title)
		{
			var titleObj = $(JSO.ContextMenu.ClassId + "MenuItem-" + this.id);
			
			if (titleObj && titleObj.childNodes && titleObj.childNodes[1])
				titleObj.childNodes[1].innerHTML = title;
		}
		this.SetIcon = function (iconPath)
		{
			var titleObj = $(JSO.ContextMenu.ClassId + "MenuItem-" + this.id);
			if (titleObj && titleObj.childNodes && titleObj.childNodes[0])
			{
				var iconDiv = titleObj.childNodes[0];
				if (!iconPath)
				{
					iconDiv.innerHTML = "&nbsp;";
				}
				else
				{
					var img = iconDiv.firstChild;
					if (!img || img.tagName!="IMG") {
						iconDiv.innerHTML = "<img src=\"" + iconPath + "\" align=absmiddle />";
					}
					else
						img.src = iconPath;
				}
			}
			
		}
		this.SetDisabled = function (disable)
		{
			var titleObj = $(JSO.ContextMenu.ClassId + "MenuItem-" + this.id);
			if (!titleObj) return;
			this.disabled = titleObj.disabled = (disable == true);
			if(disable)
				ClassNameManager.fly(titleObj).addClassName ("disabled");
			else	
				ClassNameManager.fly(titleObj).removeClassName ("disabled");
		}
		
		this.ShowSubmenu = function(e) {
			if (this.submenu) {
				var menuInfo = JSO.ContextMenu.GetMenuInfo(this.menuId);

				if (this.submenuTimer) menuInfo.doc.parentWindow.clearTimeout(this.submenuTimer);
				//Hide the previous
				if (menuInfo.CurrentSubmenu)
					menuInfo.CurrentSubmenu.Hide();


				this.submenu.Show(e);
				menuInfo.CurrentSubmenu = this.submenu;
			}
		};

		this.HideSubmenu = function(e, immediatly) {
			if (this.submenu) {
				var menuInfo = JSO.ContextMenu.GetMenuInfo(this.menuId);

				if (this.submenuTimer) menuInfo.doc.parentWindow.clearTimeout(this.submenuTimer);
				if (immediatly)
					return this.submenu.Hide();

				var submenuInfo = this.submenu;

				this.submenuTimer = menuInfo.doc.parentWindow.setTimeout(function() {
					submenuInfo.Hide();
					menuInfo.CurrentSubmenu = null;
				}, 200);

			}
		}
	}

	, GetMenuInfo: function(menuId) {

		return JSO.ContextMenu.Menus[menuId];

	}
	//Adding a new menu class
	, Add: function(id, title, width, designName, doc, isSubmenu, itemsCollection) {
		if (!designName) designName = "default";
		if (!isSubmenu && !JSO.ContextMenu.CssInitialized) {
			importStylesheet(getVirtualPath() + "multimed/contextMenu/main.css", "contextMenuCss");
			JSO.ContextMenu.CssInitialized = true;
		}

		if (!isSubmenu) importStylesheet(getVirtualPath() + "multimed/contextMenu/" + designName + ".css",
				"contextMenu" + designName + "Css");


		//Check if exists
		if (JSO.ContextMenu.Menus[id]) return JSO.ContextMenu.Menus[id];

		var menuInfo = new JSO.ContextMenu.MenuClass(id, title, width, doc, designName, isSubmenu);


		//Creating
		//Panel
		var panel = JSO.ContextMenu.Factory.MenuPanel(menuInfo);

		//Title
		if (menuInfo.title)
			panel.appendChild(JSO.ContextMenu.Factory.Title(menuInfo));

		//Container
		var container = JSO.ContextMenu.Factory.ContainerPanel(menuInfo);
		panel.appendChild(container);

		menuInfo.doc.body.appendChild(panel);

		JSO.ContextMenu.Menus[id] = menuInfo;

		if (itemsCollection)
			menuInfo.AddCollection(itemsCollection);


		return menuInfo;
	}
	//Showing the menu
	, Show: function(menuId, e, offsetLeft, offsetTop) {
		var menuInfo = JSO.ContextMenu.Menus[menuId];
		if (!menuInfo) return;

		menuInfo.Show(e, offsetLeft, offsetTop);
	}

	, PositionMenu: function(menuInfo, panel, e, offsetLeft, offsetTop) {
		var left = e.clientX + menuInfo.doc.body.scrollLeft + int(offsetLeft);
		var top = e.clientY + menuInfo.doc.body.scrollTop + int(offsetTop);

		var x = left;
		var y = top;

		//If submenu
		var parentItem = null;
		var parentItemSize = null;
		var parentItemPosition = null;
		var parentItemPositionedLeft = false;
		if (menuInfo.isSubmenu) {
			parentItem = menuInfo.$(JSO.ContextMenu.ClassId + "MenuItem-" + menuInfo.parentItemId);
			var parentMenuInfo = JSO.ContextMenu.GetMenuInfo(menuInfo.parentMenuId);
			parentItemPositionedLeft = parentMenuInfo.positionLeft == true;

			if (parentItem) {
				parentItemPosition = getObjectPosition3(parentItem);
				parentItemSize = getObjectSize(parentItem);
				x = parentItemPosition[0] + parentItemSize[0];
				y = parentItemPosition[1];
			}
		}

		//Adjust x, y 
		var totalSize = getObjectSize(panel);
		var clientSize = getClientSize();

		if ((y + totalSize[1]) > clientSize[1])
			y = clientSize[1] - totalSize[1];
		if (y < 0) y = 0;

		if (parentItemPositionedLeft || (x + totalSize[0]) > clientSize[0]) {
			if (menuInfo.isSubmenu) {
				x = parentItemPosition[0] - totalSize[0] - 4;
				menuInfo.positionLeft = true;
			}
			else {
				x = e.clientX - totalSize[0] - 10;
			}
		}
		else {
			menuInfo.positionLeft = false;
		}
		if (x < 0) x = 0;

		panel.style.left = x;
		panel.style.top = y;
	}
	//Hiding the menu
	, Hide: function() {
		if (!JSO.ContextMenu.CurrentMenu) return;
		JSO.ContextMenu.CurrentMenu.Hide();
	}
	//Creating factory
	, Factory: {

		//Creating  the panel for the menu
		MenuPanel: function(menuInfo) {
			var div = menuInfo.doc.createElement("DIV");
			div.className = "jso-contextmenu";
			if (menuInfo.isSubmenu) {
				div.className += " context-submenu";

			}
			div.id = JSO.ContextMenu.ClassId + menuInfo.id;
			div.style.display = "none";
			div.style.width = String(int(menuInfo.width) + "px");
			//Add some events
			addEvent(div, "mouseover", JSO.ContextMenu.Events.Menu.KeepDisplayed);

			addEvent(div, "mouseout", JSO.ContextMenu.Events.Menu.StartHiding);


			return div;
		}
		//Creating  the panel for the items
		, ContainerPanel: function(menuInfo) {
			var div = menuInfo.doc.createElement("DIV");
			div.className = "items-container";
			div.id = JSO.ContextMenu.ClassId + "ItemsContainer" + menuInfo.id;
			return div;
		}
		//Title div
		, Title: function(menuInfo) {
			var div = menuInfo.doc.createElement("DIV");
			div.className = "contextmenu-title";
			div.id = JSO.ContextMenu.ClassId + "MenuTitle-" + menuInfo.id;

			var partLeft = menuInfo.doc.createElement("DIV");
			partLeft.className = "left";
			div.appendChild(partLeft);

			var partRight = menuInfo.doc.createElement("DIV");
			partRight.className = "right";
			partLeft.appendChild(partRight);

			var partMiddle = menuInfo.doc.createElement("DIV");
			partMiddle.className = "middle";
			partRight.appendChild(partMiddle);


			partMiddle.appendChild(menuInfo.doc.createTextNode(menuInfo.title));

			div.appendChild(partLeft);

			return div;
		}
		//Item div
		, Item: function(itemInfo, menuInfo) {
			var div = menuInfo.doc.createElement("DIV");
			ClassNameManager.extend(div);
			div.addClassName("contextmenu-item");
			if (itemInfo.submenu)
				div.addClassName("hasSubmenu");

			div.id = JSO.ContextMenu.ClassId + "MenuItem-" + itemInfo.id;
			div.itemId = itemInfo.id;
			div.menuId = menuInfo.id;
			div.isItem = true;
			if (itemInfo.tooltip)
				div.title = itemInfo.tooltip;

			//Add some events
			addEvent(div, "mouseover", JSO.ContextMenu.Events.Items.MouseOver);
			addEvent(div, "mouseout", JSO.ContextMenu.Events.Items.MouseOut);
			addEvent(div, "click", JSO.ContextMenu.Events.Items.Click);

			var iconDiv = menuInfo.doc.createElement("DIV");
			iconDiv.className = "icon";
			if (itemInfo.iconPath) {
				var imgIcon = menuInfo.doc.createElement("IMG");
				imgIcon.src = itemInfo.iconPath;
				iconDiv.appendChild(imgIcon);
			}
			else
				iconDiv.innerHTML = "&nbsp;";
			div.appendChild(iconDiv);

			var title = menuInfo.doc.createElement("DIV");
			title.className = "item-title";
			title.appendChild(menuInfo.doc.createTextNode(itemInfo.title));
			title.style.width = String(int(menuInfo.width) - 52) + "px";

			div.appendChild(title);

			var arrowDiv = menuInfo.doc.createElement("DIV");
			arrowDiv.className = "arrow";

			if (itemInfo.submenu) {
				arrowDiv.className = "arrow hasSubmenu";
				var imgArrow = menuInfo.doc.createElement("IMG");

				imgArrow.src = getVirtualPath() + JSO.ContextMenu.ResourcesPath + "layout/arrow.gif";
				arrowDiv.appendChild(imgArrow);
			}
			else
				arrowDiv.innerHTML = "&nbsp;";
			div.appendChild(arrowDiv);



			return div;
		}
		//Separator
		, Separator: function(menuInfo) {
			var div = menuInfo.doc.createElement("DIV");
			ClassNameManager.extend(div);
			div.addClassName("contextmenu-item-separator");

			var iconDiv = menuInfo.doc.createElement("DIV");
			iconDiv.className = "icon";
			iconDiv.innerHTML = "&nbsp;";
			div.appendChild(iconDiv);

			var title = menuInfo.doc.createElement("DIV");
			title.className = "item-title";
			title.innerHTML = "&nbsp;";
			title.style.width = String(int(menuInfo.width) - 55) + "px";

			div.appendChild(title);

			var arrowDiv = menuInfo.doc.createElement("DIV");
			arrowDiv.className = "arrow";
			arrowDiv.innerHTML = "&nbsp;";
			div.appendChild(arrowDiv);

			return div;
		}
	}

	//Events
	, Events: {
		//Getting the menu info
		GetItemPanel: function(e) {
			var itemPanel = getEventSource(e);
			if (!itemPanel) return;
			if (!itemPanel.isItem)
				while (!itemPanel.isItem && itemPanel.parentNode) {
				itemPanel = itemPanel.parentNode
			}
			
			return itemPanel;
		}
		, GetMenuInfo: function(e) {
			var itemPanel = JSO.ContextMenu.Events.GetItemPanel(e);
			if (!itemPanel) return null;
			//Menu info
			return JSO.ContextMenu.Menus[itemPanel.menuId];

		}
		, Menu: {

			//Keep the menu displayed
			KeepDisplayed: function() {
				if (!JSO.ContextMenu.CurrentMenu) return;
				if (JSO.ContextMenu.CurrentMenu.menuTimer)
					JSO.ContextMenu.CurrentMenu.doc.parentWindow.clearTimeout(JSO.ContextMenu.CurrentMenu.menuTimer);
			}

			//Start hiding timeout
			, StartHiding: function() {
				if (!JSO.ContextMenu.CurrentMenu) return;
				JSO.ContextMenu.CurrentMenu.StartHiding();
			}

		}
		, Items: {
			//Item mouseover
			MouseOver: function(e) {
				if (!JSO.ContextMenu.CurrentMenu) return;

				var itemPanel = JSO.ContextMenu.Events.GetItemPanel(e);
				if (!itemPanel) return;
				
				if (itemPanel.disabled == true) return;
				
				itemPanel.addClassName("highlight");

				//Submenu?
				var menuInfo = JSO.ContextMenu.Events.GetMenuInfo(e);
				if (menuInfo.isSubmenu) menuInfo.StopParentTimer();
				var itemInfo = menuInfo.GetItemInfo(itemPanel.itemId);
				if (!itemInfo) return;
				if (itemInfo.submenu)
					itemPanel.addClassName("highlightWithSubmenu");

				itemInfo.ShowSubmenu(e);
			}
			//Item mouseout
			, MouseOut: function(e) {

				var itemPanel = JSO.ContextMenu.Events.GetItemPanel(e);
				if (!itemPanel) return;

				if (itemPanel.disabled == true) return;
				
				
				itemPanel.removeClassName("highlight");

				if (!JSO.ContextMenu.CurrentMenu) return;


				//Submenu?
				var menuInfo = JSO.ContextMenu.Events.GetMenuInfo(e);
				var itemInfo = menuInfo.GetItemInfo(itemPanel.itemId);
				if (!itemInfo) return;
				//itemInfo.HideSubmenu(e);

			}
			//Item on click
			, Click: function(e) {
				//Hide the menu
				if (e) e.cancelBubble = true;

				var itemPanel = JSO.ContextMenu.Events.GetItemPanel(e);

				//Menu info
				var menuInfo = JSO.ContextMenu.Events.GetMenuInfo(e);
				if (!menuInfo) return;

				//Item info
				var itemInfo = menuInfo.GetItemInfo(itemPanel.itemId);
				if (!itemInfo) return;
				
				if (itemInfo.disabled == true) return;
				
				if (itemInfo.action) itemInfo.action(menuInfo, itemInfo);

				JSO.ContextMenu.CurrentMenu.Hide();
				JSO.ContextMenu.CurrentMenu = null;

			}
		}
	}
}


/**
 * 
 * @namespace: JSO
 */
JSO.Ajax = {
	//Variables	
	Instances : new Array ()
	
	/**
	 * Synchronous(!) request, returns plain text
	 * 
	 * @param {} method: "POST" or "GET"
	 * @param {} url: url of the service
	 * @param {} postdata: arguments to send
	 * 
	 * @example: var firstName = JSO.Ajax.GetPlainText ("POST", "http://localhost/Services/myService.asmx/GetFirstName", "lastName=Müller");
	 * 
	 * @returns: responseText as plain text
	 */
	,GetPlainText : function (method, url, postdata)
	{
		var instance = JSO.Ajax.GetInstance();
		instance.open(method, url, false);
	    //instance.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
	    instance.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	    
	    instance.send(postdata);	    
	    return instance.responseText;
	}
	
	/**
	 * Asynchronous(!) request, calls the passed callback
	 * 
	 * @param {} method: "POST" or "GET"
	 * @param {} url: url of the service
	 * @param {} postdata: arguments to send
	 * @param {} callback: the callback to be called on complete
	 * 
	 * @example: JSO.Ajax.Send ("POST", "http://localhost/Services/myService.asmx/GetFirstName", "lastName=Müller", 
	 * 	function (response) { //TODO with the response });
	 * 
	 * @returns: xmlHttpResponse
	 */
	,Send : function (method, url, postdata, callback, additionalParams)
	{
		var instance = JSO.Ajax.GetInstance();
		
		
		instance.open(method, url, true);
	    instance.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		
		
	    if (callback)
		    instance.onreadystatechange = function (e) {
				if (instance.readyState == 4)
				{
					callback (instance, additionalParams);
				}
			};
	   
		instance.send(postdata);
		return instance;
	}
	,GetXmlDocument : function(xml) {
        var xmlDoc = null;
        if (window.DOMParser) {
            xmlDoc = new DOMParser();
            xmlDoc = xmlDoc.parseFromString(String(xml), "text/xml");

        } else {
            xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
            xmlDoc.async = false;
            xmlDoc.loadXML(xml);
        }
        return xmlDoc;
    }
	,GetInstance : function ()
	{
		var xmlHttpRequest = null;
		if (!isMS()) 
		{
			if (window.XMLHttpRequest)
	        {
	            xmlHttpRequest = new XMLHttpRequest();
	            
	            if (xmlHttpRequest.readyState == null)
	            {
	                xmlHttpRequest.readyState = 1;
	                xmlHttpRequest.addEventListener("load",
	                    function()
	                    {
	                        xmlHttpRequest.readyState = 4;
	                        if (typeof(xmlHttpRequest.onreadystatechange) == "function")
	                        {
	                            xmlHttpRequest.onreadystatechange();
	                        }
	                    },
	                    false);
	            }
	        }
		}
		else
		{
			xmlHttpRequest =new ActiveXObject("Microsoft.XMLHTTP");
			
			xmlHttpRequest.onreadystatechange = new Function ();
		}
		JSO.Ajax.Instances.push( xmlHttpRequest );
		
		return xmlHttpRequest;
	}

	,HandleActionResult : function(ajaxResponse, returnOnly) {
        var xml = ajaxResponse.responseXml || ajaxResponse.responseXML;
		
        if (xml && xml.lastChild && xml.lastChild.nodeName == "ActionResult") {
            var actionResult = new Object();
            actionResult = Object.fromXml(null, xml.lastChild);
            
			if (actionResult && returnOnly == true)
				return actionResult
            if (actionResult.ActionFailed) {

                alert(String(actionResult.Message).replace(/\\n/gi, "\n")
                        + (actionResult.Description ? "\n"
                                + String(actionResult.Description).replace(
                                        /\\n/gi, "\n") : ""));
                xml = null;
                return false;
            } else {
                xml = null;
                return true;
            }
        } else {
            alert(ajaxResponse.responseText);
            xml = null;
            return false;
        }
    }
}
JSO.DOM = {};
JSO.DOM.GetParent =
{
	ByTagName : function(child, tagToFind) {
	    if (!child) return null;
	    if (child.tagName != tagToFind) {
	        while (child.tagName != tagToFind) {
	            if (child.parentNode) child = child.parentNode;
	            else return null;
	        }
	        return child;
	    }
	    else return child;
	}
	,ByClassName : function(child, classNameToFind) {
	    if (!child) return null;
	    if (!ClassNameManager.fly(child).hasClassName (classNameToFind)) {
	        while (ClassNameManager.fly(child).hasClassName(classNameToFind)) {
	            if (child.parentNode) child = child.parentNode;
	            else return null;
	        }
	        return child;
	    }
	    else return child;
	}
	,ByProperty : function(child, propertyName, propertyValue) {
		if (!child) return null;
	    if (child[propertyName] != propertyValue) {
	        while (child[propertyName] != propertyValue) {
	            if (child.parentNode) child = child.parentNode;
	            else return null;
	        }
	        return child;
	    }
	    else return child;
	}
}
JSO.DOM.Node = function (tagName, attrs, children)
{
	var el = document.createElement (tagName);
	if (attrs)
	{
		for (var attr in attrs)
		{
			try{
			if (attr == "style")
				el.style.cssText = attrs[attr];
			else
				el [attr] =  attrs [attr];
			}catch(e){}
		}
	}
	if (children)
	{
		for (var i=0, d=children.length; i < d; i++)
		{
			el.appendChild (children[i]);
		}
	}
	return el;
}
JSO.DOM.TextNode = function (text)
{
	var el = document.createTextNode (text);
	return el;
}
JSO.Layout = {
	CssStyleReplace : /(-[a-z])/gi
	,CssStyleFunction : function(m,a){return a.charAt(1).toUpperCase()}
	,CssPropCache  : {}
};
JSO.Layout.GetPosition = function (obj)
{
   var currentObj, flyObject, clientRect, scrollInfo, docBody = (document.body || document.documentElement); 
    obj = $(obj); 
    if(obj == docBody) {
        return[0, 0]
    }
    if(obj.getBoundingClientRect) 
    {
		clientRect = obj.getBoundingClientRect(); 
		scrollInfo = JSO.Layout.GetScroll (document); 
		return [clientRect.left + scrollInfo.left, clientRect.top + scrollInfo.top]
	}
    var leftOffset = 0, topOffset = 0; currentObj = obj; 
    var absolutePosition = JSO.Layout.GetCssValue (obj, "position") == "absolute"; 
    while(currentObj) {
        leftOffset += currentObj.offsetLeft; 
	topOffset += currentObj.offsetTop; 
	if(!absolutePosition && JSO.Layout.GetCssValue (currentObj, "position") == "absolute") 
        {
			absolutePosition = true
		}
        if(CurrentNavigator.isGecko) 
        {
			flyObject = JSO.Layout.WrapObject(currentObj); 
			var P = parseInt (JSO.Layout.GetCssValue (flyObject, "borderTopWidth"), 10) || 0; 
			var H = parseInt(JSO.Layout.GetCssValue (flyObject, "borderLeftWidth"), 10) || 0; 
			leftOffset += H; 
			topOffset += P; 
			if(currentObj != obj && JSO.Layout.GetCssValue (flyObject, "overflow") != "visible") 
			{
				leftOffset += H; 
				topOffset += P
			}
        }
        currentObj = currentObj.offsetParent
	}
    if(CurrentNavigator.isSafari && absolutePosition) 
    {
        leftOffset -= docBody.offsetLeft; 
        topOffset -= docBody.offsetTop
    }
    if(CurrentNavigator.isGecko &&!absolutePosition) 
    {
        var tempObj = JSO.Layout.WrapObject (docBody); 
        tempObj = docBody;
        leftOffset += parseInt(JSO.Layout.GetCssValue (tempObj, "borderLeftWidth"), 10) || 0; 
        topOffset += parseInt(JSO.Layout.GetCssValue (tempObj, "borderTopWidth"), 10) || 0
    }
    currentObj = obj.parentNode; 
    while(currentObj && currentObj != docBody) {
        if(!CurrentNavigator.isOpera || (currentObj.tagName != "TR" && JSO.Layout.GetCssValue(currentObj, "display") != "inline")
	) 
	{
        leftOffset -= currentObj.scrollLeft; topOffset -= currentObj.scrollTop
	}
    currentObj = currentObj.parentNode
    }
    return [leftOffset, topOffset];
};
JSO.Layout.GetSize = function (obj)
{
	if (!obj) return [0,0];
	var res = [0,0];
	
	if (obj.style.display == "none" || (obj.offsetParent && obj.offsetParent.style.display == "none"))
	{
		var hiddenObject = (obj.style.display == "none" ? obj : obj.offsetParent);
		var origVisibility = hiddenObject.style.visibility || "visible";
		
		hiddenObject.style.visibility = "hidden";
		hiddenObject.style.display = "";
		res = [obj.offsetWidth, obj.offsetHeight];
		hiddenObject.style.display = "none";
		hiddenObject.style.visibility = origVisibility;
	}
	else 
		res = [obj.offsetWidth, obj.offsetHeight];
	
	return res;
	
};
JSO.Layout.GetScroll = function (d)
{
	var doc = document;
	if (d==doc || d == doc.body)
	{
		var l, t;
		if (CurrentNavigator.isIE && CurrentNavigator.isStrict)
		{
			l = doc.documentElement.scrollLeft || (doc.body.scrollLeft || 0);
			t = doc.documentElement.scrollTop || (doc.body.scrollTop || 0);
		}
		else 
		{
			l = window.pageXOffset || (doc.body.scrollLeft || 0);
			t = window.pageYOffset || (doc.body.scrollTop || 0);
		}
		return { left: l, top : t};
	}
	else 
	{
		return { left: d.scrollLeft, top : d.scrollTop };
	}
}

JSO.Layout.GetCssValue = function (el, prop)
{
	var v, cs, camel;
	if (prop == "opacity")
	{
		if (typeof el.style.filter == "string")
		{
			var m=el.style.filter.match (/alpha\(opacity=(.*)\)/i);
			if (m) 
			{
				var fv = parseFloat (m [1]);
				if (!isNaN (fv))
				{
					return fv ? fv / 100 : 0;
				}
			}
		}
		return 1;
	}
	else 
	{
		if (prop == "float")
		{
			prop = "styleFloat";
		}
	}
	
	if (! (camel = JSO.Layout.CssPropCache[prop]))
	{
		camel = JSO.Layout.CssPropCache [prop] = prop.replace (JSO.Layout.CssStyleReplace , JSO.Layout.CssStyleFunction);
	}
	
	if (v = el.style [camel])
	{
		return v;
	}
	
	if (cs = el.currentStyle)
	{
		return cs [camel];
	}
	
	return null;
}
JSO.Layout.WrapObject = function(E)
{
	var B = { dom: E };
	
	return B;
}

//Initializing utils
JSO.Initialization = {
	count:0	,
	Start : function ()
	{
		//JSO.Initialization.GetChildren(JSO,0);
		
		BrowserCompatibility.Check ();
		
		window.setTimeout("preloadAnimationImages()", 2000);
		JSO.Initialization.Styles.Import();
		JSO.Initialization.Events.Init();
		JSO.Initialization.BodyClassName();
		
		addEvent (window, "onbeforeunload", JSO.Initialization.Dispose)
	}
	,GetChildren:function(o,level)
	{
		if (!o)return;
		if (JSO.Initialization.count++ > 300)return;
		
		for (var p in o)
		{
			Log.Add("<pre style='margin:0px'>" + space("\t",level)+ p + ": " + GetInstanceName(o[p]) + "</pre>");
			JSO.Initialization.GetChildren(o[p],level+1);
		}
	}
	//Cleaning up
	,Dispose : function ()
	{
		JSO.GarbageCollector.Dispose();
	}
	,Styles : 
	{
		Import :function ()
		{
			importStylesheet(getVirtualPath() + "css/jso.css", "JSO", "css/jso.css");
		}
	}
	,Events : {
		Init : function ()
		{
			JSO.Initialization.Events.Key();
			JSO.Initialization.Events.Mouse();
		}
		,Key : function ()
		{
			addEvent (window.document, "onkeypress",checkShortCutAction);
		}
		,Mouse: function ()
		{
		}
	}
	,BodyClassName: function ()
	{
		
		try
		{
			ClassNameManager.extend (document.body);
			//Add a kind of marker for the class names by the JSO framework
			document.body.addClassName ("jso-fw");
			
			
			if (!isMS())
			{
				document.body.addClassName ("nonie");
			}
			else	
				document.body.addClassName ("msie");
			
				
			//Add the exact version of the navigator
			if (CurrentNavigator.isIE7)
			{
				document.body.addClassName ("ie7");
			}
			if (CurrentNavigator.isIE8)
			{
				document.body.addClassName ("ie8");
			}
			if (CurrentNavigator.isIE6)
			{
				document.body.addClassName ("ie6");
			}
			document.body.addClassName ("compat-mode-" + document.compatMode);
			
			//Browser name 
			document.body.addClassName (getBrowserName ().toString().toLowerCase().replace (/[ ]/ig, '-'));
			//Full version 
			document.body.addClassName ("full-version-" + fullNavigatorVersion);
			//Major version 
			document.body.addClassName ("major-version-" + majorNavigatorVersion);
			

			document.execCommand("BackgroundImageCache",false,true)
			
		}
		catch(e){}
			
	}
};



var BrowserCompatibility = {
	Browsers : {
		"IE" : { title : "Internet Explorer", minVersion : 6.0 }
		,"Firefox" : { minVersion : 2.0 }
		,"Opera" : { minVersion : 9.0 }
		,"Safari" : { minVersion : 2.0 }
		,"Chrome" : { minVersion : 2.0 }
	}
	,
	Check : function ()
	{
		var bName = "";
		var bTitle = "";
		var bVersion = 0;
		var minVersion = 0;
		for (var b in BrowserCompatibility.Browsers)
		{
			
			if (CurrentNavigator["is" + b] == true)
			{
				bTitle = bName = b;
				var bInfo = BrowserCompatibility.Browsers [b];
				if (!isEmpty (bInfo.title))
				{
					bTitle = bInfo.title;
				}
				bVersion = fullNavigatorVersion;
				var parts = Trim(String(bVersion)).split(".");
				if (parts.length > 2)
				{
					bVersion = parts [0] + "." + parts [1];
				}
				bVersion = float(bVersion);
				minVersion = float (bInfo.minVersion);
			}
		}
		
		if (bName)
		{
			
			if (bVersion < minVersion)
			{
				alert ("Ihr Browser (" + bTitle + " " + bVersion + ") ist nicht mehr aktuell.\nBitte installieren Sie mindestens die Version " + minVersion + " Ihres Browsers");
			}		
			/* JSO.MessageBox.Show ("Ihr Browser (" + bTitle + " " + bVersion + ") ist nicht mehr aktuell.","Browser-Check", JSO.MessageBox.Buttons.OK,JSO.MessageBox.Icons.Warning, 400);
			*/			
		}	
	}
}
/* Non IE adjustments */
if(typeof HTMLElement!="undefined" && ! HTMLElement.prototype.insertAdjacentElement)
{
	HTMLElement.prototype.insertAdjacentElement = function (where,parsedNode)
	{
		switch (where)
		{
			case 'beforeBegin':
				this.parentNode.insertBefore(parsedNode,this)
				break;
			case 'afterBegin':
				this.insertBefore(parsedNode,this.firstChild);
				break;
			case 'beforeEnd':
				this.appendChild(parsedNode);
				break;
			case 'afterEnd':
				if (this.nextSibling)
					this.parentNode.insertBefore(parsedNode,this.nextSibling);
				else 
					this.parentNode.appendChild(parsedNode);
				break;
		}
	}
	HTMLElement.prototype.insertAdjacentHTML = function(where,htmlStr)
	{
		var r = this.ownerDocument.createRange();
		r.setStartBefore(this);
		var parsedHTML = r.createContextualFragment(htmlStr);
		this.insertAdjacentElement(where,parsedHTML)
	}
	HTMLElement.prototype.insertAdjacentText = function(where,txtStr)
	{
		var parsedText = document.createTextNode(txtStr)
		this.insertAdjacentElement(where,parsedText)
	}
}

if (!Object.serialize)
	Object.serialize = function (obj, indentValue) {
			var hexDigits = "0123456789ABCDEF";
			
			function ToHex(d) {
				return hexDigits[d >> 8] + hexDigits[d & 0x0F];
			}
			function Escape(string) {
				return string.replace(/[\x00-\x1F'\\]/g, function(x) {
							if (x == "'" || x == "\\")
								return "\\" + x;
							return "\\x" + ToHex(String.charCodeAt(x, 0));
						})
			}
			var indent;
			if (indentValue == null) {
				indentValue = "";
				indent = "";
				// or " " } else { indent = "\n";
			}
			return GetObject(obj, indent).replace(/,$/, "");
			function GetObject(obj, indent) {
				if (typeof obj == 'string') {
					return "'" + Escape(obj) + "',";
				}
				if (obj instanceof Array) {
					result = indent + "[";
					for (var i = 0, e = obj.length; i < e; i++) {
						result += indent + indentValue
								+ GetObject(obj[i], indent + indentValue);
					}
					result += indent + "],";
					return result;
				}
				var result = "";
				if (typeof obj == 'object') {
					result += indent + "{";
					for (var property in obj) {
						result += indent + indentValue + "'" + Escape(property)
								+ "' : "
								+ GetObject(obj[property], indent + indentValue);
					}
					result += indent + "},";
				} else {
					result += obj + ",";
				}
				return result.replace(/,(\n?\s*)([\]}])/g, "$1$2");
			}
		}

//Init utils
addEvent (window, "onload", JSO.Initialization.Start);
