function wb() {
	var _self=this;
	_self.browser; 
	_self.event_key;
	_self.capture_event;
	_self.events= new Array();
	_self.events['on_mouse_left_click'] = new Array();
	_self.events['on_mouse_right_click'] = new Array();
	_self.mousex = 0;
	_self.mousey = 0;
	_self.clipboard = new Array();
	_self.cookies = new Array();
	_self.lang = new Array();
	_self.loaded = new Array();
	_self.wb_login = 0;
	_self.flash_version='';
	_self.isjquery=false;
	_self.sid = '';
	
	_self.init = function() {
		_self.wb_cookie('INIT');
		$().mousemove( function(obj) {		
			_self.mousex = obj.pageX;
			_self.mousey = obj.pageY;
		});
		_self.allow_script();
	}
	_self.allow_script = function(yreload) {
		_self.wb_cookie('SET','allow_script','1',(2 * 60 * 60 * 1000));
		if(yreload) {
			location.reload();
		}
	}
	_self.isDefined = function(yvar) {
		return this[yvar] === undefined ? false : true;
	}

	_self.browser_check = function() {
		// Browser
		var ie4=document.all
		var ie5=document.getElementById&&document.all
		var ie6=document.getElementById&&document.all&&(navigator.appVersion.indexOf("MSIE 6.")!=-1)
		var ns4=document.layers
		var ns6=document.getElementById&&!document.all

		// Browser
		if(ns4)
			ybrowser = "MOZ";
		if (ns6)
			ybrowser = "MOZ";
		if (ie4 && !ie5 && !ie6)
			ybrowser = "IE";
		if (ie5 && ie4 && !ie6)
			ybrowser = "IE";
		if (ie6)
			ybrowser = "IE";
		
		return ybrowser;
	}

	_self.browser = _self.browser_check();
	
	_self.reg_event = function(yevent,yfunction) {
		_self.events[yevent].push(yfunction);
	}
	
	_self.release_event = function(yevent) {
		var yout = _self.events[yevent].join("; ");
		eval(yout);
	}
	_self.wb_window = function(yname,ylink,ywidth,yheight,yparams) {
		if(!ywidth || ywidth=="")
			var ywidth=600;
		if(!yheight || yheight=="")
			var yheight=500;
		
		
		var ytop = (screen.height-yheight)/2;
		var yleft = (screen.width-ywidth)/2;
		var ystatus='yes';
		var yscroll='yes';
		var yresize='yes';
		if(!yparams)
			yparams="";
		if(yparams.search(/resizable=no/i)>-1) {
			yresize="no";
		}
		if(yparams.search(/scrollbars=no/i)>-1) {
			yscroll="no";
		}
		var ymenubar='no';
		if(yparams.search(/menubar=yes/i)>-1) {
			ymenubar="yes";
		}
		var yparam = "width="+ywidth+",height="+yheight+",left="+yleft+",top="+ytop+",status="+ystatus+",scrollbars="+yscroll+",menubar="+ymenubar+",resizable="+yresize;
		window.open(ylink,yname,yparam);
	}
	_self.wb_hover_src = function(yobj,yflag,ymod) {
		var yobj = yobj;
		var ysrc = yobj.src;
		if(ymod==0) {
			yobj.src = ysrc.replace(/\./,yflag+'.');
		} else {
			yobj.src = ysrc.replace(yflag,"");
		}
	}
	
	_self.wb_load_plugin = function(yplugin) {
		yreturn = false;
		yeval = "var yreturn=new "+yplugin+"();";
		eval(yeval);
		return yreturn;
	}
	
	_self.wb_load_com = function(ycom) {
		yreturn = false;
		yeval = "var yreturn=new "+ycom+"();";
		eval(yeval);
		return yreturn;
	}
	
	_self.wb_notify = function(yaction,ytitle,ymessage) {
		var yobj = parent.document.getElementById("wb_notify_box");
		if(yaction) {
			if(yobj)
				yobj.innerHTML = '<h3 onclick="javascript:parent.obj_wb.wb_notify(0)">'+ytitle+'</h3>'+ymessage;
				yobj.style.display='block';
				window.setTimeout("obj_wb.wb_notify(0)", 5000);

		} else {
				yobj.style.display='none';
		}
	}
	
	_self.wb_fontzoom = function(yaction) {
		var ymax = 16;
		var ymin = 10;
		var yfontsize = document.getElementById('main_content').style.fontSize.replace(/em/ig,"");
		if(yfontsize=="")
			yfontsize=1;
		yfontsize = parseFloat(yfontsize)*10;
		if(yaction=="+") {
			yfontsize = yfontsize+2;
			if(yfontsize<=ymax)
				document.getElementById('main_content').style.fontSize = (yfontsize/10)+"em";
		} else {
			yfontsize = yfontsize-2;
			if(yfontsize>=ymin)
				document.getElementById('main_content').style.fontSize = (yfontsize/10)+"em";
		}
	}
	
	_self.hidden_load = function(ylink) {
		wb_action_frame.window.location.href=ylink;
	}
	
	_self.wb_new = function(yroot) {
		yreturn = false;
		yroot = yroot.replace(/\:/ig,'_');
		if(!_self.loaded[yroot]) {
			var yeval = "_self.loaded[yroot]=new "+yroot+"();";
			eval(yeval);
			if(_self.loaded[yroot]) {
				return _self.loaded[yroot];
			} else {
				return false;
			}
		} else {
			return _self.loaded[yroot];
		}
	}
	
	_self.wb_clipboard = function(yaction,yvar,yvalues,ynotify) {
		if(yaction.toUpperCase()=="PUT") {
			_self.wb_cookie('SET','clipboard:'+yvar,yvalues,(2 * 60 * 60 * 1000));
			if(ynotify!="") {
				_self.wb_notify(1,'Info',ynotify);
			}
		} else {
			return _self.wb_cookie('GET','clipboard:'+yvar);
		}
	}
	_self.wb_get_content = function(yid,ydiv_hide,ydiv_show,ysrc,yaccess) {
		if(yaccess>0 && _self.wb_login!='1') {
			return true;
		}
		if(ysrc) {
			var ycheck = ':'+$('div#'+ydiv_show+yid).html()+':';;
			if(ycheck=='::') {
				$.get(ysrc,function(data) {
					data = escape(data);
					data = unescape(data);
					$('div#'+ydiv_hide+yid).hide();
					$('div#'+ydiv_show+yid).append(data);
					$('div#'+ydiv_show+yid+" div.toolbar ul").append('<li><a href="#'+yid+'" onclick="javascript:obj_wb.wb_get_content(\''+yid+'\',\''+ydiv_show+'\',\''+ydiv_hide+'\',\'\',\'\')">&raquo; Artikel schliessen</a></li>');
					$('div.bottom').show();
					$("div#"+ydiv_show+yid).slideDown('fast',function() {
						window.location.href="#"+yid;
					});
				});
			} else {
				$('div#'+ydiv_hide+yid).hide();
				$("div#"+ydiv_show+yid).slideDown('fast',function() {
					window.location.href="#"+yid;
				});
			}
			
		} else {
			$('div#'+ydiv_hide+yid).hide();
			$("div#"+ydiv_show+yid).show();
			
		}
		return false;
	}
	_self.wb_status_loading = function(ytext,ystatus) {
		if(ystatus) {
			var yleft = ($('#wrapper').width()-200)/2;
			var ytop = ($(window).height()-90)/2;
			ytext = ytext+'<br/><br/><img src="/fb/mm/gfx/progressbar.gif" alt="Progress"/>';
			var yadd = '<div id="wb_status_loading" class="wb_status_loading" style="overflow:hidden;text-align:center;font-size:0.85em;position:absolute;left:'+yleft+';top:'+ytop+';width:200px;height:90px;padding:8px;border:2px outset #FFFFFF;background-color:#E1E1E1">'+ytext+'</div>';
			$(document.body).append(yadd);
		} else {
			$('#wb_status_loading').remove();
		}
		
	}
	_self.wb_cookie = function(yaction,yvar,yvalue,ytimeout) {
		switch(yaction.toUpperCase()) {
			case "SET":
				var yexpire = new Date();
				if(!ytimeout) {
					ytimeout = (60*24*60*60*1000);
				}
				var ytimeout = yexpire.getTime() + ytimeout;
				yexpire.setTime(ytimeout);
				yvalue = yvalue.replace(/;/ig,'||');
				var yset = "wb["+yvar+"]="+yvalue+"; path=/; expires=" + yexpire.toGMTString();
				document.cookie = yset;
			break;
			case "GET":
				_self.wb_cookie('REFRESH');
				yvar = "wb:"+yvar;
				if(_self.cookies[yvar]) {
					return _self.cookies[yvar];
				}
			break;
			case "LIST":
				yreturn = "";
				for(var yfield in _self.cookies) {
					yreturn = yreturn+yfield+" = "+_self.cookies[yfield]+"\n";
				}
				return yreturn;
			break;
			case "INIT":
				_self.wb_cookie("REFRESH");
			break;
			case "REFRESH":
				if(document.cookie) {
					var ycookies = document.cookie.split(";");
					for(x=0;x<ycookies.length;x++) {
						var ytemp = ycookies[x].split("=");
						if(ytemp[0]) {
							var ytemp_var = ytemp[0].replace(/\[/ig,':');
							ytemp_var = ytemp_var.replace(/\]/ig,'');
							ytemp_value="";
							if(ytemp[1]) {
								ytemp_value = ytemp[1];
							}
							ytemp_value = ytemp_value.replace(/\|\|/ig,';');
							ytemp_var = ytemp_var.replace(/ /ig,'');
							if(ytemp_var!="") {
								_self.cookies[ytemp_var]=ytemp_value;
							}
						}
					}
				}
				
			break;
		}
	}
	
	_self.wb_dialog = function(strId,intX,intY,intWidth,intHeight,strTitle,strHtml,intType) {
		var strDb = '';
		if(!strId)
			strId = 'wbdialog'+_self.wb_uniqid();
		if(intWidth<1) {
			intWidth=300;
		}
		if(intHeight<1) {
			intHeight=230;
		}
		if(intX<0) {
			intX = ($(window).width()-intWidth)/2;
		}
		if(intY<0) {
			intY = ($(window).height()-intHeight)/2;
		}
		strDb += '<div id="'+strId+'" class="dialogbox" style="position:absolute;top:'+intY+'px;left:'+intX+'px;width:'+intWidth+'px;height:'+intHeight+'px;border:2px outset #FFFFFF;background-color:#CCCCCC;">';
		strDb += '<h3 style="padding:4px;background-color:#808080;color:#FFFFFF;margin:0px;font-size:1em;height:18px;overflow:auto;line-height:18px;"><div style="float:left;width:70%" class="title">'+strTitle+'</div><div style="float:right;width:25%;text-align:right;" class="dialogtool"><a href="#" onclick="javascript:$(\'div#'+strId+'\').remove();">[X]</a></div></h3>';
		strDb += '<div class="content" style="padding:8px;">'+strHtml+'</div>';
		strDb += '</div>';
		$("body").append(strDb);
		return strId;
	}
	
	_self.wb_uniqid = function() {
		var newDate = new Date;
		return newDate.getTime(); 
	}
	
	_self.wb_picbox = function(strSource,strAlt,strTitle) {
		var strHtml = '';
		var strId = 'wbpicbox'+_self.wb_uniqid();
		strHtml += '<div id="'+strId+'" class="picbox" style="position:absolute;display:none;z-index:1;top:0px;left:0px;border:2px outset #FFFFFF;background-color:#cccccc;">';
		strHtml += '<div id="window_title" style="text-align:right;background-color:#808080;padding:3px;overflow:auto;"><div id="butt_close" style="padding:3px;display:inline;cursor:pointer;color:#ffffff;">[ X ]</div></div>';
		strHtml += '<img id="img_'+strId+'" src="'+strSource+'" alt="'+strAlt+'" style="margin:8px;border:2px inset #ffffff"/>';
		if(strTitle) {
			strHtml += '<p class="description">'+strTitle+'</p>';
		}
		strHtml += '</div>';
		$("body").append(strHtml);
		var intWidth=$("div#"+strId).width();
		var intHeight=$("div#"+strId).height();
		var intX = ($("div#left_frame").width()-intWidth)/2;
		var intY = ($(window).height()-intHeight)/2;
		$("#"+strId).css({left:intX+"px",top:intY+"px",width:intWidth+"px",height:intHeight+"px"});
		$("#"+strId).click(function() {
			$("#"+strId).remove();
		});
		$("#butt_close").click(function() {
			$("#"+strId).remove();
		});
		$("img#img_"+strId).load(function() {
			$("#"+strId).fadeIn();
		});
	}
}
var wb = new wb();
var obj_wb = wb;

jQuery(function($) { 
	(function($){
			
		var rotateLeft = function(lValue, iShiftBits) {
			return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits));
		}
		
		var addUnsigned = function(lX, lY) {
			var lX4, lY4, lX8, lY8, lResult;
			lX8 = (lX & 0x80000000);
			lY8 = (lY & 0x80000000);
			lX4 = (lX & 0x40000000);
			lY4 = (lY & 0x40000000);
			lResult = (lX & 0x3FFFFFFF) + (lY & 0x3FFFFFFF);
			if (lX4 & lY4) return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
			if (lX4 | lY4) {
				if (lResult & 0x40000000) return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
				else return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
			} else {
				return (lResult ^ lX8 ^ lY8);
			}
		}
		
		var F = function(x, y, z) {
			return (x & y) | ((~ x) & z);
		}
		
		var G = function(x, y, z) {
			return (x & z) | (y & (~ z));
		}
		
		var H = function(x, y, z) {
			return (x ^ y ^ z);
		}
		
		var I = function(x, y, z) {
			return (y ^ (x | (~ z)));
		}
		
		var FF = function(a, b, c, d, x, s, ac) {
			a = addUnsigned(a, addUnsigned(addUnsigned(F(b, c, d), x), ac));
			return addUnsigned(rotateLeft(a, s), b);
		};
		
		var GG = function(a, b, c, d, x, s, ac) {
			a = addUnsigned(a, addUnsigned(addUnsigned(G(b, c, d), x), ac));
			return addUnsigned(rotateLeft(a, s), b);
		};
		
		var HH = function(a, b, c, d, x, s, ac) {
			a = addUnsigned(a, addUnsigned(addUnsigned(H(b, c, d), x), ac));
			return addUnsigned(rotateLeft(a, s), b);
		};
		
		var II = function(a, b, c, d, x, s, ac) {
			a = addUnsigned(a, addUnsigned(addUnsigned(I(b, c, d), x), ac));
			return addUnsigned(rotateLeft(a, s), b);
		};
		
		var convertToWordArray = function(string) {
			var lWordCount;
			var lMessageLength = string.length;
			var lNumberOfWordsTempOne = lMessageLength + 8;
			var lNumberOfWordsTempTwo = (lNumberOfWordsTempOne - (lNumberOfWordsTempOne % 64)) / 64;
			var lNumberOfWords = (lNumberOfWordsTempTwo + 1) * 16;
			var lWordArray = Array(lNumberOfWords - 1);
			var lBytePosition = 0;
			var lByteCount = 0;
			while (lByteCount < lMessageLength) {
				lWordCount = (lByteCount - (lByteCount % 4)) / 4;
				lBytePosition = (lByteCount % 4) * 8;
				lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount) << lBytePosition));
				lByteCount++;
			}
			lWordCount = (lByteCount - (lByteCount % 4)) / 4;
			lBytePosition = (lByteCount % 4) * 8;
			lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80 << lBytePosition);
			lWordArray[lNumberOfWords - 2] = lMessageLength << 3;
			lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29;
			return lWordArray;
		};
		
		var wordToHex = function(lValue) {
			var WordToHexValue = "", WordToHexValueTemp = "", lByte, lCount;
			for (lCount = 0; lCount <= 3; lCount++) {
				lByte = (lValue >>> (lCount * 8)) & 255;
				WordToHexValueTemp = "0" + lByte.toString(16);
				WordToHexValue = WordToHexValue + WordToHexValueTemp.substr(WordToHexValueTemp.length - 2, 2);
			}
			return WordToHexValue;
		};
		
		var uTF8Encode = function(string) {
			string = string.replace(/\x0d\x0a/g, "\x0a");
			var output = "";
			for (var n = 0; n < string.length; n++) {
				var c = string.charCodeAt(n);
				if (c < 128) {
					output += String.fromCharCode(c);
				} else if ((c > 127) && (c < 2048)) {
					output += String.fromCharCode((c >> 6) | 192);
					output += String.fromCharCode((c & 63) | 128);
				} else {
					output += String.fromCharCode((c >> 12) | 224);
					output += String.fromCharCode(((c >> 6) & 63) | 128);
					output += String.fromCharCode((c & 63) | 128);
				}
			}
			return output;
		};
		
		$.extend({
			md5: function(string) {
				var x = Array();
				var k, AA, BB, CC, DD, a, b, c, d;
				var S11=7, S12=12, S13=17, S14=22;
				var S21=5, S22=9 , S23=14, S24=20;
				var S31=4, S32=11, S33=16, S34=23;
				var S41=6, S42=10, S43=15, S44=21;
				string = uTF8Encode(string);
				x = convertToWordArray(string);
				a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476;
				for (k = 0; k < x.length; k += 16) {
					AA = a; BB = b; CC = c; DD = d;
					a = FF(a, b, c, d, x[k+0],  S11, 0xD76AA478);
					d = FF(d, a, b, c, x[k+1],  S12, 0xE8C7B756);
					c = FF(c, d, a, b, x[k+2],  S13, 0x242070DB);
					b = FF(b, c, d, a, x[k+3],  S14, 0xC1BDCEEE);
					a = FF(a, b, c, d, x[k+4],  S11, 0xF57C0FAF);
					d = FF(d, a, b, c, x[k+5],  S12, 0x4787C62A);
					c = FF(c, d, a, b, x[k+6],  S13, 0xA8304613);
					b = FF(b, c, d, a, x[k+7],  S14, 0xFD469501);
					a = FF(a, b, c, d, x[k+8],  S11, 0x698098D8);
					d = FF(d, a, b, c, x[k+9],  S12, 0x8B44F7AF);
					c = FF(c, d, a, b, x[k+10], S13, 0xFFFF5BB1);
					b = FF(b, c, d, a, x[k+11], S14, 0x895CD7BE);
					a = FF(a, b, c, d, x[k+12], S11, 0x6B901122);
					d = FF(d, a, b, c, x[k+13], S12, 0xFD987193);
					c = FF(c, d, a, b, x[k+14], S13, 0xA679438E);
					b = FF(b, c, d, a, x[k+15], S14, 0x49B40821);
					a = GG(a, b, c, d, x[k+1],  S21, 0xF61E2562);
					d = GG(d, a, b, c, x[k+6],  S22, 0xC040B340);
					c = GG(c, d, a, b, x[k+11], S23, 0x265E5A51);
					b = GG(b, c, d, a, x[k+0],  S24, 0xE9B6C7AA);
					a = GG(a, b, c, d, x[k+5],  S21, 0xD62F105D);
					d = GG(d, a, b, c, x[k+10], S22, 0x2441453);
					c = GG(c, d, a, b, x[k+15], S23, 0xD8A1E681);
					b = GG(b, c, d, a, x[k+4],  S24, 0xE7D3FBC8);
					a = GG(a, b, c, d, x[k+9],  S21, 0x21E1CDE6);
					d = GG(d, a, b, c, x[k+14], S22, 0xC33707D6);
					c = GG(c, d, a, b, x[k+3],  S23, 0xF4D50D87);
					b = GG(b, c, d, a, x[k+8],  S24, 0x455A14ED);
					a = GG(a, b, c, d, x[k+13], S21, 0xA9E3E905);
					d = GG(d, a, b, c, x[k+2],  S22, 0xFCEFA3F8);
					c = GG(c, d, a, b, x[k+7],  S23, 0x676F02D9);
					b = GG(b, c, d, a, x[k+12], S24, 0x8D2A4C8A);
					a = HH(a, b, c, d, x[k+5],  S31, 0xFFFA3942);
					d = HH(d, a, b, c, x[k+8],  S32, 0x8771F681);
					c = HH(c, d, a, b, x[k+11], S33, 0x6D9D6122);
					b = HH(b, c, d, a, x[k+14], S34, 0xFDE5380C);
					a = HH(a, b, c, d, x[k+1],  S31, 0xA4BEEA44);
					d = HH(d, a, b, c, x[k+4],  S32, 0x4BDECFA9);
					c = HH(c, d, a, b, x[k+7],  S33, 0xF6BB4B60);
					b = HH(b, c, d, a, x[k+10], S34, 0xBEBFBC70);
					a = HH(a, b, c, d, x[k+13], S31, 0x289B7EC6);
					d = HH(d, a, b, c, x[k+0],  S32, 0xEAA127FA);
					c = HH(c, d, a, b, x[k+3],  S33, 0xD4EF3085);
					b = HH(b, c, d, a, x[k+6],  S34, 0x4881D05);
					a = HH(a, b, c, d, x[k+9],  S31, 0xD9D4D039);
					d = HH(d, a, b, c, x[k+12], S32, 0xE6DB99E5);
					c = HH(c, d, a, b, x[k+15], S33, 0x1FA27CF8);
					b = HH(b, c, d, a, x[k+2],  S34, 0xC4AC5665);
					a = II(a, b, c, d, x[k+0],  S41, 0xF4292244);
					d = II(d, a, b, c, x[k+7],  S42, 0x432AFF97);
					c = II(c, d, a, b, x[k+14], S43, 0xAB9423A7);
					b = II(b, c, d, a, x[k+5],  S44, 0xFC93A039);
					a = II(a, b, c, d, x[k+12], S41, 0x655B59C3);
					d = II(d, a, b, c, x[k+3],  S42, 0x8F0CCC92);
					c = II(c, d, a, b, x[k+10], S43, 0xFFEFF47D);
					b = II(b, c, d, a, x[k+1],  S44, 0x85845DD1);
					a = II(a, b, c, d, x[k+8],  S41, 0x6FA87E4F);
					d = II(d, a, b, c, x[k+15], S42, 0xFE2CE6E0);
					c = II(c, d, a, b, x[k+6],  S43, 0xA3014314);
					b = II(b, c, d, a, x[k+13], S44, 0x4E0811A1);
					a = II(a, b, c, d, x[k+4],  S41, 0xF7537E82);
					d = II(d, a, b, c, x[k+11], S42, 0xBD3AF235);
					c = II(c, d, a, b, x[k+2],  S43, 0x2AD7D2BB);
					b = II(b, c, d, a, x[k+9],  S44, 0xEB86D391);
					a = addUnsigned(a, AA);
					b = addUnsigned(b, BB);
					c = addUnsigned(c, CC);
					d = addUnsigned(d, DD);
				}
				var tempValue = wordToHex(a) + wordToHex(b) + wordToHex(c) + wordToHex(d);
				return tempValue.toLowerCase();
			}
		});
	})(jQuery);
	
	$.wb = obj_wb;
	$.wb.init();
});

