var $global={};

(function(){
 $global.EmailRegex = /^(([^<>()[\]\\.,;:+\s@\"]+(\.[^<>()[\]\\.,;:+\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i;
})();

// Extending jQuery
if (!$.wait )
{
 $.extend({
  // window settimeout
  wait : function()
  {
   var args = $.makeArray(arguments),
   m = args.shift(),
   t = args.length > 0 ? args.shift() : 10;
   return window.setTimeout( function() { m.apply( this, [].concat( args ) ); }, t );
  }
 });
}

$.extend({
 preloadImg : function( url )
 {
  if(!$global.imgcacheurls) { $global.imgcacheurls=[]; }
  $global.imgcacheurls.push( url );
 },
 
 // google analytics tracker
 track : function( url, ref )
 {
  if( $global.GAT )
  {
   try { $global.GAT._trackPageview( url + ( undefined != ref ? "--ref=" + ref : "" ) ); }catch(ex){}
  }
 },
 trackExternal : function( url, ref )
 {
  $.track( "/extern/" + url.replace( /http(s)?\:\/\//gi, "" ), ref );
 },

 //url manipulation
 getRelativeUrl : function (newpath, url, ignorequery)
 {
  if (undefined == url) { url = location.pathname; }
  return url + ( "/" == url.charAt(url.length-1) ? "" : "/" ) + newpath + ( !ignorequery ? location.search : "" );
 },

 
 //equalize box heights
 equalize : function (groups)
 {
  groups.each( function (){
   var maxh = 0,
   group = $(this).children("div");
//    group = $("div.article", $(this));
  if (group.length < 2) return;
   group.each( function() {
    $(this).height("auto"); // reset
    var h = $(this).height();
    maxh = h > maxh ? h : maxh;
   });
   group.height(maxh);
  });
 },

 //email validator
 isValidEmail : function (email)
 {
  return $global.EmailRegex.test(email);
 },

 // handle right form
 handleForm : function (containerid, button, autofocus)
 {
  $("#"+containerid+" input").keydown( function(e){
   if(13==e.keyCode){ e.preventDefault(); e.stopPropagation(); $(button).click(); }
  });
  /* $(button).bind("click", function(e){ $(this).attr("disabled", "disabled"); }); */
  if (undefined == autofocus || !!autofocus) {
   $("#"+containerid+" input:text[value='']:first").focus();
  }
 },

 // is special key
 isSpecialKey : function (key)
 {
  return ("|"+[8,9,13,17,18,35,36,37,38,39,46].join("|")+"|").indexOf("|"+key+"|")>-1;
 },

 // message box
 message : function (box, type, big, text)
 {
  type = -1 == type ? "error" : 1 == type ? "okay" : "info";
  return $(box).html('<div class="msgbox '+type+'msgbox'+sizeCSS()+'"><div class="message"><div>'+text+'</div></div></div>').show();
  function sizeCSS() { if(!big){ return " smallmsgbox small"+type+"msgbox"; } return ""; }
 },

 ajaxUrl: function (url, method) {
  return method ? ( url + (url.match(/\?/) ? "&" : "?") + "_sf=" + method ) : url;
 }
});

// Google Analytics

$(function(){
 $.wait( function()
 {
  var host = ("https:" == document.location.protocol ? "https://ssl." : "http://www.");
  $.getScript(host + "google-analytics.com/ga.js", function()
  {
   $.wait( function(){
    try{
     $global.GAT=_gat._getTracker("UA-5707524-2"); // + location.host.toLowerCase().indexOf("guntramsdorf")>-1 ? "2" : "3");
     $global.GAT._setDomainName("none");
     $global.GAT._setAllowLinker(true);
     $.track($global.GA_url||'');
    }
    catch(ex){
    }
   });
  });
 }, 2500 );
});

// Textarea limit

$.fn.limit = function(max, counter) { 
	this.unbind(".limit").bind("keyup.limit blur.limit", function(e) {
		var len = $(this).val().length;
		if (len > max) {
			$(this).val($(this).val().substr(0, max));
		}
		if ($.isFunction(counter)) {
			counter.call($(this), max, len > max ? max : len);
		}
	});

	return this.each(function(i) {
		if ($.isFunction(counter)) {
			counter.call($(this), max, $(this).val().length > max ? max : $(this).val().length);
		}
	});
};


function setFontSize( size, fromCookie, a )
{
 var em;
 switch( $.trim(size) )
 {
  case "klein": em = "0.625em"; break;
  case "gross": em = "0.938em"; break;
  case "mittel":
  default: em = "0.75em"; break;
 }
 
 var o = $("#cssstyles")[0],
 s = o.sheet || o.styleSheet,
 r = s.rules || s.cssRules;
 $.each( r, function( i, rule )
 {
  if( "#main" == rule.selectorText )
  {
   rule.style.fontSize = em;
   return false;
  }
 });
 
 if( !fromCookie )
 {
    $.equalize($(".equal"));
    document.cookie="schrift=" + size + ";path=/;expires=Wed, 01 Jan 2020 00:00:00 GMT";
    a.blur();
    $.track( "/aktion/schriftgroesse/" + size + "/" );
 }
 
 return false;
}



(function(){

 // set font size

 var res = document.cookie.match(/schrift=([^;]+)/i);
 if( null != res && res.length > 1 ){ setFontSize( res[1], true ); }

 // initialize live-events

 $("input.onlydigits").live("keypress",function(e)
 {
  if( e.ctrlKey || e.altKey || e.metaKey ) { return true; }
  var chars = ( $(this).hasClass("spacesallowed") ? " " : "" ) + "0123456789",
  key = e.which || e.keyCode,
  ok = ( $.isSpecialKey( key ) || chars.indexOf( String.fromCharCode( key ) ) > -1 );
  if( !ok ){ e.preventDefault(); }
  return ok;
 });
})();


$(function(){

 $(".fixrelativeurl").each(function(){
  $(this).attr("href", $.getRelativeUrl($(this).attr("href")));
 });

 // suche

 var hint = "Suchbegriff eingeben";
 $("#search input").val(hint).bind("focus.hidehint",function(e){
  hint == $.trim($(this).val()) ? $(this).val("") : null;
 }).bind("blur.showhint", function(e){
  "" == $.trim($(this).val()) ? $(this).val(hint) : null;
 }).bind("keydown.submit", function(e){
  var val = $.trim($(this).val());
  if (13==e.keyCode && (hint==val || ""==val))
  {
   $.wait(function(){alert("Bitte einen Suchbegriff eingeben.");});
   return false;
  }
 });
 $("#searchlink a").bind("click.submit",function(e){
  $(this).blur();
  if (hint == $.trim($("#search input").val()))
   alert("Bitte einen Suchbegriff eingeben.");
 });
 
 // track external link list

 $("#links a").bind("click.track",function(e){
  $.trackExternal($(this).attr("href"),"seitenleiste");
 });
 $("#midbar a[target=_blank]").bind("click.track",function(e){
  if("/"==$(this).attr("href").charAt(0)){return;}
  $.trackExternal($(this).attr("href"));
 });

 //equalize boxes

 $.equalize($(".equal"));

 //change titles with nicer ones...

 $.fn.qtip.styles.mp = { name: 'light', "font-size":"0.875em", tip: true, background:"#f0f3f8", color:"#052d6a", 
			 border: { color:"#052d6a", width:5, radius:5 }, 
			 title: { "background-color": "#f0f3f8", "color": "#052d6a", "border-bottom": "1px solid" },
			 width: { min:30, max:500 } };

 $("[title!='']:not([rel^='lightbox'])").not(".noqtip, .noqtip [title]").qtip({ style:{name:"mp"}, position: { corner: { target: 'rightMiddle', tooltip: 'leftMiddle' }, adjust: { screen: true, x:3 } } });

 /*
 $.bt.defaults=$.extend(false,$.bt.defaults,{
  width:"280px",
  padding:"8px",
  spikeGirth:10,
  spikeLength:15,
  overlap:-3,
  overlay:false,
  positions:["most"],
  fill:"rgb(255, 255, 255)",
  windowMargin:10,
  strokeWidth:1,
  strokeStyle:"#000",
  cornerRadius:6,
  cssStyles:{color:'#333333',fontSize:'0.875em',width:'auto'}
 });
 $("label[title]").each(function(){
  var id=$(this).attr("for");
  if(null!=id&&""!=id)
  {
   $("#"+id).attr("title",$(this).attr("title"));
  }
 });
 $("#header [title],#leftbar [title]").bt();
 //$("#main [title]:not([rel^='lightbox'])").bt();
 $("#subheader [title]").bt({positions: ['bottom']});
 */

 //picture collections

 $(".piclist ul a").click(function(){
  var link = $(this),
  selected = $(".piclist-selected", link.parents("div.piclist"));
  if(link.attr("href")==$("img", selected).attr("src")){ return; }
  $(".piclist-selected").fadeOut('fast',function(){
   $("img", selected).attr("src", link.attr("href") );
   selected.fadeIn('fast');
  });
 }).each(function(){
  $.preloadImg($(this).attr("href"));
 });

 /* old behavior on mouseover:
 $(".piclist ul a").mouseenter(function(){
  $(".piclist-selected img", $(this).parents("div.piclist")).attr("src", $(this).attr("href") );
 }).each(function(){
  $.preloadImg($(this).attr("href"));
 });
 */

 //galleries

 (function()
 {
  $(".gallery ul a").mouseenter(function(){
   var dad = $(this).parents("div.gallery"),
   border=3,
   img=$("img",$(this)),
   pos=img.position(),
   w=img.width()+1,
   h=img.height()+1,
   x=Math.floor(pos.left-(w/2)-border),
   y=Math.floor(pos.top-(h/2)-border),
   maxX=dad.width()+8-(w+border+1)*2;
   x = x < -13 ? -13 : ( x > maxX ? maxX : x );
   $(".preview", dad).remove();
   $(this).append('<div class="preview" style="left:'+x+'px;top:'+y+'px;"><img src="'+img.attr("src")+'" alt="" /></div>');
   $("div", $(this)).mouseleave(function(){
    $(this).remove();
   }).mousemove(function(ev){
    var off = img.offset();
    if(ev.pageX<off.left||ev.pageX>(off.left+img.width()+2)||ev.pageY<off.top||ev.pageY>(off.top+img.height()+2)){ $(this).remove(); }
   });
  });
  $(".gallery").mouseleave(function(){
   $(".preview", $(this)).remove();
  });
 })();

 $(".faqQuestion").each(function(){
  var a=$(this).next(".faqAnswer").hide();
  if (null==a) {return;}
  $(this).html('<a href="#antwort">'+$(this).html()+'</a>');
  $("a", $(this)).click(function(){$(this).parent().siblings(".faqAnswer").hide();a.show();$(this).blur();return false;});
 });

 //preload images

 if($global.imgcacheurls)
 {
  $global.imgcache=[];
  $.each($global.imgcacheurls, function(){
   var img = new Image();
   img.src=this;
   $global.imgcache.push(img);
  });
 }

 //sms

 $("#smsblock").hover(
    function(e) {
        window.clearTimeout($global.smsblocktimer);
        var _this = $(this);
        $global.smsblocktimer = window.setTimeout(function() {
            $("#smsform > div", $(_this)).slideDown();
            $("textarea", $(_this)).animate({ height: '7.2em' }, "normal", "swing", function() {
                if ("true" == $("textarea", $(_this)).attr("hasfocus")) {
                    window.setTimeout(function() { $("textarea", $(_this)).blur().focus(); }, 100);
                }
            });
        }, 500);
    },
    function(e) {
        window.clearTimeout($global.smsblocktimer);
        var _this = $(this);
        $global.smsblocktimer = window.setTimeout(function() {
            if ("true" != $("textarea", $(_this)).attr("hasfocus")) {
                $("#smsform > div", $(_this)).slideUp();
                $("textarea", $(_this)).animate({ height: '2.4em' });
            }
        }, 500);
    }).find("#smsform").children("div").css("display", "none").end().find("textarea").focus(function(e) { $(this).attr("hasfocus", true); }).blur(function(e) { $(this).attr("hasfocus", false); });

});

$.ajaxSetup({
 url: "/xmlhttp/",
 global: false,
 type: "GET",
 dataType: "json",
 dataFilter: function(data, type) { return "json" == type ? data.substr(11) : data; }
});


$.fn.extend({
	accordion: function(elements, content, options) {
		var data = {
			elements: $(elements, $(this)),
			content: content,
			options: $.extend($.fn.accordion.defaults, options),
			active: -1,
			root: $(this),
			enabled: true,
			timer: null,
			mouseEnterTimer: null,
			mouseLeaveTimer: null
		};

		data.sleep = data.options.sleep * 1000;

		if (data.elements.size() > data.options.requiredCount) {
			$.fn.accordion.create(data);
		}
	}
});

$.fn.extend($.fn.accordion, {
	defaults: {
		requiredCount: 4,
		sleep : 5
	},
	initialized: false,
	init: function() {
		$(function() {
			$("#sizes a").bind("click", $.fn.accordion.reloadAll);
		});
	},
	all: [],
	create: function(data) {
		if (!$.fn.accordion.initialized) {
			$.fn.accordion.init();
		}
		$.fn.accordion.all.push(data);
		$.fn.accordion.kickOff(data);
	},
	reloadAll: function() {
		$.each($.fn.accordion.all, function() {
			$.fn.accordion.kickOff(this);
		});
	},
	kickOff: function(data) {
		window.clearTimeout(data.timer);
		data.elements.each(function(i) {
			$(this).unbind(".accordion").bind("mouseenter.accordion", data, $.fn.accordion.mouseEnter).bind("mouseleave.accordion", data, $.fn.accordion.mouseLeave);
			var content = $(this).find(data.content).height("auto").show();
			content.attr("mpHeight", content.height()).height(0).hide();
		});
		$.fn.accordion.moveNext(data, true);
	},
	moveNext: function(data, first) {
		if (data.enabled || first) {
			if (-1 < data.active) {
				$(data.elements).eq(data.active).find(data.content).animate({ height: 0 }, { complete: function() { $(this).hide(); } });
			}

			var next = $(data.elements).eq(++data.active);
			if (0 == next.size()) {
				next = $(data.elements).eq(0);
				data.active = 0;
			}

			var cb = first ? function() {
				var max = 0,
				active = 0,
				root = $(data.root);
				data.elements.each(function(i) {
					var height = parseInt($(this).find(data.content).attr("mpHeight"));
					if (i == data.active || (0 == i && -1 == data.active)) {
						active = height;
					}
					if (height > max) {
						max = height;
					}
				});
				root.height("auto").height(root.height() + (max - active));
			} : function() { };

			var content = next.find(data.content);
			content.show().animate({ height: content.attr("mpHeight") + "px" }, { complete: cb });

			$.fn.accordion.queueMoveNext(data);
		}
	},
	queueMoveNext: function(data) {
		data.timer = window.setTimeout(function() { $.fn.accordion.moveNext(data); }, data.sleep);
	},
	start: function(data) {
		if (!data.enabled && null == data.timer) {
			data.enabled = true;
			$.fn.accordion.queueMoveNext(data);
		}
	},
	stop: function(data) {
		data.enabled = false;
		if (null != data.timer) {
			window.clearTimeout(data.timer);
			data.timer = null;
		}
	},
	mouseEnter: function(e) {
		window.clearTimeout(e.data.mouseLeaveTimer);
		var _this = $(this);
		e.data.mouseEnterTimer = window.setTimeout(function() { $.fn.accordion.doMouseEnter(_this, e.data); }, 400);
	},
	doMouseEnter: function(_this, data) {
		$.fn.accordion.stop(data);
		if (-1 < data.active && $(_this).get(0) != $(data.elements).get(data.active)) {
			$(data.elements).eq(data.active).find(data.content).animate({ height: 0 }, { complete: function() { $(this).hide(); } });
		}
		data.active = $(data.elements).index($(_this));
		var content = $(data.content, $(_this));
		content.show().animate({ height: content.attr("mpHeight") + "px" });
	},
	mouseLeave: function(e) {
		window.clearTimeout(e.data.mouseEnterTimer);
		if (!e.data.enabled) {
			e.data.mouseLeaveTimer = window.setTimeout(function() { $.fn.accordion.doMouseLeave(e.data); }, 400);
		}
	},
	doMouseLeave: function(data) {
		$.fn.accordion.start(data);
	}
});




function UploadManager(events) {
	$.extend(this.events = {}, {}, events);
}

UploadManager.prototype = {

	/* swf loading */
	onInit: function() {
		this.customSettings.loadingTimer = $.wait(_showLoading, 750, this);
		function _showLoading(o) {
			$(o.customSettings.loadingUi).show();
			o.customSettings.loadingTimer = $.wait(_showTimeout, 12000, o);
			function _showTimeout(o) {
				o.customSettings.mgr.hideLoader.call(o);
				$.message(o.customSettings.globalError, -1, false, "Das Laden des Hochlade-Managers dauert zu lange, wenn das Problem weiterhin auftritt, nehmen Sie bitte mit uns Kontakt auf.");
			}
		}
	},
	onLoad: function() {
		this.customSettings.mgr.hideLoader.call(this);
		if ("undefined" != typeof this.customSettings.cancellAll) {
			var _this = this;
			$(this.customSettings.cancelAll).click(function(event) { _this.customSettings.mgr.onCancelAll.call(_this); });
		}
		this.customSettings.mgr.invoke.call(this, "onLoad");
	},
	onLoadFailed: function() {
		this.customSettings.mgr.hideLoader.call(this);
		$.message(this.customSettings.globalError, 0, false, 'Es scheint, dass Ihre Flash-Version nicht am neuesten Stand ist. Bitte aktualisieren Sie das Flash Plugin auf der <a href="http://get.adobe.com/de/flashplayer/" target="_blank">Adobe Webseite</a>.');
	},

	/* file queue */
	onFileQueued: function(file) {
		this.customSettings.mgr.getQueuedFileUi.call(this, file).remove();

		$(this.customSettings.queueUi).append('<div class="queuedfile" id="qf_' + file.id + '"><span class="filename">' + file.name +
		'</span><span class="filesize">' + this.customSettings.mgr.getFileSize.call(this, file) + '</span><div class="workarea"><span class="status">Status:<span>In der Warteschleife</span></span>' +
		'<span class="cancel"><a href="#abbrechen" class="more"><img src="/img/dot.gif" alt="" />abbrechen</a></span></div><div class="cl"></div></div>');

		var _this = this;
		$("a", this.customSettings.mgr.getQueuedFileUi.call(this, file)).click(function() {
			_this.customSettings.mgr.onCancel.call(_this, file); $(this).fadeOut(); return false;
		});
	},
	onFileQueuedError: function(file, err, msg) {
		window.clearTimeout(this.customSettings.generalErrorTimeout);
		var txt = "",
		type = -1;
		switch (err) {
			case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:
				txt = 0 == msg ? "Die Warteschlange ist derzeit voll." : ("Sie können derzeit nur mehr " + msg + (msg > 1 ? " Dateien" : " Datei") + " hinzufügen");
				type = 0;
				break;
			case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
				txt = "Die angegebene Datei ist zu groß";
				break;
			case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
				txt = "Die angegebene Datei ist leer.";
				break;
			case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
				txt = "Ungültiger Dateityp";
				break;
			default:
				txt = "Unbekannter Fehler (" + err + ")";
				break;
		}
		var box = $(this.customSettings.globalError);
		$.message(box, type, false, txt);
		this.customSettings.generalErrorTimeout = $.wait(function() { $(box).slideUp("slow"); }, 7000);
	},
	onDialogComplete: function(numSelected, numQueueAdded, numQueueTotal) {
		if (numQueueAdded > 0) {
			window.clearTimeout(this.customSettings.hideQueueTimer);
			this.customSettings.mgr.toggleCancelAllLink.call(this, true);
			$(this.customSettings.queueUi).slideDown("slow");
			this.customSettings.mgr.updateBar.call(this, 0);
			this.startUpload();
		}
	},
	onQueueComplete: function(uploadCount) {
		this.customSettings.mgr.invoke.call(this, "onQueueComplete", [uploadCount]);
		this.customSettings.mgr.toggleButton.call(this);
		var box = this.customSettings.queueUi,
		progress = this.customSettings.progress;
		this.customSettings.hideQueueTimer = $.wait(function() {
			$(box).slideUp("slow", function() { $(":not(h3)", $(this)).remove(); });
			$(".progress", progress).fadeOut("normal");
		}, 7500);
		this.customSettings.mgr.toggleCancelAllLink.call(this, false);
	},

	/* file upload events */
	onFileStart: function(file) {
		var valid = this.customSettings.mgr.invoke.call(this, "onFileStart", [file]);
		if (valid) {
			this.customSettings.mgr.updateFileStatus.call(this, file, "Hochladen beginnt");
		}
		return valid;
	},
	onFileProgress: function(file, bytes, total) {
		var percent = Math.ceil((bytes / total) * 100);
		this.customSettings.mgr.updateBar.call(this, percent);
		this.customSettings.mgr.updateFileStatus.call(this, file, "Wird hochgeladen");

	},
	onFileError: function(file, err, msg) {
		var txt = "",
		type = -1;
		switch (err) {
			case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:
			case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:
			case SWFUpload.UPLOAD_ERROR.IO_ERROR:
			case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:
				txt = "Upload fehlgeschlagen. Versuchen Sie es bitte nochmals (eventuell zu einem späteren Zeitpunkt)";
				break;
			case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
				txt = "Maximale Gesamtgröße der Dateien wurde überschritten. Wählen Sie bitte eine kleinere Datei.";
				break;
			case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED:
				txt = "Beim Validieren der Datei ist ein Fehler aufgetreten.";
				break;
			case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
				txt = "Hochladen abgebrochen.";
				type = 0;
				if (0 === this.getStats().files_queued) {
					this.customSettings.mgr.toggleCancelAllLink.call(this, false);
				}
				break;
			case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
				txt = "Hochladen gestoppt.";
				type = 0;
				break;
			default:
				txt = "Unbekannter Fehler (#" + err + ", '" + msg + "')";
				break;
		}

		this.customSettings.mgr.updateBar.call(this, false);
		this.customSettings.mgr.showFileError.call(this, file, txt, type);
	},
	onFileSuccess: function(file, data) {
		if ("%uFEFF" == escape(data[0])) {
			data = data.substr(1);
		}
		this.customSettings.mgr.updateBar.call(this, 100);
		this.customSettings.mgr.updateFileStatus.call(this, file, "<strong>Fertig</strong>");
		this.customSettings.mgr.invoke.call(this, "onFileSuccess", [file, data]);
	},
	onFileComplete: function(file) {
		$("a", this.customSettings.mgr.getQueuedFileUi.call(this, file)).parent().remove();
		var box = this.customSettings.mgr.getQueuedFileUi.call(this, file);
		$.wait(function() {
			$(box).slideUp("slow", function() { $(this).remove(); });
		}, 7500);
	},
	onFileRemove: function() {
		this.setStats({ successful_uploads: (this.getStats().successful_uploads - 1) });
		this.customSettings.mgr.toggleButton.call(this);
	},

	/* cancel-events */
	onCancel: function(file) {
		this.cancelUpload(file, true);
	},
	onCancelAll: function() {
		this.cancelQueue();
	},

	/* helper */
	hideLoader: function() {
		window.clearTimeout(this.customSettings.loadingTimer);
		$(this.customSettings.loadingUi).remove();
	},
	toggleCancelAllLink: function(visible) {
		if ("undefined" != typeof this.customSettings.cancellAll) {
			$(this.customSettings.cancellAll).toggle(visible);
		}
	},
	toggleButton: function() {
		this.setButtonDisabled(this.getStats().successful_uploads >= this.settings.file_upload_limit);
	},
	updateBar: function(data) {
		var parent = $(this.customSettings.progress);
		if ("boolean" === typeof data) {
			$(".progress > div", parent).toggleClass("error", !data);
			$(".progress:hidden", parent).fadeIn("normal");
			return;
		}
		$(".progress > div", parent).removeClass("error");
		$(".progress .bar", parent).css("width", data + "%");
		$(".progress .percent", parent).html(data + "%");
		$(".progress:hidden", parent).fadeIn("normal");
	},
	updateFileStatus: function(file, status) {
		$("span.status span", this.customSettings.mgr.getQueuedFileUi.call(this, file)).html(status);
	},
	showFileError: function(file, msg, type) {
		var box = this.customSettings.mgr.getQueuedFileUi.call(this, file);
		$.message($("div.workarea", box), "undefined" == typeof type ? -1 : type, false, msg);
		box.id += Math.round(Math.random() * 10000);
	},
	getQueuedFileUi: function(file) {
		return $(this.customSettings.queueUi + " div#qf_" + (null != file ? file.id : ""));
	},
	getFileSize: function(file) {
		return file.size > 500 * 1024 ?
			String(Math.round(10 * file.size / 1024 / 1024) / 10).replace(".", ",") + " MB" :
			(file.size < 25 * 1024 ? String(Math.round(10 * file.size / 1024) / 10).replace(".", ",") : Math.round(file.size / 1024)) + " kB";
	},

	/* custom events */
	invoke: function(funcName, params) {
		var result = true;
		if ("function" === typeof this.customSettings.mgr.events[funcName]) {
			result = this.customSettings.mgr.events[funcName].apply(this, params || []);
		}
		return "boolean" === typeof result ? result : true;
	}
};
