//prototype erweiterungen {

var $A = Array.from = function(iterable)
{
	if (!iterable) return [];
	if (iterable.toArray)
	{
		return iterable.toArray();
	}
	else
	{
		var results = [];
		for (var i = 0, length = iterable.length; i < length; i++)
			results.push(iterable[i]);
		return results;
	}
}


Function.prototype.bind = function()
{
	var __method 	= this,
		args 		= $A(arguments),
		object 		= args.shift();

	return 	function()
			{
				return __method.apply(object, args.concat($A(arguments)));
			}
}

Function.prototype.bindAsEventListener = function(object)
{
	var __method 	= this,
		args 		= $A(arguments),
		object 		= args.shift();

	return 	function(event)
			{
				return __method.apply(object, [event || window.event].concat(args));
			}
}

Object.extend = function(destination, source)
{
	for (var property in source)
	{
		destination[property] = source[property];
	}

	return destination;
}

//Object.prototype.clone = function()
//{
//	return Object.extend({}, this);
//}

Array.prototype.inArray = function (value,casesensitive)
{
    var i;
    var c_length = this.length;

    for(i=0; i < c_length; i++)
    {
        //if(this[i] === value)
        if(str_equals(this[i],value,casesensitive))
        {
            return true;
        }
    }

    return false;
};

//nutzbar via myList.inArray('search term',true)) || myList.inArray('search term',false))
//sucht von unten nach oben
Array.prototype.inArrayRev = function (value,casesensitive)
{
    var i;
    var c_length = this.length;

    for(i=c_length-1; i >= 0; i--)
    {
        //if(this[i] === value)
        if(str_equals(this[i],value,casesensitive))
        {
            return true;
        }
    }

    return false;
};

//Array.prototype.clear = function()
//{
//	this.length = 0;
//	return this;
//};
//
//Array.prototype.clone = function()
//{
//	return [].concat(this);
//};
//
//Array.prototype.sum = function()
//{
//	for(var i=0,sum=0;i<this.length;sum+=this[i++]);
//	return sum;
//};
//
//Array.prototype.max = function()
//{
//	return Math.max.apply({},this)
//};
//
//Array.prototype.min = function()
//{
//	return Math.min.apply({},this)
//};

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)
	}
}

//defines the innerText property for firefox
if (typeof HTMLElement != 'undefined' && typeof HTMLElement.prototype.__defineGetter__ == 'function')
{
	HTMLElement.prototype.__defineGetter__("innerText", function ()
														{
															return this.textContent;
														});
}


//bekannte htmlEntities function
String.prototype.htmlEntities = function ()
{
	return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
};

//removed html tag
String.prototype.stripTags = function ()
{
	return this.replace(/<([^>]+)>/g,'');
}

//macht aus einem string ein array
String.prototype.toArray = function()
{
	return this.split('');
}

//wandelt den string in ein array von charcodes und gibts es zurueck
String.prototype.toIntArray = function()
{
	var returnArray = [];

	for(var i=0; i<this.length; i++)
	{
		returnArray.push(this.charCodeAt(i));
	}

	return returnArray;
}

//macht alle grossbuchstaben klein,alle kleinen gross
String.prototype.swapcase = function()
{
	return 	this.replace(/([a-z])|([A-Z])/g,function($0,$1,$2)
											{
												return ($1) ? $0.toUpperCase() : $0.toLowerCase()
											}
						);
}

//example:
//var firstName	= 'Ray';
//var lastName 	= 'Houston';
//var hello 	= 'Hello. My name is {0} {1}.'.format( firstName, lastName );
String.prototype.format = function()
{
    var str = this;

    for(var i=0;i<arguments.length;i++)
    {
        var re 	= new RegExp('\\{' + (i) + '\\}','gm');
        str 	= str.replace(re, arguments[i]);
    }

    return str;
}

//erstes zeichen grossschreiben
String.prototype.capitalize = function()
{
	return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase();
}

String.PAD_LEFT  = 0;
String.PAD_RIGHT = 1;
String.PAD_BOTH  = 2;

String.prototype.pad = function(size, pad, side)
{
	var str = this, append = "", size = (size - str.length);
	var pad = ((pad != null) ? pad : " ");

	if ((typeof size != "number") || ((typeof pad != "string") || (pad == "")))
	{
		throw new Error("Wrong parameters for String.pad() method.");
	}

	if (side == String.PAD_BOTH)
	{
		str = str.pad((Math.floor(size / 2) + str.length), pad, String.PAD_LEFT);
		return str.pad((Math.ceil(size / 2) + str.length), pad, String.PAD_RIGHT);
	}

	while ((size -= pad.length) > 0)
	{
		append += pad;
	}

	append += pad.substr(0, (size + pad.length));
	return ((side == String.PAD_LEFT) ? append.concat(str) : str.concat(append));
}

String.prototype.insertAt=function(loc,strChunk)
{
	return (this.valueOf().substr(0,loc))+strChunk+(this.valueOf().substr(loc))
}


Number.prototype.format = function(d_len, d_pt, t_pt)
{
	var d_len = d_len || 0;
	var d_pt = d_pt || ".";
	var t_pt = t_pt || ",";

	if((typeof d_len != "number") || (typeof d_pt != "string") || (typeof t_pt != "string"))
	{
		throw new Error("wrong parameters for method 'String.pad()'.");
	}

	var negativ = this < 0;

	var integer = "", decimal = "";
	var n 		= new String(Math.abs(this)).split(/\./), i_len = n[0].length, i = 0;

	if(d_len > 0)
	{
		n[1] = (typeof n[1] != "undefined") ? n[1].substr(0, d_len) : "";
		decimal = d_pt.concat(n[1].pad(d_len, "0", String.PAD_RIGHT));
	}

	while(i_len > 0)
	{
		if ((++i % 3 == 1) && (i_len != n[0].length))
		{
			integer = t_pt.concat(integer);
		}

		integer = n[0].substr(--i_len, 1).concat(integer);
	}

	return negativ ? ("-" + integer + decimal) : integer + decimal;
}

//prototype erweiterungen }

function addLoadEvent(func)
{
	var oldonload = window.onload;

	if (typeof window.onload != 'function')
	{
		window.onload = func;
	}
	else
	{
		window.onload = function()
		{
			if (oldonload)
			{
				oldonload();
			}

			func();
		}
	}
}

function addUnLoadEvent(func)
{
	var oldonunload = window.onunload;

	if (typeof window.onunload != 'function')
	{
		window.onunload = func;
	}
	else
	{
		window.onunload = function()
		{
			if (oldonunload)
			{
				oldonunload();
			}

			func();
		}
	}
}

function isAlien(a)
{
   return isObject(a) && typeof a.constructor != 'function';
}

function isObject(a)
{
    return (a && typeof a == 'object') || isFunction(a);
}

function isString(a)
{
	return typeof a == 'string';
}

function isUndefined(a)
{
	return typeof a == 'undefined';
}

function isNull(a)
{
	return a === null;
}

function isFunction(a)
{
	return typeof a == 'function';
}

function isEmptyObject(o)
{
    var i, v;
    if (isObject(o))
    {
        for (i in o)
        {
            v = o[i];

            if (isUndefined(v) && isFunction(v))
            {
                return false;
            }
        }
    }

    return true;
}

function isEmpty(s)
{
	return (s === null || s == "" || typeof s == "undefined");
}

function isEmptyID(s)
{
	return (s === null || s <= 0 || s == "" || typeof s == "undefined");
}

function isNumber(a)
{
    return typeof a == 'number' && isFinite(a);
}

function isBoolean(a)
{
	return typeof a == 'boolean';
}

function isArray(a)
{
	return isObject(a) && a.constructor == Array;
}

function isIEObject(a)
{
	return isObject(a) && typeof a.constructor != 'function';
}

function isJSON(json)
{
	if(isString(json))
	{
		var str = json.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, '');
//		alert(str);
		return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str);
	}

	return false;
}


function xmlString2Array(text)
{
	//json format: [{'label1':'value1','label2':'value2},{'label1':'value1','label2':'value2,'label3:[{'test':'123'}]}]
	//beispiel zum durchgehen
	//var ar = xmlString2Array(text);
	//for(var i=0; i < ar.length; i++)
	//  alert(ar[i].label1);
	//  oder
	//  if(isObject(ar[i].label1)
	//	{
	//		for(var j=0; j < ar[i].label3.length; j++)
	//			alert(ar[i].label3[j].test);
	//	}
	//  oder
	//	alert(ar[i]); //wenn es sich um ein normales also nicht assoc array handelt

	//alert(text);

	if(isJSON(text))
		return eval("("+text+")");
	else
		alert("Fehler im JSon: "+text);

	return [];
}

function fn_round(number, nachkommastellen, dec_point, thousands_sep)
{
	if (fn_round.arguments.length < 2)	nachkommastellen	= 2;
	if (fn_round.arguments.length < 3)	dec_point			= ".";
	if (fn_round.arguments.length < 4)	thousands_sep		= "";

	var t_ret	= "";

	var ret		= Math.round(number * (Math.pow(10, nachkommastellen)));
	var s_ret	= ret.toString();
	var c_ret	= s_ret.length;
	ret			= ret / Math.pow(10, nachkommastellen);

	ret			= ret.toPrecision(c_ret);

	ret			= ret.toString();
	ret			= ret.replace(/\./, dec_point);

	dec_pos		= ret.indexOf(dec_point);

	if (dec_pos >= 4)
	{
		for (var i = 1; i <= dec_pos; i++)
		{
			t_ret	= ret.substr((dec_pos - i), 1)+t_ret;

			if (i%3 == 0)
				t_ret	= thousands_sep+t_ret;
		}

		t_ret	+= ret.substr(dec_pos);
	}
	else
		t_ret	= ret;

	if (t_ret == 0)	t_ret	= "0"+dec_point+"00";

	return t_ret;
}

function on_load(auftrag_id)
{
	load_admin_kosten(auftrag_id, 1);
}

function load_admin_kosten(elm_id, identifier)
{
	s = new xml_http2();
	s.open('/ext/marketer.php?g_function=load_admin_kosten&g_elm_id='+elm_id+'&g_identifier='+identifier, '', show_admin_kosten);
}

function show_admin_kosten(value)
{
	var value	= xmlString2Array(value);
	var c_value	= value.length;

	var min_abzug	= 30;

	var elm		= document.getElementById("admin_kosten");
	var html	= "<tr><td class='cell_header'></td><td class='cell_header'align='right'>"+"<lang>Minuten</lang>"+"</td><td class='cell_header' align='right'>"+"<lang>Stunden</lang>"+"</td></tr>";

	if (c_value > 0)
	{
		var gesamt			= 0;
		var gesamt_stunden	= 0;

		for (i = 0; i < c_value; i++)
		{
			var row		= value[i];

			var t_name	= row.name;
			var minuten	= row.minuten;

			var std		= minuten / 60;
			gesamt		+= minuten * 1;

			html += "<tr><td class='cell' align='right'>"+t_name+"</td><td class='cell' align='right'>"+minuten+"</td><td class='cell' align='right'>"+fn_round(std, 2)+"</td></tr>";
		}

		//die ersten 30 Minuten sind kostenlos
		if (gesamt >= min_abzug)
			gesamt		-= min_abzug;
		else
		{
			min_abzug	= gesamt;
			gesamt		= 0;
		}

		gesamt_stunden = fn_round((gesamt / 60),2);

		html += "<tr><td class='cell' align='right'>"+language_array["abzüglich"]+"</td><td class='cell' align='right'>"+min_abzug+"</td><td class='cell' align='right'>"+fn_round((min_abzug / 60), 2)+"</td></tr>"

		html += "<tr height='10px'><td class='cell' align='right' valign='bottom'><b>"+"<lang>Summe</lang>"+"</b></td><td class='cell' align='right' valign='bottom'><b>"+gesamt+"</b></td><td class='cell' align='right'><b>"+gesamt_stunden+"</b></td></tr>";
	}
	else
	{
		html += "<tr><td class='cell' align='right'>"+"-"+"</td><td class='cell' align='right'>"+"0"+"</td><td class='cell' align='right'>"+"0"+"</td></tr>";
		html += "<tr height='10px'><td class='cell' align='right' valign='bottom'><b>"+language_array["Summe"]+"</b></td><td class='cell' align='right' valign='bottom'><b>"+"0"+"</b></td><td class='cell' align='right'></td></tr>";
	}

	if (elm)
		elm.innerHTML = "<table cellpadding='0' cellspacing='1' border='0' width='100%'>"+html+"</table>";
}

function unmark_elm(elm)
{
	elm.className="";
}

function hideit(elm)
{
	if(elm != null && elm.style != null) elm.style.display = 'None';
}

function showit(elm)
{
	if(elm != null && elm.style != null) elm.style.display = '';
}

function toggle(elm)
{
	if(elm != null && elm.style != null)
	{
		if(elm.style.display == "")
			hideit(elm);
		else
			showit(elm);
	}
}

function dynamicGetContent(el)
{
	var content = "";

	return content;
}

function dynamicAddContent(el,content,removeFirst)
{
	if(el != null)
	{
		if (document.getElementById && !document.all)
		{
			rng 	= document.createRange();
			rng.setStartBefore(el);
			htmlFrag = rng.createContextualFragment(content);

			if(removeFirst)
			{
				while (el.hasChildNodes())
					el.removeChild(el.lastChild);
			}

			el.appendChild(htmlFrag);
		}
		else
		{

			el.innerHTML = el.innerHTML+content;
		}
	}
}

function deleteNode(el)
{
	if(el) //make sure the el exists
	{
		deleteChildNode(el); //delete el's children

		if (typeof el.outerHTML != 'undefined')
			el.outerHTML = ''; //prevent pseudo-leak in IE
		else
			if(el.parentNode) //if the el has a parent
				el.parentNode.removeChild(el); //remove the el from the DOM tree
		delete el; //clean up just to be sure
	}
}

function deleteChildNode(el)
{
	if(el) //make sure the node exists
	{
		for(var x = el.childNodes.length - 1; x >= 0; x--) //delete all of el's children
		{
			var childNode = el.childNodes[x];

			if(childNode.hasChildNodes()) //if the child node has children then delete them first
				deleteChildNode(childNode);

			if (typeof childNode.outerHTML != 'undefined')
				childNode.outerHTML = ''; //prevent pseudo-leak in IE
			else
				el.removeChild(childNode); //remove the child from the DOM tree
			delete childNode; //clean up just to be sure
		}
	}
}

function removeAllChilds(el)
{
	while(el.hasChildNodes())
		el.removeChild(el.lastChild);
}

function addHTMLContent(el,content,where,berasebefore)
{
	if(el != null)
	{
		if(berasebefore) removeAllChilds(el);
		el.insertAdjacentHTML(where,content);
	}
}

function __add(div_src,div_dst,curpos)
{
	var code = "";

	if(div_src != null)
	{
		var def 	= div_src.innerHTML;
		code 		= def;

		if(code != null && code != "")
		{
			code = code.replace(/%POS%/g,curpos);
			addHTMLContent(div_dst,code,'beforeEnd',false);
		}
	}

	return code;
}

function __insertFirst(div_src,div_dst)
{
	var bSuccess = false;

	if(div_src != null && div_dst != null)
	{
		var code 			= __add(div_src,null,0);
		addHTMLContent(div_dst,code,'afterBegin',false);
		bSuccess			= true;
	}

	return bSuccess;
}

function __del(div_src,dp,ext,berase)
{
	if(__del.arguments.length < 3)
		berase = false;

	if(dp > 0 && div_src != null)
	{
		var span = document.getElementById('del_'+dp);

		if(!berase)
		{
			if(span != null)
			{
				var hidden 		= document.createElement("input");
				hidden.type 	= "hidden";
				hidden.name 	= ext+'['+dp+'][delete_flag]';
				hidden.value 	= "1";

				span.style["display"] = "none";

				span.appendChild(hidden);
			}
		}
		else
		{
			div_src.removeChild(span);
		}
	}
}

function addLink(ext,curpos,bhasAddButton,bhasDelButton)
{
	var obj = document.getElementById('link_'+ext+'_'+curpos);

	if(obj != null)
	{
		var links = '';

		if(bhasAddButton)
			links = links + '<a href="javascript:add'+ext+'();"><img src="/images_pub/plus.gif" width="14" height="14" border="0" title="'+language_array["hinzufügen"]+'"></a>';

		if(bhasDelButton && curpos > 0)
		{
			if(links.length > 0)
				links = links + '&nbsp;';

			links = links + '<a href="javascript:del'+ext+'('+curpos+');"><img src="/images_pub/minus.gif" width="14" height="14" border="0" title="'+language_array["löschen"]+'"></a>';
		}

		obj.innerHTML = links;
	}
}

function __fillSelectBox(text, select, sel_id, no_val, def_val)
{
	select.options.length = 0;

	if (text == null || text == "")
	{
		//select.options[select.length] = new Option(no_val[1], def_val[0]);

		if(no_val != null && def_val != null)
			select.options[select.length] = new Option(no_val[1], def_val[0]);
		else if(no_val != null && def_val == null)
			select.options[select.length] = new Option(no_val[1]);
	}
	else
	{
		var elm 	= text.split("|");
		var elm_len = elm.length;

		if(def_val != null)
			select.options[select.length] = new Option(def_val[1], def_val[0]);

		var add = select.length;

		for(var i = 0; i < elm_len; i++)
		{
			var t = elm[i].split("=>");

			select.options[select.length] = new Option(t[0], t[1]);

			if(sel_id == t[1] || (t.length > 2 && t[2] == 'selectbox_checked'))
				select.selectedIndex = i+add;
		}
	}
}

function setEnabled(value,fieldname,cb_fnOff,cb_fnOn)
{
	if (setEnabled.arguments.length < 3)
		cb_fnOff = null;

	if (setEnabled.arguments.length < 4)
		cb_fnOn = null;

	//alert(value);

	var elm = null;
	
	if(isObject(fieldname))
		elm = fieldname;
	
	if(elm == null)
		elm = document.getElementsByName(fieldname)[0];

	if(elm == null)
		elm = document.getElementById(fieldname);

	if(elm != null)
	{
		if(elm.type.toLowerCase() == "button")
		{
			elm.disabled			= (value == 0 || value == "");
		}
		else if(elm.type.toLowerCase() == "textarea")
		{
			elm.readOnly			= (value == 0 || value == "");
		}
		else
		{
			//todo evtl. nochmal aendern wenn irgendwas nicht geht z.b. im angebot
			if(elm.type.toLowerCase() == "text")
				elm.readOnly			= (value == 0 || value == "");
			else if(elm.type.toLowerCase().indexOf("select") > -1)
			{
				elm.off			= (value == 0 || value == "");
				onLoadDisableSelect();
			}
			else
				elm.disabled			= (value == 0 || value == "");

			elm.style.background 	= (value == 0 || value == "") ? "#CCCCCC" : ""; //#FFFFFF

			if((value == 0  || value == "") && cb_fnOff != null)
			{
				eval(cb_fnOff);
				elm.value = "";
			}

			if(value != 0  && value != "" && cb_fnOn != null)
			{
				eval(cb_fnOn);
			}
		}
	}
}

function enableField(fieldname,cb_fnOff,cb_fnOn)
{
	setEnabled(1,fieldname,cb_fnOff,cb_fnOn);
}

function disableField(fieldname,cb_fnOff,cb_fnOn)
{
	setEnabled(0,fieldname,cb_fnOff,cb_fnOn);
}

function setEnabled2(value,fieldname,cb_fnOff,cb_fnOn)
{
	if (setEnabled2.arguments.length < 3)
		cb_fnOff = null;

	if (setEnabled2.arguments.length < 4)
		cb_fnOn = null;

	//alert(value);

	var elm = document.getElementsByName(fieldname)[0];

	if(elm==null)
		elm = document.getElementById(fieldname);

	if(elm != null)
	{
		if(elm.type. toLowerCase() == "textarea")
		{
			elm.readOnly			= (value == 0 || value == "");
		}
		else if(elm.type.toLowerCase().indexOf("select") > -1)
		{
			elm.off			= (value == 0 || value == "");
			onLoadDisableSelect();
		}
		else
		{
			//todo evtl. nochmal aendern wenn irgendwas nicht geht z.b. im angebot
			if(elm.type.toLowerCase() == "text")
				elm.readOnly			= (value == 0 || value == "");
			else
				elm.disabled			= (value == 0 || value == "");

			elm.style.background 	= (value == 0 || value == "") ? "#CCCCCC" : "#FFFFFF"; //#FFFFFF
		}

		if((value == 0  || value == "") && cb_fnOff != null)
		{
			eval(cb_fnOff+"('"+fieldname+"','"+value+"')");
		}

		if(value != 0  && value != "" && cb_fnOn != null)
		{
			eval(cb_fnOn+"('"+fieldname+"','"+value+"')");
		}
	}
}

function isNumeric(strString)
{
	var strValidChars 	= "0123456789.-";
	var strChar;
	var blnResult 		= true;

	if(strString.length == 0)
		return false;

	for(var i = 0; i < strString.length && blnResult == true; i++)
	{
		strChar = strString.charAt(i);

		if(strValidChars.indexOf(strChar) == -1)
			blnResult = false;
	}

	return blnResult;
}

function _setValue(param,objid,value)
{
	if(document.getElementById(param+objid) != null)
		document.getElementById(param+objid).innerHTML = value;
}

function _setValue2(param,objid,value)
{
	if(document.getElementById(param+objid) != null)
		document.getElementById(param+objid).value = value;
}

function _selectOption(param,objid,value)
{
	var obj = $(param+objid);
	_selectOption(obj,value);
}

function _selectOptionByObj(obj,value)
{
	if(obj != null)
	{
		var opt 	= obj.options;
		var opt_c	= opt.length;
		var selidx	= 0;

		for(var i=0; i < opt_c; i++)
		{
			if(opt[i].value == value)
				selidx = i;
		}

		alert(selidx);

		obj.selectedIndex = selidx;
	}
}

function str_equals(string1, string2, casesensitive)
{
	ret	= true;

	if (str_equals.arguments.length < 3)
		casesensitive = true;

	if (!casesensitive)
	{
		string1 = string1.toLowerCase();
		string2 = string2.toLowerCase();
	}

	if (string1.length == string2.length)
	{
		len = string1.length;

		for (i = 0; i < len && ret; i++)
		{
			if (string1.charCodeAt(i) != string2.charCodeAt(i))
				ret = false;
		}
	}
	else
		ret = false;

	return ret;
}

function padZero(num)
{
	return ((num <= 9) ? ("0" + num) : num);
}

function unformatNumber(value,kommazeichen,tausender)
{
	if(!kommazeichen)
		kommazeichen  = ".";

	if(typeof tausender == 'undefined')
		tausender = ",";

	var k = value;
	k = k.replace(new RegExp("["+tausender+"]", "gi") ,'');
	k = k.replace(kommazeichen,'.');

	return k;
}

function MessageBox(tourl,text,style)
{
	var nConfirm = 1;

//die template engine replaced alle umlaute muessen wir hier wieder zurueckdrehen {
	text = text.replace('&uuml;','ü');
	text = text.replace('&auml;','ä');
	text = text.replace('&ouml;','ö');
	text = text.replace('&Uuml;','Ü');
	text = text.replace('&Auml;','Ä');
	text = text.replace('&Ouml;','Ö');
	text = text.replace('&szlig;','ß');
//die template engine replaced alle umlaute muessen wir hier wieder zurueckdrehen }

	switch(style)
	{
		case 0:
		{
			alert(text);
		}
		break;
		case 1:
		{
			nConfirm = confirm(text);
			if(nConfirm) document.location.href=tourl;
		}
		break;
		case 2:
		{
			nConfirm = confirm(text);
			if(nConfirm) window.open(tourl,"","width=500,height=400,left=0,top=0,scrollbars=yes,dependent=yes")
		}
		break;
		case 3:
		{
			nConfirm = confirm(text);
		}
		break;
	}

	return nConfirm;
}

function trim(s, char_list)
{
	if(isString(s))
		return rtrim(ltrim(s, char_list), char_list);
	return '';
}

function ltrim(s, char_list)
{
	if(isString(s))
	{
		var found	= true;
		var len 	= char_list.length;

		while (found)
		{
			found = false;

			for (i = 0; i < len; i++)
			{
				char	= char_list.charAt(i);

				if (s.substring(0, 1) == char)
				{
					found = true
					s = s.substring(1, s.length);
				}
			}
		}

		return s;
	}
	
	return '';
}

function rtrim(s, char_list)
{
	if(isString(s))
	{
		var found	= true;
		var len 	= char_list.length;

		while (found)
		{
			found = false;

			for (i = 0; i < len; i++)
			{
				char	= char_list.charAt(i);

				if (s.substring(s.length - 1 , s.length) == char)
				{
					found = true;
						s = s.substring(0, s.length - 1);
					}
			}
		}

		return s;
	}
	
	return '';
}

function strlen(s)
{
	return s.length;
}

function id(_id)
{
	return document.getElementById(_id);
}

function $(_id)
{
	return id(_id);
}

function name(s,idx)
{
	if(typeof idx == 'undefined')
		idx = "0";

	if(idx == -1)
		return document.getElementsByName(s);

	return document.getElementsByName(s)[idx];
}

function $$(s,idx)
{
	return name(s,idx);
}


function tag(name,obj,idx)
{
	if(typeof obj == 'undefined')
		obj = document;

	if(typeof idx == 'undefined')
		idx = 0;

	if(idx == -1)
		return obj.getElementsByTagName(name);

	return obj.getElementsByTagName(name)[idx];
}

function getElementsByAttribName(node,attrib)
{
	var attribElements 	= [];
	var els 			= node.getElementsByTagName("*");
	var elsLen 			= els.length;

	for (i = 0, j = 0; i < elsLen; i++)
	{
		if(els[i].getAttribute(attrib))
		{
			attribElements[j] = els[i];
			j++;
		}
	}

	return attribElements;
}

function getElementsByClass(node,searchClass,tag)
{
	var classElements 	= new Array();
	var els 			= node.getElementsByTagName(tag);
	var elsLen 			= els.length;
	var pattern	 		= new RegExp("\b"+searchClass+"\b");

	for (i = 0, j = 0; i < elsLen; i++)
	{
		if(pattern.test(els[i].className))
		{
			classElements[j] = els[i];
			j++;
		}
	}

	return classElements;
}



function showDebug()
{
	window.top.debugWindow = window.open(	"",
											"Debug",
											"left=0,top=0,width=300,height=700,scrollbars=yes,"
											+"status=yes,resizable=yes,menubar=yes,toolbar=yes");
	window.top.debugWindow.opener = self;

	window.top.debugWindow.document.open();
	window.top.debugWindow.document.write("<HTML><HEAD><TITLE>Debug Window</TITLE>\n");

	var style = "<style>";
	style += "<!--\n";
	style += "\n";
	style += ".skin0{\n";
	style += "position:absolute;\n";
	style += "width:165px;\n";
	style += "border:2px solid black;\n";
	style += "background-color:menu;\n";
	style += "font-family:Verdana;\n";
	style += "line-height:20px;\n";
	style += "cursor:default;\n";
	style += "font-size:14px;\n";
	style += "z-index:100;\n";
	style += "visibility:hidden;\n";
	style += "}\n";
	style += "\n";
	style += ".menuitems{\n";
	style += "padding-left:10px;\n";
	style += "padding-right:10px;\n";
	style += "}\n";
	style += "-->\n";
	style += "</style>\n";

	window.top.debugWindow.document.write(style);

	window.top.debugWindow.document.write("</HEAD><BODY>\n");

	var script = "";

	script += "<div id=\"ie5menu\" class=\"skin0\" onMouseover=\"highlightie5(event)\" onMouseout=\"lowlightie5(event)\" onClick=\"jumptoie5(event)\" display:none>\n";
	script += "<div class=\"menuitems\" url=\"javascript:opener.clearDebug()\">Clear</div>\n";
	script += "</div>\n";
	script += "<script language=\"JavaScript1.2\">\n";
	script += "\n";

	script += "function setText(text)\n";
	script += "{\n";
	script += "		var pre = document.getElementById('preDebugText');\n";
	script += "		addHTMLContent(pre,text,'beforeEnd',false);\n";
	script += "}\n";

	script += "//set this variable to 1 if you wish the URLs of the highlighted menu to be displayed in the status bar\n";
	script += "var display_url=0\n";
	script += "\n";
	script += "var ie5=document.all&&document.getElementById\n";
	script += "var ns6=document.getElementById&&!document.all\n";
	script += "if (ie5||ns6)\n";
	script += "var menuobj=document.getElementById(\"ie5menu\")\n";
	script += "\n";
	script += "function showmenuie5(e){\n";
	script += "//Find out how close the mouse is to the corner of the window\n";
	script += "var rightedge=ie5? document.body.clientWidth-event.clientX : window.innerWidth-e.clientX\n";
	script += "var bottomedge=ie5? document.body.clientHeight-event.clientY : window.innerHeight-e.clientY\n";
	script += "\n";
	script += "//if the horizontal distance isn't enough to accomodate the width of the context menu\n";
	script += "if (rightedge<menuobj.offsetWidth)\n";
	script += "//move the horizontal position of the menu to the left by it's width\n";
	script += "menuobj.style.left=ie5? document.body.scrollLeft+event.clientX-menuobj.offsetWidth : window.pageXOffset+e.clientX-menuobj.offsetWidth\n";
	script += "else\n";
	script += "//position the horizontal position of the menu where the mouse was clicked\n";
	script += "menuobj.style.left=ie5? document.body.scrollLeft+event.clientX : window.pageXOffset+e.clientX\n";
	script += "\n";
	script += "//same concept with the vertical position\n";
	script += "if (bottomedge<menuobj.offsetHeight)\n";
	script += "menuobj.style.top=ie5? document.body.scrollTop+event.clientY-menuobj.offsetHeight : window.pageYOffset+e.clientY-menuobj.offsetHeight\n";
	script += "else\n";
	script += "menuobj.style.top=ie5? document.body.scrollTop+event.clientY : window.pageYOffset+e.clientY\n";
	script += "\n";
	script += "menuobj.style.visibility=\"visible\"\n";
	script += "return false\n";
	script += "}\n";
	script += "\n";
	script += "function hidemenuie5(e){\n";
	script += "menuobj.style.visibility=\"hidden\"\n";
	script += "}\n";
	script += "\n";
	script += "function highlightie5(e){\n";
	script += "var firingobj=ie5? event.srcElement : e.target\n";
	script += "if (firingobj.className==\"menuitems\"||ns6&&firingobj.parentNode.className==\"menuitems\"){\n";
	script += "if (ns6&&firingobj.parentNode.className==\"menuitems\") firingobj=firingobj.parentNode //up one node\n";
	script += "firingobj.style.backgroundColor=\"highlight\"\n";
	script += "firingobj.style.color=\"white\"\n";
	script += "if (display_url==1)\n";
	script += "window.status=event.srcElement.url\n";
	script += "}\n";
	script += "}\n";
	script += "\n";
	script += "function lowlightie5(e){\n";
	script += "var firingobj=ie5? event.srcElement : e.target\n";
	script += "if (firingobj.className==\"menuitems\"||ns6&&firingobj.parentNode.className==\"menuitems\"){\n";
	script += "if (ns6&&firingobj.parentNode.className==\"menuitems\") firingobj=firingobj.parentNode //up one node\n";
	script += "firingobj.style.backgroundColor=\"\"\n";
	script += "firingobj.style.color=\"black\"\n";
	script += "window.status=''\n";
	script += "}\n";
	script += "}\n";
	script += "\n";
	script += "function jumptoie5(e){\n";
	script += "var firingobj=ie5? event.srcElement : e.target\n";
	script += "if (firingobj.className==\"menuitems\"||ns6&&firingobj.parentNode.className==\"menuitems\"){\n";
	script += "if (ns6&&firingobj.parentNode.className==\"menuitems\") firingobj=firingobj.parentNode\n";
	script += "if (firingobj.getAttribute(\"target\"))\n";
	script += "window.open(firingobj.getAttribute(\"url\"),firingobj.getAttribute(\"target\"))\n";
	script += "else\n";
	script += "window.location=firingobj.getAttribute(\"url\")\n";
	script += "}\n";
	script += "}\n";
	script += "\n";
	script += "if (ie5||ns6){\n";
	script += "menuobj.style.display=''\n";
	script += "document.oncontextmenu=showmenuie5\n";
	script += "document.onclick=hidemenuie5\n";
	script += "}\n";
	script += "\n";
	script += "</script>\n";

	window.top.debugWindow.document.write(script);

	if(document.getElementById && !document.all)
	{
		window.top.debugWindow.document.write("<pre id='preDebugText'>\n");
	}
	else
	{
		window.top.debugWindow.document.write("<pre id='preDebugText'></pre>\n</BODY>\n</HTML>\n");
		window.top.debugWindow.document.close();
	}
}

function clearDebug()
{
	if(document.getElementById && !document.all)
	{
		window.top.debugWindow.document.close();
		window.top.debugWindow.document.open();
		window.top.debugWindow.document.write("\n");
	}
	else
	{
		var pre = window.top.debugWindow.document.getElementById('preDebugText');
		while(pre.hasChildNodes()) pre.removeChild(pre.lastChild);
	}
}

function hideDebug()
{
	if(window.top.debugWindow && !window.top.debugWindow.closed)
	{
		window.top.debugWindow.close();
		window.top.debugWindow = null;
	}
}

function htmlentities(text)
{
	if(isString(text))
	{
		text = text.replace(/\&/gi,"&amp;");
		text = text.replace(/\"/gi,"&quot;");
		text = text.replace(/\</gi,"&lt;");
		text = text.replace(/\>/gi,"&gt;");
	}

	return text;
}

function debug(text)
{
	var ajax = new ajax_handler();

	if(ajax != null)
	{
		ajax.setClass("logfile_XMLfile_helper");
		ajax.setFunction("ajaxCreateDump");
		ajax.setParameter("activity",encodeURIComponent(text));
		ajax.setParameter("backtrace",false);
		ajax.open(ajax_handler.post);
	}
}

function dump(mixed_var,max_deep)
{
	if(typeof max_deep == "undefined")
		max_deep = 0;

	var text = "";

	if(isObject(mixed_var) || isArray(mixed_var))
		text = dumpObject(mixed_var,0,max_deep);
	else if(isBoolean(mixed_var))
		text = (mixed_var == true) ? "true" : "false";
	else
		text = mixed_var;

	debug(text);
}

function dumpObject(mixed_var,level,max_deep)
{
	var code = "";

	if(dumpObject.arguments.length < 2)
		level = 0;

	if(dumpObject.arguments.length < 3)
		max_deep = 0;

	if(typeof mixed_var == 'object' || typeof mixed_var == 'array')
	{
		for (var Eigenschaft in mixed_var)
		{
			if(typeof mixed_var[Eigenschaft] != "function")
			{
				for(var i=0; i < level; i++)
					code += "\t";

				code += "Name: "+Eigenschaft;
				code += " -> ";
				code += "Argument: "+ mixed_var[Eigenschaft];

				level++;

				if(level <= max_deep && (typeof mixed_var[Eigenschaft] == 'object' || typeof mixed_var[Eigenschaft] == 'array'))
				{
					code += "<br>\n";
					code += dumpObject(mixed_var[Eigenschaft],level,max_deep); //bekomme ich nicht hin...zu viele rekursionsebenen
				}

				level--;

				code += "<br>\n";
			}
		}
	}
	else if(isBoolean(mixed_var))
		code = (mixed_var == true) ? "true" : "false";
	else
		code = mixed_var;

	return code;
}

function isnumeric(str)
{
	var re = /(^-?[1-9](\d{1,2}(\,\d{3})*|\d*)|^0{1})$/;
	return re.test(str);
}

function get_cookie(Name)
{
	var search = Name + "=";
	var returnvalue = "";

	if (document.cookie.length > 0)
	{
		offset = document.cookie.indexOf(search);

		if (offset != -1)
		{
			offset += search.length;
			end = document.cookie.indexOf(";", offset);

			if (end == -1)
				end = document.cookie.length;
			returnvalue=unescape(document.cookie.substring(offset, end));
		}
	}

	return returnvalue;
}

function set_cookie(cookie)
{
	document.cookie=cookie;
}

function createCookie(name,value,days)
{
	var expires = "";

	if(typeof days != "undefined" && days > 0)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}

	document.cookie = name+"="+value+expires+";";//path=/
}


function getStyleSheet(name)
{
	if(!name || !document.styleSheets) return null;

	var i = document.styleSheets.length;

	while(i--)
	{
		var rules = document.styleSheets[i].rules ? document.styleSheets[i].rules :
		document.styleSheets[i].cssRules;
		var j = rules.length;

		while(j--)
		{
			if(!isEmpty(rules[j].selectorText))
			{
				if(rules[j].selectorText.toUpperCase() == name.toUpperCase())
					return rules[j];
			}
		}
	}
	return null;
}

function getStyleSheetStyle(name)
{
	var cssRuleObj = getStyleSheet(name);
	if(cssRuleObj != null)
		return cssRuleObj.style;
	return null;
}

function hex2rgb(hex)
{
	return  'rgb('+parseInt(hex.substring(1,3),16)+', '+parseInt(hex.substring(3,5),16)+', '+parseInt(hex.substring(5,7),16)+')';
}

function rgb2hex(value)
{
	var hex = value;

	if(value.indexOf('rgb') > -1)
	{
		var colors = value.split("(")[1].split(")")[0].split(",");

		for(var i=0;i<3;i++)
		{
			colors[i]=(colors[i]*1).toString(16);
		}

		hex = "#"+colors.join("");
	}

	return hex;
}

function getMaskID(text)
{
	var pattern_get = "/([A-Z]{1}[0-9]{3}[0-9]{2}[0-9]+)/";
	var regex_get	= new RegExp(eval(pattern_get));
	var maskID		= regex_get.exec(text)[1]
	return maskID;
}

function decodeMaskID(maskID)
{
	//A0150700030
	var pattern = "/[A-Z]{1}[0-9]{3}[0-9]{2}(.*)/";
	var regex	= new RegExp(eval(pattern));
	var id		= Number(regex.exec(maskID)[1]);
	return id;
}

function visitCard(param1,param2)
{
	if(typeof param2 == 'undefined')
		param2 = '';

	var param = "'/ext/marketer.php?g_function=getXMLVisitCard&g_param1="+param1+"&g_param2="+param2+"'";
	var vcard = "onMouseover=\"if(g_vc_timeoutId) clearTimeout(g_vc_timeoutId); return g_visitcard.onMouseOver(event,"+param+");\" onMouseout=\"if(g_vc_timeoutDelay) VisitcardTimeout();\"";

	return vcard;
}

function openLink(link)
{
	document.location.href = link;
}

function getAmount_value(amount_obj,dec_point,thousands_sep)
{
	var amount_html		= "";
	var amount_val		= "";

	amount_html			= amount_obj.innerHTML;
	amount_html			= amount_html.replace(/([^<]*)<span class=['\"]?text_marker['\"]?>([^<]*)<\/span>/gi,"$1$2");

	amount_val			= unformatNumber(amount_html,dec_point,thousands_sep);
	amount_val			= trim(amount_val.replace(new RegExp("[ €]", "gi") ,''),'&nbsp;');

	return amount_val;
}

function calcGesamt(block_synonym,dec_point,thousands_sep,identifier)
{
	if (!document.getElementsByTagName) return;

	if(typeof identifier == 'undefined')
		identifier = '_amount';

	var tr_all 	= document.getElementsByTagName('tr');

	if(tr_all && tr_all.length)
	{
		var gesamtSumme = 0;

		for(var d = 0, tr; tr = tr_all[d]; d++)
		{
			var tr_id = tr.id;

			if(tr_id != "" && typeof tr_id != "undefined")
			{
				if(tr_id.search(block_synonym) != -1 && tr.style['display'] != 'none')
				{
					var amount 	= $(tr_id+identifier);

					//"<lang symbol='dec_point'>,</lang>"
					//"<lang symbol='thousands_sep'>.</lang>"
//					amount		= amount.innerHTML;
//					amount		= amount.replace(/([^<]*)<span class=['\"]?text_marker['\"]?>([^<]*)<\/span>/gi,"$1$2");
//					amount		= unformatNumber(amount,dec_point,thousands_sep);
//					amount_val	= trim(amount.replace(new RegExp("[ €]", "gi") ,''),'&nbsp;');

					gesamtSumme += Number(getAmount_value(amount,dec_point,thousands_sep));
				}
			}
		}

		var gesamtDiv = $(block_synonym+'gesamt');

		if(gesamtDiv != null)
			gesamtDiv.innerHTML = Number(gesamtSumme).format(2,"<lang symbol='dec_point'>,</lang>","<lang symbol='thousands_sep'>.</lang>")+"&nbsp;&euro;";
	}
}

function isValidURL(url)
{
	var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
	if(RegExp.test(url)) return true;
	return false;
}

function onLinkKeyUp(htmllink_obj)
{
	if(htmllink_obj != null && isValidURL(htmllink_obj.value))
	{
		//mark as link
		var styleObj 	= getStyleSheetStyle('INPUT.htmllink');

		if(styleObj != null)
		{
			var color 										= styleObj.color;
			htmllink_obj.style.color 						= color;

			if (document.getElementById && !document.all)
			{
				var textDecoration 								= styleObj.textDecoration;
			 	htmllink_obj.style.textDecoration  				= textDecoration;
			}
			else
			{
				var textDecorationUnderline 					= styleObj.textDecorationUnderline;
				var textDecorationNone 							= styleObj.textDecorationNone;

				htmllink_obj.style.textDecorationUnderline  	= textDecorationUnderline;
				htmllink_obj.style.textDecorationNone  			= textDecorationNone;
			}

			htmllink_obj.style.cursor  						= "pointer";
		}
	}
	else if(htmllink_obj != null)
	{
		//unmark
		var styleObj 	= getStyleSheetStyle('INPUT');

		if(styleObj != null)
		{
			var color 										= styleObj.color;
			htmllink_obj.style.color 						= color;

			if (document.getElementById && !document.all)
			{
				var textDecoration 								= styleObj.textDecoration;
			 	htmllink_obj.style.textDecoration  				= textDecoration;
			}
			else
			{
				var textDecorationUnderline 					= styleObj.textDecorationUnderline;
				var textDecorationNone 							= styleObj.textDecorationNone;

				htmllink_obj.style.textDecorationUnderline  	= textDecorationUnderline;
				htmllink_obj.style.textDecorationNone  			= textDecorationNone;
			}

			htmllink_obj.style.cursor  						= "";
		}
	}
}

function onLinkClick(htmllink)
{
	if(!isEmpty(htmllink))
	{
		//nur wenn der link gueltig ist diesen auch aufmachen ansonsten ignorieren
		if(isValidURL(htmllink))
			window.open(htmllink,'_blank');
	}
}

function timestart()
{
	var startTime = new Date().valueOf();
	return startTime;
}

function timeend(startTime,text)
{
	if(typeof text == "undefined")
		text = "";

	var endTime		= new Date().valueOf();
	var elapsedTime	= endTime-startTime;
	dump("Elapsed Time for "+text+" = " +elapsedTime+"ms (or "+ elapsedTime/1000 +"secs)");
}

function addSpecialEvent(obj,type,fn,p)
{
	obj["e"+type+fn] = fn;

	if (obj.addEventListener)
	{
		eval('obj.addEventListener( type, function(event){obj["e"+type+fn](event, ' + p + ')}, false );');
	}
	else if (obj.attachEvent)
	{
		obj[type+fn] = function() { eval ( 'obj["e"+type+fn](window.event, ' + p + ');' ); }
		obj.attachEvent("on"+type, obj[type+fn]);
	}
}

function mysqlTimeStampToDate(timestamp)
{
	//function parses mysql datetime string and returns javascript Date object
	//input has to be in this format: 2007-06-05 15:26:02
	var regex=/^([0-9]{2,4})-([0-1][0-9])-([0-3][0-9]) (?:([0-2][0-9]):([0-5][0-9]):([0-5][0-9]))?$/;
	var parts=timestamp.replace(regex,"$1 $2 $3 $4 $5 $6").split(' ');
	return new Date(parts[0],parts[1]-1,parts[2],parts[3],parts[4],parts[5]);
}

function buildFlashURL(flashlocation)
{
	var url 	= flashlocation;
	var args	= buildFlashURL.arguments;

	if(args.length > 1)
	{
		var p 		= 1;
		var bFirst 	= true;

		while(p < args.length)
		{
			if(bFirst)
			{
				bFirst = false;
				url += '?';
			}
			else
				url += '&';

			url += args[p++]+'='+encodeURIComponent(args[p++]);
		}
	}

	return url;
}

function XML_HTML_decoding()
{
	var to_decode = document.getElementsByName('decodeable');
	var s;

	for(var i = to_decode.length - 1; i >= 0; i--)
	{
		s = to_decode[i].textContent;

		if(s == undefined || (s.indexOf('&') == -1 && s.indexOf('<') == -1))
		{
			// the null or markupless element needs no reworking
		}
		else
		{
			to_decode[i].innerHTML = s;  // that's the magic
		}
	}

	return;
}

function addSlashes(str)
{
	str=str.replace(/\'/g,'\\\'');
	str=str.replace(/\"/g,'\\"');
	str=str.replace(/\\/g,'\\\\');
	str=str.replace(/\0/g,'\\0');

	str=str.replace(/\r/g,'\\r');
	str=str.replace(/\n/g,'\\n');

	return str;
}

function stripSlashes(str)
{
	str=str.replace(/\\'/g,'\'');
	str=str.replace(/\\"/g,'"');
	str=str.replace(/\\\\/g,'\\');
	str=str.replace(/\\0/g,'\0');
	return str;
}

//---debug keyhandler--//

function HtmlDecode(enc)
{
	if (enc==null) return;

	var sb = String();
	var len = enc.length;

	for (var i=0; i<len; i++)
	{
		var ch = enc.charAt(i);

		if (ch == '&')
		{
			var semicolonIndex = enc.indexOf(';', i+1);

			if (semicolonIndex > 0)
			{
				var entity = enc.substring(i + 1, semicolonIndex);

				if (entity.length > 1 && entity.charAt(0) == '#')
				{
					if (entity.charAt(1) == 'x' || entity.charAt(1) == 'X')
						ch = String.fromCharCode(eval('0'+entity.substring(1)));
					else
						ch = String.fromCharCode(eval(entity.substring(1)));
				}
				else
				{
					switch (entity)
					{
						case 'quot': ch = String.fromCharCode(0x0022); break;
						case 'amp': ch = String.fromCharCode(0x0026); break;
						case 'lt': ch = String.fromCharCode(0x003c); break;
						case 'gt': ch = String.fromCharCode(0x003e); break;
						case 'nbsp': ch = String.fromCharCode(0x00a0); break;
						case 'iexcl': ch = String.fromCharCode(0x00a1); break;
						case 'cent': ch = String.fromCharCode(0x00a2); break;
						case 'pound': ch = String.fromCharCode(0x00a3); break;
						case 'curren': ch = String.fromCharCode(0x00a4); break;
						case 'yen': ch = String.fromCharCode(0x00a5); break;
						case 'brvbar': ch = String.fromCharCode(0x00a6); break;
						case 'sect': ch = String.fromCharCode(0x00a7); break;
						case 'uml': ch = String.fromCharCode(0x00a8); break;
						case 'copy': ch = String.fromCharCode(0x00a9); break;
						case 'ordf': ch = String.fromCharCode(0x00aa); break;
						case 'laquo': ch = String.fromCharCode(0x00ab); break;
						case 'not': ch = String.fromCharCode(0x00ac); break;
						case 'shy': ch = String.fromCharCode(0x00ad); break;
						case 'reg': ch = String.fromCharCode(0x00ae); break;
						case 'macr': ch = String.fromCharCode(0x00af); break;
						case 'deg': ch = String.fromCharCode(0x00b0); break;
						case 'plusmn': ch = String.fromCharCode(0x00b1); break;
						case 'sup2': ch = String.fromCharCode(0x00b2); break;
						case 'sup3': ch = String.fromCharCode(0x00b3); break;
						case 'acute': ch = String.fromCharCode(0x00b4); break;
						case 'micro': ch = String.fromCharCode(0x00b5); break;
						case 'para': ch = String.fromCharCode(0x00b6); break;
						case 'middot': ch = String.fromCharCode(0x00b7); break;
						case 'cedil': ch = String.fromCharCode(0x00b8); break;
						case 'sup1': ch = String.fromCharCode(0x00b9); break;
						case 'ordm': ch = String.fromCharCode(0x00ba); break;
						case 'raquo': ch = String.fromCharCode(0x00bb); break;
						case 'frac14': ch = String.fromCharCode(0x00bc); break;
						case 'frac12': ch = String.fromCharCode(0x00bd); break;
						case 'frac34': ch = String.fromCharCode(0x00be); break;
						case 'iquest': ch = String.fromCharCode(0x00bf); break;
						case 'Agrave': ch = String.fromCharCode(0x00c0); break;
						case 'Aacute': ch = String.fromCharCode(0x00c1); break;
						case 'Acirc': ch = String.fromCharCode(0x00c2); break;
						case 'Atilde': ch = String.fromCharCode(0x00c3); break;
						case 'Auml': ch = String.fromCharCode(0x00c4); break;
						case 'Aring': ch = String.fromCharCode(0x00c5); break;
						case 'AElig': ch = String.fromCharCode(0x00c6); break;
						case 'Ccedil': ch = String.fromCharCode(0x00c7); break;
						case 'Egrave': ch = String.fromCharCode(0x00c8); break;
						case 'Eacute': ch = String.fromCharCode(0x00c9); break;
						case 'Ecirc': ch = String.fromCharCode(0x00ca); break;
						case 'Euml': ch = String.fromCharCode(0x00cb); break;
						case 'Igrave': ch = String.fromCharCode(0x00cc); break;
						case 'Iacute': ch = String.fromCharCode(0x00cd); break;
						case 'Icirc': ch = String.fromCharCode(0x00ce ); break;
						case 'Iuml': ch = String.fromCharCode(0x00cf); break;
						case 'ETH': ch = String.fromCharCode(0x00d0); break;
						case 'Ntilde': ch = String.fromCharCode(0x00d1); break;
						case 'Ograve': ch = String.fromCharCode(0x00d2); break;
						case 'Oacute': ch = String.fromCharCode(0x00d3); break;
						case 'Ocirc': ch = String.fromCharCode(0x00d4); break;
						case 'Otilde': ch = String.fromCharCode(0x00d5); break;
						case 'Ouml': ch = String.fromCharCode(0x00d6); break;
						case 'times': ch = String.fromCharCode(0x00d7); break;
						case 'Oslash': ch = String.fromCharCode(0x00d8); break;
						case 'Ugrave': ch = String.fromCharCode(0x00d9); break;
						case 'Uacute': ch = String.fromCharCode(0x00da); break;
						case 'Ucirc': ch = String.fromCharCode(0x00db); break;
						case 'Uuml': ch = String.fromCharCode(0x00dc); break;
						case 'Yacute': ch = String.fromCharCode(0x00dd); break;
						case 'THORN': ch = String.fromCharCode(0x00de); break;
						case 'szlig': ch = String.fromCharCode(0x00df); break;
						case 'agrave': ch = String.fromCharCode(0x00e0); break;
						case 'aacute': ch = String.fromCharCode(0x00e1); break;
						case 'acirc': ch = String.fromCharCode(0x00e2); break;
						case 'atilde': ch = String.fromCharCode(0x00e3); break;
						case 'auml': ch = String.fromCharCode(0x00e4); break;
						case 'aring': ch = String.fromCharCode(0x00e5); break;
						case 'aelig': ch = String.fromCharCode(0x00e6); break;
						case 'ccedil': ch = String.fromCharCode(0x00e7); break;
						case 'egrave': ch = String.fromCharCode(0x00e8); break;
						case 'eacute': ch = String.fromCharCode(0x00e9); break;
						case 'ecirc': ch = String.fromCharCode(0x00ea); break;
						case 'euml': ch = String.fromCharCode(0x00eb); break;
						case 'igrave': ch = String.fromCharCode(0x00ec); break;
						case 'iacute': ch = String.fromCharCode(0x00ed); break;
						case 'icirc': ch = String.fromCharCode(0x00ee); break;
						case 'iuml': ch = String.fromCharCode(0x00ef); break;
						case 'eth': ch = String.fromCharCode(0x00f0); break;
						case 'ntilde': ch = String.fromCharCode(0x00f1); break;
						case 'ograve': ch = String.fromCharCode(0x00f2); break;
						case 'oacute': ch = String.fromCharCode(0x00f3); break;
						case 'ocirc': ch = String.fromCharCode(0x00f4); break;
						case 'otilde': ch = String.fromCharCode(0x00f5); break;
						case 'ouml': ch = String.fromCharCode(0x00f6); break;
						case 'divide': ch = String.fromCharCode(0x00f7); break;
						case 'oslash': ch = String.fromCharCode(0x00f8); break;
						case 'ugrave': ch = String.fromCharCode(0x00f9); break;
						case 'uacute': ch = String.fromCharCode(0x00fa); break;
						case 'ucirc': ch = String.fromCharCode(0x00fb); break;
						case 'uuml': ch = String.fromCharCode(0x00fc); break;
						case 'yacute': ch = String.fromCharCode(0x00fd); break;
						case 'thorn': ch = String.fromCharCode(0x00fe); break;
						case 'yuml': ch = String.fromCharCode(0x00ff); break;
						case 'OElig': ch = String.fromCharCode(0x0152); break;
						case 'oelig': ch = String.fromCharCode(0x0153); break;
						case 'Scaron': ch = String.fromCharCode(0x0160); break;
						case 'scaron': ch = String.fromCharCode(0x0161); break;
						case 'Yuml': ch = String.fromCharCode(0x0178); break;
						case 'fnof': ch = String.fromCharCode(0x0192); break;
						case 'circ': ch = String.fromCharCode(0x02c6); break;
						case 'tilde': ch = String.fromCharCode(0x02dc); break;
						case 'Alpha': ch = String.fromCharCode(0x0391); break;
						case 'Beta': ch = String.fromCharCode(0x0392); break;
						case 'Gamma': ch = String.fromCharCode(0x0393); break;
						case 'Delta': ch = String.fromCharCode(0x0394); break;
						case 'Epsilon': ch = String.fromCharCode(0x0395); break;
						case 'Zeta': ch = String.fromCharCode(0x0396); break;
						case 'Eta': ch = String.fromCharCode(0x0397); break;
						case 'Theta': ch = String.fromCharCode(0x0398); break;
						case 'Iota': ch = String.fromCharCode(0x0399); break;
						case 'Kappa': ch = String.fromCharCode(0x039a); break;
						case 'Lambda': ch = String.fromCharCode(0x039b); break;
						case 'Mu': ch = String.fromCharCode(0x039c); break;
						case 'Nu': ch = String.fromCharCode(0x039d); break;
						case 'Xi': ch = String.fromCharCode(0x039e); break;
						case 'Omicron': ch = String.fromCharCode(0x039f); break;
						case 'Pi': ch = String.fromCharCode(0x03a0); break;
						case ' Rho ': ch = String.fromCharCode(0x03a1); break;
						case 'Sigma': ch = String.fromCharCode(0x03a3); break;
						case 'Tau': ch = String.fromCharCode(0x03a4); break;
						case 'Upsilon': ch = String.fromCharCode(0x03a5); break;
						case 'Phi': ch = String.fromCharCode(0x03a6); break;
						case 'Chi': ch = String.fromCharCode(0x03a7); break;
						case 'Psi': ch = String.fromCharCode(0x03a8); break;
						case 'Omega': ch = String.fromCharCode(0x03a9); break;
						case 'alpha': ch = String.fromCharCode(0x03b1); break;
						case 'beta': ch = String.fromCharCode(0x03b2); break;
						case 'gamma': ch = String.fromCharCode(0x03b3); break;
						case 'delta': ch = String.fromCharCode(0x03b4); break;
						case 'epsilon': ch = String.fromCharCode(0x03b5); break;
						case 'zeta': ch = String.fromCharCode(0x03b6); break;
						case 'eta': ch = String.fromCharCode(0x03b7); break;
						case 'theta': ch = String.fromCharCode(0x03b8); break;
						case 'iota': ch = String.fromCharCode(0x03b9); break;
						case 'kappa': ch = String.fromCharCode(0x03ba); break;
						case 'lambda': ch = String.fromCharCode(0x03bb); break;
						case 'mu': ch = String.fromCharCode(0x03bc); break;
						case 'nu': ch = String.fromCharCode(0x03bd); break;
						case 'xi': ch = String.fromCharCode(0x03be); break;
						case 'omicron': ch = String.fromCharCode(0x03bf); break;
						case 'pi': ch = String.fromCharCode(0x03c0); break;
						case 'rho': ch = String.fromCharCode(0x03c1); break;
						case 'sigmaf': ch = String.fromCharCode(0x03c2); break;
						case 'sigma': ch = String.fromCharCode(0x03c3); break;
						case 'tau': ch = String.fromCharCode(0x03c4); break;
						case 'upsilon': ch = String.fromCharCode(0x03c5); break;
						case 'phi': ch = String.fromCharCode(0x03c6); break;
						case 'chi': ch = String.fromCharCode(0x03c7); break;
						case 'psi': ch = String.fromCharCode(0x03c8); break;
						case 'omega': ch = String.fromCharCode(0x03c9); break;
						case 'thetasym': ch = String.fromCharCode(0x03d1); break;
						case 'upsih': ch = String.fromCharCode(0x03d2); break;
						case 'piv': ch = String.fromCharCode(0x03d6); break;
						case 'ensp': ch = String.fromCharCode(0x2002); break;
						case 'emsp': ch = String.fromCharCode(0x2003); break;
						case 'thinsp': ch = String.fromCharCode(0x2009); break;
						case 'zwnj': ch = String.fromCharCode(0x200c); break;
						case 'zwj': ch = String.fromCharCode(0x200d); break;
						case 'lrm': ch = String.fromCharCode(0x200e); break;
						case 'rlm': ch = String.fromCharCode(0x200f); break;
						case 'ndash': ch = String.fromCharCode(0x2013); break;
						case 'mdash': ch = String.fromCharCode(0x2014); break;
						case 'lsquo': ch = String.fromCharCode(0x2018); break;
						case 'rsquo': ch = String.fromCharCode(0x2019); break;
						case 'sbquo': ch = String.fromCharCode(0x201a); break;
						case 'ldquo': ch = String.fromCharCode(0x201c); break;
						case 'rdquo': ch = String.fromCharCode(0x201d); break;
						case 'bdquo': ch = String.fromCharCode(0x201e); break;
						case 'dagger': ch = String.fromCharCode(0x2020); break;
						case 'Dagger': ch = String.fromCharCode(0x2021); break;
						case 'bull': ch = String.fromCharCode(0x2022); break;
						case 'hellip': ch = String.fromCharCode(0x2026); break;
						case 'permil': ch = String.fromCharCode(0x2030); break;
						case 'prime': ch = String.fromCharCode(0x2032); break;
						case 'Prime': ch = String.fromCharCode(0x2033); break;
						case 'lsaquo': ch = String.fromCharCode(0x2039); break;
						case 'rsaquo': ch = String.fromCharCode(0x203a); break;
						case 'oline': ch = String.fromCharCode(0x203e); break;
						case 'frasl': ch = String.fromCharCode(0x2044); break;
						case 'euro': ch = String.fromCharCode(0x20ac); break;
						case 'image': ch = String.fromCharCode(0x2111); break;
						case 'weierp': ch = String.fromCharCode(0x2118); break;
						case 'real': ch = String.fromCharCode(0x211c); break;
						case 'trade': ch = String.fromCharCode(0x2122); break;
						case 'alefsym': ch = String.fromCharCode(0x2135); break;
						case 'larr': ch = String.fromCharCode(0x2190); break;
						case 'uarr': ch = String.fromCharCode(0x2191); break;
						case 'rarr': ch = String.fromCharCode(0x2192); break;
						case 'darr': ch = String.fromCharCode(0x2193); break;
						case 'harr': ch = String.fromCharCode(0x2194); break;
						case 'crarr': ch = String.fromCharCode(0x21b5); break;
						case 'lArr': ch = String.fromCharCode(0x21d0); break;
						case 'uArr': ch = String.fromCharCode(0x21d1); break;
						case 'rArr': ch = String.fromCharCode(0x21d2); break;
						case 'dArr': ch = String.fromCharCode(0x21d3); break;
						case 'hArr': ch = String.fromCharCode(0x21d4); break;
						case 'forall': ch = String.fromCharCode(0x2200); break;
						case 'part': ch = String.fromCharCode(0x2202); break;
						case 'exist': ch = String.fromCharCode(0x2203); break;
						case 'empty': ch = String.fromCharCode(0x2205); break;
						case 'nabla': ch = String.fromCharCode(0x2207); break;
						case 'isin': ch = String.fromCharCode(0x2208); break;
						case 'notin': ch = String.fromCharCode(0x2209); break;
						case 'ni': ch = String.fromCharCode(0x220b); break;
						case 'prod': ch = String.fromCharCode(0x220f); break;
						case 'sum': ch = String.fromCharCode(0x2211); break;
						case 'minus': ch = String.fromCharCode(0x2212); break;
						case 'lowast': ch = String.fromCharCode(0x2217); break;
						case 'radic': ch = String.fromCharCode(0x221a); break;
						case 'prop': ch = String.fromCharCode(0x221d); break;
						case 'infin': ch = String.fromCharCode(0x221e); break;
						case 'ang': ch = String.fromCharCode(0x2220); break;
						case 'and': ch = String.fromCharCode(0x2227); break;
						case 'or': ch = String.fromCharCode(0x2228); break;
						case 'cap': ch = String.fromCharCode(0x2229); break;
						case 'cup': ch = String.fromCharCode(0x222a); break;
						case 'int': ch = String.fromCharCode(0x222b); break;
						case 'there4': ch = String.fromCharCode(0x2234); break;
						case 'sim': ch = String.fromCharCode(0x223c); break;
						case 'cong': ch = String.fromCharCode(0x2245); break;
						case 'asymp': ch = String.fromCharCode(0x2248); break;
						case 'ne': ch = String.fromCharCode(0x2260); break;
						case 'equiv': ch = String.fromCharCode(0x2261); break;
						case 'le': ch = String.fromCharCode(0x2264); break;
						case 'ge': ch = String.fromCharCode(0x2265); break;
						case 'sub': ch = String.fromCharCode(0x2282); break;
						case 'sup': ch = String.fromCharCode(0x2283); break;
						case 'nsub': ch = String.fromCharCode(0x2284); break;
						case 'sube': ch = String.fromCharCode(0x2286); break;
						case 'supe': ch = String.fromCharCode(0x2287); break;
						case 'oplus': ch = String.fromCharCode(0x2295); break;
						case 'otimes': ch = String.fromCharCode(0x2297); break;
						case 'perp': ch = String.fromCharCode(0x22a5); break;
						case 'sdot': ch = String.fromCharCode(0x22c5); break;
						case 'lceil': ch = String.fromCharCode(0x2308); break;
						case 'rceil': ch = String.fromCharCode(0x2309); break;
						case 'lfloor': ch = String.fromCharCode(0x230a); break;
						case 'rfloor': ch = String.fromCharCode(0x230b); break;
						case 'lang': ch = String.fromCharCode(0x2329); break;
						case 'rang': ch = String.fromCharCode(0x232a); break;
						case 'loz': ch = String.fromCharCode(0x25ca); break;
						case 'spades': ch = String.fromCharCode(0x2660); break;
						case 'clubs': ch = String.fromCharCode(0x2663); break;
						case 'hearts': ch = String.fromCharCode(0x2665); break;
						case 'diams': ch = String.fromCharCode(0x2666); break;
						default: ch = ''; break;
					}
				}

				i = semicolonIndex;
			}
		}

		sb += ch;
	}

	return sb.toString();
}

function include(file)
{
    var script = document.createElement('script');

    var type = document.createAttribute('type');
    	type.nodeValue = 'text/javascript';

	script.setAttributeNode(type);

    var source = document.createAttribute('src');
    	source.nodeValue = file;

	script.setAttributeNode(source);

    var head = document.getElementsByTagName('head')[0];
		head.appendChild(script);
}

function extendClass(subclass, superclass)
{
	var f = function() {};
		f.prototype = superclass.prototype;

	subclass.prototype 				= new f();
	subclass.prototype.constructor	= subclass;
	subclass.superclass 			= superclass.prototype;

	if (superclass.prototype.constructor == Object.prototype.constructor)
	{
		superclass.prototype.constructor = superclass;
	}
}