(function($){
    $.fn.aqTip = function(html,options) {
       var opts = $.extend({}, $.fn.aqTip.defaults, options);
       return this.each(function() {
          var $obj = $(this);
          $('<div class="aqTip"><\/div>').appendTo($obj);
          var $layer = $('.aqTip',$obj);
          $layer.css({ display: 'none', position: 'absolute' }).css(opts.css);
          if (jQuery.isFunction(html)) html($layer);
          else $layer.html(html);
          var p = $obj.position();
          var ow = $obj.width();
          var x = p.left + ow + opts.marginX;
          if (x > document.body.clientWidth)
             x = p.left - ow - opts.marginX;
          $layer.css({ left: x+'px', top: p.top+opts.marginY+'px' });
          $obj.hover(function(){$layer.show()}, function(){$layer.hide()});
       });
    };
    $.fn.aqTip.defaults = {
       marginX: 10, marginY: 10, 
       css: {
          backgroundColor: '#fff', color: '#444',
          border: '1px solid #ddd', padding: '5px' }
    };
    
    $.fn.aqTipOne = function(html,options) {
       var opts = $.extend({}, $.fn.aqTip.defaults, options);
       return this.each(function() {
          if (!$('#aqTip').length) {
             $('<div id="aqTip"><\/div>').appendTo(document.body);
             $('#aqTip').css({ display: 'none', position: 'absolute' })
                .css(opts.css);
          }

          var $obj = $(this);
          if (html) {
             $('#aqTip').html(html);

             var p = $obj.position();
             //var ow = $obj.width() > $('#aqTip').width() ? $obj.width():$('#aqTip').width();
             var ow = $obj.width();
             var x = p.left + ow + opts.marginX;
             if (x > document.body.clientWidth)
                x = p.left - ow - opts.marginX;

             $('#aqTip').show()
                .css({ left: x+'px', top: p.top+opts.marginY+'px' })
          } else
             $('#aqTip:visible').hide()

          return false;
   });
};
})(jQuery);

(function($) {
$.extend($.fn, {
	livequery: function(type, fn, fn2) {
		var self = this, q;
		// Handle different call patterns
		if ($.isFunction(type))
			fn2 = fn, fn = type, type = undefined;
		// See if Live Query already exists
		$.each( $.livequery.queries, function(i, query) {
			if ( self.selector == query.selector && self.context == query.context &&
				type == query.type && (!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid) )
					// Found the query, exit the each loop
					return (q = query) && false;
		});
		// Create new Live Query if it wasn't found
		q = q || new $.livequery(this.selector, this.context, type, fn, fn2);
		// Make sure it is running
		q.stopped = false;
		// Run it
		$.livequery.run( q.id );
		// Contnue the chain
		return this;
	},
	
	expire: function(type, fn, fn2) {
		var self = this;
		
		// Handle different call patterns
		if ($.isFunction(type))
			fn2 = fn, fn = type, type = undefined;
		// Find the Live Query based on arguments and stop it
		$.each( $.livequery.queries, function(i, query) {
			if ( self.selector == query.selector && self.context == query.context && 
				(!type || type == query.type) && (!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid) && !this.stopped )
					$.livequery.stop(query.id);
		});
		// Continue the chain
		return this;
	}
});

$.livequery = function(selector, context, type, fn, fn2) {
	this.selector = selector;
	this.context  = context || document;
	this.type     = type;
	this.fn       = fn;
	this.fn2      = fn2;
	this.elements = [];
	this.stopped  = false;
	
	// The id is the index of the Live Query in $.livequery.queries
	this.id = $.livequery.queries.push(this)-1;
	
	// Mark the functions for matching later on
	fn.$lqguid = fn.$lqguid || $.livequery.guid++;
	if (fn2) fn2.$lqguid = fn2.$lqguid || $.livequery.guid++;
	
	// Return the Live Query
	return this;
};

$.livequery.prototype = {
	stop: function() {
		var query = this;
		
		if ( this.type )
			// Unbind all bound events
			this.elements.unbind(this.type, this.fn);
		else if (this.fn2)
			// Call the second function for all matched elements
			this.elements.each(function(i, el) {
				query.fn2.apply(el);
			});
			
		// Clear out matched elements
		this.elements = [];
		
		// Stop the Live Query from running until restarted
		this.stopped = true;
	},
	
	run: function() {
		// Short-circuit if stopped
		if ( this.stopped ) return;
		var query = this;
		
		var oEls = this.elements,
			els  = $(this.selector, this.context),
			nEls = els.not(oEls);
		
		// Set elements to the latest set of matched elements
		this.elements = els;
		
		if (this.type) {
			// Bind events to newly matched elements
			nEls.bind(this.type, this.fn);
			
			// Unbind events to elements no longer matched
			if (oEls.length > 0)
				$.each(oEls, function(i, el) {
					if ( $.inArray(el, els) < 0 )
						$.event.remove(el, query.type, query.fn);
				});
		}
		else {
			// Call the first function for newly matched elements
			nEls.each(function() {
				query.fn.apply(this);
			});
			
			// Call the second function for elements no longer matched
			if ( this.fn2 && oEls.length > 0 )
				$.each(oEls, function(i, el) {
					if ( $.inArray(el, els) < 0 )
						query.fn2.apply(el);
				});
		}
	}
};

$.extend($.livequery, {
	guid: 0,
	queries: [],
	queue: [],
	running: false,
	timeout: null,
	
	checkQueue: function() {
		if ( $.livequery.running && $.livequery.queue.length ) {
			var length = $.livequery.queue.length;
			// Run each Live Query currently in the queue
			while ( length-- )
				$.livequery.queries[ $.livequery.queue.shift() ].run();
		}
	},
	
	pause: function() {
		// Don't run anymore Live Queries until restarted
		$.livequery.running = false;
	},
	
	play: function() {
		// Restart Live Queries
		$.livequery.running = true;
		// Request a run of the Live Queries
		$.livequery.run();
	},
	
	registerPlugin: function() {
		$.each( arguments, function(i,n) {
			// Short-circuit if the method doesn't exist
			if (!$.fn[n]) return;
			
			// Save a reference to the original method
			var old = $.fn[n];
			
			// Create a new method
			$.fn[n] = function() {
				// Call the original method
				var r = old.apply(this, arguments);
				
				// Request a run of the Live Queries
				$.livequery.run();
				
				// Return the original methods result
				return r;
			}
		});
	},
	
	run: function(id) {
		if (id != undefined) {
			// Put the particular Live Query in the queue if it doesn't already exist
			if ( $.inArray(id, $.livequery.queue) < 0 )
				$.livequery.queue.push( id );
		}
		else
			// Put each Live Query in the queue if it doesn't already exist
			$.each( $.livequery.queries, function(id) {
				if ( $.inArray(id, $.livequery.queue) < 0 )
					$.livequery.queue.push( id );
			});
		
		// Clear timeout if it already exists
		if ($.livequery.timeout) clearTimeout($.livequery.timeout);
		// Create a timeout to check the queue and actually run the Live Queries
		$.livequery.timeout = setTimeout($.livequery.checkQueue, 20);
	},
	
	stop: function(id) {
		if (id != undefined)
			// Stop are particular Live Query
			$.livequery.queries[ id ].stop();
		else
			// Stop all Live Queries
			$.each( $.livequery.queries, function(id) {
				$.livequery.queries[ id ].stop();
			});
	}
});

// Register core DOM manipulation methods
$.livequery.registerPlugin('append', 'prepend', 'after', 'before', 'wrap', 'attr', 'removeAttr', 'addClass', 'removeClass', 'toggleClass', 'empty', 'remove');

// Run Live Queries when the Document is ready
$(function() { $.livequery.play(); });


// Save a reference to the original init method
var init = $.prototype.init;

// Create a new init method that exposes two new properties: selector and context
$.prototype.init = function(a,c) {
	// Call the original init and save the result
	var r = init.apply(this, arguments);
	
	// Copy over properties if they exist already
	if (a && a.selector)
		r.context = a.context, r.selector = a.selector;
		
	// Set properties
	if ( typeof a == 'string' )
		r.context = c || document, r.selector = a;
	
	// Return the result
	return r;
};

// Give the init function the jQuery prototype for later instantiation (needed after Rev 4091)
$.prototype.init.prototype = $.prototype;
	
})(jQuery);

function getHeight() {
    var h = 0;

    if (typeof(window.innerHeight) == "number") {
        h = window.innerHeight;
    } else {
        if (document.documentElement && document.documentElement.clientHeight) {
            h = document.documentElement.clientHeight;
        } else {
            if (document.body && document.body.clientHeight) {
                h = document.body.clientHeight;
            }
        }
    }

    return h;
}

function showTip(elem, id){
    var xpos = findPosX(elem);
    var ypos = findPosY(elem);
    var box = document.getElementById(id);
    active_tip = id;
    
    for(i=0; i<tiplist.length; i++){
    	document.getElementById(tiplist[i]).style.display = 'none';
    }

    box.style.display = 'block';
    box.style.top  = (ypos - box.offsetHeight - 0) + 'px';
    box.style.left = (xpos - 20) + 'px';
}


function hideTip( id ){	
	var box = document.getElementById(id);
	
	box.style.display = 'none';
	active_tip = 0;
}


function checkOut(id){
	setTimeout("killOrNot('"+id+"');",700);
	active_tip = 0;
}


function killOrNot(id){
	if(active_tip != id){
		hideTip(id);
	}
}


function stayAlive(id){
	active_tip = id;
	document.getElementById(id).style.display = 'block';
}


// http://hartshorne.ca/2006/01/23/javascript_cursor_position/
function getCursorPosition(e) {
    e = e || window.event;
    //var cursor = {x:0, y:0};

    if (e.pageX || e.pageY) {
        cursor.x = e.pageX;
        cursor.y = e.pageY;
    } 
    else {
        var de = document.documentElement;
        var b = document.body;
        cursor.x = e.clientX + 
            (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        cursor.y = e.clientY + 
            (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    }
    //return cursor;
}



// by Peter-Paul Koch & Alex Tingle
// http://blog.firetree.net/2005/07/04/javascript-find-position/
function findPosX( obj ){
  var curleft = 0;

  try{
    if ( obj.offsetParent ){
      while(1){
        curleft += obj.offsetLeft;

        if ( !obj.offsetParent ){
          break;
        }

        obj = obj.offsetParent;
      }
    }
    else if ( obj.x ){
      curleft += obj.x;
    }
  }
  catch ( e ){
//    alert(e);
  }

  return curleft;
}

function findPosY( obj ){
  var curtop = 0;

  try{
    if ( obj.offsetParent ){
      while ( 1 ){
        curtop += obj.offsetTop;

        if ( !obj.offsetParent ){
          break;
        }

        obj = obj.offsetParent;
      }
    }
    else if ( obj.y ){
      curtop += obj.y;
    }
  }
  catch ( e ){
//    alert(e);
  }

  return curtop;
}



/* 
 * init
 */
var active_tip = 0;
var tiplist = new Array(
	"tip0","tip1","tip2","tip3","tip4","tip5","tip6"
);

(function ($) {
    $.fn.mousehold = function(timeout, f) {
    	if (timeout && typeof timeout == 'function') {
    		f = timeout;
    		timeout = 100;
    	}
    	if (f && typeof f == 'function') {
    		var timer = 0;
    		var fireStep = 0;

    		return this.each(function() {
    			var clearMousehold = function() {
    				clearInterval(timer);
    				if (fireStep == 1) f.call(this, 1);
    				fireStep = 0;
    			};

    			$(this).mousedown(function() {
    				fireStep = 1;
    				var ctr = 0;
    				var t = this;
    				timer = setInterval(function() {
    					ctr++;
    					f.call(t, ctr);
    					fireStep = 2;
    				}, timeout);
    			}).mouseout(clearMousehold).mouseup(clearMousehold);
    		});
    	}
    };
})(jQuery);

function inputOnFocus(inputName, inputValue) {
    if (document.getElementsByName(inputName)[0].value==inputValue) {
        document.getElementsByName(inputName)[0].value="";
    }
}

function inputOnBlur(inputName, inputValue) {
    if (document.getElementsByName(inputName)[0].value=="") {
        document.getElementsByName(inputName)[0].value=inputValue;
    }
}

function Trenner(number) {
    number = '' + number;
    if (number.length > 3) {
        var mod = number.length % 3;
        var output = (mod > 0 ? (number.substring(0,mod)) : '');
        for (i=0 ; i < Math.floor(number.length / 3); i++) {
            if ((mod == 0) && (i == 0))
                output += number.substring(mod+ 3 * i, mod + 3 * i + 3);
            else
                output+= '.' + number.substring(mod + 3 * i, mod + 3 * i + 3);
        }
        return (output);
    }
    else return number;
}


$(function() {
    
    $.fn.anlagerechner = function() {
        $('.animation').show();
        if(typeof dataHandler != 'undefined' && $('div#anlagerechner').length != 0) {
            var anlageform, beitrag;
            anlageform = $('input[name=Anlageform]:checked').val();
            if(anlageform == 'once'){
                $('#anlagerechner div#anlagesumme_once').show();
                beitrag = $('div#anlagesumme_once div.ui-slider').slider('value',0);
                $('#anlagerechner div#anlagesumme_continous').hide();
            } else if(anlageform == 'continous'){
                $('#anlagerechner div#anlagesumme_continous').show();
                beitrag = $('div#anlagesumme_continous div.ui-slider').slider('value',0);
                $('#anlagerechner div#anlagesumme_once').hide();
            }
            $.getJSON(dataHandler.url,
            {
                "anlagedauer":$('div#anlagerechner div#anlagezeitraum div.ui-slider').slider('value',0),
                "beitrag":beitrag,
                "anlageform":anlageform
            },
            function(data){
                $("div.output div.leftFloat img").attr("src", data.graph);
                $("div.output div.rightFloat td:eq(1)").html(data.dataseT + " EUR");
                $("div.output div.rightFloat td:eq(3)").html(data.datasetM + " EUR");
                $("div.output div.rightFloat td:eq(5)").html(data.datasetR + " EUR");
                $("div.output div.rightFloat td:eq(7)").html(data.datasetSpar + " EUR");
                $("div.output div.rightFloat span#zeitraum").html("Zeitraum: " + data.startdate + " - " + data.enddate);
                $('.animation').hide();
            });
        }
    };
    
    
    $('#contact > ul').tabs();
    $("div.include table tbody tr:nth-child(odd), div#fondsergebnis tbody tr:nth-child(odd)").addClass("odd");
    $("div.include table tbody tr:nth-child(even), div#fondsergebnis tbody tr:nth-child(even)").addClass("even");

    $("table.pressOverview tbody tr:nth-child(odd)").addClass("odd");
    $("table.pressOverview tbody tr:nth-child(even)").addClass("even");

    $("div.striped table tr:nth-child(odd)").addClass("odd");
    $("div.striped table  tr:nth-child(even)").addClass("even");
    $("div.striped > div:nth-child(odd)").addClass("odd");
    $("div.striped > div:nth-child(even)").addClass("even");
    $("table.border tr td:first").addClass("first");
    $("div.include table tr td:first-child").addClass("first");
    $("ul.buttons li:last").addClass("last");
    
    $("ul[type='circle']").addClass("circle");
    $("ul[type='square']").addClass("square");
    $("ol[type='A']").addClass("upper-alpha");
    $("ol[type='a']").addClass("lower-alpha");
    $("ol[type='I']").addClass("upper-roman");
    $("ol[type='i']").addClass("lower-roman");
    $("ol[type='1']").addClass("decimal");
    
    $('span#mutual a').attr('target', '_blank');
    $('#anlagerechner .output .animation').css('opacity', '.50');
    $('#anlagerechner .output .animation').css('-moz-opacity', '0.5');
    $('#anlagerechner .output .animation').css('filter', 'alpha(opacity=50)');
    $('#landingpage-fullscreen-overlay').css({'filter':'alpha(opacity=80)', '-moz-opacity':'0.8', 'opacity':'0.8'});
    
    
    $("div.zoomOff").click(function () {
        $("div.slideContent").css("overflow", "visible");
        $("div.zoomOn").show("slow");
        $("div.zoomOff").hide("slow");
    });
    $("div.zoomOn").click(function () {
        $("div.slideContent").css("overflow", "hidden");
        $("div.zoomOff").show("slow");
        $("div.zoomOn").hide("slow");
    });
    $("h3").click(function () {
        $("div.slideContent").css("overflow", "hidden");
        $("div.slide").find("div.zoomOff").show("slow");
        $("div.slide").find("div.zoomOn").hide("slow");
    });
    $(".slide").accordion({
        header: "h3"
    });
    $('div#search_extended h3').click(function() {
        if ($("div#search_extended div.innerWrap").is(":hidden")) {
            $("div#search_extended h3 a").css("border-bottom","1px solid #D7D4CB");
            $("div#search_extended div.innerWrap").slideDown("normal");
        } else {
            $("div#search_extended div.innerWrap").slideUp("normal");
            $("div#search_extended h3 a").css("border-bottom","none");
        }
    });
    $("form#jump select").change(function() {
        var goTo = this.value;
        var temp = new Array();
        temp = goTo.split(',');
        if(temp[0] != "") {
            window.open(temp[0], temp[1]);
            return false;
        }
    });
    $("div#rightContent ul li a").each(function(i){
        var $this = $(this);
        var str = $this.text();
        if(str.indexOf(":") >= 0) {
            var pre = "<strong>" + str.substring(0, str.indexOf(":")+1) + "</strong>";
            var post = str.substring(str.indexOf(":")+1);
            $this.html(pre + post);
        }
    });
    $("div#sitemap > ul > li > ul > li").addClass('last');
    $("div#sitemap ul > li > span:last").css('border-right', 'none');
    $('ul#sectionNav li ul li ul li:last a').css('border-bottom','1px solid #ffffff');
    $("div.zoom + ul").css("margin-left", "225px");
    $('input#status_vermittler').click(function() {
         if($(this).attr("checked")) {
             $('input#vermittler_nr').removeAttr("readonly").removeClass('readonly').focus();
         } else {
             $('input#vermittler_nr').attr("readonly","readonly").addClass('readonly').val('');
         }
    });
    $('input#vermittler_nr').click(function() {
        if($(this).attr("readonly")) {
             $(this).removeAttr("readonly").removeClass('readonly').focus();
             $('input#status_vermittler').attr('checked', 'checked');
         }
    });
    
    
    $('input#status_kunde').click(function() {
         if($(this).attr("checked")) {
             $('input#versicherungs_nr').removeAttr("readonly").removeClass('readonly').focus();
         } else {
             $('input#versicherungs_nr').attr("readonly","readonly").addClass('readonly').val('');
         }
    });
    $('input#versicherungs_nr').click(function() {
        if($(this).attr("readonly")) {
             $(this).removeAttr("readonly").removeClass('readonly').focus();
             $('input#status_kunde').attr('checked', 'checked');
         }
    });
    
    $('input#ab_den').click(function() {
         if($('input#gueltig_datum').val() == "TT.MM.JJJJ") {
             $('input#gueltig_datum').val('');
         $('input#gueltig_datum').removeAttr("readonly").removeClass('readonly').focus();
         }
    });
    $('input#sofort').click(function() {
         $('input#gueltig_datum').attr("readonly","readonly").addClass('readonly').val('TT.MM.JJJJ');
    });
    
    $('input#gueltig_datum').click(function() {
        if($(this).attr("readonly")) {
             $(this).removeAttr("readonly").removeClass('readonly').focus();
             $('input#ab_den').attr('checked', 'checked');
         }
    });
    $('input.date').focus(function() {
        if($(this).val() == "TT.MM.JJJJ") {
            $(this).val('');
        }
    });
    $('input.date').blur(function() {
        if($(this).val() == "") {
            $(this).val('TT.MM.JJJJ');
        }
    });
    
    $("a.lock").each(function(i) {
        $(this).after("<span class=\"lock\">&nbsp;&nbsp;&nbsp;</span>");
    });
    
    // Slider Produktfinder
    $("ol[id^='result_']").css('display','none');
    $("div#finderResultTextContainer p[id^='finderResultText_']").css('display','none');
    $("h4[id^='headline_']").css('display','none');

    var infopaketLink = $('ul li.details a').attr('href');
    $("div[id^='produktfinder_']").each(function (i) {
        var items = $(this).find("tr.values td").size();
        var min_value = parseInt($(this).find("tr.values td:first").text());
        var max_value = parseInt($(this).find("tr.values td:last").text());
        var step_value = (max_value-min_value) / (items-1);
        var start_value = parseInt($(this).find("tr.values td.act").text());
        var dd_width = Math.round(100 / items)-1;
        $(this).find("tr.question td").attr('width', dd_width + '%');
        $(this).find("tr.question td:first").css('text-align', 'left');
        $(this).find("tr.question td:last").css('text-align', 'right');
        $(this).find("div.ui-slider").slider({
		stepping: step_value,
		min: min_value,
		max: max_value,
		change: function(e, ui) {
            var sumvalue = 0;
            var show_id = "";
            var hide_id = "";
            var thisvalue = ui.value;

            $.each($("div[id^='produktfinder_']:visible"), function(i, val) {
                if(jQuery.inArray($(this).attr('id'), eval('dataHandler.value_' + thisvalue + '.sliders')) < 0) {
                    $(this).hide();
                }
            });

            $.each($("div[id^='produktfinder_']:visible"), function(i, val) {
                if(jQuery.inArray($(this).attr('id'), eval('dataHandler.value_' + thisvalue + '.sliders')) < 0) {
                    $(this).hide();
                }
            });

            $.each($("div[id^='produktfinder_']:hidden"), function(i, val) {
                if(jQuery.inArray($(this).attr('id'), eval('dataHandler.value_' + thisvalue + '.sliders')) >= 0) {
                    $(this).show('fast');
                    $(this).find("div.ui-slider").slider('startValue', parseInt($(this).find("tr.values td.act").text()));
                }
            });
            $("div[id^='produktfinder_']:visible").each(function (i) {
                sumvalue += $(this).find("div.ui-slider").slider('value', 0);
            });
            
            $("ul#result > li").hide();
	    $("div#finderResultTextContainer > p").hide();
            $("h4[id^='headline_']").hide();
	    
	    var imageSrc = $(eval('dataHandler.result_' + sumvalue + '.image')).get(0);
	    $('img#finderResultImage').attr("src", imageSrc);
            var result = "";
            $.each(eval('dataHandler.result_' + sumvalue + '.results'), function() {
                result += "<li>" + $("#" + this).html() + "</li>";
            });

            $.each(eval('dataHandler.result_' + sumvalue + '.text'), function() {
                $("#" + this).show();
            });
	    
            $.each(eval('dataHandler.result_' + sumvalue + '.headline'), function() {
                $("#" + this).show();
            });
            var appendLink = "";
            $.each(eval('dataHandler.result_' + sumvalue + '.infopaket'), function() {
                appendLink += this + "&";
            });
            $('ul#result').prepend(result);
            $('ul li.details a').attr("href", function (i) {
                return infopaketLink + "?" + appendLink;
            });
        },
            handles: [
                {start: start_value, min: min_value, max: max_value}
            ]
        });
        
        $(this).find("div.ui-slider-bw").click(function() {
          $(this).parent().find("div.ui-slider").slider( "moveTo", "-=" + step_value, "0" );
        });
        $(this).find("div.ui-slider-fw").click(function() {
          $(this).parent().find("div.ui-slider").slider( "moveTo", "+=" + step_value, "0" );
        });
    });

    $('div.bav #produktfinder_20').hide();
    $('div.bav li#result_1').hide();
    $('div.bav li#result_3').hide();
    $('div.bav li#result_4').hide();
    $('div.bav li#result_5').hide();
    $('div.bav li#result_6').hide();
    $('div.pav li#result_2').hide();
    $('div.pav li#result_3').hide();
    $('div.pav li#result_4').hide();
    $('div.pav li#result_5').hide();
    $('div.pav li#result_7').hide();

    $("div[id^='investmentfinder_']").each(function (i) {
        var items = $(this).find("table#values_investment tr").size() - 2;
        var min_value = parseInt($(this).find("table#values_investment tr:eq(1) td.value").text());
        var max_value = parseInt($(this).find("table#values_investment tr:eq(3) td.value").text());
        var step_value = (max_value-min_value) / (items-1);
        var start_value = parseInt($(this).find("table#values_investment tr td.act").text());
        $('table#values_investment tbody tr:eq(' + (start_value) + ') td.question').css('font-weight', 'bold');
        $('div#headlineContainer h3').html(eval('dataHandler.result_' + start_value + '.title'));
	$('img#finderResultImage').attr('src', eval('dataHandler.result_' + start_value + '.image'));
        $('div#finderResult p.description').html(eval('dataHandler.result_' + start_value + '.description'));
        $('div#finderResult p.link a').html(eval('dataHandler.result_' + start_value + '.link_description'));
        $('div#finderResult p.link a').attr('href', eval('dataHandler.result_' + start_value + '.link_url'));
        $('div#finderResult p.link a').attr('title', 'Link zu: ' + eval('dataHandler.result_' + start_value + '.title'));
        var div_height = Math.round(100 / items)-1;
        $(this).find("table#values_investment tr").attr('height', div_height + '%');
        $(this).find("table#values_investment > tbody > tr:last td.question").css('vertical-align', 'top');
        $(this).find("table#values_investment > tbody > tr:last td.question").css('vertical-align', 'bottom');
        $(this).find("div.ui-slider").slider({
		stepping: step_value,
		min: min_value,
		max: max_value,
		change: function(e, ui) {
            var sumvalue = 0;
            var show_id = "";
            var hide_id = "";
            var thisvalue = ui.value;
            $('table#values_investment tbody tr td.question').css('font-weight', 'normal');
            $('table#values_investment tbody tr:eq(' + (thisvalue) + ') td.question').css('font-weight', 'bold');
            
            $.each($("div[id^='investmentfinder_']:visible"), function(i, val) {
                
                if(jQuery.inArray($(this).attr('id'), eval('dataHandler.value_' + thisvalue + '.sliders')) < 0) {
                    $(this).hide();
                }
            });

            $.each($("div[id^='investmentfinder_']:hidden"), function(i, val) {
                if(jQuery.inArray($(this).attr('id'), eval('dataHandler.value_' + thisvalue + '.sliders')) >= 0) {
                    $(this).show('fast');
                    $(this).find("div.ui-slider").slider('startValue', parseInt($(this).find("tr td.act").text()));
                }
            });
            
            $("div[id^='investmentfinder_']:visible").each(function (i) {
                sumvalue += $(this).find("div.ui-slider").slider('value', 0);
            });
            
            $("ol#result > li").hide();
            
            $('div#headlineContainer h3').html(eval('dataHandler.result_' + sumvalue + '.title'));
            $('div#finderResult p.description').html(eval('dataHandler.result_' + sumvalue + '.description'));
            $('div#finderResult p.link a').html(eval('dataHandler.result_' + sumvalue + '.link_description'));
	    $('img#finderResultImage').attr('src', eval('dataHandler.result_' + sumvalue + '.image'));
            $('div#finderResult p.link a').attr('title', 'Link zu: ' + eval('dataHandler.result_' + sumvalue + '.title'));
            $('div#finderResult p.link a').attr('href', eval('dataHandler.result_' + sumvalue + '.link_url'));
        },
            handles: [
                {start: start_value, min: min_value, max: max_value}
            ]
        });
        
        $(this).find("div.ui-slider-bw").click(function() {
          $(this).parent().find("div.ui-slider").slider( "moveTo", "-=" + step_value, "0" );
        });
        $(this).find("div.ui-slider-fw").click(function() {
          $(this).parent().find("div.ui-slider").slider( "moveTo", "+=" + step_value, "0" );
        });
    });
    
    
    $('div#anlagerechner div#anlagesumme div#anlagesumme_continous div.ui-slider').slider({
        stepping: 50,
		min: 50,
		max: 1000,
        slide: function(e, ui) {
            $('div#anlagerechner div#anlagesumme div#anlagesumme_continous div.slider-callout').css({'left' : ui.handle.css('left'), 'margin-left' : '-10px'}).html(Math.round(ui.value) + ' EUR');
        },
        change: function(e, ui) {
            $('div#anlagerechner').anlagerechner();
            },
        handles: [
                {start: 50, min: 50, max: 1000}
            ]
    });
    

    $('div#anlagerechner div#anlagesumme div#anlagesumme_once div.ui-slider').slider({
        stepping: 5000,
		min: 10000,
		max: 100000,
        slide: function(e, ui) {
            $('div#anlagerechner div#anlagesumme div#anlagesumme_once div.slider-callout').css({'left' : ui.handle.css('left'), 'margin-left' : '-10px'}).html(Trenner(Math.round(ui.value)) + ' EUR');
        },
        change: function(e, ui) {
            $('div#anlagerechner').anlagerechner();
            },
        handles: [
                {start: 10000, min: 10000, max: 100000}
            ]
    });
    $('div#anlagesumme_once').hide();
    
    $('div#anlagerechner div#anlagesumme div#anlagesumme_continous div.ui-slider-bw').click(function() {
      $('div#anlagerechner div#anlagesumme div#anlagesumme_continous div.ui-slider').slider( "moveTo", "-=" + 50, "0" );
    });
    
    $('div#anlagerechner div#anlagesumme div#anlagesumme_continous div.ui-slider-fw').click(function() {
      $('div#anlagerechner div#anlagesumme div#anlagesumme_continous div.ui-slider').slider( "moveTo", "+=" + 50, "0" );
    });
    
    $('div#anlagerechner div#anlagesumme div#anlagesumme_once div.ui-slider-bw').click(function() {
      $('div#anlagerechner div#anlagesumme div#anlagesumme_once div.ui-slider').slider( "moveTo", "-=" + 5000, "0" );
    });
    
    $('div#anlagerechner div#anlagesumme div#anlagesumme_once div.ui-slider-fw').click(function() {
      $('div#anlagerechner div#anlagesumme div#anlagesumme_once div.ui-slider').slider( "moveTo", "+=" + 5000, "0" );
    });
    
    
    $('div#anlagerechner div#anlagezeitraum div.ui-slider').slider({
        stepping: 1,
		min: 10,
		max: 38,
        slide: function(e, ui) {
            $('div#anlagerechner div#anlagezeitraum div.slider-callout').css('left', ui.handle.css('left')).html(Math.round(ui.value) + ' Jahre');
        },
        change: function(e, ui) {
            $('div#anlagerechner').anlagerechner();
            },
        handles: [
                {start: 20, min: 10, max: 38}
            ]
    });
    
    $('div#anlagerechner div#anlagezeitraum div.ui-slider-bw').click(function() {
      $('div#anlagerechner div#anlagezeitraum div.ui-slider').slider( "moveTo", "-=" + 1, "0" );
    });
    
    $('div#anlagerechner div#anlagezeitraum div.ui-slider-fw').click(function() {
      $('div#anlagerechner div#anlagezeitraum div.ui-slider').slider( "moveTo", "+=" + 1, "0" );
    });
    
    $("#once, #continous").bind(($.browser.msie ? "click" : "change"), function () {
          $('div#anlagerechner').anlagerechner();
    });

    $('.animation').hide();
    
    $('#anlagerechner span.tiphover').aqTip($('span.tip').html(), {marginX: -10, css:{width: '200px', backgroundColor: '#fff', padding: '2px', border: '1px solid #ddd'}});
    $('#fondsfinder span.tiphover').aqTip($('span.tip').html(), {marginX: -10, css:{width: '200px', backgroundColor: '#fff', padding: '2px', border: '1px solid #ddd'}});
    
    $('td.classifikation').hover(
        function(){ 
            var klasse = $(this).find('span.klasse').html();
            $(this).aqTipOne(klasse, {marginX: 5, marginY: 0, css: {backgroundColor: '#fff', padding: '2px', border: '1px solid #ddd' }}) },
            function(){ $(this).aqTipOne() }
    );
    $('td.isinhover').hover(
        function(){ 
            var isin = $(this).find('span.isin').html();
            $(this).aqTipOne(isin, {marginX: 5, marginY: 0, css: {backgroundColor: '#fff', padding: '2px', border: '1px solid #ddd' }}) },
            function(){ $(this).aqTipOne() }
    );

   
    var bgcolor;
    $('div#fondsergebnis tbody tr').hover(function() {
        bgcolor = $(this).css('background-color');
        $(this).css('background-color', '#EBF4B4');
    },
    function() {
        $(this).css('background-color', bgcolor);
    });
    
    $("#mediathekConfirm #confirm").bind(($.browser.msie ? "click" : "change"), function () {
		    if($('#mediathekConfirm #confirm').is(':checked')) {
			    $('#downloadInact').hide();
			    $('#downloadAct').show();
		    } else {
			$('#downloadInact').show();
			$('#downloadAct').hide();
		    }
    });

});

$(document).ready(function(){
    $('a.thickbox, area.thickbox, input.thickbox').click(function(){
        $('.TB_overlayBG').css({'filter':'alpha(opacity=75)', '-moz-opacity':'0.75', 'opacity':'0.75'});    // lines 41  - 43
        $('#TB_HideSelect').css({'filter':'alpha(opacity=0)', '-moz-opacity':'0', 'opacity':'0'});          // lines 154 - 156
        $('#TB_iframeContent').css({'_margin-bottom':'1px'});                                              // line  175
        
        var isMSIE6 = jQuery.browser.msie && /MSIE 6\.0/i.test(window.navigator.userAgent) && !/MSIE 7\.0/i.test(window.navigator.userAgent);
        
        // IE 6 hacks
        if (isMSIE6) {
            var Height_0 = document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'
            $('#TB_overlay').css({'height':Height_0});                                                     // line  50
            
            var MarginTop_0 = 0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px';
            $('#TB_window').css({'margin-top':MarginTop_0});                                               // line  69
            
            var MarginTop_1 = 0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px';
            $('#TB_load').css({'margin-top':MarginTop_1});                                                 // line  142
            
            var Height_1 = document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px';
            $('#TB_HideSelect').css({'height':Height_1});                                                  // line  165
        }
        
        var TB_HEIGHT = getHeight() - 50; // 50px seems to work in all most cases        
        if (!isMSIE6) {
            jQuery("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});
        }
        
        return false;
    });

    
        $(document).pngFix();
        var leftAlign = $('div#anlagerechner div#anlagezeitraum div.ui-slider-handle').css('left');
        var slider = $('div#anlagerechner div#anlagezeitraum div.ui-slider');
        if (slider.length != 0) {
            var sliderValue = $('div#anlagerechner div#anlagezeitraum div.ui-slider').slider('value',0);
        }
        if(typeof leftAlign != 'undefined' && sliderValue != 'undefined') {
            $('div#anlagerechner div#anlagezeitraum div.slider-callout').css({'left' : leftAlign, 'margin-left' : '-10px'}).html(Math.round(sliderValue) + ' Jahre');
                $('div#anlagerechner div#anlagesumme div#anlagesumme_continous div.slider-callout').css({'left' : '0px', 'margin-left' : '-10px'}).html('50 EUR');
            $('div#anlagerechner div#anlagesumme div#anlagesumme_once div.slider-callout').css({'left' : '0px', 'margin-left' : '-10px'}).html('10.000 EUR');
        }
        
        $('div#anlagerechner').anlagerechner();

        // Merkzettel hinzufuegen
        $('a.merkzettel').click(function() {
            var product = $("li.merkzettel form").serialize();
            $.get($("li.merkzettel input[name='url']").val(), product, function(text){
                $("#merkzettel").load($("li.merkzettel input[name='url']").val());
            });
        });

        // Merkzettel entfernen
        $('div#merkzettelContent div.headline a').livequery('click', function(event) {
            var product = 'produkt=' + $(this).attr('class') + '&action=remove';
            $.get($("div#merkzettelContent input[name='url']").val(), product, function(text){
                $("div#include").load($("div#merkzettelContent input[name='url_detail']").val());
                $("#merkzettel").load($("div#merkzettelContent input[name='url_portlet']").val());
            });
        });

        // Newsletter anmeldung
        $('div#newsletter input.image').livequery('click', function(event) {
            var fields = $("div#newsletter form").serialize();
            $.get($("div#newsletter input[name='url']").val(), fields, function(text){
                    $("div#newsletter p:first").html(text).fadeIn('slow');
            });
        });

    });
