//
//var JWMM = {
//		mail: function (sTo, sSubject, sBody, sUrl) {
//		var swap = function (chr) {
//		switch(chr) {
//			case "´":
//			return "'";
//			return "%3F";
//			case "?":
//			return "%3F";
//			case "&":
//			return "%27";
//			case "=":
//			return "%3E";
//		}
//		return chr;
//	};
//	var encode = function (str) {
//		return (str).replace(/\?/g, function(match){return swap(match);});
//	};
//	var amp = "&";
//	var sUrl = sUrl || window.location.href;
//	var params = "subject=" + encode(sSubject) + amp + "body=" + encode(sBody) + encode(sUrl) + "\n\n";
//	
//	window.location = encodeURI("mailto:" + sTo + "?" + params);
//	return false;
//},
//mailto: function () {
//	return JWMM.mail(JWMM.mailTo, JWMM.mailSubject, JWMM.mailBody);
//}
//		
//};
//
//function mailto(url){
//        var myUrl = escape(url);
//        parent.location.href="mailto:Your%20Contact%20Address?subject=Link-Tip&body=This%20page%20can%20be%20of%20interest%20to%20you.%20To%20view%20the%20page,%20click here:%0d%0a%0d%0a" + myUrl+ "%0d%0a%0d%0a%0d%0aIf the link doesn't work, try copying and pasting it into your browser's address bar.";
//}
//
//function openWindow(url,width,height,scroll,name,anchor)
//{ 
//	if(name==undefined){
//		name='';
//	}else{
//		name = name.replace(/\s/g,"");
//	}
//	//default scrollbars=no;
//	if(scroll=='')
//	{
//		scroll = 'no';
//	}	
//	if(anchor!=null)
//	{
//		url = url+""+anchor;
//	}
//	
//	popWindow = window.open(url,name,"toolbar=no,width="+width+",height="+height+",status=yes,scrollbars="+scroll+",resizable=no,menubar=no,dependent=no");
//	popWindow.blur;
//}
//
//
//
////FAQ Print
//
//function openFaqPrintWindow(p){
//    var printFaq = $("#printFaq").val();
//    window.open(p+printFaq,'Printview',"toolbar=no,width=745,height=500,status=yes,scrollbars=yes,resizable=no,menubar=no,dependent=no");
//}
//
//function bookmark(){
//   
//      if (!document.all){
//    	  if($("#bookmark").length > 0){
//    		  $("#bookmark").css({display: "none"});
//          }
//          
//          if($("#gwtbookmark").length > 0){
//        	  $("#gwtbookmark").css({display: "none"});
//          }
//          
//          return;
//      }
//}
//
///*
// * jQuery i18n plugin
// * @requires jQuery v1.1 or later
// *
// * Examples at: http://recurser.com/articles/2008/02/21/jquery-i18n-translation-plugin/
// * Dual licensed under the MIT and GPL licenses:
// *   http://www.opensource.org/licenses/mit-license.php
// *   http://www.gnu.org/licenses/gpl.html
// *
// * Based on 'javascript i18n that almost doesn't suck' by markos
// * http://markos.gaivo.net/blog/?p=100
// *
// * Revision: $Id$
// * Version: 1.0.0  Feb-10-2008
// */
// (function($) {
///**
// * i18n provides a mechanism for translating strings using a jscript dictionary.
// *
// */
//	var i18n_dict = {};
//
///*
// * i18n property list
// */
//$.i18n = {
//	
///**
// * setDictionary()
// * Initialise the dictionary and translate nodes
// *
// * @param property_list i18n_dict : The dictionary to use for translation
// */
//	setDictionary: function(i18n_dict_param) {
//		i18n_dict = i18n_dict_param;
//	},
//	
///**
// * _()
// * The actual translation function. Looks the given string up in the 
// * dictionary and returns the translation if one exists. If a translation 
// * is not found, returns the original word
// *
// * @param string str : The string to translate 
// * @param property_list params : params for using printf() on the string
// * @return string : Translated word
// *
// */
//	_: function (str, params) {
//		var transl = str;
//		if (i18n_dict && i18n_dict[str]) {
//			transl = i18n_dict[str];
//		}
//		return this.printf(transl, params);
//	},
//	
///**
// * toEntity()
// * Change non-ASCII characters to entity representation 
// *
// * @param string str : The string to transform
// * @return string result : Original string with non-ASCII content converted to entities
// *
// */
//	toEntity: function (str) {
//		var result = '';
//		for (var i=0;i<str.length; i++) {
//			if (str.charCodeAt(i) > 128)
//				result += "&#"+str.charCodeAt(i)+";";
//			else
//				result += str.charAt(i);
//		}
//		return result;
//	},
//	
///**
// * stripStr()
// *
// * @param string str : The string to strip
// * @return string result : Stripped string
// *
// */
// 	stripStr: function(str) {
//		return str.replace(/^\s*/, "").replace(/\s*$/, "");
//	},
//	
///**
// * stripStrML()
// *
// * @param string str : The multi-line string to strip
// * @return string result : Stripped string
// *
// */
//	stripStrML: function(str) {
//		// Split because m flag doesn't exist before JS1.5 and we need to
//		// strip newlines anyway
//		var parts = str.split('\n');
//		for (var i=0; i<parts.length; i++)
//			parts[i] = stripStr(parts[i]);
//	
//		// Don't join with empty strings, because it "concats" words
//		// And strip again
//		return stripStr(parts.join(" "));
//	},
//
///*
// * printf()
// * C-printf like function, which substitutes %s with parameters
// * given in list. %%s is used to escape %s.
// *
// * Doesn't work in IE5.0 (splice)
// *
// * @param string S : string to perform printf on.
// * @param string L : Array of arguments for printf()
// */
//	printf: function(S, L) {
//		if (!L) return S;
//
//		var nS = "";
//		var tS = S.split("%s");
//
//		for(var i=0; i<L.length; i++) {
//			if (tS[i].lastIndexOf('%') == tS[i].length-1 && i != L.length-1)
//				tS[i] += "s"+tS.splice(i+1,1)[0];
//			nS += tS[i] + L[i];
//		}
//		return nS + tS[tS.length-1];
//	}
//
//};
//
//})(jQuery);
//
//(function($) {
//
//
//// opens an url in a popup
//$.createPopupWindow = function(options) {
//
//	var settings = $.extend({
//		url: null,
//		width: 720,
//		height: 487,
//		center: true,
//		
//		scrollbars: true,
//		resizable: false,
//		toolbar: false,
//		location: false,
//		menubar: false,
//		
//		id: 'popup'
//	}, options);
//	
//	var yn = function(val) { return (val == true ? "yes" : "no"); }; // shorthand function for converting a boolean value to yes and no
//	
//	// creating messy option string
//	var optionString = "menubar=" + yn(settings.menubar) + ",location=" + yn(settings.location)
//		+ ",toolbar=" + yn(settings.toolbar) + ",resizable=" + yn(settings.resizable)
//		+ ",scrollbars=" + yn(settings.scrollbars)
//		+ ",width=" + settings.width + ",height=" + settings.height;
//	
//	if (settings.center) {
//		// if option is set, move window to center of screen
//		var winLeft = (screen.width - settings.width)/2;
//		var winTop = (screen.height - settings.height)/2;
//		
//		optionString += ",left=" + winLeft + ",top=" + winTop;
//	}
//	
//	var w = window.open(settings.url, settings.id, optionString);
//};
//
//
//
//// replace the buttons by link elements for eye-candy
//$.fn.replaceButtons = function() {
//	var msie6 = navigator.userAgent.toLowerCase().indexOf('msie 6') != -1;
//	return this.each(function() {
//		$(this).find("input[type='submit'], input[type='reset'], input[type='button'], ").each(function() {
//			var t = $(this)
//			t.hide().after($('<a href="#" class="gui-btn"><span><span>' + t.val() + '</span></span></a>').click(function() { t.trigger("click"); if(msie6) { $(this).blur(); }; return false; }));
//		});
//	});
//};
//
//$.fn.initTabs = function() {
//	var tabs = $(".tabs", this);
//	var contents = $(".tabContents", this);
//
//	var tabLinks = $("a", tabs).click(function() {
//		$("a", tabs).removeClass("active");
//		
//		var href = $(this).addClass("active").attr("href");
//		
//		$(".innerTabContents > div", contents).hide();
//		$(href).show();
//		
//		return false;
//	});
//	
//	tabLinks.filter(".active").click();
//	
//	return this;
//};
//
//
//// initialize faq lists
//$.fn.faqList = function(options) {
//	
//	var settings = $.extend({
//		questionTags: "dt", // any jQuery selector possible, you can also use span.question, div.title, etc.
//		answerTags: "dd",
//		animationSpeed: 400
//	}, options);
//
//
//	this.each(function(i, v) {
//		var l = $(this);
//		var answers = l.find(settings.answerTags).hide();
//		
//		l.find(settings.questionTags).each(function(i, v) {
//			$(this).wrapInner("<a href='#'></a>").find("> a").click(function() {
//			    $("#printFaq").val($(this).parent(":first").next().attr("id"));
//				l.find(settings.answerTags + ":visible").slideUp(settings.animationSpeed);
//				l.find(settings.questionTags + " > a.open").removeClass("open").addClass("closed");
//				if (!answers.eq(i).is(":visible")) {
//					$(this).removeClass("closed").addClass("open");
//					answers.eq(i).slideDown(settings.animationSpeed);
//				}
//				return false;
//			}).addClass("closed");
//		});
//		
//        $("dd[class^=activeItem]").show();
//        $("dd[class^=activeItem]").prev("dt:first").children(".closed").addClass("open").removeClass("closed");
//	});
//};
//
///**
// * openModalWindow()
// *
// * Display message in a lightbox-like modal overlay
// *
// */
//$.JMMShowMessage = function(message, title) {
//	
//	// creating overlay for transparent background		
//	var modal = $('<div class="modal-blackout" />').appendTo(document.body).css("opacity", 0);
//	if ($.browser.msie && $.browser.version < 7) {
//		$('<iframe frameborder="0" />').appendTo(modal);
//	}
//	
//	
//	// important: popup must use visibility: hidden; instead of display: none;
//	// to make the size calculatable before showing popup
//	var popup = $('<div class="modalPopup"><div class="popup-title" /><div class="popup-content" />'
//			+ '<div class="popup-controls"><a href="#" class="gui-btn close-this-popup"><span><span>' + $.i18n._("js.closeWindow") + '</span></span></a></div></div>')
//		.appendTo(document.body)
//		.css("visibility", "hidden");
//	
//	// closes popup with a smooth animation and removes
//	// popup elements from the document
//	var closeThisPopup = function() {
//		modal.fadeOut(250, function() { $(this).remove(); });
//		popup.fadeOut(250, function() { $(this).remove(); });
//	};
//	
//	$("a.close-this-popup", popup).click(closeThisPopup);
//	
//	$(".popup-title", popup).html(title != undefined ? title : "");
//	$(".popup-content", popup).html(message);
//	
//	// fade in modal
//	modal.fadeTo(500, 0.4, function() { popup.css("visibility", "visible"); });
//};
//
//})(jQuery);
//
//jQuery(function($) {
//
//	// set dictionary for i18n
//	// dictionary variable has to be declared before loading this file in global namespace
//	if (typeof dictionary != "undefined") {
//		$.i18n.setDictionary(dictionary);
//	}
//
//	// init search field
//	// when user focussed that field and it has it's default value, specified by a <label> element's text content
//	// the field will be emptied. If user blurs field and it is empty, default value will be restored
//	var defaultValue = $("#leftColSearchLabel").text();
//	$("#leftColSearch").val(defaultValue).focus(function() { if ($(this).val() == defaultValue) $(this).val(""); })
//		.blur(function() { if ($(this).val() == "") $(this).val(defaultValue); });
//	
//	// faq lists
//	$("#faq").initTabs().find(".tabContents > div").faqList();	
//	
//	/*$("#finder table tbody tr.entry").each(function() {
//		var t = $(this).addClass("closed");
//		var d = t.next().hide();
//		var dd = d.find("td > div").hide();
//		t.find(".title a, .category a").click(function() {
//			if (d.is(":visible")) {
//				dd.slideUp(250, function() { d.hide(); });
//				t.removeClass("open").addClass("closed");
//			} else {
//				d.show();
//				dd.slideDown();
//				t.removeClass("closed").addClass("open");
//			}
//			
//			return false;
//		});
//	});*/
//	
//	// beautify buttons
//	$("#main").replaceButtons();
//	
//	// language selector
//	$("#selectLanguage").change(function() {
//		window.location.href = $(this).val();
//	});
//	
//});
//
//$(document).ready(function() {
//	
//	if($('#mailTo').length > 0 ){
//		$('#mailTo').click(function(e){
//			e.stopPropagation();
//			return JWMM.mailto();
//		});
//	};
//	
//	$('textarea').each(function(){
//		var $this = $(this);
//		if ($this.val().match(/^\s/) != null) {
//			$this.val("");
//		}
//	}); 
//	
//});

if(!JWMM){
	var JWMM = {
	
		glossaryDelay: null,
		
		discoverGlossaryBubbles: function () {
			$('a.glossary').mouseover(JWMM.showGlossaryBubble);
			$('a.glossary').mouseout(JWMM.showGlossaryBubble);
		},
		showGlossaryBubble: function (e) {
			//var temp = this.hash.substring(0, this.hash.indexOf('_')).toLowerCase();
			var temp = this.hash.substring(0, this.hash.length-9).toLowerCase();
			var bubble = $(temp+"_glossaryLink");
			var bubble_width = bubble.width();
			var body_width = $(document.body).width();
			var max_offset = body_width - bubble_width - 20;
			var offset = $(this).offset();
			offset.left = offset.left - 50;
			
			e.stopPropagation();
			// modify offset to keep bubble inside the window bounds
			if (offset.left < 0) {
				offset.left = 0;
			} else if (offset.left > max_offset) {
				$(".source", bubble).css("left", Math.floor(offset.left - max_offset + 70)+"px");
				offset.left = max_offset;
			}
			if (e.type == "mouseout") {
				bubble.fadeOut(100, function () {
					$(".source", bubble).css("left", null)
				});
			} else {
				bubble.css({top: offset.top - bubble.innerHeight(), left: offset.left});
				bubble.fadeIn(250);
			}
			
			return false;
		},
		mail: function (sTo, sSubject, sBody, sUrl) {
			var swap = function (chr) {
				switch(chr) {
					case "´":
					return "'";
					return "%3F";
					case "?":
					return "%3F";
					case "&":
					return "%27";
					case "=":
					return "%3E";
				}
				return chr;
			};
			var encode = function (str) {
				return (str).replace(/\?/g, function(match){return swap(match);});
			};
			var amp = "&";
			var sUrl = sUrl || window.location.href;
			var params = "subject=" + encode(sSubject) + amp + "body=" + encode(sBody) + encode(sUrl) + "\n\n";
			
			window.location = encodeURI("mailto:" + sTo + "?" + params);
			return false;
		},
		mailto: function () {
			return JWMM.mail(JWMM.mailTo, JWMM.mailSubject, JWMM.mailBody);
		},
		prepareDropdowns: function () {
			var buildList = function (opts) {
				var ul = $.UL();
				var l = opts.length;
				var cName = "";
				var selID = 0;
				
				for(var i=0; i < l; i++) {
					var o = opts[i];
					
					if (i % 2 == 0) {
						cName = "odd";
					} else {
						cName = "even";
					}
					
					if (i == 0) {
						cName += " first";
					} else if (i == l-1) {
						cName += " last";
					}
					
					if (o.selected) {
						selID = i;
					}
					
					$(ul).append($.LI({Class:cName},
						$.A({href:o.value == "" ? "#" : o.value, title:o.text}, o.text)
					));
				}
				return [selID,ul];
			};
			
			var buildMenu = function (idx, elm) {
				var select = $("select", elm)[0];
				if (!select) return false;
				var opts = select.options;
				var list = buildList(opts);
				
				$(elm).before(
					$.DIV({Class:"widget"},
						$.DIV({Class:"content"},
							$.A({href:"#", title:"Click to open"}, $.NBSP)
						)
					)
				);
				
				$(elm).before(
					$.DIV({Class:"textlink"},
						$.DIV({Class:"content"},
							$.A({href:"#", title:"Click to open"}, opts[list[0]].text)
						),
						$.DIV({id: select.name, Class:"options"},
							list[1]
						)
					)
				);
				return true;
			};
			
			$(".ft-dropdown form").map(function (i, elm) {
				if (buildMenu(i, elm)) {
					$(this).remove();
				}
			});
		}
	};
}

function mailto(url){
        var myUrl = escape(url);
        parent.location.href="mailto:Your%20Contact%20Address?subject=Link-Tip&body=This%20page%20can%20be%20of%20interest%20to%20you.%20To%20view%20the%20page,%20click here:%0d%0a%0d%0a" + myUrl+ "%0d%0a%0d%0a%0d%0aIf the link doesn't work, try copying and pasting it into your browser's address bar.";
}

function openWindow(url,width,height,scroll,name,anchor)
{ 
	if(name==undefined){
		name='';
	}else{
		name = name.replace(/\s/g,"");
	}
	//default scrollbars=no;
	if(scroll=='')
	{
		scroll = 'no';
	}	
	if(anchor!=null)
	{
		url = url+""+anchor;
	}
	
	popWindow = window.open(url,name,"toolbar=no,width="+width+",height="+height+",status=yes,scrollbars="+scroll+",resizable=no,menubar=no,dependent=no");
	popWindow.blur;
}



//FAQ Print

function openFaqPrintWindow(p){
    var printFaq = $("#printFaq").val();
    window.open(p+printFaq,'Printview',"toolbar=no,width=745,height=500,status=yes,scrollbars=yes,resizable=no,menubar=no,dependent=no");
}

function bookmark(){
   
      if (!document.all){
    	  if($("#bookmark").length > 0){
    		  $("#bookmark").css({display: "none"});
          }
          
          if($("#gwtbookmark").length > 0){
        	  $("#gwtbookmark").css({display: "none"});
          }
          
          return;
      }
}

/*
 * jQuery i18n plugin
 * @requires jQuery v1.1 or later
 *
 * Examples at: http://recurser.com/articles/2008/02/21/jquery-i18n-translation-plugin/
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Based on 'javascript i18n that almost doesn't suck' by markos
 * http://markos.gaivo.net/blog/?p=100
 *
 * Revision: $Id$
 * Version: 1.0.0  Feb-10-2008
 */
 (function($) {
/**
 * i18n provides a mechanism for translating strings using a jscript dictionary.
 *
 */
	var i18n_dict = {};

/*
 * i18n property list
 */
$.i18n = {
	
/**
 * setDictionary()
 * Initialise the dictionary and translate nodes
 *
 * @param property_list i18n_dict : The dictionary to use for translation
 */
	setDictionary: function(i18n_dict_param) {
		i18n_dict = i18n_dict_param;
	},
	
/**
 * _()
 * The actual translation function. Looks the given string up in the 
 * dictionary and returns the translation if one exists. If a translation 
 * is not found, returns the original word
 *
 * @param string str : The string to translate 
 * @param property_list params : params for using printf() on the string
 * @return string : Translated word
 *
 */
	_: function (str, params) {
		var transl = str;
		if (i18n_dict && i18n_dict[str]) {
			transl = i18n_dict[str];
		}
		return this.printf(transl, params);
	},
	
/**
 * toEntity()
 * Change non-ASCII characters to entity representation 
 *
 * @param string str : The string to transform
 * @return string result : Original string with non-ASCII content converted to entities
 *
 */
	toEntity: function (str) {
		var result = '';
		for (var i=0;i<str.length; i++) {
			if (str.charCodeAt(i) > 128)
				result += "&#"+str.charCodeAt(i)+";";
			else
				result += str.charAt(i);
		}
		return result;
	},
	
/**
 * stripStr()
 *
 * @param string str : The string to strip
 * @return string result : Stripped string
 *
 */
 	stripStr: function(str) {
		return str.replace(/^\s*/, "").replace(/\s*$/, "");
	},
	
/**
 * stripStrML()
 *
 * @param string str : The multi-line string to strip
 * @return string result : Stripped string
 *
 */
	stripStrML: function(str) {
		// Split because m flag doesn't exist before JS1.5 and we need to
		// strip newlines anyway
		var parts = str.split('\n');
		for (var i=0; i<parts.length; i++)
			parts[i] = stripStr(parts[i]);
	
		// Don't join with empty strings, because it "concats" words
		// And strip again
		return stripStr(parts.join(" "));
	},

/*
 * printf()
 * C-printf like function, which substitutes %s with parameters
 * given in list. %%s is used to escape %s.
 *
 * Doesn't work in IE5.0 (splice)
 *
 * @param string S : string to perform printf on.
 * @param string L : Array of arguments for printf()
 */
	printf: function(S, L) {
		if (!L) return S;

		var nS = "";
		var tS = S.split("%s");

		for(var i=0; i<L.length; i++) {
			if (tS[i].lastIndexOf('%') == tS[i].length-1 && i != L.length-1)
				tS[i] += "s"+tS.splice(i+1,1)[0];
			nS += tS[i] + L[i];
		}
		return nS + tS[tS.length-1];
	}

};

})(jQuery);

(function($) {


// opens an url in a popup
$.createPopupWindow = function(options) {

	var settings = $.extend({
		url: null,
		width: 720,
		height: 487,
		center: true,
		
		scrollbars: true,
		resizable: false,
		toolbar: false,
		location: false,
		menubar: false,
		
		id: 'popup'
	}, options);
	
	var yn = function(val) { return (val == true ? "yes" : "no"); }; // shorthand function for converting a boolean value to yes and no
	
	// creating messy option string
	var optionString = "menubar=" + yn(settings.menubar) + ",location=" + yn(settings.location)
		+ ",toolbar=" + yn(settings.toolbar) + ",resizable=" + yn(settings.resizable)
		+ ",scrollbars=" + yn(settings.scrollbars)
		+ ",width=" + settings.width + ",height=" + settings.height;
	
	if (settings.center) {
		// if option is set, move window to center of screen
		var winLeft = (screen.width - settings.width)/2;
		var winTop = (screen.height - settings.height)/2;
		
		optionString += ",left=" + winLeft + ",top=" + winTop;
	}
	
	var w = window.open(settings.url, settings.id, optionString);
};



// replace the buttons by link elements for eye-candy
$.fn.replaceButtons = function() {
	var msie6 = navigator.userAgent.toLowerCase().indexOf('msie 6') != -1;
	return this.each(function() {
		$(this).find("input[type='submit'], input[type='reset'], input[type='button'], ").each(function() {
			var t = $(this)
			t.hide().after($('<a href="#" class="gui-btn"><span><span>' + t.val() + '</span></span></a>').click(function() { t.trigger("click"); if(msie6) { $(this).blur(); }; return false; }));
		});
	});
};

$.fn.initTabs = function() {
	var tabs = $(".tabs", this);
	var contents = $(".tabContents", this);

	var tabLinks = $("a", tabs).click(function() {
		$("a", tabs).removeClass("active");
		
		var href = $(this).addClass("active").attr("href");
		
		$(".innerTabContents > div", contents).hide();
		$(href).show();
		
		return false;
	});
	
	tabLinks.filter(".active").click();
	
	return this;
};


// initialize faq lists
$.fn.faqList = function(options) {
	
	var settings = $.extend({
		questionTags: "dt", // any jQuery selector possible, you can also use span.question, div.title, etc.
		answerTags: "dd",
		animationSpeed: 400
	}, options);


	this.each(function(i, v) {
		var l = $(this);
		var answers = l.find(settings.answerTags).hide();
		
		l.find(settings.questionTags).each(function(i, v) {
			$(this).wrapInner("<a href='#'></a>").find("> a").click(function() {
			    $("#printFaq").val($(this).parent(":first").next().attr("id"));
				l.find(settings.answerTags + ":visible").slideUp(settings.animationSpeed);
				l.find(settings.questionTags + " > a.open").removeClass("open").addClass("closed");
				if (!answers.eq(i).is(":visible")) {
					$(this).removeClass("closed").addClass("open");
					answers.eq(i).slideDown(settings.animationSpeed);
				}
				return false;
			}).addClass("closed");
		});
		
        $("dd[class^=activeItem]").show();
        $("dd[class^=activeItem]").prev("dt:first").children(".closed").addClass("open").removeClass("closed");
	});
};

/**
 * openModalWindow()
 *
 * Display message in a lightbox-like modal overlay
 *
 */
$.JMMShowMessage = function(message, title) {
	
	// creating overlay for transparent background		
	var modal = $('<div class="modal-blackout" />').appendTo(document.body).css("opacity", 0);
	if ($.browser.msie && $.browser.version < 7) {
		$('<iframe frameborder="0" />').appendTo(modal);
	}
	
	
	// important: popup must use visibility: hidden; instead of display: none;
	// to make the size calculatable before showing popup
	var popup = $('<div class="modalPopup"><div class="popup-title" /><div class="popup-content" />'
			+ '<div class="popup-controls"><a href="#" class="gui-btn close-this-popup"><span><span>' + $.i18n._("js.closeWindow") + '</span></span></a></div></div>')
		.appendTo(document.body)
		.css("visibility", "hidden");
	
	// closes popup with a smooth animation and removes
	// popup elements from the document
	var closeThisPopup = function() {
		modal.fadeOut(250, function() { $(this).remove(); });
		popup.fadeOut(250, function() { $(this).remove(); });
	};
	
	$("a.close-this-popup", popup).click(closeThisPopup);
	
	$(".popup-title", popup).html(title != undefined ? title : "");
	$(".popup-content", popup).html(message);
	
	// fade in modal
	modal.fadeTo(500, 0.4, function() { popup.css("visibility", "visible"); });
};

})(jQuery);

jQuery(function($) {

	// set dictionary for i18n
	// dictionary variable has to be declared before loading this file in global namespace
	if (typeof dictionary != "undefined") {
		$.i18n.setDictionary(dictionary);
	}

	// init search field
	// when user focussed that field and it has it's default value, specified by a <label> element's text content
	// the field will be emptied. If user blurs field and it is empty, default value will be restored
	var defaultValue = $("#leftColSearchLabel").text();
	$("#leftColSearch").val(defaultValue).focus(function() { if ($(this).val() == defaultValue) $(this).val(""); })
		.blur(function() { if ($(this).val() == "") $(this).val(defaultValue); });
	
	// faq lists
	$("#faq").initTabs().find(".tabContents > div").faqList();	
	
	/*$("#finder table tbody tr.entry").each(function() {
		var t = $(this).addClass("closed");
		var d = t.next().hide();
		var dd = d.find("td > div").hide();
		t.find(".title a, .category a").click(function() {
			if (d.is(":visible")) {
				dd.slideUp(250, function() { d.hide(); });
				t.removeClass("open").addClass("closed");
			} else {
				d.show();
				dd.slideDown();
				t.removeClass("closed").addClass("open");
			}
			
			return false;
		});
	});*/
	
	// beautify buttons
	$("#main").replaceButtons();
	
	// language selector
	$("#selectLanguage").change(function() {
		window.location.href = $(this).val();
	});
	
});

$(document).ready(function() {
	
	if($('#mailTo').length > 0 ){
		$('#mailTo').click(function(e){
			e.stopPropagation();
			return JWMM.mailto();
		});
	};
	
	$('textarea').each(function(){
		var $this = $(this);
		if ($this.val().match(/^\s/) != null) {
			$this.val("");
		}
	}); 

	if ($('a.glossary').length > 0) {
		JWMM.discoverGlossaryBubbles();
		
		$('body').append($('div.glossaryBubble'));
	}
	
	if ($("ul.level-1 li a").length > 0) {		
		$("ul.level-1 li").mouseenter(
			function () {
				$(this).find(".level-2").css({
					"display": "block"
				}),
				$(this).find(".fixDiv").addClass("doubleselected");
			}
		)
		$("ul.level-1 li").mouseleave(
			function () {
				$(this).find(".level-2").css({
					"display": "none"
				}),
				$(this).find(".fixDiv").removeClass("doubleselected");
			}
		)
	}

	/* third level navi */
	if ($("ul.level-2 li a").length > 0) {	
		
		$("ul.level-2 li").mouseenter(
			function () {
				$(this).find(".level-3").css({
					"display": "block",
					"left": ($(this).width()-10),
					"top": ($(this).position().top-2)
				});
				$(this).addClass("selected");
			}
		) 
		$("ul.level-2 li").mouseleave(
			function () {
				$(this).find(".level-3").css({
					"display": "none"
				});
				$(this).removeClass("selected");
			}
		)
	}
	
	if ($("#glossaryNav").length > 0) {
		$("#glossaryNav a").click(JWMM.toggleGlossary);
		if (window.location.hash.length > 0) {
			$("#glossaryNav a[href='#glossary_"+window.location.hash.substr(1)+"']").click();
		}
	}
	
    $('.readmore').click(function () {

        $(this.parentNode.parentNode).children('.toggle').removeClass('hidden'); 
        $(this).addClass('hidden'); 
        $(this.parentNode).children('.showless').removeClass('hidden');   
        
        return false;
    });    
      
    $('.showless').click(function () {
        $(this.parentNode.parentNode).children('.toggle').addClass('hidden');    
        $(this).addClass('hidden'); 
        $(this.parentNode).children('.readmore').removeClass('hidden');   
        
        return false;
    });   
    
    slide2nextSlide = function (count, ms) {
		var slideID = parseInt($('div.itemPos').html())+1;
		if(slideID < 0) {slideID = count - slideID; }
		if(slideID >= count) {slideID = slideID -count; }
		$('div.itemPos').html(slideID);
		$('#leftCol .teaser h3.question').html(myJobjet.slides[slideID].question);
		$('#leftCol .teaser div.answer').html(myJobjet.slides[slideID].answer);
		str = new String($('#leftCol .teaser p.readMore a').attr('href'));
		str = str.substring(0, str.indexOf('?')).concat('?faqCategory='+myJobjet.slides[slideID].category+'&faqItemPosition='+myJobjet.slides[slideID].itemPos+'&faqListPosition='+myJobjet.slides[slideID].listPos+'#'+myJobjet.slides[slideID].category+myJobjet.slides[slideID].itemPos+myJobjet.slides[slideID].listPos);
		$('#leftCol .teaser p.readMore a').attr('href', str);
		$('#leftCol .teaser a.faqLink').attr('href', str);
		if(ms != 0){
			var test = 'slide2nextSlide('+count+','+ms+')';
			window.setTimeout(test, ms);
    	}
    };
    
	slide2prevSlide = function (count) {
		var  slideID = parseInt($('div.itemPos').html())-1;
		if(slideID < 0) {slideID = count + slideID; }
		if(slideID >= count) {slideID -= count; }
		$('div.itemPos').html(slideID);
		$('#leftCol .teaser h3.question').html(myJobjet.slides[slideID].question);
		$('#leftCol .teaser div.answer').html(myJobjet.slides[slideID].answer);
		str = new String($('#leftCol .teaser p.readMore a').attr('href'));
		str = str.substring(0, str.indexOf('?')).concat('?faqCategory='+myJobjet.slides[slideID].category+'&faqItemPosition='+myJobjet.slides[slideID].itemPos+'&faqListPosition='+myJobjet.slides[slideID].listPos+'#'+myJobjet.slides[slideID].category+myJobjet.slides[slideID].itemPos+myJobjet.slides[slideID].listPos);
		$('#leftCol .teaser p.readMore a').attr('href', str);
		$('#leftCol .teaser a.faqLink').attr('href', str);
		
    };
    
    
    /*** ie6 bugfixes fürs menü ***/
    var isIE6 = /msie|MSIE 6/.test(navigator.userAgent);
    if(isIE6){

    	/* width fix for toplevel */  
    	var menubreite = 0;
    	$('.topli').each(function(index){
    		menubreite += $(this).width();
    	});
    	
    	var padding = ($('#topNav').width()-menubreite)/$('.topli').length;
    	$('.topli').each(function(index){
    		$(this).css("width", padding+$(this).width());
    		$(this).children('a').css("width", $(this).width());
    		$(this).children('div').children('a').css("width", $(this).width());
    		$(this).children('div').children('ul').css("margin-left", -($(this).width()+2));
    	});

    	/* width fix for sublevel */  
        $('#topNav .level-2').each(function(index){
    		var max = 0;
	    	$(this).children('li').each(function(index){
	    		if(max < $(this).children('a').text().length) { max = $(this).children('a').text().length; }
	    	});
	    	$(this).width(max*8);
    	});
        
    	/* width fix for subsublevel */  
        $('.level-3').each(function(index){
    		var max = 0;
	    	$(this).children('li').each(function(index){
	    		if(max < $(this).children('a').text().length) { max = $(this).children('a').text().length; }
	    	});
	    	$(this).width(max*8);
    	});
        
    	/* width fix and position fix for subsublevel */ 
        if ($("ul.level-2 li a").length > 0) {	
    		
    		$("ul.level-2 li").mouseenter(
    			function () {
    				$(this).find(".level-3").css({
    					"display": "block",
    					"left": ($(this).width()-10),
    					"top": -36
    				});
    				$(this).addClass("selected");
    			}
    		) 
    		
    		$("ul.level-2 li").mouseleave(
    			function () {
    				$(this).find(".level-3").css({
    					"display": "none"
    				});
    				$(this).removeClass("selected");
    			}
    		)
    	}
    }
    
    var isIE7 = (navigator.appVersion.indexOf('MSIE 7.')==-1) ? false : true;
    var isIE8 = (navigator.appVersion.indexOf('MSIE 8.')==-1) ? false : true;
    if(isIE7||isIE8){
    	/* width fix for toplevel */  
    	var menubreite = 0;
    	$('.topli').each(function(index){
    		menubreite += $(this).width();
    	});
    	
    	var padding = ($('#topNav').width()-menubreite)/$('.topli').length;
    	$('.topli').each(function(index){
    		$(this).css("width", padding+$(this).width());    	
			$(this).children('div').children('ul').css("left", $(this).offset().left);
    	});
    	
    	
    }
});


