/**
 * HoverAccordion - jQuery plugin for intuitively opening accordions and menus
 * http://berndmatzner.de/jquery/hoveraccordion/
 * Copyright (c) 2008 Bernd Matzner
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * Requires jQuery 1.2.1 or higher
 * Version: 0.5.0
 *
 * Usage:
 * $('#YourUnorderedListID').hoverAccordion();
 * or
 * $('.YourUnorderedListClass').hoverAccordion({
 *  speed: 'slow',
 *  activateitem: '1',
 *  active: 'current',
 *  header: 'title',
 *  hover: 'highlight',
 *  opened: 'arrowdown',
 *  closed: 'arrowup'
 *  keepheight: 'false'
 * });
 */
(function($){
    $.fn.hoverAccordion = function(options){
        // Setup options
        options = jQuery.extend({
            speed: 'fast', // Speed at which the subitems open up - valid options are: slow, normal, fast
            activateitem: 'current', // 'true': Automatically activate items with links corresponding to the current page, '2': Activate item #2
            active: 'current', // Class name of the initially active element
            header: 'header', // Class name for header items
            hover: 'hover', // Class name for hover effect
            opened: 'opened', // Class name for open header items
            closed: 'closed', // Class name for closed header items
            keepheight: 'false' // 'true': Set the height of each accordion item to the size of the largest one, 'false': Leave height as is
        }, options);
        
        // Current hover status
        var thislist = this;
        
        // Current URL
        var thisurl = window.location.href;
        
        // Interval for detecting intended element activation
        var i = 0;
        
        // Change display status of subitems when hovering
        function doHover(obj){
            if ($(obj).html() == undefined) 
                obj = this;
            
            // Change only one display status at a time
            if (!thislist.is(':animated')) {
                var newelem = $(obj).parent().children('ul');
                var oldelem = $(obj).parent().parent().children('li').children('ul:visible');
                if (options.keepheight == 'true') {
                    thisheight = maxheight;
                }
                else {
                    thisheight = newelem.height();
                }
                
                // Change display status if not already open
                if (!newelem.is(':visible')) {
                    newelem.children().hide();
                    newelem.animate({
                        height: thisheight
                    }, {
                        step: function(n, fx){
                            newelem.height(thisheight - n);
                        },
                        duration: options.speed
                    }).children().show();
                    
                    oldelem.animate({
                        height: 'hide'
                    }, {
                        step: function(n, fx){
                            newelem.height(thisheight - n);
                        },
                        duration: options.speed
                    }).children().hide();
                    
                    // Switch classes for headers
                    oldelem.parent().children('a').addClass(options.closed).removeClass(options.opened);
                    newelem.parent().children('a').addClass(options.opened).removeClass(options.closed);
                }
            }
        };
        
        var itemNo = 0;
        var maxheight = 0;
        
        // Setup initial state and hover events
        $(this).children('li').each(function(){
            var thisitem = $(this);
            
            itemNo++;
            
            // Set current link to current URL to 'active' and disable anchor links
            var thislink = thisitem.children('a');
            
            if (thislink.length > 0) {
                // Hover effect for all links
                thislink.hover(function(){
                    $(this).addClass(options.hover);
                }, function(){
                    $(this).removeClass(options.hover);
                });
                
                var thishref = thislink.attr('href');
                
                if (thishref == '#') {
                    // Add a click event if the header does not contain a link
                    thislink.click(function(){
                        doHover(this);
                        this.blur();
                        return false;
                    });
                }
                else 
                    if (options.activateitem == 'true' && thisurl.indexOf(thishref) > 0 && thisurl.length - thisurl.lastIndexOf(thishref) == thishref.length) {
                        thislink.parent().addClass(options.active);
                    }
            }
            
            var thischild = thisitem.children('ul');
            
            // Initialize subitems
            if (thischild.length > 0) {
                if (maxheight < thischild.height()) 
                    maxheight = thischild.height();
                
                // Change appearance of the header element of the active item
                thischild.children('li.' + options.active).parent().parent().children('a').addClass(options.header);
                
                // Bind hover events to all subitems
                thislink.hover(function(){
                    var t = this;
                    i = setInterval(function(){
                        doHover(t);
                        clearInterval(i);
                    }, 400);
                }, function(){
                    clearInterval(i);
                });
                
                
                // Set current link to current URL to 'active'
                if (options.activateitem == 'true') {
                    thischild.children('li').each(function(){
                        var m = $(this).children('a').attr('href');
                        if (m) {
                            if (thisurl.indexOf(m) > 0 && thisurl.length - thisurl.lastIndexOf(m) == m.length) {
                                $(this).addClass(options.active).parent().parent().children('a').addClass(options.opened);
                            }
                        }
                    });
                }
                else 
                    if (parseInt(options.activateitem) == itemNo) {
                        thisitem.addClass(options.active).children('a').addClass(options.opened);
                    }
            }
            
            // Close all subitems except for those with active items
            thischild.not($(this).parent().children('li.' + options.active).children('ul')).not(thischild.children('li.' + options.active).parent()).hide().parent().children('a').addClass(options.closed);
        });
        
        return this;
    };
})(jQuery);







function close_info_box() {

$(".active_box").animate({width: "0px"}, 400, "easeInOutExpo" ).removeClass("active_box");

}

/* ------------------------------------------ birthday special ------------------------------------------ */

	$.fn.fixPNG = function() {
		return this.each(function () {
			var image = $(this).css('backgroundImage');

			if (image.match(/^url\(["']?(.*\.png)["']?\)$/i)) {
				image = RegExp.$1;
				$(this).css({
					'backgroundImage': 'none',
					'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=" + ($(this).css('backgroundRepeat') == 'no-repeat' ? 'crop' : 'scale') + ", src='" + image + "')"
				}).each(function () {
					var position = $(this).css('position');
					if (position != 'absolute' && position != 'relative')
						$(this).css('position', 'relative');
				});
			}
		});
	};

	var isIE = ($.browser.msie && parseInt($.browser.version.substr(0,1)) < 8);

/* ------------------------------------------ birthday special end ------------------------------------------ */


jQuery(document).ready(function(){



/* ------------------------------------------ birthday special ------------------------------------------ */
	
	
	$("#b-day-thegeorge").show();
	if (isIE) {
		$("#geschenk_close").fixPNG();
	}
	$("#geschenk_close, #linktohomepage").click(function () {
		$("#b-day-thegeorge").hide();
	});


/* ------------------------------------------ birthday special end ------------------------------------------ */




/* ------------------------------------------ navigation ------------------------------------------ */
	
	
	$("#content_left").hide();
	$(".info_box").css({ "width":"0px" });
	$("#content_right").css({ "width":"0px" });
	
	$("#content_left").fadeIn(1500);
	$("#content_right").animate({width: "500px"}, 1000, "easeInOutExpo" );

	


/* ------------------------------------------ content ------------------------------------------ */




	$("a[rel='info_box']").click(function () {
		var box = $(this).attr("href");
		box=box.substring(1);
	if ( $("#"+box).hasClass("active_box") ) {
 		$("#"+box).animate({width: "0px"}, 400, "easeInOutExpo" ).removeClass("active_box");
	}
	else {	
		$(".active_box").animate({width: "0px"}, 400, "easeInOutExpo" ).removeClass("active_box");
		$("#"+box).show();
		$("#"+box).animate({width: "300px"}, 1000, "easeInOutExpo" ).addClass("active_box");
	}
});


	
	
});
$(document).ready(function(){
   $('#navi > ul').hoverAccordion();

	/* $('#navi').bind("mouseleave",function(){

      		$(".opened").next().slideUp(300);
		$(".opened").removeClass("opened");
		$("li.current > ul li").show();
		$("li.current > ul").slideDown(300);
    	}); */

$(function()
{
	$('.scroll-pane').jScrollPane();
});

var myFile = document.location.toString();
	if (myFile.match('#')) { // the URL contains an anchor
	// click the navigation item corresponding to the anchor
	var myAnchor = '#' + myFile.split('#')[1];
	// myAnchor = myAnchor.substring(1);

	myAnchor=decodeURI(myAnchor);
	// alert(myAnchor);
	if (myAnchor != "") {
		$('a[href="' + myAnchor + '"]').click();
	}

}



});

function open_vanity_fair() {
	$("#vanity_fair_container").animate({top: "0px"}, 500, "easeInOutExpo" );
	
	$("#white_vanity_fair").animate({width: "200px",paddingRight: "60px"}, 500, "easeInOutExpo" );
	$("#white_vanity_fair").fadeIn(750);
}
function close_vanity_fair() {
	$("#white_vanity_fair").animate({width: "0px"}, 200, "easeInOutExpo" );
	$("#white_vanity_fair").fadeOut(200);
	$("#vanity_fair_container").animate({top: "-100px",paddingRight: "0px"}, 200, "easeInOutExpo" );
	
}